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
 
DeclarationFragmentsprepend (DeclarationFragments Other)
 Prepend another DeclarationFragments to the beginning.
 
DeclarationFragmentsappend (DeclarationFragments Other)
 Append another DeclarationFragments to the end.
 
DeclarationFragmentsappend (StringRef Spelling, FragmentKind Kind, StringRef PreciseIdentifier="", const Decl *Declaration=nullptr)
 Append a new Fragment to the end of the Fragments.
 
DeclarationFragmentsinsert (FragmentIterator It, DeclarationFragments Other)
 Inserts another DeclarationFragments at It.
 
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 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.

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

Definition at line 130 of file DeclarationFragments.h.

References end(), insert(), and clang::Other.

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().

◆ 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 operations.

Definition at line 138 of file DeclarationFragments.h.

References clang::Declaration, and Text.

◆ 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 operations.

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 operations.

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

Referenced by append(), and insert().

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

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

◆ getStructureTypeFragment()

DeclarationFragments DeclarationFragments::getStructureTypeFragment ( const RecordDecl Decl)
static

◆ insert()

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

Inserts another DeclarationFragments at It.

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

Definition at line 156 of file DeclarationFragments.h.

References begin(), end(), clang::Other, and Text.

Referenced by append(), and prepend().

◆ 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

◆ prepend()

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

Prepend another DeclarationFragments to the beginning.

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

Definition at line 122 of file DeclarationFragments.h.

References begin(), insert(), and clang::Other.

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

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


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