clang API Documentation
#include <ContinuationIndenter.h>
Public Member Functions | |
| ContinuationIndenter (const FormatStyle &Style, const AdditionalKeywords &Keywords, SourceManager &SourceMgr, WhitespaceManager &Whitespaces, encoding::Encoding Encoding, bool BinPackInconclusiveFunctions) | |
Constructs a ContinuationIndenter to format Line starting in column FirstIndent. | |
| LineState | getInitialState (unsigned FirstIndent, const AnnotatedLine *Line, bool DryRun) |
Get the initial state, i.e. the state after placing Line's first token at FirstIndent. | |
| bool | canBreak (const LineState &State) |
Returns true, if a line break after State is allowed. | |
| bool | mustBreak (const LineState &State) |
Returns true, if a line break after State is mandatory. | |
| unsigned | addTokenToState (LineState &State, bool Newline, bool DryRun, unsigned ExtraSpaces=0) |
Appends the next token to State and updates information necessary for indentation. | |
| unsigned | getColumnLimit (const LineState &State) const |
| Get the column limit for this line. This is the style's column limit, potentially reduced for preprocessor definitions. | |
Definition at line 35 of file ContinuationIndenter.h.
| clang::format::ContinuationIndenter::ContinuationIndenter | ( | const FormatStyle & | Style, |
| const AdditionalKeywords & | Keywords, | ||
| SourceManager & | SourceMgr, | ||
| WhitespaceManager & | Whitespaces, | ||
| encoding::Encoding | Encoding, | ||
| bool | BinPackInconclusiveFunctions | ||
| ) |
Constructs a ContinuationIndenter to format Line starting in column FirstIndent.
Definition at line 59 of file ContinuationIndenter.cpp.
| unsigned clang::format::ContinuationIndenter::addTokenToState | ( | LineState & | State, |
| bool | Newline, | ||
| bool | DryRun, | ||
| unsigned | ExtraSpaces = 0 |
||
| ) |
Appends the next token to State and updates information necessary for indentation.
Puts the token on the current line if Newline is false and adds a line break and necessary indentation otherwise.
If DryRun is false, also creates and stores the required Replacement.
Definition at line 236 of file ContinuationIndenter.cpp.
References clang::format::LineState::Column, Current, clang::SourceRange::getBegin(), clang::SourceRange::getEnd(), clang::Token::getIdentifierInfo(), clang::IdentifierInfo::getPPKeywordID(), clang::SourceManager::getSpellingColumnNumber(), clang::format::LineState::NextToken, clang::format::FormatToken::Previous, clang::format::LineState::Stack, clang::format::FormatToken::Tok, clang::format::TT_ImplicitStringLiteral, clang::format::FormatToken::Type, and clang::format::FormatToken::WhitespaceRange.
Referenced by clang::format::CommaSeparatedList::formatAfterToken().
| bool clang::format::ContinuationIndenter::canBreak | ( | const LineState & | State | ) |
Returns true, if a line break after State is allowed.
Definition at line 92 of file ContinuationIndenter.cpp.
References clang::format::FormatStyle::AlwaysBreakAfterDefinitionReturnType, clang::format::BK_BracedInit, clang::format::FormatToken::BlockKind, clang::format::FormatToken::CanBreakBefore, clang::format::FormatToken::closesBlockTypeList(), clang::format::LineState::Column, Current, clang::format::FormatToken::is(), clang::format::FormatToken::isMemberAccess(), clang::format::FormatToken::isNot(), clang::format::FormatToken::isOneOf(), clang::format::FormatStyle::Language, clang::format::FormatStyle::LK_JavaScript, clang::format::LineState::LowestLevelOnLine, clang::format::FormatToken::MustBreakBefore, clang::format::FormatToken::NestingLevel, clang::format::LineState::NextToken, clang::format::FormatToken::opensScope(), clang::format::FormatToken::Previous, Previous, clang::format::LineState::Stack, clang::format::LineState::StartOfLineLevel, clang::format::TT_DictLiteral, clang::format::TT_FunctionDeclarationName, and clang::format::FormatToken::Type.
| unsigned clang::format::ContinuationIndenter::getColumnLimit | ( | const LineState & | State | ) | const |
Get the column limit for this line. This is the style's column limit, potentially reduced for preprocessor definitions.
Definition at line 1133 of file ContinuationIndenter.cpp.
References clang::format::FormatStyle::ColumnLimit, clang::format::AnnotatedLine::InPPDirective, and clang::format::LineState::Line.
Referenced by mustBreak().
| LineState clang::format::ContinuationIndenter::getInitialState | ( | unsigned | FirstIndent, |
| const AnnotatedLine * | Line, | ||
| bool | DryRun | ||
| ) |
Get the initial state, i.e. the state after placing Line's first token at FirstIndent.
Definition at line 70 of file ContinuationIndenter.cpp.
References clang::format::LineState::Column, clang::format::AnnotatedLine::First, clang::format::LineState::FirstIndent, clang::format::LineState::IgnoreStackForComparison, clang::format::AnnotatedLine::Level, clang::format::LineState::Line, Line, clang::format::LineState::LineContainsContinuedForLoopSection, clang::format::LineState::LowestLevelOnLine, clang::format::LineState::NextToken, clang::format::LineState::Stack, clang::format::LineState::StartOfLineLevel, clang::format::LineState::StartOfStringLiteral, and State.
| bool clang::format::ContinuationIndenter::mustBreak | ( | const LineState & | State | ) |
Returns true, if a line break after State is mandatory.
Definition at line 135 of file ContinuationIndenter.cpp.
References clang::format::FormatStyle::AllowShortFunctionsOnASingleLine, clang::format::FormatStyle::AlwaysBreakBeforeMultilineStrings, clang::prec::Assignment, clang::format::BK_Block, clang::format::FormatToken::BlockKind, clang::format::FormatStyle::BreakBeforeBinaryOperators, clang::format::FormatStyle::BreakBeforeTernaryOperators, clang::format::FormatStyle::BreakConstructorInitializersBeforeComma, clang::format::FormatToken::closesBlockTypeList(), clang::format::FormatToken::ClosesTemplateDeclaration, clang::format::LineState::Column, clang::format::FormatStyle::ColumnLimit, Current, clang::format::FormatToken::EndsBinaryExpression, clang::prec::Equality, getColumnLimit(), clang::format::getLengthToMatchingParen(), clang::format::FormatToken::getPrecedence(), clang::format::FormatToken::is(), clang::format::FormatToken::isNot(), clang::format::FormatToken::isOneOf(), clang::format::FormatToken::isTrailingComment(), clang::format::LineState::LineContainsContinuedForLoopSection, clang::format::FormatToken::MustBreakBefore, clang::format::FormatToken::NestingLevel, clang::format::LineState::NextToken, clang::format::FormatToken::Previous, Previous, clang::prec::Relational, clang::format::FormatStyle::SFS_All, clang::format::LineState::Stack, clang::format::startsNextParameter(), clang::format::startsSegmentOfBuilderTypeCall(), clang::format::TT_ArrayInitializerLSquare, clang::format::TT_BinaryOperator, clang::format::TT_ConditionalExpr, clang::format::TT_CtorInitializerColon, clang::format::TT_DictLiteral, clang::format::TT_FunctionDeclarationName, clang::format::TT_InlineASMColon, clang::format::TT_OverloadedOperator, clang::format::TT_SelectorName, and clang::format::FormatToken::Type.