Lines Matching defs:Tok
39 // Returns true if a binary operator following \p Tok should be unindented when
41 static bool shouldUnindentNextOperator(const FormatToken &Tok) {
42 const FormatToken *Previous = Tok.getPreviousNonComment();
48 // the ), ], } or > matching \c Tok.
49 static unsigned getLengthToMatchingParen(const FormatToken &Tok,
89 if (!Tok.MatchingParen)
91 FormatToken *End = Tok.MatchingParen;
99 while (MatchingStackIndex >= 0 && Stack[MatchingStackIndex].Tok != LBrace)
116 return End->TotalLength - Tok.TotalLength + 1;
119 static unsigned getLengthToNextOperator(const FormatToken &Tok) {
120 if (!Tok.NextOperator)
122 return Tok.NextOperator->TotalLength - Tok.TotalLength;
125 // Returns \c true if \c Tok is the "." or "->" of a call and starts the next
127 static bool startsSegmentOfBuilderTypeCall(const FormatToken &Tok) {
128 return Tok.isMemberAccess() && Tok.Previous && Tok.Previous->closesScope();
266 State.Stack.push_back(ParenState(/*Tok=*/nullptr, FirstIndent, FirstIndent,
619 (Previous.Tok.isLiteral() && (Previous.TokenText.ends_with("\\n\"") ||
644 (!Previous.Tok.getIdentifierInfo() ||
645 Previous.Tok.getIdentifierInfo()->getPPKeywordID() ==
727 const FormatToken *Tok = &Previous;
728 while (Tok && CurrentState.VariablePos >= Tok->ColumnWidth) {
729 CurrentState.VariablePos -= Tok->ColumnWidth;
730 if (Tok->SpacesRequiredBefore != 0)
732 Tok = Tok->Previous;
790 auto IsOpeningBracket = [&](const FormatToken &Tok) {
792 return Tok.is(tok::l_brace) && Tok.isNot(BK_Block) &&
795 if (!Tok.isOneOf(tok::l_paren, TT_TemplateOpener, tok::l_square) &&
799 if (!Tok.Previous)
801 if (Tok.Previous->isIf())
803 return !Tok.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while,
1128 return PState.Tok != nullptr; // Ignore fake parens.
1466 return CurrentState.Indent - Current.Tok.getLength() -
1471 return CurrentState.Indent - NextNonComment->Tok.getLength() -
1524 auto IsWrappedConditional = [](const FormatToken &Tok) {
1525 if (!(Tok.is(TT_ConditionalExpr) && Tok.is(tok::question)))
1527 if (Tok.MustBreakBefore)
1530 const FormatToken *Next = Tok.getNextNonComment();
1696 NewParenState.Tok = nullptr;
1919 for (const FormatToken *Tok = &Current;
1920 Tok && Tok != Current.MatchingParen; Tok = Tok->Next) {
1921 if (Tok->MustBreakBefore ||
1922 (Tok->CanBreakBefore && Tok->NewlinesBefore > 0)) {
2154 Current.Tok.getLocation().getLocWithOffset(2);
2165 Current.Tok.getLocation().getLocWithOffset(Current.TokenText.size() -
2176 Current.Tok.getLocation().getLocWithOffset(OldPrefixSize);
2281 auto Tok = Current.getPreviousNonComment();
2282 if (!Tok || Tok->isNot(tok::l_paren))
2284 Tok = Tok->getPreviousNonComment();
2285 if (!Tok)
2287 if (Tok->is(TT_TemplateCloser)) {
2288 Tok = Tok->MatchingParen;
2289 if (Tok)
2290 Tok = Tok->getPreviousNonComment();
2292 if (!Tok || Tok->isNot(tok::identifier))
2294 return Tok->TokenText;