#ifndef LLVM_CLANG_LIB_FORMAT_QUALIFIERALIGNMENTFIXER_H
#define LLVM_CLANG_LIB_FORMAT_QUALIFIERALIGNMENTFIXER_H
#include "TokenAnalyzer.h"
namespace clang {
namespace format {
typedef std::function<std::pair<tooling::Replacements, unsigned>(
const Environment &)>
AnalyzerPass;
class QualifierAlignmentFixer : public TokenAnalyzer {
SmallVector<AnalyzerPass, 8> Passes;
StringRef &Code;
ArrayRef<tooling::Range> Ranges;
unsigned FirstStartColumn;
unsigned NextStartColumn;
unsigned LastStartColumn;
StringRef FileName;
public:
QualifierAlignmentFixer(const Environment &Env, const FormatStyle &Style,
StringRef &Code, ArrayRef<tooling::Range> Ranges,
unsigned FirstStartColumn, unsigned NextStartColumn,
unsigned LastStartColumn, StringRef FileName);
std::pair<tooling::Replacements, unsigned>
analyze(TokenAnnotator &Annotator,
SmallVectorImpl<AnnotatedLine *> &AnnotatedLines,
FormatTokenLexer &Tokens) override;
static void PrepareLeftRightOrdering(const std::vector<std::string> &Order,
std::vector<std::string> &LeftOrder,
std::vector<std::string> &RightOrder,
std::vector<tok::TokenKind> &Qualifiers);
};
class LeftRightQualifierAlignmentFixer : public TokenAnalyzer {
std::string Qualifier;
bool RightAlign;
SmallVector<tok::TokenKind, 8> QualifierTokens;
std::vector<tok::TokenKind> ConfiguredQualifierTokens;
public:
LeftRightQualifierAlignmentFixer(
const Environment &Env, const FormatStyle &Style,
const std::string &Qualifier,
const std::vector<tok::TokenKind> &ConfiguredQualifierTokens,
bool RightAlign);
std::pair<tooling::Replacements, unsigned>
analyze(TokenAnnotator &Annotator,
SmallVectorImpl<AnnotatedLine *> &AnnotatedLines,
FormatTokenLexer &Tokens) override;
static tok::TokenKind getTokenFromQualifier(const std::string &Qualifier);
const FormatToken *analyzeRight(const SourceManager &SourceMgr,
const AdditionalKeywords &Keywords,
tooling::Replacements &Fixes,
const FormatToken *Tok,
const std::string &Qualifier,
tok::TokenKind QualifierType);
const FormatToken *analyzeLeft(const SourceManager &SourceMgr,
const AdditionalKeywords &Keywords,
tooling::Replacements &Fixes,
const FormatToken *Tok,
const std::string &Qualifier,
tok::TokenKind QualifierType);
static bool isQualifierOrType(const FormatToken *Tok,
const std::vector<tok::TokenKind> &Qualifiers);
static bool isPossibleMacro(const FormatToken *Tok);
};
} }
#endif