#include "ContinuationIndenter.h"
#include "BreakableToken.h"
#include "FormatInternal.h"
#include "FormatToken.h"
#include "WhitespaceManager.h"
#include "clang/Basic/OperatorPrecedence.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TokenKinds.h"
#include "clang/Format/Format.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Debug.h"
#include <optional>
#define DEBUG_TYPE …
namespace clang {
namespace format {
static bool shouldIndentWrappedSelectorName(const FormatStyle &Style,
LineType LineType) { … }
static bool shouldUnindentNextOperator(const FormatToken &Tok) { … }
static unsigned getLengthToMatchingParen(const FormatToken &Tok,
ArrayRef<ParenState> Stack) { … }
static unsigned getLengthToNextOperator(const FormatToken &Tok) { … }
static bool startsSegmentOfBuilderTypeCall(const FormatToken &Tok) { … }
static bool isAlignableBinaryOperator(const FormatToken &Token) { … }
static bool startsNextOperand(const FormatToken &Current) { … }
static bool mustBreakBinaryOperation(const FormatToken &Current,
const FormatStyle &Style) { … }
static bool opensProtoMessageField(const FormatToken &LessTok,
const FormatStyle &Style) { … }
static std::optional<StringRef> getRawStringDelimiter(StringRef TokenText) { … }
static StringRef
getCanonicalRawStringDelimiter(const FormatStyle &Style,
FormatStyle::LanguageKind Language) { … }
RawStringFormatStyleManager::RawStringFormatStyleManager(
const FormatStyle &CodeStyle) { … }
std::optional<FormatStyle>
RawStringFormatStyleManager::getDelimiterStyle(StringRef Delimiter) const { … }
std::optional<FormatStyle>
RawStringFormatStyleManager::getEnclosingFunctionStyle(
StringRef EnclosingFunction) const { … }
ContinuationIndenter::ContinuationIndenter(const FormatStyle &Style,
const AdditionalKeywords &Keywords,
const SourceManager &SourceMgr,
WhitespaceManager &Whitespaces,
encoding::Encoding Encoding,
bool BinPackInconclusiveFunctions)
: … { … }
LineState ContinuationIndenter::getInitialState(unsigned FirstIndent,
unsigned FirstStartColumn,
const AnnotatedLine *Line,
bool DryRun) { … }
bool ContinuationIndenter::canBreak(const LineState &State) { … }
bool ContinuationIndenter::mustBreak(const LineState &State) { … }
unsigned ContinuationIndenter::addTokenToState(LineState &State, bool Newline,
bool DryRun,
unsigned ExtraSpaces) { … }
void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
unsigned ExtraSpaces) { … }
unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
bool DryRun) { … }
unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) { … }
static bool hasNestedBlockInlined(const FormatToken *Previous,
const FormatToken &Current,
const FormatStyle &Style) { … }
unsigned ContinuationIndenter::moveStateToNextToken(LineState &State,
bool DryRun, bool Newline) { … }
void ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
bool Newline) { … }
void ContinuationIndenter::moveStatePastFakeRParens(LineState &State) { … }
void ContinuationIndenter::moveStatePastScopeOpener(LineState &State,
bool Newline) { … }
void ContinuationIndenter::moveStatePastScopeCloser(LineState &State) { … }
void ContinuationIndenter::moveStateToNewBlock(LineState &State, bool NewLine) { … }
static unsigned getLastLineEndColumn(StringRef Text, unsigned StartColumn,
unsigned TabWidth,
encoding::Encoding Encoding) { … }
unsigned ContinuationIndenter::reformatRawStringLiteral(
const FormatToken &Current, LineState &State,
const FormatStyle &RawStringStyle, bool DryRun, bool Newline) { … }
unsigned ContinuationIndenter::addMultilineToken(const FormatToken &Current,
LineState &State) { … }
unsigned ContinuationIndenter::handleEndOfLine(const FormatToken &Current,
LineState &State, bool DryRun,
bool AllowBreak, bool Newline) { … }
static StringRef getEnclosingFunctionName(const FormatToken &Current) { … }
std::optional<FormatStyle>
ContinuationIndenter::getRawStringStyle(const FormatToken &Current,
const LineState &State) { … }
std::unique_ptr<BreakableToken>
ContinuationIndenter::createBreakableToken(const FormatToken &Current,
LineState &State, bool AllowBreak) { … }
std::pair<unsigned, bool>
ContinuationIndenter::breakProtrudingToken(const FormatToken &Current,
LineState &State, bool AllowBreak,
bool DryRun, bool Strict) { … }
unsigned ContinuationIndenter::getColumnLimit(const LineState &State) const { … }
bool ContinuationIndenter::nextIsMultilineString(const LineState &State) { … }
}
}