clang  15.0.0git
Public Member Functions | Static Public Attributes | List of all members
clang::format::BreakableBlockComment Class Reference

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

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

Public Member Functions

 BreakableBlockComment (const FormatToken &Token, unsigned StartColumn, unsigned OriginalStartColumn, bool FirstInLine, bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style, bool UseCRLF)
 
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...
 
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). More...
 
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. More...
 
unsigned getContentStartColumn (unsigned LineIndex, bool Break) const override
 Returns the column at which content in line LineIndex starts, assuming no reflow. More...
 
unsigned getContentIndent (unsigned LineIndex) const override
 Returns additional content indent required for the second line after the content at line LineIndex is broken. More...
 
void insertBreak (unsigned LineIndex, unsigned TailOffset, Split Split, unsigned ContentIndent, WhitespaceManager &Whitespaces) const override
 Emits the previously retrieved Split via Whitespaces. More...
 
Split getReflowSplit (unsigned LineIndex, const llvm::Regex &CommentPragmasRegex) const override
 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...
 
void reflow (unsigned LineIndex, WhitespaceManager &Whitespaces) const override
 Reflows the current line into the end of the previous one. More...
 
bool introducesBreakBeforeToken () const override
 Returns whether there will be a line break at the start of the token. More...
 
void adaptStartOfLine (unsigned LineIndex, WhitespaceManager &Whitespaces) const override
 Replaces the whitespace between LineIndex-1 and LineIndex. More...
 
Split getSplitAfterLastLine (unsigned TailOffset) const override
 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...
 
bool mayReflow (unsigned LineIndex, const llvm::Regex &CommentPragmasRegex) const override
 
- Public Member Functions inherited from clang::format::BreakableComment
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...
 
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 ()
 
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...
 
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...
 

Static Public Attributes

static const llvm::StringSet ContentIndentingJavadocAnnotations
 

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...
 
- Protected Member Functions inherited from clang::format::BreakableComment
 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
 
- Protected Member Functions inherited from clang::format::BreakableToken
 BreakableToken (const FormatToken &Tok, bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style)
 
- Protected Attributes inherited from clang::format::BreakableComment
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
 

Detailed Description

Definition at line 357 of file BreakableToken.h.

Constructor & Destructor Documentation

◆ BreakableBlockComment()

clang::format::BreakableBlockComment::BreakableBlockComment ( const FormatToken Token,
unsigned  StartColumn,
unsigned  OriginalStartColumn,
bool  FirstInLine,
bool  InPPDirective,
encoding::Encoding  Encoding,
const FormatStyle Style,
bool  UseCRLF 
)

Definition at line 364 of file BreakableToken.cpp.

Member Function Documentation

◆ adaptStartOfLine()

void clang::format::BreakableBlockComment::adaptStartOfLine ( unsigned  LineIndex,
WhitespaceManager Whitespaces 
) const
overridevirtual

Replaces the whitespace between LineIndex-1 and LineIndex.

Reimplemented from clang::format::BreakableToken.

Definition at line 670 of file BreakableToken.cpp.

◆ getContentIndent()

unsigned clang::format::BreakableBlockComment::getContentIndent ( unsigned  LineIndex) const
overridevirtual

◆ getContentStartColumn()

unsigned clang::format::BreakableBlockComment::getContentStartColumn ( unsigned  LineIndex,
bool  Break 
) const
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.

Definition at line 564 of file BreakableToken.cpp.

References clang::format::BreakableComment::ContentColumn, and max().

◆ getRangeLength()

unsigned clang::format::BreakableBlockComment::getRangeLength ( unsigned  LineIndex,
unsigned  Offset,
StringRef::size_type  Length,
unsigned  StartColumn 
) const
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 536 of file BreakableToken.cpp.

References clang::format::encoding::columnWidthWithTabs(), clang::format::BreakableComment::Content, clang::format::BreakableToken::Encoding, Offset, clang::format::BreakableComment::StartColumn, clang::format::BreakableToken::Style, and clang::format::FormatStyle::TabWidth.

Referenced by getRemainingLength().

◆ getReflowSplit()

BreakableToken::Split clang::format::BreakableBlockComment::getReflowSplit ( unsigned  LineIndex,
const llvm::Regex &  CommentPragmasRegex 
) const
overridevirtual

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.

Returning (StringRef::npos, 0) indicates reflowing is not possible.

The range will include any whitespace preceding the specified line's content.

If the split is not contained within one token, for example when reflowing line comments, returns (0, <length>).

Reimplemented from clang::format::BreakableToken.

Definition at line 625 of file BreakableToken.cpp.

References clang::format::Blanks, clang::format::BreakableComment::Content, getContentIndent(), and mayReflow().

◆ getRemainingLength()

unsigned clang::format::BreakableBlockComment::getRemainingLength ( unsigned  LineIndex,
unsigned  Offset,
unsigned  StartColumn 
) const
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.

Definition at line 545 of file BreakableToken.cpp.

References clang::format::BreakableComment::Content, getRangeLength(), clang::format::BreakableComment::Lines, Offset, and clang::format::BreakableComment::StartColumn.

◆ getSplit()

BreakableToken::Split clang::format::BreakableBlockComment::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.

Reimplemented from clang::format::BreakableComment.

Definition at line 488 of file BreakableToken.cpp.

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

◆ getSplitAfterLastLine()

BreakableToken::Split clang::format::BreakableBlockComment::getSplitAfterLastLine ( unsigned  TailOffset) const
overridevirtual

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.

A result having offset == StringRef::npos means that no reformat is necessary.

Reimplemented from clang::format::BreakableToken.

Definition at line 720 of file BreakableToken.cpp.

References clang::format::Blanks, clang::format::BreakableComment::Content, and Line.

◆ insertBreak()

void clang::format::BreakableBlockComment::insertBreak ( unsigned  LineIndex,
unsigned  TailOffset,
Split  Split,
unsigned  ContentIndent,
WhitespaceManager Whitespaces 
) const
overridevirtual

Emits the previously retrieved Split via Whitespaces.

Implements clang::format::BreakableToken.

Definition at line 594 of file BreakableToken.cpp.

◆ introducesBreakBeforeToken()

bool clang::format::BreakableBlockComment::introducesBreakBeforeToken ( ) const
overridevirtual

Returns whether there will be a line break at the start of the token.

Reimplemented from clang::format::BreakableToken.

Definition at line 643 of file BreakableToken.cpp.

References clang::format::Blanks, and clang::format::BreakableComment::Lines.

◆ mayReflow()

bool clang::format::BreakableBlockComment::mayReflow ( unsigned  LineIndex,
const llvm::Regex &  CommentPragmasRegex 
) const
overridevirtual

◆ reflow()

void clang::format::BreakableBlockComment::reflow ( unsigned  LineIndex,
WhitespaceManager Whitespaces 
) const
overridevirtual

Reflows the current line into the end of the previous one.

Reimplemented from clang::format::BreakableToken.

Definition at line 649 of file BreakableToken.cpp.

Member Data Documentation

◆ ContentIndentingJavadocAnnotations

const llvm::StringSet clang::format::BreakableBlockComment::ContentIndentingJavadocAnnotations
static
Initial value:
= {
"@param", "@return", "@returns", "@throws", "@type", "@template",
"@see", "@deprecated", "@define", "@exports", "@mods", "@private",
}

Definition at line 391 of file BreakableToken.h.

Referenced by getContentIndent().


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