clang
3.7.0
|
Base class for single line tokens that can be broken. More...
#include <BreakableToken.h>
Public Member Functions | |
unsigned | getLineCount () const override |
Returns the number of lines in this token in the original code. More... | |
unsigned | getLineLengthAfterSplit (unsigned LineIndex, unsigned TailOffset, StringRef::size_type Length) const override |
Returns the number of columns required to format the piece of line at LineIndex , from byte offset Offset with length Length . More... | |
![]() | |
virtual | ~BreakableToken () |
virtual Split | getSplit (unsigned LineIndex, unsigned TailOffset, unsigned ColumnLimit) const =0 |
Returns a range (offset, length) at which to break the line at LineIndex , if previously broken at TailOffset . If possible, do not violate ColumnLimit . More... | |
virtual void | insertBreak (unsigned LineIndex, unsigned TailOffset, Split Split, WhitespaceManager &Whitespaces)=0 |
Emits the previously retrieved Split via Whitespaces . More... | |
virtual void | replaceWhitespace (unsigned LineIndex, unsigned TailOffset, Split Split, WhitespaceManager &Whitespaces)=0 |
Replaces the whitespace range described by Split with a single space. More... | |
virtual void | replaceWhitespaceBefore (unsigned LineIndex, WhitespaceManager &Whitespaces) |
Replaces the whitespace between LineIndex-1 and LineIndex . More... | |
Protected Member Functions | |
BreakableSingleLineToken (const FormatToken &Tok, unsigned IndentLevel, unsigned StartColumn, StringRef Prefix, StringRef Postfix, bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style) | |
![]() | |
BreakableToken (const FormatToken &Tok, unsigned IndentLevel, bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style) | |
Protected Attributes | |
unsigned | StartColumn |
StringRef | Prefix |
StringRef | Postfix |
StringRef | Line |
![]() | |
const FormatToken & | Tok |
const unsigned | IndentLevel |
const bool | InPPDirective |
const encoding::Encoding | Encoding |
const FormatStyle & | Style |
Additional Inherited Members | |
![]() | |
typedef std::pair < StringRef::size_type, unsigned > | Split |
Contains starting character index and length of split. More... | |
Base class for single line tokens that can be broken.
getSplit()
needs to be implemented by child classes.
Definition at line 91 of file BreakableToken.h.
|
protected |
Definition at line 144 of file BreakableToken.cpp.
References Line, and clang::format::FormatToken::TokenText.
|
overridevirtual |
Returns the number of lines in this token in the original code.
Implements clang::format::BreakableToken.
Definition at line 134 of file BreakableToken.cpp.
|
overridevirtual |
Returns the number of columns required to format the piece of line at LineIndex
, from byte offset Offset
with length Length
.
Note that previous breaks are not taken into account. Offset
is always specified from the start of the (original) line. Length
can be set to StringRef::npos, which means "to the end of line".
Implements clang::format::BreakableToken.
Definition at line 136 of file BreakableToken.cpp.
References clang::format::encoding::columnWidthWithTabs(), clang::format::BreakableToken::Encoding, Line, Postfix, Prefix, StartColumn, clang::format::BreakableToken::Style, and clang::format::FormatStyle::TabWidth.
|
protected |
Definition at line 111 of file BreakableToken.h.
Referenced by BreakableSingleLineToken(), getLineLengthAfterSplit(), clang::format::BreakableStringLiteral::getSplit(), and clang::format::BreakableLineComment::getSplit().
|
protected |
Definition at line 109 of file BreakableToken.h.
Referenced by getLineLengthAfterSplit(), clang::format::BreakableStringLiteral::getSplit(), clang::format::BreakableStringLiteral::insertBreak(), and clang::format::BreakableLineComment::insertBreak().
|
protected |
Definition at line 107 of file BreakableToken.h.
Referenced by clang::format::BreakableLineComment::BreakableLineComment(), getLineLengthAfterSplit(), clang::format::BreakableStringLiteral::getSplit(), clang::format::BreakableLineComment::getSplit(), clang::format::BreakableStringLiteral::insertBreak(), clang::format::BreakableLineComment::insertBreak(), and clang::format::BreakableLineComment::replaceWhitespaceBefore().
|
protected |