clang API Documentation
Base class for strategies on how to break tokens. More...
#include <BreakableToken.h>
Public Types | |
typedef std::pair < StringRef::size_type, unsigned > | Split |
Contains starting character index and length of split. | |
Public Member Functions | |
virtual | ~BreakableToken () |
virtual unsigned | getLineCount () const =0 |
Returns the number of lines in this token in the original code. | |
virtual unsigned | getLineLengthAfterSplit (unsigned LineIndex, unsigned Offset, StringRef::size_type Length) const =0 |
Returns the number of columns required to format the piece of line at LineIndex , from byte offset Offset with length Length . | |
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 . | |
virtual void | insertBreak (unsigned LineIndex, unsigned TailOffset, Split Split, WhitespaceManager &Whitespaces)=0 |
Emits the previously retrieved Split via Whitespaces . | |
virtual void | replaceWhitespace (unsigned LineIndex, unsigned TailOffset, Split Split, WhitespaceManager &Whitespaces)=0 |
Replaces the whitespace range described by Split with a single space. | |
virtual void | replaceWhitespaceBefore (unsigned LineIndex, WhitespaceManager &Whitespaces) |
Replaces the whitespace between LineIndex-1 and LineIndex . | |
Protected Member Functions | |
BreakableToken (const FormatToken &Tok, unsigned IndentLevel, bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style) | |
Protected Attributes | |
const FormatToken & | Tok |
const unsigned | IndentLevel |
const bool | InPPDirective |
const encoding::Encoding | Encoding |
const FormatStyle & | Style |
Base class for strategies on how to break tokens.
FIXME: The interface seems set in stone, so we might want to just pull the strategy into the class, instead of controlling it from the outside.
Definition at line 34 of file BreakableToken.h.
typedef std::pair<StringRef::size_type, unsigned> clang::format::BreakableToken::Split |
Contains starting character index and length of split.
Definition at line 37 of file BreakableToken.h.
virtual clang::format::BreakableToken::~BreakableToken | ( | ) | [inline, virtual] |
Definition at line 39 of file BreakableToken.h.
clang::format::BreakableToken::BreakableToken | ( | const FormatToken & | Tok, |
unsigned | IndentLevel, | ||
bool | InPPDirective, | ||
encoding::Encoding | Encoding, | ||
const FormatStyle & | Style | ||
) | [inline, protected] |
Definition at line 75 of file BreakableToken.h.
virtual unsigned clang::format::BreakableToken::getLineCount | ( | ) | const [pure virtual] |
Returns the number of lines in this token in the original code.
Implemented in clang::format::BreakableBlockComment, and clang::format::BreakableSingleLineToken.
virtual unsigned clang::format::BreakableToken::getLineLengthAfterSplit | ( | unsigned | LineIndex, |
unsigned | Offset, | ||
StringRef::size_type | Length | ||
) | const [pure virtual] |
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".
Implemented in clang::format::BreakableBlockComment, and clang::format::BreakableSingleLineToken.
virtual Split clang::format::BreakableToken::getSplit | ( | unsigned | LineIndex, |
unsigned | TailOffset, | ||
unsigned | ColumnLimit | ||
) | const [pure virtual] |
Returns a range (offset, length) at which to break the line at LineIndex
, if previously broken at TailOffset
. If possible, do not violate ColumnLimit
.
Implemented in clang::format::BreakableBlockComment, clang::format::BreakableLineComment, and clang::format::BreakableStringLiteral.
virtual void clang::format::BreakableToken::insertBreak | ( | unsigned | LineIndex, |
unsigned | TailOffset, | ||
Split | Split, | ||
WhitespaceManager & | Whitespaces | ||
) | [pure virtual] |
Emits the previously retrieved Split
via Whitespaces
.
Implemented in clang::format::BreakableBlockComment, clang::format::BreakableLineComment, and clang::format::BreakableStringLiteral.
virtual void clang::format::BreakableToken::replaceWhitespace | ( | unsigned | LineIndex, |
unsigned | TailOffset, | ||
Split | Split, | ||
WhitespaceManager & | Whitespaces | ||
) | [pure virtual] |
Replaces the whitespace range described by Split
with a single space.
Implemented in clang::format::BreakableBlockComment, clang::format::BreakableLineComment, and clang::format::BreakableStringLiteral.
virtual void clang::format::BreakableToken::replaceWhitespaceBefore | ( | unsigned | LineIndex, |
WhitespaceManager & | Whitespaces | ||
) | [inline, virtual] |
Replaces the whitespace between LineIndex-1
and LineIndex
.
Reimplemented in clang::format::BreakableBlockComment, and clang::format::BreakableLineComment.
Definition at line 71 of file BreakableToken.h.
const encoding::Encoding clang::format::BreakableToken::Encoding [protected] |
Definition at line 84 of file BreakableToken.h.
Referenced by clang::format::BreakableSingleLineToken::getLineLengthAfterSplit(), clang::format::BreakableBlockComment::getLineLengthAfterSplit(), clang::format::BreakableStringLiteral::getSplit(), clang::format::BreakableLineComment::getSplit(), and clang::format::BreakableBlockComment::getSplit().
const unsigned clang::format::BreakableToken::IndentLevel [protected] |
const bool clang::format::BreakableToken::InPPDirective [protected] |
const FormatStyle& clang::format::BreakableToken::Style [protected] |
Definition at line 85 of file BreakableToken.h.
Referenced by clang::format::BreakableSingleLineToken::getLineLengthAfterSplit(), clang::format::BreakableBlockComment::getLineLengthAfterSplit(), clang::format::BreakableStringLiteral::getSplit(), clang::format::BreakableLineComment::getSplit(), and clang::format::BreakableBlockComment::getSplit().
const FormatToken& clang::format::BreakableToken::Tok [protected] |
Definition at line 81 of file BreakableToken.h.
Referenced by clang::format::BreakableStringLiteral::insertBreak(), clang::format::BreakableLineComment::insertBreak(), clang::format::BreakableBlockComment::insertBreak(), clang::format::BreakableLineComment::replaceWhitespace(), clang::format::BreakableBlockComment::replaceWhitespace(), clang::format::BreakableLineComment::replaceWhitespaceBefore(), and clang::format::BreakableBlockComment::replaceWhitespaceBefore().