class ContinuationIndenter
Declaration
class ContinuationIndenter { /* full declaration omitted */ };
Declared at: clang/lib/Format/ContinuationIndenter.h:50
Member Variables
- private clang::format::FormatStyle Style
- private const clang::format::AdditionalKeywords& Keywords
- private const clang::SourceManager& SourceMgr
- private clang::format::WhitespaceManager& Whitespaces
- private encoding::Encoding Encoding
- private bool BinPackInconclusiveFunctions
- private llvm::Regex CommentPragmasRegex
- private const clang::format::RawStringFormatStyleManager RawStringFormats
Method Overview
- public ContinuationIndenter(const clang::format::FormatStyle & Style, const clang::format::AdditionalKeywords & Keywords, const clang::SourceManager & SourceMgr, clang::format::WhitespaceManager & Whitespaces, encoding::Encoding Encoding, bool BinPackInconclusiveFunctions)
- private unsigned int addMultilineToken(const clang::format::FormatToken & Current, clang::format::LineState & State)
- private void addTokenOnCurrentLine(clang::format::LineState & State, bool DryRun, unsigned int ExtraSpaces)
- private unsigned int addTokenOnNewLine(clang::format::LineState & State, bool DryRun)
- public unsigned int addTokenToState(clang::format::LineState & State, bool Newline, bool DryRun, unsigned int ExtraSpaces = 0)
- private std::pair<unsigned int, bool> breakProtrudingToken(const clang::format::FormatToken & Current, clang::format::LineState & State, bool AllowBreak, bool DryRun, bool Strict)
- public bool canBreak(const clang::format::LineState & State)
- private std::unique_ptr<BreakableToken> createBreakableToken(const clang::format::FormatToken & Current, clang::format::LineState & State, bool AllowBreak)
- public unsigned int getColumnLimit(const clang::format::LineState & State) const
- public clang::format::LineState getInitialState(unsigned int FirstIndent, unsigned int FirstStartColumn, const clang::format::AnnotatedLine * Line, bool DryRun)
- private unsigned int getNewLineColumn(const clang::format::LineState & State)
- private llvm::Optional<FormatStyle> getRawStringStyle(const clang::format::FormatToken & Current, const clang::format::LineState & State)
- private unsigned int handleEndOfLine(const clang::format::FormatToken & Current, clang::format::LineState & State, bool DryRun, bool AllowBreak, bool Newline)
- private void moveStatePastFakeLParens(clang::format::LineState & State, bool Newline)
- private void moveStatePastFakeRParens(clang::format::LineState & State)
- private void moveStatePastScopeCloser(clang::format::LineState & State)
- private void moveStatePastScopeOpener(clang::format::LineState & State, bool Newline)
- private void moveStateToNewBlock(clang::format::LineState & State)
- private unsigned int moveStateToNextToken(clang::format::LineState & State, bool DryRun, bool Newline)
- public bool mustBreak(const clang::format::LineState & State)
- private bool nextIsMultilineString(const clang::format::LineState & State)
- private unsigned int reformatRawStringLiteral(const clang::format::FormatToken & Current, clang::format::LineState & State, const clang::format::FormatStyle & RawStringStyle, bool DryRun, bool Newline)
Methods
¶ContinuationIndenter(
const clang::format::FormatStyle& Style,
const clang::format::AdditionalKeywords&
Keywords,
const clang::SourceManager& SourceMgr,
clang::format::WhitespaceManager& Whitespaces,
encoding::Encoding Encoding,
bool BinPackInconclusiveFunctions)
ContinuationIndenter(
const clang::format::FormatStyle& Style,
const clang::format::AdditionalKeywords&
Keywords,
const clang::SourceManager& SourceMgr,
clang::format::WhitespaceManager& Whitespaces,
encoding::Encoding Encoding,
bool BinPackInconclusiveFunctions)
Description
Constructs a \c ContinuationIndenter to format \p Line starting in column \p FirstIndent.
Declared at: clang/lib/Format/ContinuationIndenter.h:54
Parameters
- const clang::format::FormatStyle& Style
- const clang::format::AdditionalKeywords& Keywords
- const clang::SourceManager& SourceMgr
- clang::format::WhitespaceManager& Whitespaces
- encoding::Encoding Encoding
- bool BinPackInconclusiveFunctions
¶unsigned int addMultilineToken(
const clang::format::FormatToken& Current,
clang::format::LineState& State)
unsigned int addMultilineToken(
const clang::format::FormatToken& Current,
clang::format::LineState& State)
Description
Adds a multiline token to the \p State.
Declared at: clang/lib/Format/ContinuationIndenter.h:182
Parameters
- const clang::format::FormatToken& Current
- clang::format::LineState& State
Returns
Extra penalty for the first line of the literal: last line is handled in \c addNextStateToQueue, and the penalty for other lines doesn't matter, as we don't change them.
¶void addTokenOnCurrentLine(
clang::format::LineState& State,
bool DryRun,
unsigned int ExtraSpaces)
void addTokenOnCurrentLine(
clang::format::LineState& State,
bool DryRun,
unsigned int ExtraSpaces)
Description
Appends the next token to \p State and updates information necessary for indentation. Puts the token on the current line. If \p DryRun is \c false, also creates and stores the required\c Replacement.
Declared at: clang/lib/Format/ContinuationIndenter.h:162
Parameters
- clang::format::LineState& State
- bool DryRun
- unsigned int ExtraSpaces
¶unsigned int addTokenOnNewLine(
clang::format::LineState& State,
bool DryRun)
unsigned int addTokenOnNewLine(
clang::format::LineState& State,
bool DryRun)
Description
Appends the next token to \p State and updates information necessary for indentation. Adds a line break and necessary indentation. If \p DryRun is \c false, also creates and stores the required\c Replacement.
Declared at: clang/lib/Format/ContinuationIndenter.h:172
Parameters
- clang::format::LineState& State
- bool DryRun
¶unsigned int addTokenToState(
clang::format::LineState& State,
bool Newline,
bool DryRun,
unsigned int ExtraSpaces = 0)
unsigned int addTokenToState(
clang::format::LineState& State,
bool Newline,
bool DryRun,
unsigned int ExtraSpaces = 0)
Description
Appends the next token to \p State and updates information necessary for indentation. Puts the token on the current line if \p Newline is \c false and adds a line break and necessary indentation otherwise. If \p DryRun is \c false, also creates and stores the required\c Replacement.
Declared at: clang/lib/Format/ContinuationIndenter.h:84
Parameters
- clang::format::LineState& State
- bool Newline
- bool DryRun
- unsigned int ExtraSpaces = 0
¶std::pair<unsigned int, bool>
breakProtrudingToken(
const clang::format::FormatToken& Current,
clang::format::LineState& State,
bool AllowBreak,
bool DryRun,
bool Strict)
std::pair<unsigned int, bool>
breakProtrudingToken(
const clang::format::FormatToken& Current,
clang::format::LineState& State,
bool AllowBreak,
bool DryRun,
bool Strict)
Description
If the current token sticks out over the end of the line, break it if possible. The returned penalty will cover the cost of the additional line breaks and column limit violation in all lines except for the last one. The penalty for the column limit violation in the last line (and in single line tokens) is handled in \c addNextStateToQueue. \p Strict indicates whether reflowing is allowed to leave characters protruding the column limit; if true, lines will be split strictly within the column limit where possible; if false, words are allowed to protrude over the column limit as long as the penalty is less than the penalty of a break.
Declared at: clang/lib/Format/ContinuationIndenter.h:144
Parameters
- const clang::format::FormatToken& Current
- clang::format::LineState& State
- bool AllowBreak
- bool DryRun
- bool Strict
Returns
A pair (penalty, exceeded), where penalty is the extra penalty when tokens are broken or lines exceed the column limit, and exceeded indicates whether the algorithm purposefully left lines exceeding the column limit.
¶bool canBreak(
const clang::format::LineState& State)
bool canBreak(
const clang::format::LineState& State)
Description
Returns \c true, if a line break after \p State is allowed.
Declared at: clang/lib/Format/ContinuationIndenter.h:71
Parameters
- const clang::format::LineState& State
¶std::unique_ptr<BreakableToken>
createBreakableToken(
const clang::format::FormatToken& Current,
clang::format::LineState& State,
bool AllowBreak)
std::unique_ptr<BreakableToken>
createBreakableToken(
const clang::format::FormatToken& Current,
clang::format::LineState& State,
bool AllowBreak)
Description
Returns the \c BreakableToken starting at \p Current, or nullptr if the current token cannot be broken.
Declared at: clang/lib/Format/ContinuationIndenter.h:152
Parameters
- const clang::format::FormatToken& Current
- clang::format::LineState& State
- bool AllowBreak
¶unsigned int getColumnLimit(
const clang::format::LineState& State) const
unsigned int getColumnLimit(
const clang::format::LineState& State) const
Description
Get the column limit for this line. This is the style's column limit, potentially reduced for preprocessor definitions.
Declared at: clang/lib/Format/ContinuationIndenter.h:89
Parameters
- const clang::format::LineState& State
¶clang::format::LineState getInitialState(
unsigned int FirstIndent,
unsigned int FirstStartColumn,
const clang::format::AnnotatedLine* Line,
bool DryRun)
clang::format::LineState getInitialState(
unsigned int FirstIndent,
unsigned int FirstStartColumn,
const clang::format::AnnotatedLine* Line,
bool DryRun)
Description
Get the initial state, i.e. the state after placing \p Line's first token at \p FirstIndent. When reformatting a fragment of code, as in the case of formatting inside raw string literals, \p FirstStartColumn is the column at which the state of the parent formatter is.
Declared at: clang/lib/Format/ContinuationIndenter.h:65
Parameters
- unsigned int FirstIndent
- unsigned int FirstStartColumn
- const clang::format::AnnotatedLine* Line
- bool DryRun
¶unsigned int getNewLineColumn(
const clang::format::LineState& State)
unsigned int getNewLineColumn(
const clang::format::LineState& State)
Description
Calculate the new column for a line wrap before the next token.
Declared at: clang/lib/Format/ContinuationIndenter.h:175
Parameters
- const clang::format::LineState& State
¶llvm::Optional<FormatStyle> getRawStringStyle(
const clang::format::FormatToken& Current,
const clang::format::LineState& State)
llvm::Optional<FormatStyle> getRawStringStyle(
const clang::format::FormatToken& Current,
const clang::format::LineState& State)
Description
If \p Current is a raw string that is configured to be reformatted, return the style to be used.
Declared at: clang/lib/Format/ContinuationIndenter.h:123
Parameters
- const clang::format::FormatToken& Current
- const clang::format::LineState& State
¶unsigned int handleEndOfLine(
const clang::format::FormatToken& Current,
clang::format::LineState& State,
bool DryRun,
bool AllowBreak,
bool Newline)
unsigned int handleEndOfLine(
const clang::format::FormatToken& Current,
clang::format::LineState& State,
bool DryRun,
bool AllowBreak,
bool Newline)
Description
If the current token is at the end of the current line, handle the transition to the next line.
Declared at: clang/lib/Format/ContinuationIndenter.h:118
Parameters
- const clang::format::FormatToken& Current
- clang::format::LineState& State
- bool DryRun
- bool AllowBreak
- bool Newline
¶void moveStatePastFakeLParens(
clang::format::LineState& State,
bool Newline)
void moveStatePastFakeLParens(
clang::format::LineState& State,
bool Newline)
Description
Update 'State' according to the next token's fake left parentheses.
Declared at: clang/lib/Format/ContinuationIndenter.h:97
Parameters
- clang::format::LineState& State
- bool Newline
¶void moveStatePastFakeRParens(
clang::format::LineState& State)
void moveStatePastFakeRParens(
clang::format::LineState& State)
Description
Update 'State' according to the next token's fake r_parens.
Declared at: clang/lib/Format/ContinuationIndenter.h:99
Parameters
- clang::format::LineState& State
¶void moveStatePastScopeCloser(
clang::format::LineState& State)
void moveStatePastScopeCloser(
clang::format::LineState& State)
Description
Update 'State' according to the next token being one of ")>}]".
Declared at: clang/lib/Format/ContinuationIndenter.h:104
Parameters
- clang::format::LineState& State
¶void moveStatePastScopeOpener(
clang::format::LineState& State,
bool Newline)
void moveStatePastScopeOpener(
clang::format::LineState& State,
bool Newline)
Description
Update 'State' according to the next token being one of "(<{[".
Declared at: clang/lib/Format/ContinuationIndenter.h:102
Parameters
- clang::format::LineState& State
- bool Newline
¶void moveStateToNewBlock(
clang::format::LineState& State)
void moveStateToNewBlock(
clang::format::LineState& State)
Description
Update 'State' with the next token opening a nested block.
Declared at: clang/lib/Format/ContinuationIndenter.h:106
Parameters
- clang::format::LineState& State
¶unsigned int moveStateToNextToken(
clang::format::LineState& State,
bool DryRun,
bool Newline)
unsigned int moveStateToNextToken(
clang::format::LineState& State,
bool DryRun,
bool Newline)
Description
Mark the next token as consumed in \p State and modify its stacks accordingly.
Declared at: clang/lib/Format/ContinuationIndenter.h:94
Parameters
- clang::format::LineState& State
- bool DryRun
- bool Newline
¶bool mustBreak(
const clang::format::LineState& State)
bool mustBreak(
const clang::format::LineState& State)
Description
Returns \c true, if a line break after \p State is mandatory.
Declared at: clang/lib/Format/ContinuationIndenter.h:74
Parameters
- const clang::format::LineState& State
¶bool nextIsMultilineString(
const clang::format::LineState& State)
bool nextIsMultilineString(
const clang::format::LineState& State)
Description
Returns \c true if the next token starts a multiline string literal. This includes implicitly concatenated strings, strings that will be broken by clang-format and string literals with escaped newlines.
Declared at: clang/lib/Format/ContinuationIndenter.h:189
Parameters
- const clang::format::LineState& State
¶unsigned int reformatRawStringLiteral(
const clang::format::FormatToken& Current,
clang::format::LineState& State,
const clang::format::FormatStyle&
RawStringStyle,
bool DryRun,
bool Newline)
unsigned int reformatRawStringLiteral(
const clang::format::FormatToken& Current,
clang::format::LineState& State,
const clang::format::FormatStyle&
RawStringStyle,
bool DryRun,
bool Newline)
Description
Reformats a raw string literal.
Declared at: clang/lib/Format/ContinuationIndenter.h:111
Parameters
- const clang::format::FormatToken& Current
- clang::format::LineState& State
- const clang::format::FormatStyle& RawStringStyle
- bool DryRun
- bool Newline
Returns
An extra penalty induced by reformatting the token.