clang 18.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.
 

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 48 of file DeclarationFragments.h.

Member Typedef Documentation

◆ ConstFragmentIterator

Definition at line 106 of file DeclarationFragments.h.

◆ FragmentIterator

Definition at line 105 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 53 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 161 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 140 of file DeclarationFragments.h.

References clang::Declaration, and Text.

Referenced by appendSpace(), 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::getFragmentsForRedeclarableTemplate(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForSpecialCXXMethod(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForStruct(), 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(), and clang::extractapi::DeclarationFragmentsBuilder::getSubHeadingForMacro().

◆ 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 63 of file DeclarationFragments.cpp.

References append(), clang::Last, and Text.

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::getFragmentsForRedeclarableTemplate(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForSpecialCXXMethod(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForStruct(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForTemplateArguments(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForTemplateParameters(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForTypedef(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVar(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVarTemplate(), clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVarTemplatePartialSpecialization(), and clang::extractapi::DeclarationFragmentsBuilder::getFragmentsForVarTemplateSpecialization().

◆ begin()

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

◆ cbegin()

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

Definition at line 114 of file DeclarationFragments.h.

◆ cend()

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

Definition at line 116 of file DeclarationFragments.h.

◆ end()

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

Definition at line 112 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 80 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 108 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 128 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

Definition at line 119 of file DeclarationFragments.h.

References clang::Declaration.

◆ parseFragmentKindFromString()

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

Get the corresponding FragmentKind from string S.

Definition at line 111 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

◆ replace()

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

Definition at line 174 of file DeclarationFragments.h.


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