45 CCTUInfo(CCAllocator), Results(Results){};
49 unsigned NumResults)
final;
56 std::shared_ptr<GlobalCodeCompletionAllocator> CCAllocator;
58 std::vector<std::string> &Results;
64 for (
unsigned I = 0; I < NumResults; ++I) {
65 auto &
Result = InResults[I];
68 if (
auto *
ID =
Result.Declaration->getIdentifier()) {
69 Results.push_back(
ID->getName().str());
73 Results.push_back(
Result.Keyword);
86 : ParentCI(ParentCI) {}
97 std::unique_ptr<ASTImporter> Importer;
126 : ChildTUDeclCtxt(ChildASTCtxt.getTranslationUnitDecl()),
127 ParentASTCtxt(ParentASTCtxt),
128 ParentTUDeclCtxt(ParentASTCtxt.getTranslationUnitDecl()) {
130 new ASTImporter(ChildASTCtxt, ChildFM, ParentASTCtxt, ParentFM,
132 Importer.reset(importer);
139 auto ParentDeclName =
143 ParentTUDeclCtxt->
lookup(ParentDeclName);
145 if (!lookup_result.
empty()) {
153 assert(ChildDeclContext && ChildDeclContext == ChildTUDeclCtxt &&
154 "No child decl context!");
159 for (
auto *DeclCtxt = ParentTUDeclCtxt; DeclCtxt !=
nullptr;
161 for (
auto &IDeclContext : DeclCtxt->decls()) {
162 if (
NamedDecl *
Decl = llvm::dyn_cast<NamedDecl>(IDeclContext)) {
163 if (
auto DeclOrErr = Importer->Import(
Decl)) {
165 llvm::dyn_cast<NamedDecl>(*DeclOrErr)) {
167 importedNamedDecl->getDeclName(),
172 llvm::consumeError(DeclOrErr.takeError());
182 std::vector<std::string> &CCResults) {
194 auto Act = std::unique_ptr<IncrementalSyntaxOnlyAction>(
196 std::unique_ptr<llvm::MemoryBuffer> MB =
203 AU->setOwnsRemappedFileBuffers(
false);
206 std::make_shared<clang::PCHContainerOperations>(), *diag,
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TranslationUnitDecl * getTranslationUnitDecl() const
void setExternalSource(IntrusiveRefCntPtr< ExternalASTSource > Source)
Attach an external AST source to the AST context.
Imports selected nodes from one AST context into another context, merging AST nodes where appropriate...
static ASTUnit * LoadFromCompilerInvocationAction(std::shared_ptr< CompilerInvocation > CI, std::shared_ptr< PCHContainerOperations > PCHContainerOps, IntrusiveRefCntPtr< DiagnosticsEngine > Diags, FrontendAction *Action=nullptr, ASTUnit *Unit=nullptr, bool Persistent=true, StringRef ResourceFilesPath=StringRef(), bool OnlyLocalDecls=false, CaptureDiagsKind CaptureDiagnostics=CaptureDiagsKind::None, unsigned PrecompilePreambleAfterNParses=0, bool CacheCodeCompletionResults=false, bool UserFilesAreVolatile=false, std::unique_ptr< ASTUnit > *ErrAST=nullptr)
Create an ASTUnit from a source file, via a CompilerInvocation object, by invoking the optionally pro...
Abstract interface for a consumer of code-completion information.
Options controlling the behavior of code completion.
unsigned IncludeCodePatterns
Show code patterns in code completion results.
unsigned IncludeMacros
Show macros in code completion results.
unsigned IncludeBriefComments
Show brief documentation comments in code completion results.
unsigned IncludeGlobals
Show top-level decls in code completion results.
An allocator used specifically for the purpose of code completion.
The context in which code completion occurred, so that the code-completion consumer can process the r...
Captures a result of code completion.
@ RK_Declaration
Refers to a declaration.
@ RK_Keyword
Refers to a keyword or symbol.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
FileManager & getFileManager() const
Return the current file manager to the caller.
IntrusiveRefCntPtr< DiagnosticsEngine > getDiagnosticsPtr() const
ASTContext & getASTContext() const
FrontendOptions & getFrontendOpts()
std::shared_ptr< CompilerInvocation > getInvocationPtr()
LangOptions & getLangOpts()
SourceManager & getSourceManager() const
Return the current source manager.
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
void setHasExternalVisibleStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations visible in this context.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
void setHasExternalLexicalStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations lexically in this context.
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
The name of a declaration.
Options for controlling the compiler diagnostics engine.
Abstract interface for external sources of AST nodes.
static DeclContextLookupResult SetExternalVisibleDeclsForName(const DeclContext *DC, DeclarationName Name, ArrayRef< NamedDecl * > Decls)
ExternalSource(ASTContext &ChildASTCtxt, FileManager &ChildFM, ASTContext &ParentASTCtxt, FileManager &ParentFM)
void completeVisibleDeclsMap(const clang::DeclContext *childDeclContext) override
Ensures that the table of all visible declarations inside this context is up to date.
bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) override
Find all declarations with the given name in the given context, and add them to the context by callin...
Implements support for file system lookup, file system caching, and directory search management.
CompilerInstance & getCompilerInstance() const
virtual void ExecuteAction()=0
Callback to run the program action, using the initialized compiler instance.
SmallVector< FrontendInputFile, 0 > Inputs
The input files and their types.
Allocator for a cached set of global code completions.
Implements an efficient mapping from strings to IdentifierInfo nodes.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
IncrementalSyntaxOnlyAction(const CompilerInstance *ParentCI)
void ExecuteAction() override
Implement the ExecuteAction interface by running Sema on the already-initialized AST consumer.
This represents a decl that may have a name.
ReplCompletionConsumer(std::vector< std::string > &Results)
void ProcessCodeCompleteResults(class Sema &S, CodeCompletionContext Context, CodeCompletionResult *InResults, unsigned NumResults) final
Process the finalized code-completion results.
CodeCompletionAllocator & getAllocator() override
Retrieve the allocator that will be used to allocate code completion strings.
CodeCompletionTUInfo & getCodeCompletionTUInfo() override
Sema - This implements semantic analysis and AST building for C.
The top declaration context.
void codeComplete(CompilerInstance *InterpCI, llvm::StringRef Content, unsigned Line, unsigned Col, const CompilerInstance *ParentCI, std::vector< std::string > &CCResults)
@ Result
The result type of a method or function.
clang::CodeCompleteOptions getClangCompleteOpts()
const std::string CodeCompletionFileName