Lines Matching defs:Line
23 bool startsExternCBlock(const AnnotatedLine &Line) {
24 const FormatToken *Next = Line.First->getNextNonComment();
26 return Line.startsWith(tok::kw_extern) && Next && Next->isStringLiteral() &&
57 /// Update the indent state given that \p Line is going to be formatted
59 void nextLine(const AnnotatedLine &Line) {
60 Offset = getIndentOffset(Line);
63 if (Line.Level >= IndentForLevel.size())
64 IndentForLevel.resize(Line.Level + 1, -1);
66 (Line.InPPDirective ||
68 Line.Type == LT_CommentAbovePPDirective))) {
71 Indent = Line.InMacroBody
72 ? Line.PPLevel * PPIndentWidth +
73 (Line.Level - Line.PPLevel) * Style.IndentWidth
74 : Line.Level * PPIndentWidth;
80 if (!Line.InPPDirective) {
81 assert(Line.Level <= IndentForLevel.size());
82 IndentForLevel.resize(Line.Level + 1);
84 Indent = getIndent(Line.Level);
88 if (Line.IsContinuation)
89 Indent = Line.Level * Style.IndentWidth + Style.ContinuationIndentWidth;
92 /// Update the level indent to adapt to the given \p Line.
97 void adjustToUnmodifiedLine(const AnnotatedLine &Line) {
98 if (Line.InPPDirective || Line.IsContinuation)
100 assert(Line.Level < IndentForLevel.size());
101 if (Line.First->is(tok::comment) && IndentForLevel[Line.Level] != -1)
103 unsigned LevelIndent = Line.First->OriginalColumn;
106 IndentForLevel[Line.Level] = LevelIndent;
114 int getIndentOffset(const AnnotatedLine &Line) {
121 if (Line.Type == LT_AccessModifier || RootToken.isObjCAccessSpecifier())
141 if (IsAccessModifier(*Line.First)) {
187 const AnnotatedLine *Line,
189 if (!Line->startsWith(tok::r_brace))
191 size_t StartLineIndex = Line->MatchingOpeningBlockLineIndex;
198 StringRef getNamespaceTokenText(const AnnotatedLine *Line) {
199 const FormatToken *NamespaceToken = Line->First->getNamespaceToken();
204 const AnnotatedLine *Line,
207 getMatchingNamespaceToken(Line, AnnotatedLines);
334 const AnnotatedLine *Line = nullptr;
339 Line = *J;
344 if (!Line)
348 const auto *LastNonComment = Line->getLastNonComment();
635 AnnotatedLine &Line = **I;
636 if (Line.First->isNot(tok::kw_do) && Line.First->isNot(tok::kw_else) &&
637 Line.Last->isNot(tok::kw_else) && Line.Last->isNot(tok::r_paren)) {
641 if (Line.First->is(tok::kw_do) && Line.Last->isNot(tok::kw_do))
653 if (I + 2 != E && Line.startsWith(tok::kw_if) &&
680 const AnnotatedLine *Line = I[1 + NumStmts];
681 if (Line->InPPDirective != InPPDirective)
683 if (Line->InMacroBody != InMacroBody)
685 if (Line->First->isOneOf(tok::kw_case, tok::kw_default, tok::r_brace))
687 if (Line->First->isOneOf(tok::kw_if, tok::kw_for, tok::kw_switch,
692 if (Line->First->is(tok::comment)) {
693 if (Level != Line->Level)
697 Line = *J;
698 if (Line->InPPDirective != InPPDirective)
700 if (Line->First->isOneOf(tok::kw_case, tok::kw_default, tok::r_brace))
702 if (Line->First->isNot(tok::comment) || Level != Line->Level)
707 if (Line->Last->is(tok::comment))
724 AnnotatedLine &Line = **I;
730 Line.First->isOneOf(tok::at, tok::minus, tok::plus)) {
736 if (Line.First->is(tok::kw_case) ||
737 (Line.First->Next && Line.First->Next->is(tok::kw_else))) {
741 if (Line.First->is(tok::kw_default)) {
742 const FormatToken *Tok = Line.First->getNextNonComment();
747 auto IsCtrlStmt = [](const auto &Line) {
748 return Line.First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while,
757 if (IsCtrlStmt(Line) ||
758 Line.First->isOneOf(tok::kw_try, tok::kw___try, tok::kw_catch,
766 Line.First->isOneOf(tok::kw_if, tok::kw_else) &&
772 Line.First->isOneOf(tok::kw_if, tok::kw_else) &&
779 Line.First->isOneOf(tok::kw_while, tok::kw_do, tok::kw_for,
786 Line.First->isOneOf(tok::kw_while, tok::kw_do, tok::kw_for,
798 if (Line.First->isOneOf(tok::kw_try, tok::kw___try, tok::kw_catch,
804 if (Line.endsWith(tok::l_brace)) {
806 Line.First->is(TT_BlockLBrace)) {
810 if (IsSplitBlock && Line.First == Line.Last &&
826 (Style.SpaceInEmptyBlock || Line.Last->is(tok::comment)) ? 1 : 0;
829 } else if (Limit != 0 && !Line.startsWithNamespace() &&
830 !startsExternCBlock(Line)) {
832 if (isRecordLBrace(*Line.Last))
865 // { <-- current Line
868 if (Line.First == Line.Last && Line.First->isNot(TT_FunctionLBrace) &&
919 bool containsMustBreak(const AnnotatedLine *Line) {
920 assert(Line->First);
923 for (const FormatToken *Tok = Line->First->Next; Tok; Tok = Tok->Next)
1005 virtual unsigned formatLine(const AnnotatedLine &Line, unsigned FirstIndent,
1078 State.Line->InPPDirective);
1108 unsigned formatLine(const AnnotatedLine &Line, unsigned FirstIndent,
1112 &Line, /*DryRun=*/false);
1134 unsigned formatLine(const AnnotatedLine &Line, unsigned FirstIndent,
1138 Indenter->getInitialState(FirstIndent, FirstStartColumn, &Line, DryRun);
1159 unsigned formatLine(const AnnotatedLine &Line, unsigned FirstIndent,
1162 Indenter->getInitialState(FirstIndent, FirstStartColumn, &Line, DryRun);
1166 if (State.Line->Type == LT_ObjCMethodDecl)
1357 for (const AnnotatedLine *Line =
1359 Line; PrevPrevLine = PreviousLine, PreviousLine = Line, Line = NextLine,
1361 assert(Line->First);
1362 const AnnotatedLine &TheLine = *Line;
1383 Status->Line =
1460 static auto computeNewlines(const AnnotatedLine &Line,
1465 const auto &RootToken = *Line.First;
1473 !getNamespaceToken(&Line, Lines)) {
1477 if (!PreviousLine && Line.Level > 0)
1553 const AnnotatedLine &Line, const AnnotatedLine *PreviousLine,
1557 FormatToken &RootToken = *Line.First;
1570 computeNewlines(Line, PreviousLine, PrevPrevLine, Lines, Style);
1581 (Line.Type == LT_PreprocessorDirective ||
1582 Line.Type == LT_ImportStatement)) {
1588 Line.InPPDirective &&