clang 19.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
clang::extractapi::DeclarationFragments Class Reference

DeclarationFragments is a vector of tagged important parts of a symbol's declaration. More...

#include "clang/ExtractAPI/DeclarationFragments.h"

Classes

struct  Fragment
 Fragment holds information of a single fragment. More...
 

Public Types

enum class  FragmentKind {
  None , Keyword , Attribute , NumberLiteral ,
  StringLiteral , Identifier , TypeIdentifier , GenericParameter ,
  ExternalParam , InternalParam , Text
}
 The kind of a fragment. More...
 
using FragmentIterator = std::vector< Fragment >::iterator
 
using ConstFragmentIterator = std::vector< Fragment >::const_iterator
 

Public Member Functions

 DeclarationFragments ()=default
 
const std::vector< Fragment > & getFragments () const
 
FragmentIterator begin ()
 
FragmentIterator end ()
 
ConstFragmentIterator cbegin () const
 
ConstFragmentIterator cend () const
 
DeclarationFragmentsinsert (FragmentIterator It, StringRef Spelling, FragmentKind Kind, StringRef PreciseIdentifier="", const Decl *Declaration=nullptr)
 
DeclarationFragmentsinsert (FragmentIterator It, DeclarationFragments &&Other)
 
DeclarationFragmentsappend (StringRef Spelling, FragmentKind Kind, StringRef PreciseIdentifier="", const Decl *Declaration=nullptr)
 Append a new Fragment to the end of the Fragments.
 
DeclarationFragmentsappend (DeclarationFragments &&Other)
 Append another DeclarationFragments to the end.
 
DeclarationFragmentspop_back ()
 
DeclarationFragmentsreplace (std::string NewSpelling, unsigned Position)
 
DeclarationFragmentsappendSpace ()
 Append a text Fragment of a space character.
 
DeclarationFragmentsappendSemicolon ()
 Append a text Fragment of a semicolon character.
 
DeclarationFragmentsremoveTrailingSemicolon ()
 Removes a trailing semicolon character if present.
 

Static Public Member Functions

static StringRef getFragmentKindString (FragmentKind Kind)
 Get the string description of a FragmentKind Kind.
 
static FragmentKind parseFragmentKindFromString (StringRef S)
 Get the corresponding FragmentKind from string S.
 
static DeclarationFragments getExceptionSpecificationString (ExceptionSpecificationType ExceptionSpec)
 
static DeclarationFragments getStructureTypeFragment (const RecordDecl *Decl)
 

Detailed Description

DeclarationFragments is a vector of tagged important parts of a symbol's declaration.

The fragments sequence can be joined to form spans of declaration text, with attached information useful for purposes like syntax-highlighting etc. For example:

const -> keyword "const"
int -> type "int"
pi; -> identifier "pi"
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.

Definition at line 46 of file DeclarationFragments.h.

Member Typedef Documentation

◆ ConstFragmentIterator

Definition at line 104 of file DeclarationFragments.h.

◆ FragmentIterator

Definition at line 103 of file DeclarationFragments.h.

Member Enumeration Documentation

◆ FragmentKind

The kind of a fragment.

Enumerator
None 

Unknown fragment kind.

Keyword 
Attribute 
NumberLiteral 
StringLiteral 
Identifier 
TypeIdentifier 

Identifier that refers to a type in the context.

GenericParameter 

Parameter that's used as generics in the context.

For example template parameters.

ExternalParam 

External parameters in Objective-C methods.

For example, forKey in

- (void) setValue:(Value)value forKey(Key)key
InternalParam 

Internal/local parameters in Objective-C methods.

For example, key in

- (void) setValue:(Value)value forKey(Key)key
Text 

Definition at line 51 of file DeclarationFragments.h.

Constructor & Destructor Documentation

◆ DeclarationFragments()

clang::extractapi::DeclarationFragments::DeclarationFragments ( )
default

Member Function Documentation

◆ append() [1/2]

DeclarationFragments & clang::extractapi::DeclarationFragments::append ( DeclarationFragments &&  Other)
inline

Append another DeclarationFragments to the end.

Note: Other is moved from and cannot be used after a call to this method.

Returns
a reference to the DeclarationFragments object itself after appending to chain up consecutive appends.

Definition at line 159 of file DeclarationFragments.h.

References clang::Other.

◆ append() [2/2]

DeclarationFragments & clang::extractapi::DeclarationFragments::append ( StringRef  Spelling,
FragmentKind  Kind,
StringRef  PreciseIdentifier = "",
const Decl Declaration = nullptr 
)
inline

Append a new Fragment to the end of the Fragments.

Returns
a reference to the DeclarationFragments object itself after appending to chain up consecutive appends.

Definition at line 138 of file DeclarationFragments.h.

References clang::Declaration, and Text.

