clang API Documentation

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
clang::format::BreakableToken Class Reference

Base class for strategies on how to break tokens. More...

#include <BreakableToken.h>

Inheritance diagram for clang::format::BreakableToken:
Inheritance graph
[legend]
Collaboration diagram for clang::format::BreakableToken:
Collaboration graph
[legend]

List of all members.

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 FormatTokenTok
const unsigned IndentLevel
const bool InPPDirective
const encoding::Encoding Encoding
const FormatStyleStyle

Detailed Description

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.


Member Typedef Documentation

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.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.


Member Data Documentation


The documentation for this class was generated from the following file: