#include "WhitespaceManager.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include <algorithm>
namespace clang {
namespace format {
bool WhitespaceManager::Change::IsBeforeInFile::operator()(
const Change &C1, const Change &C2) const { … }
WhitespaceManager::Change::Change(const FormatToken &Tok,
bool CreateReplacement,
SourceRange OriginalWhitespaceRange,
int Spaces, unsigned StartOfTokenColumn,
unsigned NewlinesBefore,
StringRef PreviousLinePostfix,
StringRef CurrentLinePrefix, bool IsAligned,
bool ContinuesPPDirective, bool IsInsideToken)
: … { … }
void WhitespaceManager::replaceWhitespace(FormatToken &Tok, unsigned Newlines,
unsigned Spaces,
unsigned StartOfTokenColumn,
bool IsAligned, bool InPPDirective) { … }
void WhitespaceManager::addUntouchableToken(const FormatToken &Tok,
bool InPPDirective) { … }
llvm::Error
WhitespaceManager::addReplacement(const tooling::Replacement &Replacement) { … }
bool WhitespaceManager::inputUsesCRLF(StringRef Text, bool DefaultToCRLF) { … }
void WhitespaceManager::replaceWhitespaceInToken(
const FormatToken &Tok, unsigned Offset, unsigned ReplaceChars,
StringRef PreviousPostfix, StringRef CurrentPrefix, bool InPPDirective,
unsigned Newlines, int Spaces) { … }
const tooling::Replacements &WhitespaceManager::generateReplacements() { … }
void WhitespaceManager::calculateLineBreakInformation() { … }
template <typename F>
static void
AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End,
unsigned Column, bool RightJustify, F &&Matches,
SmallVector<WhitespaceManager::Change, 16> &Changes) { … }
template <typename F>
static unsigned AlignTokens(const FormatStyle &Style, F &&Matches,
SmallVector<WhitespaceManager::Change, 16> &Changes,
unsigned StartAt,
const FormatStyle::AlignConsecutiveStyle &ACS = { … }
static void AlignMatchingTokenSequence(
unsigned &StartOfSequence, unsigned &EndOfSequence, unsigned &MinColumn,
std::function<bool(const WhitespaceManager::Change &C)> Matches,
SmallVector<WhitespaceManager::Change, 16> &Changes) { … }
void WhitespaceManager::alignConsecutiveMacros() { … }
void WhitespaceManager::alignConsecutiveAssignments() { … }
void WhitespaceManager::alignConsecutiveBitFields() { … }
void WhitespaceManager::alignConsecutiveColons(
const FormatStyle::AlignConsecutiveStyle &AlignStyle, TokenType Type) { … }
void WhitespaceManager::alignConsecutiveShortCaseStatements(bool IsExpr) { … }
void WhitespaceManager::alignConsecutiveTableGenBreakingDAGArgColons() { … }
void WhitespaceManager::alignConsecutiveTableGenCondOperatorColons() { … }
void WhitespaceManager::alignConsecutiveTableGenDefinitions() { … }
void WhitespaceManager::alignConsecutiveDeclarations() { … }
void WhitespaceManager::alignChainedConditionals() { … }
void WhitespaceManager::alignTrailingComments() { … }
void WhitespaceManager::alignTrailingComments(unsigned Start, unsigned End,
unsigned Column) { … }
void WhitespaceManager::alignEscapedNewlines() { … }
void WhitespaceManager::alignEscapedNewlines(unsigned Start, unsigned End,
unsigned Column) { … }
void WhitespaceManager::alignArrayInitializers() { … }
void WhitespaceManager::alignArrayInitializers(unsigned Start, unsigned End) { … }
void WhitespaceManager::alignArrayInitializersRightJustified(
CellDescriptions &&CellDescs) { … }
void WhitespaceManager::alignArrayInitializersLeftJustified(
CellDescriptions &&CellDescs) { … }
bool WhitespaceManager::isSplitCell(const CellDescription &Cell) { … }
WhitespaceManager::CellDescriptions WhitespaceManager::getCells(unsigned Start,
unsigned End) { … }
unsigned WhitespaceManager::calculateCellWidth(unsigned Start, unsigned End,
bool WithSpaces) const { … }
void WhitespaceManager::alignToStartOfCell(unsigned Start, unsigned End) { … }
WhitespaceManager::CellDescriptions
WhitespaceManager::linkCells(CellDescriptions &&CellDesc) { … }
void WhitespaceManager::generateChanges() { … }
void WhitespaceManager::storeReplacement(SourceRange Range, StringRef Text) { … }
void WhitespaceManager::appendNewlineText(std::string &Text,
unsigned Newlines) { … }
void WhitespaceManager::appendEscapedNewlineText(
std::string &Text, unsigned Newlines, unsigned PreviousEndOfTokenColumn,
unsigned EscapedNewlineColumn) { … }
void WhitespaceManager::appendIndentText(std::string &Text,
unsigned IndentLevel, unsigned Spaces,
unsigned WhitespaceStartColumn,
bool IsAligned) { … }
unsigned WhitespaceManager::appendTabIndent(std::string &Text, unsigned Spaces,
unsigned Indentation) { … }
}
}