Lines Matching defs:Current

1243   void updateParameterCount(FormatToken *Left, FormatToken *Current) {
1247 if (Current->is(tok::l_brace) && Current->is(BK_Block))
1249 if (Current->is(tok::comma)) {
1253 Left->Role->CommaFound(Current);
1254 } else if (Left->ParameterCount == 0 && Current->isNot(tok::comment)) {
2180 void modifyContext(const FormatToken &Current) {
2182 if (Current.getPrecedence() != prec::Assignment)
2188 assert(Current.Previous);
2189 if (Current.Previous->is(tok::kw_operator)) {
2196 assert(Tok); // Current token is on the same line.
2205 assert(Current.Previous->Previous);
2206 return !Current.Previous->Previous->isOneOf(tok::kw_typename,
2234 return !Current.Previous || Current.Previous->isNot(tok::kw_operator);
2240 for (FormatToken *Previous = Current.Previous;
2258 } else if (Current.is(tok::lessless) &&
2259 (!Current.Previous ||
2260 Current.Previous->isNot(tok::kw_operator))) {
2262 } else if (Current.isOneOf(tok::kw_return, tok::kw_throw)) {
2264 } else if (Current.is(TT_TrailingReturnArrow)) {
2266 } else if (Current.isOneOf(TT_LambdaArrow, Keywords.kw_assert)) {
2268 } else if (Current.Previous &&
2269 Current.Previous->is(TT_CtorInitializerColon)) {
2272 } else if (Current.Previous && Current.Previous->is(TT_InheritanceColon)) {
2274 } else if (Current.isOneOf(tok::r_paren, tok::greater, tok::comma)) {
2275 for (FormatToken *Previous = Current.Previous;
2284 } else if (Current.is(tok::kw_new)) {
2286 } else if (Current.is(tok::semi) ||
2287 (Current.is(tok::exclaim) && Current.Previous &&
2288 Current.Previous->isNot(tok::kw_operator))) {
2296 static FormatToken *untilMatchingParen(FormatToken *Current) {
2299 while (Current) {
2300 if (Current->is(tok::l_paren))
2302 if (Current->is(tok::r_paren))
2306 Current = Current->Next;
2308 return Current;
2311 static bool isDeductionGuide(FormatToken &Current) {
2313 if (Current.Previous && Current.Previous->is(tok::r_paren) &&
2314 Current.startsSequence(tok::arrow, tok::identifier, tok::less)) {
2316 FormatToken *TemplateCloser = Current.Next->Next;
2338 Current.Previous->MatchingParen) {
2342 Current.Previous->MatchingParen->Previous;
2345 LeadingIdentifier->TokenText == Current.Next->TokenText;
2351 void determineTokenType(FormatToken &Current) {
2352 if (Current.isNot(TT_Unknown)) {
2358 Current.is(tok::exclaim)) {
2359 if (Current.Previous) {
2363 *Current.Previous, /* AcceptIdentifierName= */ true)
2364 : Current.Previous->is(tok::identifier);
2366 Current.Previous->isOneOf(
2370 Current.Previous->Tok.isLiteral()) {
2371 Current.setType(TT_NonNullAssertion);
2375 if (Current.Next &&
2376 Current.Next->isOneOf(TT_BinaryOperator, Keywords.kw_as)) {
2377 Current.setType(TT_NonNullAssertion);
2383 // function declaration have been found. In this case, 'Current' is a
2386 Current.is(Keywords.kw_instanceof)) {
2387 Current.setType(TT_BinaryOperator);
2388 } else if (isStartOfName(Current) &&
2389 (!Line.MightBeFunctionDecl || Current.NestingLevel != 0)) {
2390 Contexts.back().FirstStartOfName = &Current;
2391 Current.setType(TT_StartOfName);
2392 } else if (Current.is(tok::semi)) {
2397 } else if (Current.isOneOf(tok::kw_auto, tok::kw___auto_type)) {
2399 } else if (Current.is(tok::arrow) &&
2401 Current.setType(TT_LambdaArrow);
2402 } else if (Current.is(tok::arrow) && Style.isVerilog()) {
2404 Current.setType(TT_BinaryOperator);
2405 } else if (Current.is(tok::arrow) && AutoFound &&
2406 Line.MightBeFunctionDecl && Current.NestingLevel == 0 &&
2407 !Current.Previous->isOneOf(tok::kw_operator, tok::identifier)) {
2409 Current.setType(TT_TrailingReturnArrow);
2410 } else if (Current.is(tok::arrow) && Current.Previous &&
2411 Current.Previous->is(tok::r_brace) &&
2412 Current.Previous->is(BK_Block)) {
2415 Current.setType(TT_TrailingReturnArrow);
2416 } else if (isDeductionGuide(Current)) {
2418 Current.setType(TT_TrailingReturnArrow);
2419 } else if (Current.isPointerOrReference()) {
2420 Current.setType(determineStarAmpUsage(
2421 Current,
2424 } else if (Current.isOneOf(tok::minus, tok::plus, tok::caret) ||
2425 (Style.isVerilog() && Current.is(tok::pipe))) {
2426 Current.setType(determinePlusMinusCaretUsage(Current));
2427 if (Current.is(TT_UnaryOperator) && Current.is(tok::caret))
2429 } else if (Current.isOneOf(tok::minusminus, tok::plusplus)) {
2430 Current.setType(determineIncrementUsage(Current));
2431 } else if (Current.isOneOf(tok::exclaim, tok::tilde)) {
2432 Current.setType(TT_UnaryOperator);
2433 } else if (Current.is(tok::question)) {
2438 Current.setType(TT_JsTypeOptionalQuestion);
2441 Current.setType(TT_Unknown);
2443 Current.setType(TT_ConditionalExpr);
2445 } else if (Current.isBinaryOperator() &&
2446 (!Current.Previous || Current.Previous->isNot(tok::l_square)) &&
2447 (Current.isNot(tok::greater) &&
2450 if (Current.is(tok::lessequal) && Contexts.size() == 1 &&
2454 Current.ForcedPrecedence = prec::Assignment;
2455 Current.setFinalizedType(TT_BinaryOperator);
2457 if (Current.getPrecedence() == prec::Assignment)
2460 Current.setType(TT_BinaryOperator);
2461 } else if (Current.is(tok::comment)) {
2462 if (Current.TokenText.starts_with("/*")) {
2463 if (Current.TokenText.ends_with("*/")) {
2464 Current.setType(TT_BlockComment);
2468 Current.Tok.setKind(tok::unknown);
2471 Current.setType(TT_LineComment);
2473 } else if (Current.is(tok::string_literal)) {
2475 Current.getPreviousNonComment() &&
2476 Current.getPreviousNonComment()->isOneOf(tok::comma, tok::l_brace) &&
2477 Current.getNextNonComment() &&
2478 Current.getNextNonComment()->isOneOf(tok::comma, tok::r_brace)) {
2479 Current.setType(TT_StringInConcatenation);
2481 } else if (Current.is(tok::l_paren)) {
2482 if (lParenStartsCppCast(Current))
2483 Current.setType(TT_CppCastLParen);
2484 } else if (Current.is(tok::r_paren)) {
2485 if (rParenEndsCast(Current))
2486 Current.setType(TT_CastRParen);
2487 if (Current.MatchingParen && Current.Next &&
2488 !Current.Next->isBinaryOperator() &&
2489 !Current.Next->isOneOf(
2492 if (FormatToken *AfterParen = Current.MatchingParen->Next;
2495 if (FormatToken *BeforeParen = Current.MatchingParen->Previous;
2502 Current.setType(TT_FunctionAnnotationRParen);
2506 } else if (Current.is(tok::at) && Current.Next && !Style.isJavaScript() &&
2510 switch (Current.Next->Tok.getObjCKeywordID()) {
2514 Current.setType(TT_ObjCDecl);
2517 Current.setType(TT_ObjCProperty);
2522 } else if (Current.is(tok::period)) {
2523 FormatToken *PreviousNoComment = Current.getPreviousNonComment();
2526 Current.setType(TT_DesignatedInitializerPeriod);
2527 } else if (Style.Language == FormatStyle::LK_Java && Current.Previous &&
2528 Current.Previous->isOneOf(TT_JavaAnnotation,
2530 Current.setType(Current.Previous->getType());
2532 } else if (canBeObjCSelectorComponent(Current) &&
2535 Current.Previous && Current.Previous->is(TT_CastRParen) &&
2536 Current.Previous->MatchingParen &&
2537 Current.Previous->MatchingParen->Previous &&
2538 Current.Previous->MatchingParen->Previous->is(
2543 Current.setType(TT_SelectorName);
2544 } else if (Current.isOneOf(tok::identifier, tok::kw_const, tok::kw_noexcept,
2546 Current.Previous &&
2547 !Current.Previous->isOneOf(tok::equal, tok::at,
2553 Current.setType(TT_TrailingAnnotation);
2556 Current.Previous) {
2557 if (Current.Previous->is(tok::at) &&
2558 Current.isNot(Keywords.kw_interface)) {
2559 const FormatToken &AtToken = *Current.Previous;
2562 Current.setType(TT_LeadingJavaAnnotation);
2564 Current.setType(TT_JavaAnnotation);
2565 } else if (Current.Previous->is(tok::period) &&
2566 Current.Previous->isOneOf(TT_JavaAnnotation,
2568 Current.setType(Current.Previous->getType());
3171 : Style(Style), Keywords(Keywords), Line(Line), Current(Line.First) {}
3177 while (Current && (Current->is(tok::kw_return) ||
3178 (Current->is(tok::colon) &&
3179 Current->isOneOf(TT_ObjCMethodExpr, TT_DictLiteral)))) {
3183 if (!Current || Precedence > PrecedenceArrowAndPeriod)
3199 FormatToken *Start = Current;
3205 while (Current) {
3231 if (Precedence == CurrentPrecedence && Current &&
3232 Current->is(TT_SelectorName)) {
3235 Start = Current;
3240 Precedence == prec::Additive && Current) {
3243 FormatToken *Prev = Current->getPreviousNonComment();
3253 if (!Current ||
3254 (Current->closesScope() &&
3255 (Current->MatchingParen || Current->is(TT_TemplateString))) ||
3258 Precedence == prec::Assignment && Current->is(tok::colon))) {
3265 if (Current->opensScope() ||
3266 Current->isOneOf(TT_RequiresClause,
3270 while (Current && (!Current->closesScope() || Current->opensScope())) {
3279 LatestOperator->NextOperator = Current;
3280 LatestOperator = Current;
3281 Current->OperatorIndex = OperatorIndex;
3292 if (LatestOperator && (Current || Precedence > 0)) {
3301 auto Ret = Current ? Current : Line.Last;
3321 if (Current) {
3322 const FormatToken *NextNonComment = Current->getNextNonComment();
3323 if (Current->is(TT_ConditionalExpr))
3325 if (NextNonComment && Current->is(TT_SelectorName) &&
3330 if (Current->is(TT_JsComputedPropertyName))
3332 if (Current->is(TT_LambdaArrow))
3334 if (Current->is(TT_FatArrow))
3336 if (Current->isOneOf(tok::semi, TT_InlineASMColon, TT_SelectorName) ||
3337 (Current->is(tok::comment) && NextNonComment &&
3341 if (Current->is(TT_RangeBasedForLoopColon))
3344 Current->is(Keywords.kw_instanceof)) {
3348 Current->isOneOf(Keywords.kw_in, Keywords.kw_as)) {
3351 if (Current->is(TT_BinaryOperator) || Current->is(tok::comma))
3352 return Current->getPrecedence();
3353 if (Current->isOneOf(tok::period, tok::arrow) &&
3354 Current->isNot(TT_TrailingReturnArrow)) {
3358 Current->isOneOf(Keywords.kw_extends, Keywords.kw_implements,
3364 if (Style.isVerilog() && Current->is(tok::colon))
3382 if (!End && Current)
3383 End = Current->getPreviousNonComment();
3395 while (Current && Current->is(TT_UnaryOperator)) {
3396 Tokens.push_back(Current);
3407 while (Current && Current->isTrailingComment())
3409 FormatToken *Start = Current;
3411 if (!Current || Current->isNot(tok::question))
3415 if (!Current || Current->isNot(TT_ConditionalExpr))
3423 if (Current)
3424 Current = Current->Next;
3425 while (Current &&
3426 (Current->NewlinesBefore == 0 || SkipPastLeadingComments) &&
3427 Current->isTrailingComment()) {
3428 Current = Current->Next;
3436 if (!Current)
3439 FormatToken *Start = Current;
3555 while (Current && Current != FirstOfType) {
3556 if (Current->opensScope()) {
3570 FormatToken *Current;
3750 // This function heuristically determines whether 'Current' starts the name of a
3753 const FormatToken &Current,
3756 if (Current.is(TT_FunctionDeclarationName))
3759 if (!Current.Tok.getIdentifierInfo())
3762 const auto *Prev = Current.getPreviousNonComment();
3814 const auto *Next = Current.Next;
3818 if (Current.is(tok::kw_operator)) {
3833 if (Current.isNot(TT_StartOfName) || Current.NestingLevel != 0)
4049 for (auto *Current = First->Next; Current; Current = Current->Next) {
4050 const FormatToken *Prev = Current->Previous;
4051 if (Current->is(TT_LineComment)) {
4053 Current->SpacesRequiredBefore =
4058 Current->SpacesRequiredBefore = 0;
4060 Current->SpacesRequiredBefore = Style.SpacesBeforeTrailingComments;
4070 if (!Current->HasUnescapedNewline) {
4071 for (FormatToken *Parameter = Current->Previous; Parameter;
4084 } else if (!Current->Finalized && Current->SpacesRequiredBefore == 0 &&
4085 spaceRequiredBefore(Line, *Current)) {
4086 Current->SpacesRequiredBefore = 1;
4091 Current->MustBreakBefore = true;
4093 Current->MustBreakBefore =
4094 Current->MustBreakBefore || mustBreakBefore(Line, *Current);
4095 if (!Current->MustBreakBefore && InFunctionDecl &&
4096 Current->is(TT_FunctionDeclarationName)) {
4097 Current->MustBreakBefore = mustBreakForReturnType(Line);
4101 Current->CanBreakBefore =
4102 Current->MustBreakBefore || canBreakBefore(Line, *Current);
4109 if (Current->MustBreakBefore || Prev->Children.size() > 1 ||
4112 Current->IsMultiline) {
4113 Current->TotalLength = Prev->TotalLength + Style.ColumnLimit;
4115 Current->TotalLength = Prev->TotalLength + Current->ColumnWidth +
4116 ChildSize + Current->SpacesRequiredBefore;
4119 if (Current->is(TT_CtorInitializerColon))
4131 Current->SplitPenalty = splitPenalty(Line, *Current, InFunctionDecl);
4133 Current->is(TT_SelectorName) && Current->ParameterIndex > 0) {
4134 if (Current->ParameterIndex == 1)
4135 Current->SplitPenalty += 5 * Current->BindingStrength;
4137 Current->SplitPenalty += 20 * Current->BindingStrength;
4143 for (auto *Current = First; Current; Current = Current->Next) {
4144 if (Current->Role)
4145 Current->Role->precomputeFormattingInfos(Current);
4146 if (Current->MatchingParen &&
4147 Current->MatchingParen->opensBlockOrBlockTypeList(Style) &&
4151 Current->IndentLevel = IndentLevel;
4152 if (Current->opensBlockOrBlockTypeList(Style))
4162 FormatToken *Current = Line.Last;
4163 while (Current) {
4164 Current->UnbreakableTailLength = UnbreakableTailLength;
4165 if (Current->CanBreakBefore ||
4166 Current->isOneOf(tok::comment, tok::string_literal)) {
4170 Current->ColumnWidth + Current->SpacesRequiredBefore;
4172 Current = Current->Previous;