Lines Matching full:current

92   // Maintains a stack level corresponding to the current End token.
131 // Returns \c true if \c Current starts a new parameter.
132 static bool startsNextParameter(const FormatToken &Current,
134 const FormatToken &Previous = *Current.Previous;
135 if (Current.is(TT_CtorInitializerComma) &&
139 if (Style.Language == FormatStyle::LK_Proto && Current.is(TT_SelectorName))
141 return Previous.is(tok::comma) && !Current.isTrailingComment() &&
291 const FormatToken &Current = *State.NextToken;
292 const FormatToken &Previous = *Current.Previous;
294 assert(&Previous == Current.Previous);
295 if (!Current.CanBreakBefore && !(CurrentState.BreakBeforeClosingBrace &&
296 Current.closesBlockOrBlockTypeList(Style))) {
301 if (!Current.MustBreakBefore && Previous.is(tok::l_brace) &&
314 State.LowestLevelOnLine < Current.NestingLevel) {
317 if (Current.isMemberAccess() && CurrentState.ContainsUnwrappedBuilder)
331 if (Current.is(TT_FunctionDeclarationName)) {
346 if (!Current.isOneOf(TT_BinaryOperator, tok::comma) &&
351 Current.isNot(TT_LambdaLBrace)) &&
359 if (Current.is(TT_ConditionalExpr) && Previous.is(tok::r_paren) &&
372 const FormatToken &Current = *State.NextToken;
373 const FormatToken &Previous = *Current.Previous;
375 if (Style.BraceWrapping.BeforeLambdaBody && Current.CanBreakBefore &&
376 Current.is(TT_LambdaLBrace) && Previous.isNot(TT_LineComment)) {
377 auto LambdaBodyLength = getLengthToMatchingParen(Current, State.Stack);
380 if (Current.MustBreakBefore ||
381 (Current.is(TT_InlineASMColon) &&
388 (Current.closesBlockOrBlockTypeList(Style) ||
389 (Current.is(tok::r_brace) &&
390 Current.isBlockIndentedInitRBrace(Style)))) {
393 if (CurrentState.BreakBeforeClosingParen && Current.is(tok::r_paren))
397 Current.ObjCSelectorNameParts > 1 &&
398 Current.startsSequence(TT_SelectorName, tok::colon, tok::caret)) {
407 if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) ||
408 (Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) &&
415 (Style.BreakBeforeTernaryOperators && Current.is(TT_ConditionalExpr) &&
419 CurrentState.BreakBeforeParameter && !Current.isTrailingComment() &&
420 !Current.isOneOf(tok::r_paren, tok::r_brace)) {
424 ((Style.BreakBeforeTernaryOperators && Current.is(TT_ConditionalExpr) &&
425 Current.is(tok::colon)) ||
443 : Current;
448 (!Current.isTrailingComment() || Current.NewlinesBefore > 0) &&
455 if (Current.is(TT_ObjCMethodExpr) && Previous.isNot(TT_SelectorName) &&
459 if (Current.is(TT_SelectorName) && Previous.isNot(tok::at) &&
462 !Current.startsSequence(TT_SelectorName, tok::colon, tok::caret))) {
467 if (Current.isMemberAccess() && Style.ColumnLimit != 0 &&
468 State.Column + getLengthToNextOperator(Current) > Style.ColumnLimit &&
470 Current.NestingLevel < State.StartOfLineLevel)) {
474 if (startsSegmentOfBuilderTypeCall(Current) &&
490 Current.CanBreakBefore) {
499 Previous.is(tok::comma) || Current.NestingLevel < 2) &&
508 // current style uses wrapping before or after operators for the given
510 if (Previous.is(TT_BinaryOperator) && Current.CanBreakBefore) {
513 CurrentState.BreakBeforeParameter && !Current.isTrailingComment()) {
536 } else if (Current.is(TT_BinaryOperator) && Current.CanBreakBefore &&
542 if (Current.is(tok::lessless) && Current.isNot(TT_OverloadedOperator) &&
547 if (Current.NestingLevel == 0 && !Current.isTrailingComment()) {
553 if (Current.is(tok::kw_concept)) {
563 if (Current.is(TT_RequiresClause)) {
574 Current.NewlinesBefore > 0);
580 if (Previous.is(TT_LeadingJavaAnnotation) && Current.isNot(tok::l_paren) &&
581 Current.isNot(TT_LeadingJavaAnnotation)) {
592 if (BreakBeforeDecoratedTokens.contains(Current.TokenText))
596 if (Current.is(TT_FunctionDeclarationName) &&
613 !Current.isOneOf(tok::r_brace, tok::comment)) {
617 if (Current.is(tok::lessless) &&
636 const FormatToken &Current = *State.NextToken;
643 if (Current.is(TT_ImplicitStringLiteral) &&
648 SourceMgr.getSpellingColumnNumber(Current.WhitespaceRange.getEnd());
649 if (Current.LastNewlineOffset != 0) {
651 // determined by the current end column.
655 SourceMgr.getSpellingColumnNumber(Current.WhitespaceRange.getBegin());
674 FormatToken &Current = *State.NextToken;
681 Style.isCpp() && [&Current] {
687 const auto *Prev = Current.Previous;
691 if (Prev->is(TT_BlockComment) && Current.SpacesRequiredBefore == 0)
693 const auto *PrevNonComment = Current.getPreviousNonComment();
696 if (Current.isOneOf(tok::comment, tok::l_paren, TT_LambdaLSquare))
720 if (Current.is(tok::equal) &&
721 (State.Line->First->is(tok::kw_for) || Current.NestingLevel == 0) &&
738 unsigned Spaces = Current.SpacesRequiredBefore + ExtraSpaces;
758 Whitespaces.replaceWhitespace(Current, /*Newlines=*/0, Spaces,
766 Current.is(TT_InheritanceColon)) {
774 if (Current.is(TT_SelectorName) && !CurrentState.ObjCSelectorNameFound) {
777 unsigned FirstColonPos = State.Column + Spaces + Current.ColumnWidth;
778 if (Current.LongestObjCSelectorName == 0)
780 else if (MinIndent + Current.LongestObjCSelectorName > FirstColonPos)
781 CurrentState.ColonPos = MinIndent + Current.LongestObjCSelectorName;
816 Current.FakeLParens.size() > 0 &&
817 Current.FakeLParens.back() > prec::Unknown) {
832 !(Current.MacroParent && Previous.MacroParent) &&
833 (Current.isNot(TT_LineComment) ||
838 if (CurrentState.AvoidBinPacking && startsNextParameter(Current, Style))
840 if (startsSegmentOfBuilderTypeCall(Current) &&
845 if (Current.is(TT_LambdaArrow) && Style.Language == FormatStyle::LK_Java)
847 if (Current.isMemberAccess() && Previous.is(tok::r_paren) &&
863 const FormatToken *P = Current.getPreviousNonComment();
864 if (Current.isNot(tok::comment) && P &&
890 if (Current.isNot(tok::comment) && Previous.is(tok::l_paren) &&
897 } else if (!Current.isOneOf(tok::comment, tok::caret) &&
903 (!Current.isTrailingComment() || Current.NewlinesBefore > 0) &&
914 Current.StartsBinaryExpression)) {
922 } else if (Current.is(TT_CSharpGenericTypeConstraintColon)) {
942 FormatToken &Current = *State.NextToken;
951 const FormatToken *PreviousNonComment = Current.getPreviousNonComment();
954 NextNonComment = &Current;
1001 if (Current.isNot(TT_LambdaArrow) &&
1002 (!Style.isJavaScript() || Current.NestingLevel != 0 ||
1004 !Current.isOneOf(Keywords.kw_async, Keywords.kw_function))) {
1055 Current.NestingLevel == 0) {
1062 if (Current.is(TT_BinaryOperator) && Current.CanBreakBefore)
1067 if (Current.is(tok::r_brace) && Current.MatchingParen &&
1070 !Current.MatchingParen->Children.empty()) {
1077 std::max(1u, std::min(Current.NewlinesBefore, MaxEmptyLinesToKeep));
1080 Whitespaces.replaceWhitespace(Current, Newlines, State.Column, State.Column,
1084 if (!Current.isTrailingComment())
1086 if (Current.is(tok::lessless)) {
1093 State.StartOfLineLevel = Current.NestingLevel;
1094 State.LowestLevelOnLine = Current.NestingLevel;
1099 (!Style.isCpp() && Current.is(tok::r_brace) && State.Stack.size() > 1 &&
1101 (Style.Language == FormatStyle::LK_ObjC && Current.is(tok::r_brace) &&
1106 (Current.MatchingParen &&
1107 Current.MatchingParen->is(TT_RequiresExpressionLBrace));
1111 Current.MatchingParen && Current.MatchingParen->is(TT_LambdaLBrace)) {
1147 Current.NestingLevel != 0) &&
1151 Current.isNot(TT_BinaryOperator) && !PreviousNonComment->opensScope() &&
1155 Current.isNot(TT_LambdaLBrace))) {
1211 FormatToken &Current = *State.NextToken;
1215 Current.isNot(TT_CSharpGenericTypeConstraint)) {
1219 const FormatToken &Previous = *Current.Previous;
1224 const FormatToken *PreviousNonComment = Current.getPreviousNonComment();
1227 NextNonComment = &Current;
1231 Current.isOneOf(Keywords.kw_implements, Keywords.kw_extends)) {
1251 if (Current.NestingLevel == 0 ||
1258 if (Current.is(TT_LambdaArrow) &&
1263 if ((Current.isOneOf(tok::r_brace, tok::r_square) ||
1264 (Current.is(tok::greater) && (Style.isProto() || Style.isTableGen()))) &&
1266 if (Current.closesBlockOrBlockTypeList(Style))
1268 if (Current.MatchingParen && Current.MatchingParen->is(BK_BracedInit))
1287 if (Current.is(tok::r_paren) && State.Stack.size() > 1 &&
1288 (!Current.Next ||
1289 Current.Next->isOneOf(tok::semi, tok::kw_const, tok::l_brace))) {
1294 if (Style.isTableGen() && Current.is(TT_TableGenDAGArgCloser) &&
1299 (Current.is(tok::r_paren) ||
1300 (Current.is(tok::r_brace) && Current.MatchingParen &&
1301 Current.MatchingParen->is(BK_BracedInit))) &&
1314 if (Current.is(tok::identifier) && Current.Next &&
1315 (!Style.isVerilog() || Current.Next->is(tok::colon)) &&
1316 (Current.Next->is(TT_DictLiteral) ||
1317 (Style.isProto() && Current.Next->isOneOf(tok::less, tok::l_brace)))) {
1340 (Previous.is(tok::colon) && !Current.FakeLParens.empty() &&
1341 Current.FakeLParens.back() == prec::Conditional)) &&
1358 if (Current.is(TT_RequiresClause)) {
1377 Current.isNot(tok::l_paren)) ||
1459 !Current.isBinaryOperator() &&
1460 !Current.isOneOf(tok::colon, tok::comment)) {
1463 if (Current.is(TT_ProtoExtensionLSquare))
1465 if (Current.isBinaryOperator() && CurrentState.UnindentOperator) {
1466 return CurrentState.Indent - Current.Tok.getLength() -
1467 Current.SpacesRequiredBefore;
1469 if (Current.is(tok::comment) && NextNonComment->isBinaryOperator() &&
1484 const FormatToken &Current,
1492 return Style.BraceWrapping.BeforeLambdaBody && Current.is(TT_LambdaLSquare);
1498 const FormatToken &Current = *State.NextToken;
1501 if (Current.is(TT_CSharpGenericTypeConstraint))
1503 if (Current.isOneOf(tok::comma, TT_BinaryOperator))
1505 if (Current.isOneOf(TT_InheritanceColon, TT_CSharpGenericTypeConstraintColon))
1507 if (Current.is(tok::lessless) && Current.isNot(TT_OverloadedOperator)) {
1513 if (Current.is(TT_BinaryOperator) && Current.isNot(tok::lessless))
1515 if (Current.is(TT_ConditionalExpr) && Current.Previous &&
1516 Current.Previous->isNot(TT_ConditionalExpr)) {
1519 if (Current.is(TT_ArraySubscriptLSquare) &&
1533 if (IsWrappedConditional(Current))
1535 if (Style.BreakBeforeTernaryOperators && Current.is(tok::question))
1537 if (!Style.BreakBeforeTernaryOperators && Current.isNot(tok::colon)) {
1538 const FormatToken *Previous = Current.Previous;
1544 if (!Current.opensScope() && !Current.closesScope() &&
1545 Current.isNot(TT_PointerOrReference)) {
1547 std::min(State.LowestLevelOnLine, Current.NestingLevel);
1549 if (Current.isMemberAccess())
1550 CurrentState.StartOfFunctionCall = !Current.NextOperator ? 0 : State.Column;
1551 if (Current.is(TT_SelectorName))
1553 if (Current.is(TT_CtorInitializerColon) &&
1575 if (Current.is(TT_CtorInitializerColon) &&
1585 if (Current.is(TT_InheritanceColon)) {
1589 if (Current.isOneOf(TT_BinaryOperator, TT_ConditionalExpr) && Newline)
1590 CurrentState.NestedBlockIndent = State.Column + Current.ColumnWidth + 1;
1591 if (Current.isOneOf(TT_LambdaLSquare, TT_LambdaArrow))
1593 if (Current.is(TT_RequiresExpression) &&
1599 const FormatToken *Previous = Current.getPreviousNonComment();
1607 if (Current.isNot(tok::comment) && !Current.ClosesRequiresClause &&
1620 !Newline && hasNestedBlockInlined(Previous, Current, Style);
1632 if (Current.is(TT_ObjCStringLiteral) && State.StartOfStringLiteral == 0)
1634 if (Current.is(TT_CSharpStringLiteral) && State.StartOfStringLiteral == 0) {
1636 } else if (Current.is(TT_TableGenMultiLineString) &&
1639 } else if (Current.isStringLiteral() && State.StartOfStringLiteral == 0) {
1641 } else if (!Current.isOneOf(tok::comment, tok::identifier, tok::hash) &&
1642 !Current.isStringLiteral()) {
1646 State.Column += Current.ColumnWidth;
1654 Keywords.isVerilogEndOfLabel(Current)) {
1660 handleEndOfLine(Current, State, DryRun, AllowBreak, Newline);
1662 if (Current.Role)
1663 Current.Role->formatFromToken(State, this, DryRun);
1677 const FormatToken &Current = *State.NextToken;
1678 if (Current.FakeLParens.empty())
1681 const FormatToken *Previous = Current.getPreviousNonComment();
1693 for (const auto &PrecedenceLevel : llvm::reverse(Current.FakeLParens)) {
1712 if (!Current.isTrailingComment() &&
1718 PrecedenceLevel > prec::Comma || Current.NestingLevel == 0) &&
1735 if ((shouldUnindentNextOperator(Current) ||
1758 Current.isNot(TT_UnaryOperator) &&
1770 &PrecedenceLevel == &Current.FakeLParens.back() &&
1776 !Current.isTrailingComment())) {
1806 const FormatToken &Current = *State.NextToken;
1807 if (!Current.opensScope())
1813 if (Current.isOneOf(tok::less, tok::l_paren) &&
1818 if (Current.MatchingParen && Current.is(BK_Block)) {
1829 if (Current.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare) ||
1830 opensProtoMessageField(Current, Style)) {
1831 if (Current.opensBlockOrBlockTypeList(Style)) {
1834 } else if (Current.is(tok::l_brace)) {
1841 const FormatToken *NextNonComment = Current.getNextNonComment();
1842 bool EndsInComma = Current.MatchingParen &&
1843 Current.MatchingParen->Previous &&
1844 Current.MatchingParen->Previous->is(tok::comma);
1845 AvoidBinPacking = EndsInComma || Current.is(TT_DictLiteral) ||
1851 if (Current.ParameterCount > 1)
1858 if (Style.isTableGen() && Current.is(TT_TableGenDAGArgOpenerToBreak) &&
1864 const FormatToken *Next = Current.Next;
1873 if (Current.is(tok::less) && Current.ParentBracket == tok::l_paren) {
1879 Current.MatchingParen &&
1880 Current.MatchingParen->getPreviousNonComment() &&
1881 Current.MatchingParen->getPreviousNonComment()->is(tok::comma);
1895 Current.getPreviousNonComment() &&
1896 Current.getPreviousNonComment()->is(tok::kw__Generic);
1904 (Current.is(PPK_OnePerLine) ||
1905 (!BinPackInconclusiveFunctions && Current.is(PPK_Inconclusive))));
1907 if (Current.is(TT_ObjCMethodExpr) && Current.MatchingParen &&
1912 if (getLengthToMatchingParen(Current, State.Stack) + State.Column >
1919 for (const FormatToken *Tok = &Current;
1920 Tok && Tok != Current.MatchingParen; Tok = Tok->Next) {
1933 // Generally inherit NoLineBreak from the current scope to nested scope.
1937 Current.Children.empty() &&
1938 !Current.isOneOf(TT_DictLiteral, TT_ArrayInitializerLSquare) &&
1940 (Current.is(TT_TemplateOpener) &&
1943 ParenState(&Current, NewIndent, LastSpace, AvoidBinPacking, NoLineBreak));
1947 NewState.HasMultipleNestedBlocks = (Current.BlockParameterCount > 1);
1949 if (Style.BraceWrapping.BeforeLambdaBody && Current.Next &&
1950 Current.is(tok::l_paren)) {
1952 FormatToken const *next = Current.Next;
1962 NewState.IsInsideObjCArrayLiteral = Current.is(TT_ArrayInitializerLSquare) &&
1963 Current.Previous &&
1964 Current.Previous->is(tok::at);
1968 const FormatToken &Current = *State.NextToken;
1969 if (!Current.closesScope())
1975 (Current.isOneOf(tok::r_paren, tok::r_square, TT_TemplateString) ||
1976 (Current.is(tok::r_brace) && State.NextToken != State.Line->First) ||
1979 (Current.is(tok::greater) && Current.is(TT_DictLiteral)))) {
1995 if (CurrentState.BreakBeforeParameter && Current.MatchingParen &&
1996 Current.MatchingParen->Previous) {
1997 const FormatToken &CurrentScopeOpener = *Current.MatchingParen->Previous;
2002 CurrentScopeOpener.TotalLength - Current.TotalLength - 1;
2003 if (State.Column + Current.ColumnWidth + NecessarySpaceInLine <=
2010 if (Current.is(tok::r_square)) {
2012 const FormatToken *NextNonComment = Current.getNextNonComment();
2060 const FormatToken &Current, LineState &State,
2062 unsigned StartColumn = State.Column - Current.ColumnWidth;
2063 StringRef OldDelimiter = *getRawStringDelimiter(Current.TokenText);
2075 Current.TokenText.substr(OldPrefixSize).drop_back(OldSuffixSize));
2092 // - if the content starts on newline, it is one level more than the current
2099 bool ContentStartsOnNewline = Current.TokenText[OldPrefixSize] == '\n';
2122 (!Newline && Current.Next && Current.Next->is(tok::r_paren))
2135 // - if the raw string prefix does not start on a newline, it is the current
2138 Current.NewlinesBefore ? FirstStartColumn - NewPrefixSize : CurrentIndent;
2148 return addMultilineToken(Current, State);
2154 Current.Tok.getLocation().getLocWithOffset(2);
2165 Current.Tok.getLocation().getLocWithOffset(Current.TokenText.size() -
2176 Current.Tok.getLocation().getLocWithOffset(OldPrefixSize);
2207 unsigned ContinuationIndenter::addMultilineToken(const FormatToken &Current,
2216 State.Column = Current.LastLineColumnWidth;
2223 unsigned ContinuationIndenter::handleEndOfLine(const FormatToken &Current,
2229 auto RawStringStyle = getRawStringStyle(Current, State);
2230 if (RawStringStyle && !Current.Finalized) {
2231 Penalty = reformatRawStringLiteral(Current, State, *RawStringStyle, DryRun,
2233 } else if (Current.IsMultiline && Current.isNot(TT_BlockComment)) {
2236 Penalty = addMultilineToken(Current, State);
2248 Current, State, AllowBreak, /*DryRun=*/true, Strict);
2254 breakProtrudingToken(Current, StrictState, AllowBreak,
2266 breakProtrudingToken(Current, OriginalState, AllowBreak, /*DryRun=*/false,
2279 static StringRef getEnclosingFunctionName(const FormatToken &Current) {
2280 // Look for: 'function(' or 'function<templates>(' before Current.
2281 auto Tok = Current.getPreviousNonComment();
2298 ContinuationIndenter::getRawStringStyle(const FormatToken &Current,
2300 if (!Current.isStringLiteral())
2302 auto Delimiter = getRawStringDelimiter(Current.TokenText);
2308 getEnclosingFunctionName(Current));
2317 ContinuationIndenter::createBreakableToken(const FormatToken &Current,
2319 unsigned StartColumn = State.Column - Current.ColumnWidth;
2320 if (Current.isStringLiteral()) {
2337 if (Current.IsUnterminatedLiteral)
2348 if (Style.isVerilog() && Current.Previous &&
2349 Current.Previous->isOneOf(tok::kw_export, Keywords.kw_import)) {
2352 StringRef Text = Current.TokenText;
2356 // UnbreakableTailLength of Current is an overapproximation in that case and
2360 : Current.UnbreakableTailLength;
2377 Current, QuoteStyle,
2378 /*UnindentPlus=*/shouldUnindentNextOperator(Current), StartColumn,
2397 Current, StartColumn, Prefix, Postfix, UnbreakableTailLength,
2400 } else if (Current.is(TT_BlockComment)) {
2405 switchesFormatting(Current)) {
2409 Current, StartColumn, Current.OriginalColumn, !Current.Previous,
2411 } else if (Current.is(TT_LineComment) &&
2412 (!Current.Previous ||
2413 Current.Previous->isNot(TT_ImplicitStringLiteral))) {
2415 for (const FormatToken *T = &Current; T && T->is(TT_LineComment);
2423 CommentPragmasRegex.match(Current.TokenText.substr(2)) ||
2424 switchesFormatting(Current) || !RegularComments) {
2428 Current, StartColumn, /*InPPDirective=*/false, Encoding, Style);
2434 ContinuationIndenter::breakProtrudingToken(const FormatToken &Current,
2438 createBreakableToken(Current, State, AllowBreak);
2443 if (Current.is(TT_LineComment)) {
2452 if (Current.UnbreakableTailLength >= ColumnLimit)
2456 unsigned StartColumn = State.Column - Current.ColumnWidth;
2457 unsigned NewBreakPenalty = Current.isStringLiteral()
2473 // Where we are in the content of the current logical line.
2478 // The number of columns left in the current logical line after TailOffset.
2495 // we'll start reflowing if the current line is broken or whitespace is
2498 // Break the current token until we can fit the rest of the line.
2505 // If the current token doesn't fit, find the latest possible split in the
2506 // current line so that breaking at it will be under the column limit.
2527 // Check whether the next natural split point after the current one can
2554 // into the current line.
2572 // If the whitespace compression makes us fit, continue on the current
2579 // penalty of introducing a new break, continue on the current line.
2593 // The current line fits after compressing the whitespace - reflow
2610 // Update the ContentIndent only if the current line was not reflown with
2659 // After breaking a line, try to reflow the next line into the current
2665 // current one.
2675 // When we reflow, we need to add a space between the end of the current
2679 // of the current one; the split will include any leading whitespace of
2690 // If the rest of the next line fits into the current line below the
2704 // of the next line to that break point onto the current line is
2793 Current.UnbreakableTailLength;
2802 if (Current.isNot(TT_LineComment))
2806 if (Current.is(TT_BlockComment))
2823 const FormatToken &Current = *State.NextToken;
2824 if (!Current.isStringLiteral() || Current.is(TT_ImplicitStringLiteral))
2829 if (Current.TokenText.starts_with("R\""))
2831 if (Current.IsMultiline)
2833 if (Current.getNextNonComment() &&
2834 Current.getNextNonComment()->isStringLiteral()) {
2838 State.Column + Current.ColumnWidth + Current.UnbreakableTailLength >