10 #ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INCLUDEFIXER_H 11 #define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INCLUDEFIXER_H 15 #include "clang/Format/Format.h" 16 #include "clang/Sema/ExternalSemaSource.h" 17 #include "clang/Tooling/Core/Replacement.h" 18 #include "clang/Tooling/Tooling.h" 24 class CompilerInvocation;
27 class PCHContainerOperations;
29 namespace include_fixer {
38 std::vector<IncludeFixerContext> &Contexts,
40 bool MinimizeIncludePaths =
true);
45 runInvocation(std::shared_ptr<clang::CompilerInvocation> Invocation,
46 clang::FileManager *Files,
47 std::shared_ptr<clang::PCHContainerOperations> PCHContainerOps,
48 clang::DiagnosticConsumer *Diagnostics)
override;
55 std::vector<IncludeFixerContext> &Contexts;
58 bool MinimizeIncludePaths;
62 std::string FallbackStyle;
82 bool AddQualifiers =
true);
89 bool MinimizeIncludePaths,
90 bool GenerateDiagnostics)
91 : SymbolIndexMgr(SymbolIndexMgr),
92 MinimizeIncludePaths(MinimizeIncludePaths),
93 GenerateDiagnostics(GenerateDiagnostics) {}
96 void setFilePath(StringRef FilePath) { this->FilePath = FilePath; }
100 bool MaybeDiagnoseMissingCompleteType(clang::SourceLocation
Loc,
101 clang::QualType T)
override;
105 clang::TypoCorrection CorrectTypo(
const DeclarationNameInfo &Typo,
106 int LookupKind, Scope *S, CXXScopeSpec *SS,
107 CorrectionCandidateCallback &CCC,
108 DeclContext *MemberContext,
109 bool EnteringContext,
110 const ObjCObjectPointerType *OPT)
override;
113 std::string minimizeInclude(StringRef Include,
114 const clang::SourceManager &SourceManager,
115 clang::HeaderSearch &HeaderSearch)
const;
119 const clang::SourceManager &SourceManager,
120 clang::HeaderSearch &HeaderSearch,
121 ArrayRef<find_all_symbols::SymbolInfo> MatchedSymbols)
const;
125 return MatchedSymbols;
130 std::vector<find_all_symbols::SymbolInfo>
133 CompilerInstance *CI;
139 std::vector<IncludeFixerContext::QuerySymbolInfo> QuerySymbolInfos;
144 std::vector<find_all_symbols::SymbolInfo> MatchedSymbols;
147 std::string FilePath;
150 bool MinimizeIncludePaths =
true;
153 bool GenerateDiagnostics =
false;
158 #endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INCLUDEFIXER_H
SourceLocation Loc
'#' location in the include directive
Handles callbacks from sema, does the include lookup and turns it into an IncludeFixerContext.
llvm::Expected< tooling::Replacements > createIncludeFixerReplacements(StringRef Code, const IncludeFixerContext &Context, const clang::format::FormatStyle &Style, bool AddQualifiers)
A context for a file being processed.
IncludeFixerSemaSource(SymbolIndexManager &SymbolIndexMgr, bool MinimizeIncludePaths, bool GenerateDiagnostics)
bool runInvocation(std::shared_ptr< clang::CompilerInvocation > Invocation, clang::FileManager *Files, std::shared_ptr< clang::PCHContainerOperations > PCHContainerOps, clang::DiagnosticConsumer *Diagnostics) override
ArrayRef< find_all_symbols::SymbolInfo > getMatchedSymbols() const
Get the global matched symbols.
This class provides an interface for finding the header files corresponding to an identifier in the s...
~IncludeFixerActionFactory() override
void setFilePath(StringRef FilePath)
IncludeFixerActionFactory(SymbolIndexManager &SymbolIndexMgr, std::vector< IncludeFixerContext > &Contexts, StringRef StyleName, bool MinimizeIncludePaths=true)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
CharSourceRange Range
SourceRange for the file name.
void setCompilerInstance(CompilerInstance *CI)
static cl::opt< std::string > FormatStyle("format-style", cl::desc(R"(
Style for formatting code around applied fixes:
- 'none' (default) turns off formatting
- 'file' (literally 'file', not a placeholder)
uses .clang-format file in the closest parent
directory
- '{ <json> }' specifies options inline, e.g.
-format-style='{BasedOnStyle: llvm, IndentWidth: 8}'
- 'llvm', 'google', 'webkit', 'mozilla'
See clang-format documentation for the up-to-date
information about formatting styles and options.
This option overrides the 'FormatStyle` option in
.clang-tidy file, if any.
)"), cl::init("none"), cl::cat(ClangTidyCategory))