clang  19.0.0git
Public Types | Public Member Functions | Protected Attributes | List of all members
clang::format::BreakableStringLiteralUsingOperators Class Reference

#include "/home/runner/work/llvm/llvm/repo/clang/lib/Format/BreakableToken.h"

Inheritance diagram for clang::format::BreakableStringLiteralUsingOperators:
Inheritance graph
[legend]

Public Types

enum  QuoteStyleType { DoubleQuotes , SingleQuotes , AtDoubleQuotes }
 
- Public Types inherited from clang::format::BreakableToken
typedef std::pair< StringRef::size_type, unsignedSplit
 Contains starting character index and length of split. More...
 

Public Member Functions

 BreakableStringLiteralUsingOperators (const FormatToken &Tok, QuoteStyleType QuoteStyle, bool UnindentPlus, unsigned StartColumn, unsigned UnbreakableTailLength, bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style)
 Creates a breakable token for a single line string literal for C#, Java, JavaScript, or Verilog. 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...
 
void insertBreak (unsigned LineIndex, unsigned TailOffset, Split Split, unsigned ContentIndent, WhitespaceManager &Whitespaces) const override
 Emits the previously retrieved Split via Whitespaces. More...
 
void updateAfterBroken (WhitespaceManager &Whitespaces) const override
 Adds replacements that are needed when the token is broken. More...
 
- Public Member Functions inherited from clang::format::BreakableStringLiteral
 BreakableStringLiteral (const FormatToken &Tok, unsigned StartColumn, StringRef Prefix, StringRef Postfix, unsigned UnbreakableTailLength, bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style)
 Creates a breakable token for a single line string literal. 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...
 
unsigned getLineCount () const override
 Returns the number of lines in this token in the original code. 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...
 
- Public Member Functions inherited from clang::format::BreakableToken
virtual ~BreakableToken ()
 
virtual unsigned getContentIndent (unsigned LineIndex) const
 Returns additional content indent required for the second line after the content at line LineIndex is broken. 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 bool supportsReflow () const
 Returns whether the token supports reflowing text. 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 Attributes

bool BracesNeeded
 
QuoteStyleType QuoteStyle
 
StringRef LeftBraceQuote
 
StringRef RightBraceQuote
 
int ContinuationIndent
 
- Protected Attributes inherited from clang::format::BreakableStringLiteral
unsigned StartColumn
 
StringRef Prefix
 
StringRef Postfix
 
StringRef Line
 
unsigned UnbreakableTailLength
 
- Protected Attributes inherited from clang::format::BreakableToken
const FormatTokenTok
 
const bool InPPDirective
 
const encoding::Encoding Encoding
 
const FormatStyleStyle
 

Additional Inherited Members

- Protected Member Functions inherited from clang::format::BreakableToken
 BreakableToken (const FormatToken &Tok, bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style)
 

Detailed Description

Definition at line 288 of file BreakableToken.h.

Member Enumeration Documentation

◆ QuoteStyleType

Enumerator
DoubleQuotes 
SingleQuotes 
AtDoubleQuotes 

Definition at line 290 of file BreakableToken.h.

Constructor & Destructor Documentation

◆ BreakableStringLiteralUsingOperators()

clang::format::BreakableStringLiteralUsingOperators::BreakableStringLiteralUsingOperators ( const FormatToken Tok,
QuoteStyleType  QuoteStyle,
bool  UnindentPlus,
unsigned  StartColumn,
unsigned  UnbreakableTailLength,
bool  InPPDirective,
encoding::Encoding  Encoding,
const FormatStyle Style 
)

Creates a breakable token for a single line string literal for C#, Java, JavaScript, or Verilog.

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

Definition at line 295 of file BreakableToken.cpp.

Member Function Documentation

◆ getContentStartColumn()

unsigned clang::format::BreakableStringLiteralUsingOperators::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.

Reimplemented from clang::format::BreakableStringLiteral.

Definition at line 365 of file BreakableToken.cpp.

References AtDoubleQuotes, BracesNeeded, ContinuationIndent, LeftBraceQuote, max(), clang::format::BreakableStringLiteral::Prefix, QuoteStyle, and clang::format::BreakableStringLiteral::StartColumn.

◆ getRemainingLength()

unsigned clang::format::BreakableStringLiteralUsingOperators::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::BreakableStringLiteral.

Definition at line 357 of file BreakableToken.cpp.

References BracesNeeded, clang::format::encoding::columnWidthWithTabs(), clang::format::BreakableToken::Encoding, clang::format::BreakableStringLiteral::Line, Offset, RightBraceQuote, clang::format::BreakableStringLiteral::StartColumn, clang::format::BreakableToken::Style, clang::format::FormatStyle::TabWidth, and clang::format::BreakableStringLiteral::UnbreakableTailLength.

◆ insertBreak()

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

Emits the previously retrieved Split via Whitespaces.

Reimplemented from clang::format::BreakableStringLiteral.

Definition at line 376 of file BreakableToken.cpp.

◆ updateAfterBroken()

void clang::format::BreakableStringLiteralUsingOperators::updateAfterBroken ( WhitespaceManager Whitespaces) const
overridevirtual

Adds replacements that are needed when the token is broken.

Such as wrapping a JavaScript string in parentheses after it gets broken with plus signs.

Reimplemented from clang::format::BreakableToken.

Definition at line 388 of file BreakableToken.cpp.

Member Data Documentation

◆ BracesNeeded

bool clang::format::BreakableStringLiteralUsingOperators::BracesNeeded
protected

Definition at line 316 of file BreakableToken.h.

Referenced by getContentStartColumn(), and getRemainingLength().

◆ ContinuationIndent

int clang::format::BreakableStringLiteralUsingOperators::ContinuationIndent
protected

Definition at line 324 of file BreakableToken.h.

Referenced by getContentStartColumn().

◆ LeftBraceQuote

StringRef clang::format::BreakableStringLiteralUsingOperators::LeftBraceQuote
protected

Definition at line 320 of file BreakableToken.h.

Referenced by getContentStartColumn().

◆ QuoteStyle

QuoteStyleType clang::format::BreakableStringLiteralUsingOperators::QuoteStyle
protected

Definition at line 317 of file BreakableToken.h.

Referenced by getContentStartColumn().

◆ RightBraceQuote

StringRef clang::format::BreakableStringLiteralUsingOperators::RightBraceQuote
protected

Definition at line 321 of file BreakableToken.h.

Referenced by getRemainingLength().


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