9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INCLUDEFIXER_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INCLUDEFIXER_H
16#include "clang/AST/Type.h"
17#include "clang/Basic/Diagnostic.h"
18#include "clang/Basic/SourceLocation.h"
19#include "clang/Sema/ExternalSemaSource.h"
20#include "clang/Tooling/Inclusions/HeaderIncludes.h"
21#include "llvm/ADT/DenseMap.h"
22#include "llvm/ADT/IntrusiveRefCntPtr.h"
23#include "llvm/ADT/StringMap.h"
24#include "llvm/ADT/StringRef.h"
36 IncludeFixer(llvm::StringRef File, std::shared_ptr<IncludeInserter> Inserter,
37 const SymbolIndex &Index,
unsigned IndexRequestLimit,
39 : File(File), Inserter(std::move(Inserter)), Index(Index),
44 std::vector<Fix>
fix(DiagnosticsEngine::Level DiagLevel,
45 const clang::Diagnostic &
Info)
const;
54 std::vector<Fix> fixIncompleteType(
const Type &T)
const;
57 std::vector<Fix> fixesForSymbols(
const SymbolSlab &Syms)
const;
59 std::optional<Fix> insertHeader(llvm::StringRef
Name,
60 llvm::StringRef
Symbol =
"",
61 tooling::IncludeDirective Directive =
62 tooling::IncludeDirective::Include)
const;
64 struct UnresolvedName {
67 std::vector<std::string> Scopes;
71 class UnresolvedNameRecorder;
77 std::vector<Fix> fixUnresolvedName()
const;
80 std::shared_ptr<IncludeInserter> Inserter;
81 const SymbolIndex &Index;
82 const unsigned IndexRequestLimit;
83 mutable unsigned IndexRequestCount = 0;
88 std::optional<UnresolvedName> LastUnresolvedName;
94 mutable llvm::StringMap<SymbolSlab> FuzzyFindCache;
95 mutable llvm::DenseMap<SymbolID, SymbolSlab> LookupCache;
97 std::optional<const SymbolSlab *>
98 fuzzyFindCached(
const FuzzyFindRequest &Req)
const;
99 std::optional<const SymbolSlab *> lookupCached(
const SymbolID &
ID)
const;
llvm::SmallString< 256U > Name
const MacroDirective * Directive
Attempts to recover from error diagnostics by suggesting include insertion fixes.
IncludeFixer(llvm::StringRef File, std::shared_ptr< IncludeInserter > Inserter, const SymbolIndex &Index, unsigned IndexRequestLimit, Symbol::IncludeDirective Directive)
llvm::IntrusiveRefCntPtr< ExternalSemaSource > unresolvedNameRecorder()
Returns an ExternalSemaSource that records failed name lookups in Sema.
std::vector< Fix > fix(DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) const
Returns include insertions that can potentially recover the diagnostic.
Interface for symbol indexes that can be used for searching or matching symbols among a set of symbol...
An immutable symbol container that stores a set of symbols.
@ Info
An information message.
@ Type
An inlay hint that for a type annotation.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
The class presents a C++ symbol, e.g.