Referenced by getExceptionSpecificationString(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForClassTemplatePartialSpecialization(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForClassTemplateSpecialization(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForConcept(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForConversionFunction(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForCXXClass(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForCXXMethod(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForEnum(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForEnumConstant(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForField(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForFunction(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForFunctionTemplate(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForFunctionTemplateSpecialization(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForMacro(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForNamespace(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForObjCCategory(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForObjCInterface(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForObjCMethod(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForObjCProperty(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForObjCProtocol(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForOverloadedOperator(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForRecordDecl(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForRedeclarableTemplate(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForSpecialCXXMethod(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForTemplateArguments(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForTemplateParameters(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForTypedef(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVar(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVarTemplate(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVarTemplatePartialSpecialization(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVarTemplateSpecialization(), clang::extractapi::DeclarationFragmentsBuilder::getFunctionSignature(), getStructureTypeFragment(), clang::extractapi::DeclarationFragmentsBuilder::getSubHeading(), clang::extractapi::DeclarationFragmentsBuilder::getSubHeadingForMacro(), and clang::extractapi::impl::ExtractAPIVisitorBase< Derived >::VisitTypedefNameDecl().

◆ appendSemicolon()

DeclarationFragments & DeclarationFragments::appendSemicolon ( )

Append a text Fragment of a semicolon character.

Returns
a reference to the DeclarationFragments object itself after appending to chain up consecutive appends.

Definition at line 83 of file DeclarationFragments.cpp.

Referenced by clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForClassTemplatePartialSpecialization(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForClassTemplateSpecialization(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForConcept(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForConversionFunction(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForCXXClass(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForCXXMethod(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForEnum(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForField(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForFunction(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForNamespace(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForObjCMethod(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForObjCProperty(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForOverloadedOperator(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForRecordDecl(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForSpecialCXXMethod(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForTypedef(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVar(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVarTemplate(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVarTemplatePartialSpecialization(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVarTemplateSpecialization(), and clang::extractapi::impl::ExtractAPIVisitorBase< Derived >::VisitTypedefNameDecl().

◆ appendSpace()

DeclarationFragments & DeclarationFragments::appendSpace ( )

Append a text Fragment of a space character.

Returns
a reference to the DeclarationFragments object itself after appending to chain up consecutive appends.

Definition at line 79 of file DeclarationFragments.cpp.

Referenced by clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForClassTemplatePartialSpecialization(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForClassTemplateSpecialization(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForConcept(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForConversionFunction(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForCXXClass(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForCXXMethod(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForEnum(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForField(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForFunction(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForFunctionTemplate(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForFunctionTemplateSpecialization(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForMacro(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForNamespace(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForObjCCategory(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForObjCInterface(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForObjCMethod(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForObjCProperty(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForObjCProtocol(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForOverloadedOperator(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForRecordDecl(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForRedeclarableTemplate(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForSpecialCXXMethod(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForTemplateArguments(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForTemplateParameters(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForTypedef(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVar(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVarTemplate(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVarTemplatePartialSpecialization(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVarTemplateSpecialization(), and clang::extractapi::impl::ExtractAPIVisitorBase< Derived >::VisitTypedefNameDecl().

◆ begin()

FragmentIterator clang::extractapi::DeclarationFragments::begin ( )
inline

◆ cbegin()

ConstFragmentIterator clang::extractapi::DeclarationFragments::cbegin ( ) const
inline

Definition at line 112 of file DeclarationFragments.h.

◆ cend()

ConstFragmentIterator clang::extractapi::DeclarationFragments::cend ( ) const
inline

Definition at line 114 of file DeclarationFragments.h.

◆ end()

FragmentIterator clang::extractapi::DeclarationFragments::end ( )
inline

Definition at line 110 of file DeclarationFragments.h.

◆ getExceptionSpecificationString()

DeclarationFragments DeclarationFragments::getExceptionSpecificationString ( ExceptionSpecificationType  ExceptionSpec)
static

◆ getFragmentKindString()

StringRef DeclarationFragments::getFragmentKindString ( DeclarationFragments::FragmentKind  Kind)
static

Get the string description of a FragmentKind Kind.

Definition at line 98 of file DeclarationFragments.cpp.

References Attribute, ExternalParam, GenericParameter, Identifier, InternalParam, Keyword, None, NumberLiteral, StringLiteral, Text, and TypeIdentifier.

◆ getFragments()

const std::vector< Fragment > & clang::extractapi::DeclarationFragments::getFragments ( ) const
inline

Definition at line 106 of file DeclarationFragments.h.

Referenced by clang::extractapi::FunctionSignature::empty().

◆ getStructureTypeFragment()

DeclarationFragments DeclarationFragments::getStructureTypeFragment ( const RecordDecl Decl)
static

◆ insert() [1/2]

DeclarationFragments & clang::extractapi::DeclarationFragments::insert ( FragmentIterator  It,
DeclarationFragments &&  Other 
)
inline

Definition at line 126 of file DeclarationFragments.h.

References clang::Other.

◆ insert() [2/2]

DeclarationFragments & clang::extractapi::DeclarationFragments::insert ( FragmentIterator  It,
StringRef  Spelling,
FragmentKind  Kind,
StringRef  PreciseIdentifier = "",
const Decl Declaration = nullptr 
)
inline

◆ parseFragmentKindFromString()

DeclarationFragments::FragmentKind DeclarationFragments::parseFragmentKindFromString ( StringRef  S)
static

Get the corresponding FragmentKind from string S.

Definition at line 129 of file DeclarationFragments.cpp.

References Attribute, ExternalParam, GenericParameter, Identifier, InternalParam, Keyword, None, NumberLiteral, StringLiteral, Text, and TypeIdentifier.

◆ pop_back()

DeclarationFragments & clang::extractapi::DeclarationFragments::pop_back ( )
inline

◆ removeTrailingSemicolon()

DeclarationFragments & DeclarationFragments::removeTrailingSemicolon ( )

Removes a trailing semicolon character if present.

Returns
a reference to the DeclarationFragments object itself after removing to chain up consecutive operations.

Definition at line 87 of file DeclarationFragments.cpp.

References clang::Last, and Text.

Referenced by clang::extractapi::impl::ExtractAPIVisitorBase< Derived >::VisitTypedefNameDecl().

◆ replace()

DeclarationFragments & clang::extractapi::DeclarationFragments::replace ( std::string  NewSpelling,
unsigned  Position 
)
inline

Definition at line 172 of file DeclarationFragments.h.


The documentation for this class was generated from the following files: