#include "QualifierAlignmentFixer.h"
#include "FormatToken.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Regex.h"
#include <algorithm>
#include <optional>
#define DEBUG_TYPE …
namespace clang {
namespace format {
void addQualifierAlignmentFixerPasses(const FormatStyle &Style,
SmallVectorImpl<AnalyzerPass> &Passes) { … }
static void replaceToken(const SourceManager &SourceMgr,
tooling::Replacements &Fixes,
const CharSourceRange &Range, std::string NewText) { … }
static void removeToken(const SourceManager &SourceMgr,
tooling::Replacements &Fixes,
const FormatToken *First) { … }
static void insertQualifierAfter(const SourceManager &SourceMgr,
tooling::Replacements &Fixes,
const FormatToken *First,
const std::string &Qualifier) { … }
static void insertQualifierBefore(const SourceManager &SourceMgr,
tooling::Replacements &Fixes,
const FormatToken *First,
const std::string &Qualifier) { … }
static bool endsWithSpace(const std::string &s) { … }
static bool startsWithSpace(const std::string &s) { … }
static void rotateTokens(const SourceManager &SourceMgr,
tooling::Replacements &Fixes, const FormatToken *First,
const FormatToken *Last, bool Left) { … }
static bool
isConfiguredQualifier(const FormatToken *const Tok,
const std::vector<tok::TokenKind> &Qualifiers) { … }
static bool isQualifier(const FormatToken *const Tok) { … }
const FormatToken *LeftRightQualifierAlignmentFixer::analyzeRight(
const SourceManager &SourceMgr, const AdditionalKeywords &Keywords,
tooling::Replacements &Fixes, const FormatToken *const Tok,
const std::string &Qualifier, tok::TokenKind QualifierType) { … }
const FormatToken *LeftRightQualifierAlignmentFixer::analyzeLeft(
const SourceManager &SourceMgr, const AdditionalKeywords &Keywords,
tooling::Replacements &Fixes, const FormatToken *const Tok,
const std::string &Qualifier, tok::TokenKind QualifierType) { … }
tok::TokenKind LeftRightQualifierAlignmentFixer::getTokenFromQualifier(
const std::string &Qualifier) { … }
LeftRightQualifierAlignmentFixer::LeftRightQualifierAlignmentFixer(
const Environment &Env, const FormatStyle &Style,
const std::string &Qualifier,
const std::vector<tok::TokenKind> &QualifierTokens, bool RightAlign)
: … { … }
std::pair<tooling::Replacements, unsigned>
LeftRightQualifierAlignmentFixer::analyze(
TokenAnnotator & ,
SmallVectorImpl<AnnotatedLine *> &AnnotatedLines,
FormatTokenLexer &Tokens) { … }
void LeftRightQualifierAlignmentFixer::fixQualifierAlignment(
SmallVectorImpl<AnnotatedLine *> &AnnotatedLines, FormatTokenLexer &Tokens,
tooling::Replacements &Fixes) { … }
void prepareLeftRightOrderingForQualifierAlignmentFixer(
const std::vector<std::string> &Order, std::vector<std::string> &LeftOrder,
std::vector<std::string> &RightOrder,
std::vector<tok::TokenKind> &Qualifiers) { … }
bool isQualifierOrType(const FormatToken *Tok, const LangOptions &LangOpts) { … }
bool isConfiguredQualifierOrType(const FormatToken *Tok,
const std::vector<tok::TokenKind> &Qualifiers,
const LangOptions &LangOpts) { … }
bool isPossibleMacro(const FormatToken *Tok) { … }
}
}