Update CodeCompletion and SignatureHelp.

This commit is contained in:
ykiko
2024-10-27 13:55:30 +08:00
parent e1afd40663
commit 2890873428
5 changed files with 101 additions and 28 deletions

View File

@@ -78,11 +78,25 @@ void Compiler::generatePCM(llvm::StringRef outpath) {
}
void Compiler::codeCompletion(llvm::StringRef filepath, std::uint32_t line, std::uint32_t column) {
auto& completion = instance->getFrontendOpts().CodeCompletionAt;
completion.FileName = filepath;
completion.Line = line;
completion.Column = column;
buildAST();
auto& location = instance->getFrontendOpts().CodeCompletionAt;
location.FileName = filepath;
location.Line = line;
location.Column = column;
if(content != "") {
auto buffer = llvm::MemoryBuffer::getMemBufferCopy(content);
instance->getPreprocessorOpts().addRemappedFile(filepath, buffer.release());
}
if(!action->BeginSourceFile(*instance, instance->getFrontendOpts().Inputs[0])) {
llvm::errs() << "Failed to begin source file\n";
std::terminate();
}
if(auto error = action->Execute()) {
llvm::errs() << "Failed to execute action: " << error << "\n";
std::terminate();
}
}
void Compiler::ExecuteAction() {
@@ -102,7 +116,7 @@ void Compiler::ExecuteAction() {
// Beacuse CompilerInstance may create new Preprocessor in `BeginSourceFile`,
// So we must need to create TokenCollector here.
// clang::syntax::TokenCollector collector{preproc};
CodeCompleteCollector collect2(*instance);
// CodeCompleteCollector collect2(*instance);
// FIXME: clang-tidy, include-fixer, etc?