9 #ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INCLUDEFIXER_H 10 #define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INCLUDEFIXER_H 14 #include "clang/Format/Format.h" 15 #include "clang/Sema/ExternalSemaSource.h" 16 #include "clang/Tooling/Core/Replacement.h" 17 #include "clang/Tooling/Tooling.h" 23 class CompilerInvocation;
26 class PCHContainerOperations;
28 namespace include_fixer {
37 std::vector<IncludeFixerContext> &Contexts,
39 bool MinimizeIncludePaths =
true);
44 runInvocation(std::shared_ptr<clang::CompilerInvocation> Invocation,
45 clang::FileManager *
Files,
46 std::shared_ptr<clang::PCHContainerOperations> PCHContainerOps,
47 clang::DiagnosticConsumer *Diagnostics)
override;
54 std::vector<IncludeFixerContext> &Contexts;
57 bool MinimizeIncludePaths;
61 std::string FallbackStyle;
81 bool AddQualifiers =
true);
88 bool MinimizeIncludePaths,
89 bool GenerateDiagnostics)
90 : SymbolIndexMgr(SymbolIndexMgr),
91 MinimizeIncludePaths(MinimizeIncludePaths),
92 GenerateDiagnostics(GenerateDiagnostics) {}
95 void setFilePath(StringRef FilePath) { this->FilePath = FilePath; }
99 bool MaybeDiagnoseMissingCompleteType(clang::SourceLocation
Loc,
100 clang::QualType T)
override;
104 clang::TypoCorrection CorrectTypo(
const DeclarationNameInfo &Typo,
105 int LookupKind, Scope *S, CXXScopeSpec *SS,
106 CorrectionCandidateCallback &CCC,
107 DeclContext *MemberContext,
108 bool EnteringContext,
109 const ObjCObjectPointerType *OPT)
override;
112 std::string minimizeInclude(StringRef Include,
113 const clang::SourceManager &SourceManager,
114 clang::HeaderSearch &HeaderSearch)
const;
118 const clang::SourceManager &SourceManager,
119 clang::HeaderSearch &HeaderSearch,
120 ArrayRef<find_all_symbols::SymbolInfo> MatchedSymbols)
const;
124 return MatchedSymbols;
129 std::vector<find_all_symbols::SymbolInfo>
132 CompilerInstance *CI;
138 std::vector<IncludeFixerContext::QuerySymbolInfo> QuerySymbolInfos;
143 std::vector<find_all_symbols::SymbolInfo> MatchedSymbols;
146 std::string FilePath;
149 bool MinimizeIncludePaths =
true;
152 bool GenerateDiagnostics =
false;
157 #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)
llvm::StringMap< std::string > Files
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))