clang 20.0.0git
|
#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/Format/BreakableToken.h"
Public Member Functions | |
BreakableStringLiteral (const FormatToken &Tok, unsigned StartColumn, StringRef Prefix, StringRef Postfix, unsigned UnbreakableTailLength, bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style) | |
Creates a breakable token for a single line string literal. | |
Split | getSplit (unsigned LineIndex, unsigned TailOffset, unsigned ColumnLimit, unsigned ContentStartColumn, const llvm::Regex &CommentPragmasRegex) const override |
Returns a range (offset, length) at which to break the line at LineIndex , if previously broken at TailOffset . | |
void | insertBreak (unsigned LineIndex, unsigned TailOffset, Split Split, unsigned ContentIndent, WhitespaceManager &Whitespaces) const override |
Emits the previously retrieved Split via Whitespaces . | |
void | compressWhitespace (unsigned LineIndex, unsigned TailOffset, Split Split, WhitespaceManager &Whitespaces) const override |
Replaces the whitespace range described by Split with a single space. | |
unsigned | getLineCount () const override |
Returns the number of lines in this token in the original code. | |
unsigned | getRangeLength (unsigned LineIndex, unsigned Offset, StringRef::size_type Length, unsigned StartColumn) const override |
Returns the number of columns required to format the text in the byte range [Offset , Offset + Length ). | |
unsigned | getRemainingLength (unsigned LineIndex, unsigned Offset, unsigned StartColumn) const override |
Returns the number of columns required to format the text following the byte Offset in the line LineIndex , including potentially unbreakable sequences of tokens following after the end of the token. | |
unsigned | getContentStartColumn (unsigned LineIndex, bool Break) const override |
Returns the column at which content in line LineIndex starts, assuming no reflow. | |
Public Member Functions inherited from clang::format::BreakableToken | |
virtual | ~BreakableToken () |
virtual unsigned | getLineCount () const =0 |
Returns the number of lines in this token in the original code. | |
virtual unsigned | getRangeLength (unsigned LineIndex, unsigned Offset, StringRef::size_type Length, unsigned StartColumn) const =0 |
Returns the number of columns required to format the text in the byte range [Offset , Offset + Length ). | |
virtual unsigned | getRemainingLength (unsigned LineIndex, unsigned Offset, unsigned StartColumn) const |
Returns the number of columns required to format the text following the byte Offset in the line LineIndex , including potentially unbreakable sequences of tokens following after the end of the token. | |
virtual unsigned | getContentStartColumn (unsigned LineIndex, bool Break) const =0 |
Returns the column at which content in line LineIndex starts, assuming no reflow. | |
virtual unsigned | getContentIndent (unsigned LineIndex) const |
Returns additional content indent required for the second line after the content at line LineIndex is broken. | |
virtual Split | getSplit (unsigned LineIndex, unsigned TailOffset, unsigned ColumnLimit, unsigned ContentStartColumn, const llvm::Regex &CommentPragmasRegex) const =0 |
Returns a range (offset, length) at which to break the line at LineIndex , if previously broken at TailOffset . | |
virtual void | insertBreak (unsigned LineIndex, unsigned TailOffset, Split Split, unsigned ContentIndent, WhitespaceManager &Whitespaces) const =0 |
Emits the previously retrieved Split via Whitespaces . | |
unsigned | getLengthAfterCompression (unsigned RemainingTokenColumns, Split Split) const |
Returns the number of columns needed to format RemainingTokenColumns , assuming that Split is within the range measured by RemainingTokenColumns , and that the whitespace in Split is reduced to a single space. | |
virtual void | compressWhitespace (unsigned LineIndex, unsigned TailOffset, Split Split, WhitespaceManager &Whitespaces) const =0 |
Replaces the whitespace range described by Split with a single space. | |
virtual bool | supportsReflow () const |
Returns whether the token supports reflowing text. | |
virtual Split | getReflowSplit (unsigned LineIndex, const llvm::Regex &CommentPragmasRegex) const |
Returns a whitespace range (offset, length) of the content at LineIndex such that the content of that line is reflown to the end of the previous one. | |
virtual void | reflow (unsigned LineIndex, WhitespaceManager &Whitespaces) const |
Reflows the current line into the end of the previous one. | |
virtual bool | introducesBreakBeforeToken () const |
Returns whether there will be a line break at the start of the token. | |
virtual void | adaptStartOfLine (unsigned LineIndex, WhitespaceManager &Whitespaces) const |
Replaces the whitespace between LineIndex-1 and LineIndex . | |
virtual Split | getSplitAfterLastLine (unsigned TailOffset) const |
Returns a whitespace range (offset, length) of the content at the last line that needs to be reformatted after the last line has been reformatted. | |
void | replaceWhitespaceAfterLastLine (unsigned TailOffset, Split SplitAfterLastLine, WhitespaceManager &Whitespaces) const |
Replaces the whitespace from SplitAfterLastLine on the last line after the last line has been formatted by performing a reformatting. | |
virtual void | updateNextToken (LineState &State) const |
Updates the next token of State to the next token after this one. | |
virtual void | updateAfterBroken (WhitespaceManager &Whitespaces) const |
Adds replacements that are needed when the token is broken. | |
Protected Attributes | |
unsigned | StartColumn |
StringRef | Prefix |
StringRef | Postfix |
StringRef | Line |
unsigned | UnbreakableTailLength |
Protected Attributes inherited from clang::format::BreakableToken | |
const FormatToken & | Tok |
const bool | InPPDirective |
const encoding::Encoding | Encoding |
const FormatStyle & | Style |
Additional Inherited Members | |
Public Types inherited from clang::format::BreakableToken | |
typedef std::pair< StringRef::size_type, unsigned > | Split |
Contains starting character index and length of split. | |
Protected Member Functions inherited from clang::format::BreakableToken | |
BreakableToken (const FormatToken &Tok, bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style) | |
Definition at line 247 of file BreakableToken.h.
clang::format::BreakableStringLiteral::BreakableStringLiteral | ( | const FormatToken & | Tok, |
unsigned | StartColumn, | ||
StringRef | Prefix, | ||
StringRef | Postfix, | ||
unsigned | UnbreakableTailLength, | ||
bool | InPPDirective, | ||
encoding::Encoding | Encoding, | ||
const FormatStyle & | Style | ||
) |
Creates a breakable token for a single line string literal.
StartColumn
specifies the column in which the token will start after formatting.
Definition at line 267 of file BreakableToken.cpp.
References Line, Postfix, Prefix, clang::format::BreakableToken::Tok, and clang::format::FormatToken::TokenText.
|
inlineoverridevirtual |
Replaces the whitespace range described by Split
with a single space.
Implements clang::format::BreakableToken.
Definition at line 264 of file BreakableToken.h.
|
overridevirtual |
Returns the column at which content in line LineIndex
starts, assuming no reflow.
If Break
is true, returns the column at which the line should start after the line break. If Break
is false, returns the column at which the line itself will start.
Implements clang::format::BreakableToken.
Reimplemented in clang::format::BreakableStringLiteralUsingOperators.
Definition at line 262 of file BreakableToken.cpp.
References Prefix, and StartColumn.
|
overridevirtual |
Returns the number of lines in this token in the original code.
Implements clang::format::BreakableToken.
Definition at line 244 of file BreakableToken.cpp.
|
overridevirtual |
Returns the number of columns required to format the text in the byte range [Offset
, Offset
+
Length
).
Offset
is the byte offset from the start of the content of the line at LineIndex
.
StartColumn
is the column at which the text starts in the formatted file, needed to compute tab stops correctly.
Implements clang::format::BreakableToken.
Definition at line 246 of file BreakableToken.cpp.
|
overridevirtual |
Returns the number of columns required to format the text following the byte Offset
in the line LineIndex
, including potentially unbreakable sequences of tokens following after the end of the token.
Offset
is the byte offset from the start of the content of the line at LineIndex
.
StartColumn
is the column at which the text starts in the formatted file, needed to compute tab stops correctly.
For breakable tokens that never use extra space at the end of a line, this is equivalent to getRangeLength with a Length of StringRef::npos.
Reimplemented from clang::format::BreakableToken.
Reimplemented in clang::format::BreakableStringLiteralUsingOperators.
Definition at line 255 of file BreakableToken.cpp.
References clang::format::encoding::columnWidthWithTabs(), clang::format::BreakableToken::Encoding, Line, Postfix, StartColumn, clang::format::BreakableToken::Style, clang::format::FormatStyle::TabWidth, and UnbreakableTailLength.
|
overridevirtual |
Returns a range (offset, length) at which to break the line at LineIndex
, if previously broken at TailOffset
.
If possible, do not violate ColumnLimit
, assuming the text starting at TailOffset
in the token is formatted starting at ContentStartColumn in the reformatted file.
Implements clang::format::BreakableToken.
Definition at line 279 of file BreakableToken.cpp.
References clang::format::BreakableToken::Encoding, clang::format::getStringSplit(), Line, Postfix, clang::format::BreakableToken::Style, and clang::format::FormatStyle::TabWidth.
|
overridevirtual |
Emits the previously retrieved Split
via Whitespaces
.
Implements clang::format::BreakableToken.
Reimplemented in clang::format::BreakableStringLiteralUsingOperators.
Definition at line 286 of file BreakableToken.cpp.
References clang::format::BreakableToken::InPPDirective, Postfix, Prefix, StartColumn, and clang::format::BreakableToken::Tok.
|
protected |
Definition at line 282 of file BreakableToken.h.
Referenced by BreakableStringLiteral(), getRemainingLength(), clang::format::BreakableStringLiteralUsingOperators::getRemainingLength(), and getSplit().
|
protected |
Definition at line 280 of file BreakableToken.h.
Referenced by BreakableStringLiteral(), clang::format::BreakableStringLiteralUsingOperators::BreakableStringLiteralUsingOperators(), getRemainingLength(), getSplit(), insertBreak(), and clang::format::BreakableStringLiteralUsingOperators::insertBreak().
|
protected |
Definition at line 278 of file BreakableToken.h.
Referenced by BreakableStringLiteral(), clang::format::BreakableStringLiteralUsingOperators::BreakableStringLiteralUsingOperators(), getContentStartColumn(), clang::format::BreakableStringLiteralUsingOperators::getContentStartColumn(), insertBreak(), and clang::format::BreakableStringLiteralUsingOperators::insertBreak().
|
protected |
Definition at line 276 of file BreakableToken.h.
Referenced by getContentStartColumn(), clang::format::BreakableStringLiteralUsingOperators::getContentStartColumn(), getRemainingLength(), clang::format::BreakableStringLiteralUsingOperators::getRemainingLength(), insertBreak(), and clang::format::BreakableStringLiteralUsingOperators::insertBreak().
|
protected |
Definition at line 285 of file BreakableToken.h.
Referenced by getRemainingLength(), and clang::format::BreakableStringLiteralUsingOperators::getRemainingLength().