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"
23class CompilerInvocation;
26class PCHContainerOperations;
28namespace 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,
54 std::vector<IncludeFixerContext> &Contexts;
57 bool MinimizeIncludePaths;
61 std::string FallbackStyle;
80 const format::FormatStyle &Style = format::getLLVMStyle(),
81 bool AddQualifiers =
true);
88 bool MinimizeIncludePaths,
89 bool GenerateDiagnostics)
90 : SymbolIndexMgr(SymbolIndexMgr),
91 MinimizeIncludePaths(MinimizeIncludePaths),
92 GenerateDiagnostics(GenerateDiagnostics) {}
96 this->FilePath = std::string(FilePath);
102 clang::QualType T)
override;
106 clang::TypoCorrection
CorrectTypo(
const DeclarationNameInfo &Typo,
107 int LookupKind, Scope *S, CXXScopeSpec *SS,
108 CorrectionCandidateCallback &CCC,
109 DeclContext *MemberContext,
110 bool EnteringContext,
111 const ObjCObjectPointerType *OPT)
override;
115 const clang::SourceManager &SourceManager,
116 clang::HeaderSearch &HeaderSearch)
const;
120 const clang::SourceManager &SourceManager,
121 clang::HeaderSearch &HeaderSearch,
122 ArrayRef<find_all_symbols::SymbolInfo> MatchedSymbols)
const;
126 return MatchedSymbols;
131 std::vector<find_all_symbols::SymbolInfo>
132 query(StringRef Query, StringRef ScopedQualifiers, tooling::Range
Range);
134 CompilerInstance *CI;
140 std::vector<IncludeFixerContext::QuerySymbolInfo> QuerySymbolInfos;
145 std::vector<find_all_symbols::SymbolInfo> MatchedSymbols;
148 std::string FilePath;
151 bool MinimizeIncludePaths =
true;
154 bool GenerateDiagnostics =
false;
CharSourceRange Range
SourceRange for the file name.
std::unique_ptr< CompilerInvocation > CI
WantDiagnostics Diagnostics
bool runInvocation(std::shared_ptr< clang::CompilerInvocation > Invocation, clang::FileManager *Files, std::shared_ptr< clang::PCHContainerOperations > PCHContainerOps, clang::DiagnosticConsumer *Diagnostics) override
~IncludeFixerActionFactory() override
A context for a file being processed.
Handles callbacks from sema, does the include lookup and turns it into an IncludeFixerContext.
IncludeFixerContext getIncludeFixerContext(const clang::SourceManager &SourceManager, clang::HeaderSearch &HeaderSearch, ArrayRef< find_all_symbols::SymbolInfo > MatchedSymbols) const
Get the include fixer context for the queried symbol.
void setFilePath(StringRef FilePath)
void setCompilerInstance(CompilerInstance *CI)
IncludeFixerSemaSource(SymbolIndexManager &SymbolIndexMgr, bool MinimizeIncludePaths, bool GenerateDiagnostics)
std::string minimizeInclude(StringRef Include, const clang::SourceManager &SourceManager, clang::HeaderSearch &HeaderSearch) const
Get the minimal include for a given path.
clang::TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, int LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, DeclContext *MemberContext, bool EnteringContext, const ObjCObjectPointerType *OPT) override
Callback for unknown identifiers.
ArrayRef< find_all_symbols::SymbolInfo > getMatchedSymbols() const
Get the global matched symbols.
bool MaybeDiagnoseMissingCompleteType(clang::SourceLocation Loc, clang::QualType T) override
Callback for incomplete types.
This class provides an interface for finding the header files corresponding to an identifier in the s...
llvm::Expected< tooling::Replacements > createIncludeFixerReplacements(StringRef Code, const IncludeFixerContext &Context, const clang::format::FormatStyle &Style, bool AddQualifiers)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//