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

Public Member Functions

 DeclarationFragments ()=default
 
const std::vector< Fragment > & getFragments () const
 
DeclarationFragmentsappendFront (StringRef Spelling, FragmentKind Kind, StringRef PreciseIdentifier="", const Decl *Declaration=nullptr)
 
DeclarationFragmentsappendFront (DeclarationFragments &&Other)
 
void removeLast ()
 
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.
 
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.
 

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

◆ append() [2/2]

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

◆ appendFront() [1/2]

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

Definition at line 111 of file DeclarationFragments.h.

◆ appendFront() [2/2]

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

Definition at line 103 of file DeclarationFragments.h.

References clang::Declaration.

◆ appendSpace()

DeclarationFragments & DeclarationFragments::appendSpace ( )

◆ getFragmentKindString()

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

Get the string description of a FragmentKind Kind.

Definition at line 39 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 100 of file DeclarationFragments.h.

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

◆ parseFragmentKindFromString()

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

Get the corresponding FragmentKind from string S.

Definition at line 70 of file DeclarationFragments.cpp.

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

◆ removeLast()

void clang::extractapi::DeclarationFragments::removeLast ( )
inline

Definition at line 119 of file DeclarationFragments.h.


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