mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-24 16:45:07 +00:00
Remove $ccls/base and clean up; deduplicate codeLens
This commit is contained in:
parent
69f749ac9f
commit
ce72cf7bd9
@ -209,7 +209,6 @@ target_sources(ccls PRIVATE
|
||||
)
|
||||
|
||||
target_sources(ccls PRIVATE
|
||||
src/messages/ccls_base.cc
|
||||
src/messages/ccls_callHierarchy.cc
|
||||
src/messages/ccls_callers.cc
|
||||
src/messages/ccls_fileInfo.cc
|
||||
|
@ -538,7 +538,7 @@ void CompletionPreloadMain(ClangCompleteManager *completion_manager) {
|
||||
}
|
||||
}
|
||||
|
||||
void CompletionQueryMain(ClangCompleteManager *completion_manager) {
|
||||
void CompletionMain(ClangCompleteManager *completion_manager) {
|
||||
while (true) {
|
||||
// Fetching the completion request blocks until we have a request.
|
||||
std::unique_ptr<ClangCompleteManager::CompletionRequest> request =
|
||||
@ -576,7 +576,7 @@ void CompletionQueryMain(ClangCompleteManager *completion_manager) {
|
||||
FOpts.SkipFunctionBodies = true;
|
||||
CI->getLangOpts()->CommentOpts.ParseAllComments = true;
|
||||
|
||||
StoreDiags DC;
|
||||
DiagnosticConsumer DC;
|
||||
WorkingFiles::Snapshot snapshot =
|
||||
completion_manager->working_files_->AsSnapshot({StripFileType(path)});
|
||||
std::vector<std::unique_ptr<llvm::MemoryBuffer>> Bufs;
|
||||
@ -595,7 +595,7 @@ void CompletionQueryMain(ClangCompleteManager *completion_manager) {
|
||||
}
|
||||
}
|
||||
|
||||
void DiagnosticQueryMain(ClangCompleteManager *manager) {
|
||||
void DiagnosticMain(ClangCompleteManager *manager) {
|
||||
while (true) {
|
||||
// Fetching the completion request blocks until we have a request.
|
||||
ClangCompleteManager::DiagnosticRequest request =
|
||||
@ -698,8 +698,8 @@ ClangCompleteManager::ClangCompleteManager(Project *project,
|
||||
completion_sessions_(kMaxCompletionSessions),
|
||||
PCH(std::make_shared<PCHContainerOperations>()) {
|
||||
std::thread([&]() {
|
||||
set_thread_name("comp-query");
|
||||
ccls::CompletionQueryMain(this);
|
||||
set_thread_name("comp");
|
||||
ccls::CompletionMain(this);
|
||||
})
|
||||
.detach();
|
||||
std::thread([&]() {
|
||||
@ -708,8 +708,8 @@ ClangCompleteManager::ClangCompleteManager(Project *project,
|
||||
})
|
||||
.detach();
|
||||
std::thread([&]() {
|
||||
set_thread_name("diag-query");
|
||||
ccls::DiagnosticQueryMain(this);
|
||||
set_thread_name("diag");
|
||||
ccls::DiagnosticMain(this);
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
|
@ -999,7 +999,6 @@ public:
|
||||
break;
|
||||
case Decl::EnumConstant:
|
||||
var->def.kind = lsSymbolKind::EnumMember;
|
||||
// TODO Pretty printer may print =
|
||||
if (is_def && strchr(var->def.detailed_name, '=') == nullptr) {
|
||||
auto *ECD = cast<EnumConstantDecl>(D);
|
||||
const auto &Val = ECD->getInitVal();
|
||||
|
@ -1,54 +0,0 @@
|
||||
// Copyright 2017-2018 ccls Authors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
#include "message_handler.h"
|
||||
#include "pipeline.hh"
|
||||
#include "query_utils.h"
|
||||
using namespace ccls;
|
||||
|
||||
namespace {
|
||||
|
||||
MethodType kMethodType = "$ccls/base";
|
||||
|
||||
struct In_CclsBase : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
|
||||
lsTextDocumentPositionParams params;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(In_CclsBase, id, params);
|
||||
REGISTER_IN_MESSAGE(In_CclsBase);
|
||||
|
||||
struct Handler_CclsBase : BaseMessageHandler<In_CclsBase> {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
|
||||
void Run(In_CclsBase *request) override {
|
||||
QueryFile *file;
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorkingFile *working_file =
|
||||
working_files->GetFileByFilename(file->def->path);
|
||||
|
||||
Out_LocationList out;
|
||||
out.id = request->id;
|
||||
for (SymbolRef sym :
|
||||
FindSymbolsAtLocation(working_file, file, request->params.position)) {
|
||||
if (sym.kind == SymbolKind::Type) {
|
||||
if (const auto *def = db->GetType(sym).AnyDef())
|
||||
out.result = GetLsLocationExs(db, working_files,
|
||||
GetTypeDeclarations(db, def->bases));
|
||||
break;
|
||||
} else if (sym.kind == SymbolKind::Func) {
|
||||
if (const auto *def = db->GetFunc(sym).AnyDef())
|
||||
out.result = GetLsLocationExs(db, working_files,
|
||||
GetFuncDeclarations(db, def->bases));
|
||||
break;
|
||||
}
|
||||
}
|
||||
pipeline::WriteStdout(kMethodType, out);
|
||||
}
|
||||
};
|
||||
REGISTER_MESSAGE_HANDLER(Handler_CclsBase);
|
||||
} // namespace
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include "message_handler.h"
|
||||
#include "pipeline.hh"
|
||||
using namespace ccls;
|
||||
#include "query_utils.h"
|
||||
using namespace ccls;
|
||||
|
||||
|
@ -8,19 +8,19 @@
|
||||
#include "query_utils.h"
|
||||
using namespace ccls;
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
namespace {
|
||||
MethodType kMethodType = "textDocument/codeLens";
|
||||
|
||||
struct lsDocumentCodeLensParams {
|
||||
lsTextDocumentIdentifier textDocument;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(lsDocumentCodeLensParams, textDocument);
|
||||
|
||||
using TCodeLens = lsCodeLens<lsCodeLensUserData, lsCodeLensCommandArguments>;
|
||||
struct In_TextDocumentCodeLens : public RequestInMessage {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
lsDocumentCodeLensParams params;
|
||||
struct Params {
|
||||
lsTextDocumentIdentifier textDocument;
|
||||
} params;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(In_TextDocumentCodeLens::Params, textDocument);
|
||||
MAKE_REFLECT_STRUCT(In_TextDocumentCodeLens, id, params);
|
||||
REGISTER_IN_MESSAGE(In_TextDocumentCodeLens);
|
||||
|
||||
@ -84,19 +84,17 @@ struct Handler_TextDocumentCodeLens
|
||||
: BaseMessageHandler<In_TextDocumentCodeLens> {
|
||||
MethodType GetMethodType() const override { return kMethodType; }
|
||||
void Run(In_TextDocumentCodeLens *request) override {
|
||||
auto ¶ms = request->params;
|
||||
Out_TextDocumentCodeLens out;
|
||||
out.id = request->id;
|
||||
|
||||
lsDocumentUri file_as_uri = request->params.textDocument.uri;
|
||||
std::string path = file_as_uri.GetPath();
|
||||
|
||||
std::string path = params.textDocument.uri.GetPath();
|
||||
clang_complete->NotifyView(path);
|
||||
|
||||
QueryFile *file;
|
||||
if (!FindFileOrFail(db, project, request->id,
|
||||
request->params.textDocument.uri.GetPath(), &file)) {
|
||||
params.textDocument.uri.GetPath(), &file))
|
||||
return;
|
||||
}
|
||||
|
||||
CommonCodeLensParams common;
|
||||
common.result = &out.result;
|
||||
@ -104,8 +102,10 @@ struct Handler_TextDocumentCodeLens
|
||||
common.working_files = working_files;
|
||||
common.working_file = working_files->GetFileByFilename(file->def->path);
|
||||
|
||||
std::unordered_set<Range> seen;
|
||||
for (auto [sym, refcnt] : file->outline2refcnt) {
|
||||
if (refcnt <= 0) continue;
|
||||
if (refcnt <= 0 || !seen.insert(sym.range).second)
|
||||
continue;
|
||||
// NOTE: We OffsetColumn so that the code lens always show up in a
|
||||
// predictable order. Otherwise, the client may randomize it.
|
||||
Use use{{sym.range, sym.usr, sym.kind, sym.role}, file->id};
|
||||
|
Loading…
Reference in New Issue
Block a user