clang  15.0.0git
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
clang::format::BreakableComment Class Referenceabstract

#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/Format/BreakableToken.h"

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

Public Member Functions

bool supportsReflow () const override
 Returns whether the token supports reflowing text. More...
 
unsigned getLineCount () const override
 Returns the number of lines in this token in the original code. More...
 
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. More...
 
void compressWhitespace (unsigned LineIndex, unsigned TailOffset, Split Split, WhitespaceManager &Whitespaces) const override
 Replaces the whitespace range described by Split with a single space. More...
 
- Public Member Functions inherited from clang::format::BreakableToken
virtual ~BreakableToken ()
 
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). More...
 
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. More...
 
virtual unsigned getContentStartColumn (unsigned LineIndex, bool Break) const =0
 Returns the column at which content in line LineIndex starts, assuming no reflow. More...
 
virtual unsigned getContentIndent (unsigned LineIndex) const
 Returns additional content indent required for the second line after the content at line LineIndex is broken. More...
 
virtual void insertBreak (unsigned LineIndex, unsigned TailOffset, Split Split, unsigned ContentIndent, WhitespaceManager &Whitespaces) const =0
 Emits the previously retrieved Split via Whitespaces. More...
 
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. More...
 
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. More...
 
virtual void reflow (unsigned LineIndex, WhitespaceManager &Whitespaces) const
 Reflows the current line into the end of the previous one. More...
 
virtual bool introducesBreakBeforeToken () const
 Returns whether there will be a line break at the start of the token. More...
 
virtual void adaptStartOfLine (unsigned LineIndex, WhitespaceManager &Whitespaces) const
 Replaces the whitespace between LineIndex-1 and LineIndex. More...
 
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. More...
 
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. More...
 
virtual void updateNextToken (LineState &State) const
 Updates the next token of State to the next token after this one. More...
 

Protected Member Functions

 BreakableComment (const FormatToken &Token, unsigned StartColumn, bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style)
 Creates a breakable token for a comment. More...
 
const FormatTokentokenAt (unsigned LineIndex) const
 
virtual bool mayReflow (unsigned LineIndex, const llvm::Regex &CommentPragmasRegex) const =0
 
- Protected Member Functions inherited from clang::format::BreakableToken
 BreakableToken (const FormatToken &Tok, bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style)
 

Protected Attributes

SmallVector< StringRef, 16 > Lines
 
SmallVector< StringRef, 16 > Content
 
SmallVector< FormatToken *, 16 > Tokens
 
SmallVector< int, 16 > ContentColumn
 
unsigned StartColumn
 
StringRef ReflowPrefix = " "
 
- Protected Attributes inherited from clang::format::BreakableToken
const FormatTokenTok
 
const bool InPPDirective
 
const encoding::Encoding Encoding
 
const FormatStyleStyle
 

Additional Inherited Members

- Public Types inherited from clang::format::BreakableToken
typedef std::pair< StringRef::size_type, unsignedSplit
 Contains starting character index and length of split. More...
 

Detailed Description

Definition at line 286 of file BreakableToken.h.

Constructor & Destructor Documentation

◆ BreakableComment()

clang::format::BreakableComment::BreakableComment ( const FormatToken Token,
unsigned  StartColumn,
bool  InPPDirective,
encoding::Encoding  Encoding,
const FormatStyle Style 
)
protected

Creates a breakable token for a comment.

StartColumn specifies the column in which the comment will start after formatting.

Definition at line 293 of file BreakableToken.cpp.

Member Function Documentation

◆ compressWhitespace()

void clang::format::BreakableComment::compressWhitespace ( unsigned  LineIndex,
unsigned  TailOffset,
Split  Split,
WhitespaceManager Whitespaces 
) const
overridevirtual

Replaces the whitespace range described by Split with a single space.

Implements clang::format::BreakableToken.

Definition at line 314 of file BreakableToken.cpp.

◆ getLineCount()

unsigned clang::format::BreakableComment::getLineCount ( ) const
overridevirtual

Returns the number of lines in this token in the original code.

Implements clang::format::BreakableToken.

Definition at line 300 of file BreakableToken.cpp.

References Lines.

◆ getSplit()

BreakableToken::Split clang::format::BreakableComment::getSplit ( unsigned  LineIndex,
unsigned  TailOffset,
unsigned  ColumnLimit,
unsigned  ContentStartColumn,
const llvm::Regex &  CommentPragmasRegex 
) const
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.

Reimplemented in clang::format::BreakableBlockComment.

Definition at line 303 of file BreakableToken.cpp.

References Content, clang::format::BreakableToken::Encoding, clang::format::getCommentSplit(), clang::format::BreakableToken::Style, and clang::format::FormatStyle::TabWidth.

◆ mayReflow()

virtual bool clang::format::BreakableComment::mayReflow ( unsigned  LineIndex,
const llvm::Regex &  CommentPragmasRegex 
) const
protectedpure virtual

◆ supportsReflow()

bool clang::format::BreakableComment::supportsReflow ( ) const
inlineoverridevirtual

Returns whether the token supports reflowing text.

Reimplemented from clang::format::BreakableToken.

Definition at line 297 of file BreakableToken.h.

◆ tokenAt()

const FormatToken & clang::format::BreakableComment::tokenAt ( unsigned  LineIndex) const
protected

Member Data Documentation

◆ Content

SmallVector<StringRef, 16> clang::format::BreakableComment::Content
protected

◆ ContentColumn

SmallVector<int, 16> clang::format::BreakableComment::ContentColumn
protected

◆ Lines

SmallVector<StringRef, 16> clang::format::BreakableComment::Lines
protected

◆ ReflowPrefix

StringRef clang::format::BreakableComment::ReflowPrefix = " "
protected

Definition at line 354 of file BreakableToken.h.

◆ StartColumn

unsigned clang::format::BreakableComment::StartColumn
protected

◆ Tokens

SmallVector<FormatToken *, 16> clang::format::BreakableComment::Tokens
protected

Definition at line 329 of file BreakableToken.h.

Referenced by tokenAt().


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