clang
19.0.0git
|
A wrapper around a Token
storing information about the whitespace characters preceding it.
More...
#include "/home/runner/work/llvm/llvm/repo/clang/lib/Format/FormatToken.h"
Public Member Functions | |
FormatToken () | |
BraceBlockKind | getBlockKind () const |
void | setBlockKind (BraceBlockKind BBK) |
FormatDecision | getDecision () const |
void | setDecision (FormatDecision D) |
ParameterPackingKind | getPackingKind () const |
void | setPackingKind (ParameterPackingKind K) |
TokenType | getType () const |
Returns the token's type, e.g. More... | |
void | setType (TokenType T) |
void | setFinalizedType (TokenType T) |
Sets the type and also the finalized flag. More... | |
void | overwriteFixedType (TokenType T) |
bool | isTypeFinalized () const |
bool | is (tok::TokenKind Kind) const |
bool | is (TokenType TT) const |
bool | is (const IdentifierInfo *II) const |
bool | is (tok::PPKeywordKind Kind) const |
bool | is (BraceBlockKind BBK) const |
bool | is (ParameterPackingKind PPK) const |
template<typename A , typename B > | |
bool | isOneOf (A K1, B K2) const |
template<typename A , typename B , typename... Ts> | |
bool | isOneOf (A K1, B K2, Ts... Ks) const |
template<typename T > | |
bool | isNot (T Kind) const |
bool | isIf (bool AllowConstexprMacro=true) const |
bool | closesScopeAfterBlock () const |
template<typename A , typename... Ts> | |
bool | startsSequence (A K1, Ts... Tokens) const |
true if this token starts a sequence with the given tokens in order, following the Next pointers, ignoring comments. More... | |
template<typename A , typename... Ts> | |
bool | endsSequence (A K1, Ts... Tokens) const |
true if this token ends a sequence with the given tokens in order, following the Previous pointers, ignoring comments. More... | |
bool | isStringLiteral () const |
bool | isAttribute () const |
bool | isObjCAtKeyword (tok::ObjCKeywordKind Kind) const |
bool | isAccessSpecifier (bool ColonRequired=true) const |
bool | canBePointerOrReferenceQualifier () const |
bool | isTypeName (const LangOptions &LangOpts) const |
bool | isTypeOrIdentifier (const LangOptions &LangOpts) const |
bool | isObjCAccessSpecifier () const |
bool | opensScope () const |
Returns whether Tok is ([{ or an opening < of a template or in protos. More... | |
bool | closesScope () const |
Returns whether Tok is )]} or a closing > of a template or in protos. More... | |
bool | isMemberAccess () const |
Returns true if this is a "." or "->" accessing a member. More... | |
bool | isPointerOrReference () const |
bool | isUnaryOperator () const |
bool | isBinaryOperator () const |
bool | isTrailingComment () const |
bool | isFunctionLikeKeyword () const |
Returns true if this is a keyword that can be used like a function call (e.g. More... | |
bool | isLabelString () const |
Returns true if this is a string literal that's like a label, e.g. More... | |
SourceLocation | getStartOfNonWhitespace () const |
Returns actual token start location without leading escaped newlines and whitespace. More... | |
bool | hasWhitespaceBefore () const |
Returns true if the range of whitespace immediately preceding the Token is not empty. More... | |
prec::Level | getPrecedence () const |
FormatToken * | getPreviousNonComment () const |
Returns the previous token ignoring comments. More... | |
FormatToken * | getNextNonComment () const |
Returns the next token ignoring comments. More... | |
bool | isBlockIndentedInitRBrace (const FormatStyle &Style) const |
Returns true if this token ends a block indented initializer list. More... | |
bool | opensBlockOrBlockTypeList (const FormatStyle &Style) const |
Returns true if this tokens starts a block-type list, i.e. More... | |
bool | isCppStructuredBinding (bool IsCpp) const |
Returns whether the token is the left square bracket of a C++ structured binding declaration. More... | |
bool | closesBlockOrBlockTypeList (const FormatStyle &Style) const |
Same as opensBlockOrBlockTypeList, but for the closing token. More... | |
const FormatToken * | getNamespaceToken () const |
Return the actual namespace token, if this token starts a namespace block. More... | |
void | copyFrom (const FormatToken &Tok) |
Public Attributes | |
Token | Tok |
The Token . More... | |
StringRef | TokenText |
The raw text of the token. More... | |
std::shared_ptr< TokenRole > | Role |
A token can have a special role that can carry extra information about the token's formatting. More... | |
SourceRange | WhitespaceRange |
The range of the whitespace immediately preceding the Token . More... | |
unsigned | HasUnescapedNewline: 1 |
Whether there is at least one unescaped newline before the Token . More... | |
unsigned | IsMultiline: 1 |
Whether the token text contains newlines (escaped or not). More... | |
unsigned | IsFirst: 1 |
Indicates that this is the first token of the file. More... | |
unsigned | MustBreakBefore: 1 |
Whether there must be a line break before this token. More... | |
unsigned | MustBreakBeforeFinalized: 1 |
Whether MustBreakBefore is finalized during parsing and must not be reset between runs. More... | |
unsigned | IsUnterminatedLiteral: 1 |
Set to true if this token is an unterminated literal. More... | |
unsigned | CanBreakBefore: 1 |
true if it is allowed to break before this token. More... | |
unsigned | ClosesTemplateDeclaration: 1 |
true if this is the ">" of "template<..>". More... | |
unsigned | StartsBinaryExpression: 1 |
true if this token starts a binary expression, i.e. More... | |
unsigned | EndsBinaryExpression: 1 |
true if this token ends a binary expression. More... | |
unsigned | PartOfMultiVariableDeclStmt: 1 |
Is this token part of a DeclStmt defining multiple variables? More... | |
unsigned | ContinuesLineCommentSection: 1 |
Does this line comment continue a line comment section? More... | |
unsigned | Finalized: 1 |
If true , this token has been fully formatted (indented and potentially re-formatted inside), and we do not allow further formatting changes. More... | |
unsigned | ClosesRequiresClause: 1 |
true if this is the last token within requires clause. More... | |
unsigned | EndsCppAttributeGroup: 1 |
true if this token ends a group of C++ attributes. More... | |
prec::Level | ForcedPrecedence = prec::Unknown |
Used to set an operator precedence explicitly. More... | |
unsigned | NewlinesBefore = 0 |
The number of newlines immediately before the Token . More... | |
int | Newlines = -1 |
The number of newlines immediately before the Token after formatting. More... | |
unsigned | LastNewlineOffset = 0 |
The offset just past the last ' ' in this token's leading whitespace (relative to WhiteSpaceStart ). More... | |
unsigned | ColumnWidth = 0 |
The width of the non-whitespace parts of the token (or its first line for multi-line tokens) in columns. More... | |
unsigned | LastLineColumnWidth = 0 |
Contains the width in columns of the last line of a multi-line token. More... | |
unsigned | SpacesRequiredBefore = 0 |
The number of spaces that should be inserted before this token. More... | |
unsigned | ParameterCount = 0 |
Number of parameters, if this is "(", "[" or "<". More... | |
unsigned | BlockParameterCount = 0 |
Number of parameters that are nested blocks, if this is "(", "[" or "<". More... | |
tok::TokenKind | ParentBracket = tok::unknown |
If this is a bracket ("<", "(", "[" or "{"), contains the kind of the surrounding bracket. More... | |
unsigned | TotalLength = 0 |
The total length of the unwrapped line up to and including this token. More... | |
unsigned | OriginalColumn = 0 |
The original 0-based column of this token, including expanded tabs. More... | |
unsigned | UnbreakableTailLength = 0 |
The length of following tokens until the next natural split point, or the next token that can be broken. More... | |
unsigned | BindingStrength = 0 |
The binding strength of a token. More... | |
unsigned | NestingLevel = 0 |
The nesting level of this token, i.e. More... | |
unsigned | IndentLevel = 0 |
The indent level of this token. Copied from the surrounding line. More... | |
unsigned | SplitPenalty = 0 |
Penalty for inserting a line break before this token. More... | |
unsigned | LongestObjCSelectorName = 0 |
If this is the first ObjC selector name in an ObjC method definition or call, this contains the length of the longest name. More... | |
unsigned | ObjCSelectorNameParts = 0 |
If this is the first ObjC selector name in an ObjC method definition or call, this contains the number of parts that the whole selector consist of. More... | |
unsigned | ParameterIndex = 0 |
The 0-based index of the parameter/argument. More... | |
SmallVector< prec::Level, 4 > | FakeLParens |
Stores the number of required fake parentheses and the corresponding operator precedence. More... | |
unsigned | FakeRParens = 0 |
Insert this many fake ) after this token for correct indentation. More... | |
unsigned | OperatorIndex = 0 |
If this is an operator (or "."/"->") in a sequence of operators with the same precedence, contains the 0-based operator index. More... | |
FormatToken * | NextOperator = nullptr |
If this is an operator (or "."/"->") in a sequence of operators with the same precedence, points to the next operator. More... | |
FormatToken * | MatchingParen = nullptr |
If this is a bracket, this points to the matching one. More... | |
FormatToken * | Previous = nullptr |
The previous token in the unwrapped line. More... | |
FormatToken * | Next = nullptr |
The next token in the unwrapped line. More... | |
bool | StartsColumn = false |
The first token in set of column elements. More... | |
bool | ArrayInitializerLineStart = false |
This notes the start of the line of an array initializer. More... | |
bool | IsArrayInitializer = false |
This starts an array initializer. More... | |
bool | Optional = false |
Is optional and can be removed. More... | |
bool | MightBeFunctionDeclParen = false |
Might be function declaration open/closing paren. More... | |
int8_t | BraceCount = 0 |
Number of optional braces to be inserted after this token: -1: a single left brace 0: no braces >0: number of right braces. More... | |
SmallVector< AnnotatedLine *, 1 > | Children |
If this token starts a block, this contains all the unwrapped lines in it. More... | |
std::optional< MacroExpansion > | MacroCtx |
bool | MacroParent = false |
When macro expansion introduces nodes with children, those are marked as MacroParent . More... | |
A wrapper around a Token
storing information about the whitespace characters preceding it.
Definition at line 290 of file FormatToken.h.
|
inline |
Definition at line 291 of file FormatToken.h.
|
inline |
Definition at line 673 of file FormatToken.h.
|
inline |
Same as opensBlockOrBlockTypeList, but for the closing token.
Definition at line 839 of file FormatToken.h.
|
inline |
Returns whether Tok
is )]} or a closing > of a template or in protos.
Definition at line 704 of file FormatToken.h.
Referenced by clang::format::startsSegmentOfBuilderTypeCall().
|
inline |
Definition at line 628 of file FormatToken.h.
References endsSequence(), and is().
|
inline |
Definition at line 860 of file FormatToken.h.
Referenced by clang::format::MacroExpander::expand().
|
inline |
true
if this token ends a sequence with the given tokens in order, following the Previous
pointers, ignoring comments.
For example, given tokens [T1, T2, T3], the function returns true if 3 tokens ending at this (ignoring comments) are [T3, T2, T1]. In other words, the tokens passed to this function need to the reverse of the order the tokens appear in code.
Definition at line 650 of file FormatToken.h.
Referenced by closesScopeAfterBlock().
|
inline |
Definition at line 382 of file FormatToken.h.
|
inline |
Definition at line 395 of file FormatToken.h.
|
inline |
Return the actual namespace token, if this token starts a namespace block.
Definition at line 847 of file FormatToken.h.
|
inline |
Returns the next token ignoring comments.
Definition at line 811 of file FormatToken.h.
Referenced by clang::format::AnnotatedLine::getFirstNonComment(), clang::format::AnnotatedLine::isComment(), and clang::format::CommaSeparatedList::precomputeFormattingInfos().
|
inline |
Definition at line 408 of file FormatToken.h.
Referenced by isOneOf().
|
inline |
Definition at line 795 of file FormatToken.h.
References clang::SourceRange::getBegin(), clang::SourceRange::getEnd(), and WhitespaceRange.
Referenced by isTrailingComment().
|
inline |
Returns the previous token ignoring comments.
Definition at line 803 of file FormatToken.h.
Referenced by clang::format::AnnotatedLine::getLastNonComment(), clang::format::CommaSeparatedList::precomputeFormattingInfos(), and clang::format::shouldUnindentNextOperator().
|
inline |
Returns actual token start location without leading escaped newlines and whitespace.
This can be different to Tok.getLocation(), which includes leading escaped newlines.
Definition at line 785 of file FormatToken.h.
Referenced by clang::format::WhitespaceManager::replaceWhitespaceInToken().
|
inline |
Returns the token's type, e.g.
whether "<" is a template opener or binary operator.
Definition at line 423 of file FormatToken.h.
|
inline |
Returns true
if the range of whitespace immediately preceding the Token
is not empty.
Definition at line 791 of file FormatToken.h.
References clang::SourceRange::getEnd(), and WhitespaceRange.
|
inline |
Definition at line 611 of file FormatToken.h.
|
inline |
Definition at line 604 of file FormatToken.h.
|
inline |
Definition at line 612 of file FormatToken.h.
|
inline |
Definition at line 607 of file FormatToken.h.
References clang::Token::is(), and Tok.
|
inline |
Definition at line 602 of file FormatToken.h.
Referenced by closesScopeAfterBlock(), clang::format::continuesLineCommentSection(), clang::format::CommaSeparatedList::formatAfterToken(), clang::format::AnnotatedLine::getFirstNonComment(), clang::format::AnnotatedLine::getLastNonComment(), clang::format::FormatTokenSource::getNextNonComment(), clang::format::isAllmanBrace(), clang::format::isAllmanLambdaBrace(), clang::format::AnnotatedLine::isComment(), clang::format::isCtorOrDtorName(), isIf(), clang::format::markOptionalBraces(), clang::format::MacroExpander::DefinitionParser::parse(), and clang::format::CommaSeparatedList::precomputeFormattingInfos().
Definition at line 603 of file FormatToken.h.
Definition at line 664 of file FormatToken.h.
|
inline |
Definition at line 656 of file FormatToken.h.
|
inline |
Definition at line 740 of file FormatToken.h.
bool clang::format::FormatToken::isBlockIndentedInitRBrace | ( | const FormatStyle & | Style | ) | const |
Returns true
if this token ends a block indented initializer list.
Definition at line 56 of file FormatToken.cpp.
Returns whether the token is the left square bracket of a C++ structured binding declaration.
Definition at line 827 of file FormatToken.h.
|
inline |
Returns true
if this is a keyword that can be used like a function call (e.g.
sizeof, typeid, ...).
Definition at line 752 of file FormatToken.h.
Definition at line 623 of file FormatToken.h.
|
inline |
Returns true
if this is a string literal that's like a label, e.g.
ends with "=" or ":".
Definition at line 767 of file FormatToken.h.
|
inline |
Returns true
if this is a "." or "->" accessing a member.
Definition at line 714 of file FormatToken.h.
Referenced by clang::format::startsSegmentOfBuilderTypeCall().
Definition at line 621 of file FormatToken.h.
Referenced by clang::format::isPossibleMacro(), and clang::format::MacroExpander::DefinitionParser::parse().
|
inline |
Definition at line 684 of file FormatToken.h.
|
inline |
Definition at line 660 of file FormatToken.h.
References clang::Token::getKind(), clang::tok::isStringLiteral(), and Tok.
|
inline |
Definition at line 614 of file FormatToken.h.
Referenced by clang::format::CommaSeparatedList::formatAfterToken(), clang::format::isAllmanBrace(), clang::format::isAllmanLambdaBrace(), clang::format::isAltOperator(), clang::format::isC78Type(), clang::format::IsFunctionArgument(), isIf(), isPointerOrReference(), clang::format::AdditionalKeywords::isTableGenKeyword(), clang::format::AdditionalKeywords::isVerilogIdentifier(), clang::format::AdditionalKeywords::isVerilogQualifier(), and clang::format::tokenCanStartNewLine().
|
inline |
Definition at line 618 of file FormatToken.h.
References getPackingKind().
|
inline |
Definition at line 720 of file FormatToken.h.
References isOneOf().
|
inline |
Definition at line 654 of file FormatToken.h.
|
inline |
Definition at line 745 of file FormatToken.h.
References clang::prec::Comma, and getPrecedence().
Referenced by clang::format::CommaSeparatedList::precomputeFormattingInfos().
|
inline |
Definition at line 450 of file FormatToken.h.
References MacroCtx, and clang::format::MR_UnexpandedArg.
bool clang::format::FormatToken::isTypeName | ( | const LangOptions & | LangOpts | ) | const |
Definition at line 44 of file FormatToken.cpp.
bool clang::format::FormatToken::isTypeOrIdentifier | ( | const LangOptions & | LangOpts | ) | const |
Definition at line 52 of file FormatToken.cpp.
|
inline |
Definition at line 724 of file FormatToken.h.
bool clang::format::FormatToken::opensBlockOrBlockTypeList | ( | const FormatStyle & | Style | ) | const |
Returns true
if this tokens starts a block-type list, i.e.
a list that should be indented with a block indent.
Definition at line 71 of file FormatToken.cpp.
|
inline |
Returns whether Tok
is ([{ or an opening < of a template or in protos.
Definition at line 694 of file FormatToken.h.
|
inline |
Definition at line 444 of file FormatToken.h.
References MacroCtx, clang::format::MR_UnexpandedArg, and clang::T.
|
inline |
Definition at line 385 of file FormatToken.h.
|
inline |
Definition at line 398 of file FormatToken.h.
Referenced by clang::format::WhitespaceManager::replaceWhitespace().
|
inline |
Sets the type and also the finalized flag.
This prevents the type to be reset in TokenAnnotator::resetTokenMetadata(). If the type needs to be set to another one please use overwriteFixedType, or even better remove the need to reassign the type.
Definition at line 438 of file FormatToken.h.
|
inline |
Definition at line 411 of file FormatToken.h.
|
inline |
Definition at line 424 of file FormatToken.h.
|
inline |
true
if this token starts a sequence with the given tokens in order, following the Next
pointers, ignoring comments.
Definition at line 639 of file FormatToken.h.
This notes the start of the line of an array initializer.
Definition at line 568 of file FormatToken.h.
unsigned clang::format::FormatToken::BindingStrength = 0 |
The binding strength of a token.
This is a combined value of operator precedence, parenthesis nesting, etc.
Definition at line 509 of file FormatToken.h.
unsigned clang::format::FormatToken::BlockParameterCount = 0 |
Number of parameters that are nested blocks, if this is "(", "[" or "<".
Definition at line 488 of file FormatToken.h.
int8_t clang::format::FormatToken::BraceCount = 0 |
Number of optional braces to be inserted after this token: -1: a single left brace 0: no braces >0: number of right braces.
Definition at line 583 of file FormatToken.h.
unsigned clang::format::FormatToken::CanBreakBefore |
true
if it is allowed to break before this token.
Definition at line 345 of file FormatToken.h.
Referenced by clang::format::CommaSeparatedList::precomputeFormattingInfos().
SmallVector<AnnotatedLine *, 1> clang::format::FormatToken::Children |
If this token starts a block, this contains all the unwrapped lines in it.
Definition at line 587 of file FormatToken.h.
Referenced by clang::format::isItAnEmptyLambdaAllowed().
unsigned clang::format::FormatToken::ClosesRequiresClause |
true
if this is the last token within requires clause.
Definition at line 372 of file FormatToken.h.
unsigned clang::format::FormatToken::ClosesTemplateDeclaration |
true
if this is the ">" of "template<..>".
Definition at line 348 of file FormatToken.h.
unsigned clang::format::FormatToken::ColumnWidth = 0 |
The width of the non-whitespace parts of the token (or its first line for multi-line tokens) in columns.
We need this to correctly measure number of columns a token spans.
Definition at line 474 of file FormatToken.h.
unsigned clang::format::FormatToken::ContinuesLineCommentSection |
Does this line comment continue a line comment section?
Only set to true if Type
== TT_LineComment
.
Definition at line 364 of file FormatToken.h.
unsigned clang::format::FormatToken::EndsBinaryExpression |
true
if this token ends a binary expression.
Definition at line 354 of file FormatToken.h.
unsigned clang::format::FormatToken::EndsCppAttributeGroup |
true
if this token ends a group of C++ attributes.
Definition at line 375 of file FormatToken.h.
SmallVector<prec::Level, 4> clang::format::FormatToken::FakeLParens |
Stores the number of required fake parentheses and the corresponding operator precedence.
If multiple fake parentheses start at a token, this vector stores them in reverse order, i.e. inner fake parenthesis first.
Definition at line 543 of file FormatToken.h.
unsigned clang::format::FormatToken::FakeRParens = 0 |
Insert this many fake ) after this token for correct indentation.
Definition at line 545 of file FormatToken.h.
unsigned clang::format::FormatToken::Finalized |
If true
, this token has been fully formatted (indented and potentially re-formatted inside), and we do not allow further formatting changes.
Definition at line 369 of file FormatToken.h.
Referenced by clang::format::WhitespaceManager::addUntouchableToken(), clang::format::BreakableBlockComment::mayReflow(), clang::format::BreakableLineCommentSection::mayReflow(), clang::format::WhitespaceManager::replaceWhitespace(), and clang::format::WhitespaceManager::replaceWhitespaceInToken().
prec::Level clang::format::FormatToken::ForcedPrecedence = prec::Unknown |
Used to set an operator precedence explicitly.
Definition at line 453 of file FormatToken.h.
unsigned clang::format::FormatToken::HasUnescapedNewline |
Whether there is at least one unescaped newline before the Token
.
Definition at line 323 of file FormatToken.h.
Referenced by clang::format::CommaSeparatedList::precomputeFormattingInfos().
unsigned clang::format::FormatToken::IndentLevel = 0 |
The indent level of this token. Copied from the surrounding line.
Definition at line 516 of file FormatToken.h.
Referenced by clang::format::WhitespaceManager::Change::indentAndNestingLevel().
This starts an array initializer.
Definition at line 571 of file FormatToken.h.
unsigned clang::format::FormatToken::IsFirst |
Indicates that this is the first token of the file.
Definition at line 329 of file FormatToken.h.
Referenced by clang::format::WhitespaceManager::addUntouchableToken(), clang::format::WhitespaceManager::replaceWhitespace(), and clang::format::WhitespaceManager::replaceWhitespaceInToken().
unsigned clang::format::FormatToken::IsMultiline |
Whether the token text contains newlines (escaped or not).
Definition at line 326 of file FormatToken.h.
unsigned clang::format::FormatToken::IsUnterminatedLiteral |
Set to true
if this token is an unterminated literal.
Definition at line 342 of file FormatToken.h.
unsigned clang::format::FormatToken::LastLineColumnWidth = 0 |
Contains the width in columns of the last line of a multi-line token.
Definition at line 478 of file FormatToken.h.
unsigned clang::format::FormatToken::LastNewlineOffset = 0 |
The offset just past the last '
' in this token's leading whitespace (relative to WhiteSpaceStart
).
0 if there is no '
'.
Definition at line 469 of file FormatToken.h.
unsigned clang::format::FormatToken::LongestObjCSelectorName = 0 |
If this is the first ObjC selector name in an ObjC method definition or call, this contains the length of the longest name.
This being set to 0 means that the selectors should not be colon-aligned, e.g. because several of them are block-type.
Definition at line 526 of file FormatToken.h.
std::optional<MacroExpansion> clang::format::FormatToken::MacroCtx |
Definition at line 591 of file FormatToken.h.
Referenced by clang::format::WhitespaceManager::addUntouchableToken(), clang::format::MacroExpander::expand(), isTypeFinalized(), overwriteFixedType(), clang::format::WhitespaceManager::replaceWhitespace(), and clang::format::WhitespaceManager::replaceWhitespaceInToken().
When macro expansion introduces nodes with children, those are marked as MacroParent
.
FIXME: The formatting code currently hard-codes the assumption that child nodes are introduced by blocks following an opening brace. This is deeply baked into the code and disentangling this will require signficant refactorings. MacroParent
allows us to special-case the cases in which we treat parents as block-openers for now.
Definition at line 600 of file FormatToken.h.
FormatToken* clang::format::FormatToken::MatchingParen = nullptr |
If this is a bracket, this points to the matching one.
Definition at line 556 of file FormatToken.h.
Referenced by clang::format::CommaSeparatedList::formatAfterToken(), clang::format::IsFunctionArgument(), and clang::format::markOptionalBraces().
Might be function declaration open/closing paren.
Definition at line 577 of file FormatToken.h.
unsigned clang::format::FormatToken::MustBreakBefore |
Whether there must be a line break before this token.
This happens for example when a preprocessor directive ended directly before the token.
Definition at line 335 of file FormatToken.h.
Referenced by clang::format::CommaSeparatedList::precomputeFormattingInfos().
unsigned clang::format::FormatToken::MustBreakBeforeFinalized |
Whether MustBreakBefore is finalized during parsing and must not be reset between runs.
Definition at line 339 of file FormatToken.h.
unsigned clang::format::FormatToken::NestingLevel = 0 |
The nesting level of this token, i.e.
the number of surrounding (), [], {} or <>.
Definition at line 513 of file FormatToken.h.
Referenced by clang::format::WhitespaceManager::Change::indentAndNestingLevel().
int clang::format::FormatToken::Newlines = -1 |
The number of newlines immediately before the Token
after formatting.
This is used to avoid overlapping whitespace replacements when Newlines
is recomputed for a finalized preprocessor branching directive.
Definition at line 465 of file FormatToken.h.
unsigned clang::format::FormatToken::NewlinesBefore = 0 |
The number of newlines immediately before the Token
.
This can be used to determine what the user wrote in the original code and thereby e.g. leave an empty line between two function definitions.
Definition at line 459 of file FormatToken.h.
Referenced by clang::format::WhitespaceManager::addUntouchableToken(), and clang::format::TokenAnnotator::setCommentLineLevels().
FormatToken* clang::format::FormatToken::Next = nullptr |
The next token in the unwrapped line.
Definition at line 562 of file FormatToken.h.
Referenced by clang::format::CommaSeparatedList::formatAfterToken(), clang::format::IsFunctionArgument(), clang::format::maxNestingDepth(), clang::format::CommaSeparatedList::precomputeFormattingInfos(), and clang::format::BreakableLineCommentSection::updateNextToken().
FormatToken* clang::format::FormatToken::NextOperator = nullptr |
If this is an operator (or "."/"->") in a sequence of operators with the same precedence, points to the next operator.
Definition at line 553 of file FormatToken.h.
Referenced by clang::format::getLengthToNextOperator().
unsigned clang::format::FormatToken::ObjCSelectorNameParts = 0 |
If this is the first ObjC selector name in an ObjC method definition or call, this contains the number of parts that the whole selector consist of.
Definition at line 531 of file FormatToken.h.
unsigned clang::format::FormatToken::OperatorIndex = 0 |
If this is an operator (or "."/"->") in a sequence of operators with the same precedence, contains the 0-based operator index.
Definition at line 549 of file FormatToken.h.
Is optional and can be removed.
Definition at line 574 of file FormatToken.h.
Referenced by clang::format::markOptionalBraces().
unsigned clang::format::FormatToken::OriginalColumn = 0 |
The original 0-based column of this token, including expanded tabs.
The configured TabWidth is used as tab width.
Definition at line 500 of file FormatToken.h.
Referenced by clang::format::WhitespaceManager::addUntouchableToken(), and clang::format::TokenAnnotator::setCommentLineLevels().
unsigned clang::format::FormatToken::ParameterCount = 0 |
Number of parameters, if this is "(", "[" or "<".
Definition at line 484 of file FormatToken.h.
unsigned clang::format::FormatToken::ParameterIndex = 0 |
The 0-based index of the parameter/argument.
For ObjC it is set for the selector name token. For now calculated only for ObjC.
Definition at line 536 of file FormatToken.h.
tok::TokenKind clang::format::FormatToken::ParentBracket = tok::unknown |
If this is a bracket ("<", "(", "[" or "{"), contains the kind of the surrounding bracket.
Definition at line 492 of file FormatToken.h.
unsigned clang::format::FormatToken::PartOfMultiVariableDeclStmt |
Is this token part of a DeclStmt
defining multiple variables?
Only set if Type
== TT_StartOfName
.
Definition at line 359 of file FormatToken.h.
FormatToken* clang::format::FormatToken::Previous = nullptr |
The previous token in the unwrapped line.
Definition at line 559 of file FormatToken.h.
Referenced by clang::format::isCtorOrDtorName(), clang::format::CommaSeparatedList::precomputeFormattingInfos(), and clang::format::startsSegmentOfBuilderTypeCall().
std::shared_ptr<TokenRole> clang::format::FormatToken::Role |
A token can have a special role that can carry extra information about the token's formatting.
FIXME: Make FormatToken for parsing and AnnotatedToken two different classes and make this a unique_ptr in the AnnotatedToken class.
Definition at line 316 of file FormatToken.h.
unsigned clang::format::FormatToken::SpacesRequiredBefore = 0 |
The number of spaces that should be inserted before this token.
Definition at line 481 of file FormatToken.h.
unsigned clang::format::FormatToken::SplitPenalty = 0 |
Penalty for inserting a line break before this token.
Definition at line 519 of file FormatToken.h.
unsigned clang::format::FormatToken::StartsBinaryExpression |
true
if this token starts a binary expression, i.e.
has at least one fake l_paren with a precedence greater than prec::Unknown.
Definition at line 352 of file FormatToken.h.
The first token in set of column elements.
Definition at line 565 of file FormatToken.h.
Token clang::format::FormatToken::Tok |
The Token
.
Definition at line 304 of file FormatToken.h.
Referenced by is(), clang::format::isConfiguredQualifier(), clang::format::AdditionalKeywords::IsJavaScriptIdentifier(), isObjCAtKeyword(), clang::format::isQualifier(), clang::format::AdditionalKeywords::isWordLike(), clang::format::JavaScriptImportSorter::JavaScriptImportSorter(), and clang::format::ScopedMacroState::ScopedMacroState().
StringRef clang::format::FormatToken::TokenText |
The raw text of the token.
Contains the raw token text without leading whitespace and without leading escaped newlines.
Definition at line 310 of file FormatToken.h.
Referenced by clang::format::continuesLineCommentSection(), clang::format::isAltOperator(), clang::format::isCtorOrDtorName(), clang::format::isPossibleMacro(), and clang::format::MacroExpander::DefinitionParser::parse().
unsigned clang::format::FormatToken::TotalLength = 0 |
The total length of the unwrapped line up to and including this token.
Definition at line 496 of file FormatToken.h.
Referenced by clang::format::getLengthToNextOperator().
unsigned clang::format::FormatToken::UnbreakableTailLength = 0 |
The length of following tokens until the next natural split point, or the next token that can be broken.
Definition at line 504 of file FormatToken.h.
SourceRange clang::format::FormatToken::WhitespaceRange |
The range of the whitespace immediately preceding the Token
.
Definition at line 319 of file FormatToken.h.
Referenced by clang::format::WhitespaceManager::addUntouchableToken(), getPrecedence(), hasWhitespaceBefore(), and clang::format::WhitespaceManager::replaceWhitespace().