Lines Matching refs:Current
48 static bool startsNextParameter(const FormatToken &Current, in startsNextParameter() argument
50 const FormatToken &Previous = *Current.Previous; in startsNextParameter()
51 if (Current.is(TT_CtorInitializerComma) && in startsNextParameter()
54 return Previous.is(tok::comma) && !Current.isTrailingComment() && in startsNextParameter()
93 const FormatToken &Current = *State.NextToken; in canBreak() local
94 const FormatToken &Previous = *Current.Previous; in canBreak()
95 assert(&Previous == Current.Previous); in canBreak()
96 if (!Current.CanBreakBefore && in canBreak()
98 Current.closesBlockOrBlockTypeList(Style))) in canBreak()
102 if (!Current.MustBreakBefore && Previous.is(tok::l_brace) && in canBreak()
114 State.LowestLevelOnLine < Current.NestingLevel) in canBreak()
116 if (Current.isMemberAccess() && State.Stack.back().ContainsUnwrappedBuilder) in canBreak()
128 if (Current.is(TT_FunctionDeclarationName) && State.Column < 6) { in canBreak()
137 const FormatToken &Current = *State.NextToken; in mustBreak() local
138 const FormatToken &Previous = *Current.Previous; in mustBreak()
139 if (Current.MustBreakBefore || Current.is(TT_InlineASMColon)) in mustBreak()
142 Current.closesBlockOrBlockTypeList(Style)) in mustBreak()
146 if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) || in mustBreak()
147 (Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName)) || in mustBreak()
148 (Style.BreakBeforeTernaryOperators && Current.is(TT_ConditionalExpr) && in mustBreak()
152 State.Stack.back().BreakBeforeParameter && !Current.isTrailingComment() && in mustBreak()
153 !Current.isOneOf(tok::r_paren, tok::r_brace)) in mustBreak()
161 if (Current.is(TT_CtorInitializerColon) && in mustBreak()
162 (State.Column + State.Line->Last->TotalLength - Current.TotalLength + 2 > in mustBreak()
168 if (Current.is(TT_SelectorName) && State.Stack.back().ObjCSelectorNameFound && in mustBreak()
178 Previous.is(tok::comma) || Current.NestingLevel < 2) && in mustBreak()
187 if (Previous.is(TT_BinaryOperator) && Current.CanBreakBefore) { in mustBreak()
203 if ((!IsComparison || LHSIsBinaryExpr) && !Current.isTrailingComment() && in mustBreak()
207 } else if (Current.is(TT_BinaryOperator) && Current.CanBreakBefore && in mustBreak()
213 if (Current.is(tok::lessless) && Current.isNot(TT_OverloadedOperator) && in mustBreak()
218 if (Current.NestingLevel == 0 && !Current.isTrailingComment()) { in mustBreak()
226 if (Previous.is(TT_LeadingJavaAnnotation) && Current.isNot(tok::l_paren) && in mustBreak()
227 Current.isNot(TT_LeadingJavaAnnotation)) in mustBreak()
232 if ((Current.is(TT_FunctionDeclarationName) || in mustBreak()
233 (Current.is(tok::kw_operator) && !Previous.is(tok::coloncolon))) && in mustBreak()
237 if (startsSegmentOfBuilderTypeCall(Current) && in mustBreak()
246 Previous.is(tok::l_brace) && !Current.isOneOf(tok::r_brace, tok::comment)) in mustBreak()
249 if (Current.is(tok::lessless) && Previous.is(tok::identifier) && in mustBreak()
259 const FormatToken &Current = *State.NextToken; in addTokenToState() local
262 if ((Current.is(TT_ImplicitStringLiteral) && in addTokenToState()
263 (Current.Previous->Tok.getIdentifierInfo() == nullptr || in addTokenToState()
264 Current.Previous->Tok.getIdentifierInfo()->getPPKeywordID() == in addTokenToState()
267 SourceMgr.getSpellingColumnNumber(Current.WhitespaceRange.getEnd()); in addTokenToState()
268 if (Current.LastNewlineOffset != 0) { in addTokenToState()
274 SourceMgr.getSpellingColumnNumber(Current.WhitespaceRange.getBegin()); in addTokenToState()
293 FormatToken &Current = *State.NextToken; in addTokenOnCurrentLine() local
295 if (Current.is(tok::equal) && in addTokenOnCurrentLine()
296 (State.Line->First->is(tok::kw_for) || Current.NestingLevel == 0) && in addTokenOnCurrentLine()
311 unsigned Spaces = Current.SpacesRequiredBefore + ExtraSpaces; in addTokenOnCurrentLine()
314 Whitespaces.replaceWhitespace(Current, /*Newlines=*/0, /*IndentLevel=*/0, in addTokenOnCurrentLine()
317 if (Current.is(TT_SelectorName) && in addTokenOnCurrentLine()
319 if (Current.LongestObjCSelectorName == 0) in addTokenOnCurrentLine()
321 else if (State.Stack.back().Indent + Current.LongestObjCSelectorName > in addTokenOnCurrentLine()
322 State.Column + Spaces + Current.ColumnWidth) in addTokenOnCurrentLine()
326 Current.LongestObjCSelectorName; in addTokenOnCurrentLine()
328 State.Stack.back().ColonPos = State.Column + Spaces + Current.ColumnWidth; in addTokenOnCurrentLine()
342 (Current.isNot(TT_LineComment) || Previous.BlockKind == BK_BracedInit)) in addTokenOnCurrentLine()
344 if (State.Stack.back().AvoidBinPacking && startsNextParameter(Current, Style)) in addTokenOnCurrentLine()
346 if (startsSegmentOfBuilderTypeCall(Current) && in addTokenOnCurrentLine()
350 if (Current.is(TT_LambdaArrow) && Style.Language == FormatStyle::LK_Java) in addTokenOnCurrentLine()
352 if (Current.isMemberAccess() && Previous.is(tok::r_paren) && in addTokenOnCurrentLine()
365 if (Current.isNot(tok::comment) && Previous.is(tok::l_paren) && in addTokenOnCurrentLine()
372 } else if (!Current.isOneOf(tok::comment, tok::caret) && in addTokenOnCurrentLine()
381 Current.StartsBinaryExpression)) { in addTokenOnCurrentLine()
408 FormatToken &Current = *State.NextToken; in addTokenOnNewLine() local
415 const FormatToken *PreviousNonComment = Current.getPreviousNonComment(); in addTokenOnNewLine()
418 NextNonComment = &Current; in addTokenOnNewLine()
448 Current.NestingLevel != 0 || !PreviousNonComment->is(tok::equal) || in addTokenOnNewLine()
449 !Current.is(Keywords.kw_function)) in addTokenOnNewLine()
493 Current.NestingLevel == 0) in addTokenOnNewLine()
498 if (Current.is(TT_BinaryOperator) && Current.CanBreakBefore) in addTokenOnNewLine()
503 1u, std::min(Current.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1)); in addTokenOnNewLine()
504 Whitespaces.replaceWhitespace(Current, Newlines, in addTokenOnNewLine()
509 if (!Current.isTrailingComment()) in addTokenOnNewLine()
511 State.StartOfLineLevel = Current.NestingLevel; in addTokenOnNewLine()
512 State.LowestLevelOnLine = Current.NestingLevel; in addTokenOnNewLine()
518 Current.is(tok::r_brace) && State.Stack.size() > 1 && in addTokenOnNewLine()
527 Current.NestingLevel != 0) && in addTokenOnNewLine()
531 Current.isNot(TT_BinaryOperator) && !PreviousNonComment->opensScope()) in addTokenOnNewLine()
557 FormatToken &Current = *State.NextToken; in getNewLineColumn() local
558 const FormatToken &Previous = *Current.Previous; in getNewLineColumn()
563 const FormatToken *PreviousNonComment = Current.getPreviousNonComment(); in getNewLineColumn()
566 NextNonComment = &Current; in getNewLineColumn()
570 Current.isOneOf(Keywords.kw_implements, Keywords.kw_extends)) in getNewLineColumn()
575 return Current.NestingLevel == 0 ? State.FirstIndent in getNewLineColumn()
577 if (Current.isOneOf(tok::r_brace, tok::r_square) && State.Stack.size() > 1) { in getNewLineColumn()
578 if (Current.closesBlockOrBlockTypeList(Style)) in getNewLineColumn()
580 if (Current.MatchingParen && in getNewLineColumn()
581 Current.MatchingParen->BlockKind == BK_BracedInit) in getNewLineColumn()
585 if (Current.is(tok::identifier) && Current.Next && in getNewLineColumn()
586 Current.Next->is(TT_DictLiteral)) in getNewLineColumn()
655 if (Previous.is(tok::r_paren) && !Current.isBinaryOperator() && in getNewLineColumn()
656 !Current.isOneOf(tok::colon, tok::comment)) in getNewLineColumn()
669 const FormatToken &Current = *State.NextToken; in moveStateToNextToken() local
671 if (Current.is(TT_InheritanceColon)) in moveStateToNextToken()
673 if (Current.is(tok::lessless) && Current.isNot(TT_OverloadedOperator)) { in moveStateToNextToken()
679 if ((Current.is(TT_BinaryOperator) && Current.isNot(tok::lessless)) || in moveStateToNextToken()
680 Current.is(TT_ConditionalExpr)) in moveStateToNextToken()
682 if (Current.is(TT_ArraySubscriptLSquare) && in moveStateToNextToken()
685 if ((Current.is(tok::question) && Style.BreakBeforeTernaryOperators) || in moveStateToNextToken()
686 (Current.getPreviousNonComment() && Current.isNot(tok::colon) && in moveStateToNextToken()
687 Current.getPreviousNonComment()->is(tok::question) && in moveStateToNextToken()
690 if (!Current.opensScope() && !Current.closesScope()) in moveStateToNextToken()
692 std::min(State.LowestLevelOnLine, Current.NestingLevel); in moveStateToNextToken()
693 if (Current.isMemberAccess()) in moveStateToNextToken()
695 Current.LastOperator ? 0 : State.Column; in moveStateToNextToken()
696 if (Current.is(TT_SelectorName)) { in moveStateToNextToken()
703 if (Current.is(TT_CtorInitializerColon)) { in moveStateToNextToken()
716 if (Current.isOneOf(TT_BinaryOperator, TT_ConditionalExpr) && Newline) in moveStateToNextToken()
718 State.Column + Current.ColumnWidth + 1; in moveStateToNextToken()
721 const FormatToken *Previous = Current.getPreviousNonComment(); in moveStateToNextToken()
729 if (Current.isNot(tok::comment) && Previous && in moveStateToNextToken()
750 if (Current.isStringLiteral() && State.StartOfStringLiteral == 0) in moveStateToNextToken()
752 if (Current.is(TT_ObjCStringLiteral) && State.StartOfStringLiteral == 0) in moveStateToNextToken()
754 else if (!Current.isOneOf(tok::comment, tok::identifier, tok::hash) && in moveStateToNextToken()
755 !Current.isStringLiteral()) in moveStateToNextToken()
758 State.Column += Current.ColumnWidth; in moveStateToNextToken()
760 unsigned Penalty = breakProtrudingToken(Current, State, DryRun); in moveStateToNextToken()
766 if (Current.Role) in moveStateToNextToken()
767 Current.Role->formatFromToken(State, this, DryRun); in moveStateToNextToken()
781 const FormatToken &Current = *State.NextToken; in moveStatePastFakeLParens() local
782 const FormatToken *Previous = Current.getPreviousNonComment(); in moveStatePastFakeLParens()
794 I = Current.FakeLParens.rbegin(), in moveStatePastFakeLParens()
795 E = Current.FakeLParens.rend(); in moveStatePastFakeLParens()
803 if (!Current.isTrailingComment() && in moveStatePastFakeLParens()
808 *I != prec::Comma || Current.NestingLevel == 0)) in moveStatePastFakeLParens()
839 if (*I != prec::Conditional && !Current.is(TT_UnaryOperator)) in moveStatePastFakeLParens()
848 !Current.isTrailingComment())) in moveStatePastFakeLParens()
871 const FormatToken &Current = *State.NextToken; in moveStatePastScopeOpener() local
872 if (!Current.opensScope()) in moveStatePastScopeOpener()
875 if (Current.MatchingParen && Current.BlockKind == BK_Block) { in moveStatePastScopeOpener()
887 if (Current.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare)) { in moveStatePastScopeOpener()
888 if (Current.opensBlockOrBlockTypeList(Style)) { in moveStatePastScopeOpener()
895 const FormatToken *NextNoComment = Current.getNextNonComment(); in moveStatePastScopeOpener()
897 Current.isOneOf(TT_ArrayInitializerLSquare, TT_DictLiteral) || in moveStatePastScopeOpener()
900 if (Current.ParameterCount > 1) in moveStatePastScopeOpener()
912 if (Current.Tok.getKind() == tok::less && in moveStatePastScopeOpener()
913 Current.ParentBracket == tok::l_paren) { in moveStatePastScopeOpener()
922 (Current.PackingKind == PPK_OnePerLine || in moveStatePastScopeOpener()
924 Current.PackingKind == PPK_Inconclusive))); in moveStatePastScopeOpener()
925 if (Current.is(TT_ObjCMethodExpr) && Current.MatchingParen) { in moveStatePastScopeOpener()
929 if (getLengthToMatchingParen(Current) + State.Column > in moveStatePastScopeOpener()
935 for (const FormatToken *Tok = &Current; in moveStatePastScopeOpener()
936 Tok && Tok != Current.MatchingParen; Tok = Tok->Next) { in moveStatePastScopeOpener()
950 Current.Children.empty() && in moveStatePastScopeOpener()
951 !Current.isOneOf(TT_DictLiteral, TT_ArrayInitializerLSquare) && in moveStatePastScopeOpener()
953 (Current.is(TT_TemplateOpener) && in moveStatePastScopeOpener()
959 State.Stack.back().HasMultipleNestedBlocks = Current.BlockParameterCount > 1; in moveStatePastScopeOpener()
963 const FormatToken &Current = *State.NextToken; in moveStatePastScopeCloser() local
964 if (!Current.closesScope()) in moveStatePastScopeCloser()
970 (Current.isOneOf(tok::r_paren, tok::r_square) || in moveStatePastScopeCloser()
971 (Current.is(tok::r_brace) && State.NextToken != State.Line->First) || in moveStatePastScopeCloser()
975 if (Current.is(tok::r_square)) { in moveStatePastScopeCloser()
977 const FormatToken *NextNonComment = Current.getNextNonComment(); in moveStatePastScopeCloser()
998 unsigned ContinuationIndenter::addMultilineToken(const FormatToken &Current, in addMultilineToken() argument
1007 State.Column = Current.LastLineColumnWidth; in addMultilineToken()
1014 unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current, in breakProtrudingToken() argument
1019 if (Current.isNot(TT_BlockComment) && Current.IsMultiline) in breakProtrudingToken()
1020 return addMultilineToken(Current, State); in breakProtrudingToken()
1023 if (Current.is(TT_ImplicitStringLiteral) || in breakProtrudingToken()
1027 if (!Current.isStringLiteral() && !Current.is(tok::comment)) in breakProtrudingToken()
1031 unsigned StartColumn = State.Column - Current.ColumnWidth; in breakProtrudingToken()
1034 if (Current.isStringLiteral()) { in breakProtrudingToken()
1050 if (Current.IsUnterminatedLiteral) in breakProtrudingToken()
1053 StringRef Text = Current.TokenText; in breakProtrudingToken()
1061 if (Text.startswith("\"") && Current.Previous && in breakProtrudingToken()
1062 Current.Previous->is(tok::at)) { in breakProtrudingToken()
1073 Current, State.Line->Level, StartColumn, Prefix, Postfix, in breakProtrudingToken()
1078 } else if (Current.is(TT_BlockComment) && Current.isTrailingComment()) { in breakProtrudingToken()
1080 CommentPragmasRegex.match(Current.TokenText.substr(2))) in breakProtrudingToken()
1083 Current, State.Line->Level, StartColumn, Current.OriginalColumn, in breakProtrudingToken()
1084 !Current.Previous, State.Line->InPPDirective, Encoding, Style)); in breakProtrudingToken()
1085 } else if (Current.is(TT_LineComment) && in breakProtrudingToken()
1086 (Current.Previous == nullptr || in breakProtrudingToken()
1087 Current.Previous->isNot(TT_ImplicitStringLiteral))) { in breakProtrudingToken()
1089 CommentPragmasRegex.match(Current.TokenText.substr(2))) in breakProtrudingToken()
1091 Token.reset(new BreakableLineComment(Current, State.Line->Level, in breakProtrudingToken()
1099 if (Current.UnbreakableTailLength >= ColumnLimit) in breakProtrudingToken()
1102 unsigned RemainingSpace = ColumnLimit - Current.UnbreakableTailLength; in breakProtrudingToken()
1144 Penalty += Current.SplitPenalty; in breakProtrudingToken()
1162 if (Current.isNot(TT_LineComment)) { in breakProtrudingToken()
1167 Penalty += Current.isStringLiteral() ? Style.PenaltyBreakString in breakProtrudingToken()
1181 const FormatToken &Current = *State.NextToken; in nextIsMultilineString() local
1182 if (!Current.isStringLiteral() || Current.is(TT_ImplicitStringLiteral)) in nextIsMultilineString()
1187 if (Current.TokenText.startswith("R\"")) in nextIsMultilineString()
1189 if (Current.IsMultiline) in nextIsMultilineString()
1191 if (Current.getNextNonComment() && in nextIsMultilineString()
1192 Current.getNextNonComment()->isStringLiteral()) in nextIsMultilineString()
1195 State.Column + Current.ColumnWidth + Current.UnbreakableTailLength > in nextIsMultilineString()