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 getMatchingNamespaceToken(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 getMatchingNamespaceTokenText(const AnnotatedLine *Line,
207 getMatchingNamespaceToken(Line, AnnotatedLines);
334 const AnnotatedLine *Line = nullptr;
339 Line = *J;
344 if (!Line)
348 const auto *LastNonComment = Line->getLastNonComment();
713 AnnotatedLine &Line = **I;
714 if (Line.First->isNot(tok::kw_do) && Line.First->isNot(tok::kw_else) &&
715 Line.Last->isNot(tok::kw_else) && Line.Last->isNot(tok::r_paren)) {
719 if (Line.First->is(tok::kw_do) && Line.Last->isNot(tok::kw_do))
731 if (I + 2 != E && Line.startsWith(tok::kw_if) &&
757 const AnnotatedLine *Line = I[1 + NumStmts];
758 if (Line->InPPDirective != InPPDirective)
760 if (Line->InMacroBody != InMacroBody)
762 if (Line->First->isOneOf(tok::kw_case, tok::kw_default, tok::r_brace))
764 if (Line->First->isOneOf(tok::kw_if, tok::kw_for, tok::kw_switch,
769 if (Line->First->is(tok::comment)) {
770 if (Level != Line->Level)
774 Line = *J;
775 if (Line->InPPDirective != InPPDirective)
777 if (Line->First->isOneOf(tok::kw_case, tok::kw_default, tok::r_brace))
779 if (Line->First->isNot(tok::comment) || Level != Line->Level)
784 if (Line->Last->is(tok::comment))
800 AnnotatedLine &Line = **I;
806 Line.First->isOneOf(tok::at, tok::minus, tok::plus)) {
812 if (Line.First->is(tok::kw_case) ||
813 (Line.First->Next && Line.First->Next->is(tok::kw_else))) {
817 if (Line.First->is(tok::kw_default)) {
818 const FormatToken *Tok = Line.First->getNextNonComment();
823 auto IsCtrlStmt = [](const auto &Line) {
824 return Line.First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while,
833 if (IsCtrlStmt(Line) ||
834 Line.First->isOneOf(tok::kw_try, tok::kw___try, tok::kw_catch,
837 Line.startsWithExportBlock()) {
843 Line.First->isOneOf(tok::kw_if, tok::kw_else) &&
849 Line.First->isOneOf(tok::kw_if, tok::kw_else) &&
856 Line.First->isOneOf(tok::kw_while, tok::kw_do, tok::kw_for,
863 Line.First->isOneOf(tok::kw_while, tok::kw_do, tok::kw_for,
875 if (Line.First->isOneOf(tok::kw_try, tok::kw___try, tok::kw_catch,
881 if (Line.endsWith(tok::l_brace)) {
883 Line.First->is(TT_BlockLBrace)) {
887 if (IsSplitBlock && Line.First == Line.Last &&
903 (Style.SpaceInEmptyBlock || Line.Last->is(tok::comment)) ? 1 : 0;
906 } else if (Limit != 0 && !Line.startsWithNamespace() &&
907 !startsExternCBlock(Line)) {
909 if (isRecordLBrace(*Line.Last))
942 // { <-- current Line
945 if (Line.First == Line.Last && Line.First->isNot(TT_FunctionLBrace) &&
1010 bool containsMustBreak(const AnnotatedLine *Line) {
1011 assert(Line->First);
1014 for (const FormatToken *Tok = Line->First->Next; Tok; Tok = Tok->Next)
1096 virtual unsigned formatLine(const AnnotatedLine &Line, unsigned FirstIndent,
1169 State.Line->InPPDirective);
1199 unsigned formatLine(const AnnotatedLine &Line, unsigned FirstIndent,
1203 &Line, /*DryRun=*/false);
1225 unsigned formatLine(const AnnotatedLine &Line, unsigned FirstIndent,
1229 Indenter->getInitialState(FirstIndent, FirstStartColumn, &Line, DryRun);
1250 unsigned formatLine(const AnnotatedLine &Line, unsigned FirstIndent,
1253 Indenter->getInitialState(FirstIndent, FirstStartColumn, &Line, DryRun);
1257 if (State.Line->Type == LT_ObjCMethodDecl)
1448 for (const AnnotatedLine *Line =
1450 Line; PrevPrevLine = PreviousLine, PreviousLine = Line, Line = NextLine,
1452 assert(Line->First);
1453 const AnnotatedLine &TheLine = *Line;
1474 Status->Line =
1551 static auto computeNewlines(const AnnotatedLine &Line,
1556 const auto &RootToken = *Line.First;
1564 !getNamespaceToken(&Line, Lines)) {
1568 if (!PreviousLine && Line.Level > 0)
1592 else if (!Line.startsWithNamespace())
1596 if (Line.startsWith(TT_NamespaceRBrace)) {
1661 const AnnotatedLine &Line, const AnnotatedLine *PreviousLine,
1665 FormatToken &RootToken = *Line.First;
1678 computeNewlines(Line, PreviousLine, PrevPrevLine, Lines, Style);
1689 (Line.Type == LT_PreprocessorDirective ||
1690 Line.Type == LT_ImportStatement)) {
1696 Line.InPPDirective &&