From 62d0c49b0a93dab42e9de34d4330fe1effcc98c8 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 13 Sep 2018 00:18:37 -0700 Subject: [PATCH] Rename hierarchies to $ccls/{call,inheritance,member} bool flat = false; -> bool hierarchy = false; (set it to true to enable hierarchical view) Delete $ccls/callers (which is what $ccls/call does now) --- CMakeLists.txt | 7 +- src/hierarchy.hh | 27 ++++++ .../{ccls_callHierarchy.cc => ccls_call.cc} | 48 ++++++----- src/messages/ccls_callers.cc | 50 ----------- ...itanceHierarchy.cc => ccls_inheritance.cc} | 72 +++++++--------- ...ccls_memberHierarchy.cc => ccls_member.cc} | 85 ++++++++----------- src/query_utils.cc | 12 --- src/query_utils.h | 20 ----- 8 files changed, 125 insertions(+), 196 deletions(-) create mode 100644 src/hierarchy.hh rename src/messages/{ccls_callHierarchy.cc => ccls_call.cc} (82%) delete mode 100644 src/messages/ccls_callers.cc rename src/messages/{ccls_inheritanceHierarchy.cc => ccls_inheritance.cc} (70%) rename src/messages/{ccls_memberHierarchy.cc => ccls_member.cc} (77%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01eead6c..20a4bd91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -209,11 +209,10 @@ target_sources(ccls PRIVATE ) target_sources(ccls PRIVATE - src/messages/ccls_callHierarchy.cc - src/messages/ccls_callers.cc + src/messages/ccls_call.cc src/messages/ccls_fileInfo.cc - src/messages/ccls_inheritanceHierarchy.cc - src/messages/ccls_memberHierarchy.cc + src/messages/ccls_inheritance.cc + src/messages/ccls_member.cc src/messages/ccls_navigate.cc src/messages/ccls_reload.cc src/messages/ccls_vars.cc diff --git a/src/hierarchy.hh b/src/hierarchy.hh new file mode 100644 index 00000000..5a78c949 --- /dev/null +++ b/src/hierarchy.hh @@ -0,0 +1,27 @@ +// Copyright 2017-2018 ccls Authors +// SPDX-License-Identifier: Apache-2.0 + +#pragma once + +#include "lsp.h" + +#include +#include + +template +void FlattenHierarchy(const Node &root, Out_LocationList &out) { + std::queue q; + for (auto &entry : root.children) + q.push(&entry); + while (q.size()) { + auto *entry = q.front(); + q.pop(); + if (entry->location.uri.raw_uri.size()) + out.result.push_back({entry->location}); + for (auto &entry1 : entry->children) + q.push(&entry1); + } + std::sort(out.result.begin(), out.result.end()); + out.result.erase(std::unique(out.result.begin(), out.result.end()), + out.result.end()); +} diff --git a/src/messages/ccls_callHierarchy.cc b/src/messages/ccls_call.cc similarity index 82% rename from src/messages/ccls_callHierarchy.cc rename to src/messages/ccls_call.cc index b53f574e..432be592 100644 --- a/src/messages/ccls_callHierarchy.cc +++ b/src/messages/ccls_call.cc @@ -1,6 +1,7 @@ // Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 +#include "hierarchy.hh" #include "message_handler.h" #include "pipeline.hh" #include "query_utils.h" @@ -10,7 +11,7 @@ using namespace ccls; namespace { -MethodType kMethodType = "$ccls/callHierarchy"; +MethodType kMethodType = "$ccls/call"; enum class CallType : uint8_t { Direct = 0, @@ -24,7 +25,7 @@ bool operator&(CallType lhs, CallType rhs) { return uint8_t(lhs) & uint8_t(rhs); } -struct In_CclsCallHierarchy : public RequestInMessage { +struct In_CclsCall : public RequestInMessage { MethodType GetMethodType() const override { return kMethodType; } struct Params { @@ -44,15 +45,16 @@ struct In_CclsCallHierarchy : public RequestInMessage { CallType callType = CallType::All; bool qualified = true; int levels = 1; + bool hierarchy = false; }; Params params; }; -MAKE_REFLECT_STRUCT(In_CclsCallHierarchy::Params, textDocument, position, id, - callee, callType, qualified, levels); -MAKE_REFLECT_STRUCT(In_CclsCallHierarchy, id, params); -REGISTER_IN_MESSAGE(In_CclsCallHierarchy); +MAKE_REFLECT_STRUCT(In_CclsCall::Params, textDocument, position, id, + callee, callType, qualified, levels, hierarchy); +MAKE_REFLECT_STRUCT(In_CclsCall, id, params); +REGISTER_IN_MESSAGE(In_CclsCall); -struct Out_CclsCallHierarchy : public lsOutMessage { +struct Out_CclsCall : public lsOutMessage { struct Entry { Usr usr; std::string id; @@ -67,12 +69,12 @@ struct Out_CclsCallHierarchy : public lsOutMessage { lsRequestId id; std::optional result; }; -MAKE_REFLECT_STRUCT(Out_CclsCallHierarchy::Entry, id, name, location, callType, +MAKE_REFLECT_STRUCT(Out_CclsCall::Entry, id, name, location, callType, numChildren, children); -MAKE_REFLECT_STRUCT_MANDATORY_OPTIONAL(Out_CclsCallHierarchy, jsonrpc, id, +MAKE_REFLECT_STRUCT_MANDATORY_OPTIONAL(Out_CclsCall, jsonrpc, id, result); -bool Expand(MessageHandler *m, Out_CclsCallHierarchy::Entry *entry, bool callee, +bool Expand(MessageHandler *m, Out_CclsCall::Entry *entry, bool callee, CallType call_type, bool qualified, int levels) { const QueryFunc &func = m->db->Func(entry->usr); const QueryFunc::Def *def = func.AnyDef(); @@ -82,7 +84,7 @@ bool Expand(MessageHandler *m, Out_CclsCallHierarchy::Entry *entry, bool callee, auto handle = [&](Use use, CallType call_type1) { entry->numChildren++; if (levels > 0) { - Out_CclsCallHierarchy::Entry entry1; + Out_CclsCall::Entry entry1; entry1.id = std::to_string(use.usr); entry1.usr = use.usr; if (auto loc = GetLsLocation(m->db, m->working_files, use)) @@ -148,17 +150,17 @@ bool Expand(MessageHandler *m, Out_CclsCallHierarchy::Entry *entry, bool callee, return true; } -struct Handler_CclsCallHierarchy : BaseMessageHandler { +struct Handler_CclsCall : BaseMessageHandler { MethodType GetMethodType() const override { return kMethodType; } - std::optional + std::optional BuildInitial(Usr root_usr, bool callee, CallType call_type, bool qualified, int levels) { const auto *def = db->Func(root_usr).AnyDef(); if (!def) return {}; - Out_CclsCallHierarchy::Entry entry; + Out_CclsCall::Entry entry; entry.id = std::to_string(root_usr); entry.usr = root_usr; entry.callType = CallType::Direct; @@ -171,9 +173,9 @@ struct Handler_CclsCallHierarchy : BaseMessageHandler { return entry; } - void Run(In_CclsCallHierarchy *request) override { + void Run(In_CclsCall *request) override { auto ¶ms = request->params; - Out_CclsCallHierarchy out; + Out_CclsCall out; out.id = request->id; if (params.id.size()) { @@ -182,7 +184,7 @@ struct Handler_CclsCallHierarchy : BaseMessageHandler { } catch (...) { return; } - Out_CclsCallHierarchy::Entry entry; + Out_CclsCall::Entry entry; entry.id = std::to_string(params.usr); entry.usr = params.usr; entry.callType = CallType::Direct; @@ -207,9 +209,17 @@ struct Handler_CclsCallHierarchy : BaseMessageHandler { } } - pipeline::WriteStdout(kMethodType, out); + if (params.hierarchy) { + pipeline::WriteStdout(kMethodType, out); + return; + } + Out_LocationList out1; + out1.id = request->id; + if (out.result) + FlattenHierarchy(*out.result, out1); + pipeline::WriteStdout(kMethodType, out1); } }; -REGISTER_MESSAGE_HANDLER(Handler_CclsCallHierarchy); +REGISTER_MESSAGE_HANDLER(Handler_CclsCall); } // namespace diff --git a/src/messages/ccls_callers.cc b/src/messages/ccls_callers.cc deleted file mode 100644 index 15a5a370..00000000 --- a/src/messages/ccls_callers.cc +++ /dev/null @@ -1,50 +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/callers"; - -struct In_CclsCallers : public RequestInMessage { - MethodType GetMethodType() const override { return kMethodType; } - lsTextDocumentPositionParams params; -}; -MAKE_REFLECT_STRUCT(In_CclsCallers, id, params); -REGISTER_IN_MESSAGE(In_CclsCallers); - -struct Handler_CclsCallers : BaseMessageHandler { - MethodType GetMethodType() const override { return kMethodType; } - void Run(In_CclsCallers *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::Func) { - QueryFunc &func = db->GetFunc(sym); - std::vector uses = func.uses; - for (Use func_ref : GetUsesForAllBases(db, func)) - uses.push_back(func_ref); - for (Use func_ref : GetUsesForAllDerived(db, func)) - uses.push_back(func_ref); - out.result = GetLsLocationExs(db, working_files, uses); - break; - } - } - pipeline::WriteStdout(kMethodType, out); - } -}; -REGISTER_MESSAGE_HANDLER(Handler_CclsCallers); -} // namespace diff --git a/src/messages/ccls_inheritanceHierarchy.cc b/src/messages/ccls_inheritance.cc similarity index 70% rename from src/messages/ccls_inheritanceHierarchy.cc rename to src/messages/ccls_inheritance.cc index c4a0696d..ebbe5d02 100644 --- a/src/messages/ccls_inheritanceHierarchy.cc +++ b/src/messages/ccls_inheritance.cc @@ -1,18 +1,18 @@ // Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 +#include "hierarchy.hh" #include "message_handler.h" #include "pipeline.hh" #include "query_utils.h" using namespace ccls; -#include #include namespace { -MethodType kMethodType = "$ccls/inheritanceHierarchy"; +MethodType kMethodType = "$ccls/inheritance"; -struct In_CclsInheritanceHierarchy : public RequestInMessage { +struct In_CclsInheritance : public RequestInMessage { MethodType GetMethodType() const override { return kMethodType; } struct Params { // If id+kind are specified, expand a node; otherwise textDocument+position @@ -28,17 +28,17 @@ struct In_CclsInheritanceHierarchy : public RequestInMessage { bool derived = false; bool qualified = true; int levels = 1; - bool flat = false; + bool hierarchy = false; } params; }; -MAKE_REFLECT_STRUCT(In_CclsInheritanceHierarchy::Params, textDocument, position, - id, kind, derived, qualified, levels, flat); -MAKE_REFLECT_STRUCT(In_CclsInheritanceHierarchy, id, params); -REGISTER_IN_MESSAGE(In_CclsInheritanceHierarchy); +MAKE_REFLECT_STRUCT(In_CclsInheritance::Params, textDocument, position, + id, kind, derived, qualified, levels, hierarchy); +MAKE_REFLECT_STRUCT(In_CclsInheritance, id, params); +REGISTER_IN_MESSAGE(In_CclsInheritance); -struct Out_CclsInheritanceHierarchy - : public lsOutMessage { +struct Out_CclsInheritance + : public lsOutMessage { struct Entry { Usr usr; std::string id; @@ -54,16 +54,16 @@ struct Out_CclsInheritanceHierarchy lsRequestId id; std::optional result; }; -MAKE_REFLECT_STRUCT(Out_CclsInheritanceHierarchy::Entry, id, kind, name, +MAKE_REFLECT_STRUCT(Out_CclsInheritance::Entry, id, kind, name, location, numChildren, children); -MAKE_REFLECT_STRUCT_MANDATORY_OPTIONAL(Out_CclsInheritanceHierarchy, jsonrpc, +MAKE_REFLECT_STRUCT_MANDATORY_OPTIONAL(Out_CclsInheritance, jsonrpc, id, result); -bool Expand(MessageHandler *m, Out_CclsInheritanceHierarchy::Entry *entry, +bool Expand(MessageHandler *m, Out_CclsInheritance::Entry *entry, bool derived, bool qualified, int levels); template -bool ExpandHelper(MessageHandler *m, Out_CclsInheritanceHierarchy::Entry *entry, +bool ExpandHelper(MessageHandler *m, Out_CclsInheritance::Entry *entry, bool derived, bool qualified, int levels, Q &entity) { const auto *def = entity.AnyDef(); if (def) { @@ -85,7 +85,7 @@ bool ExpandHelper(MessageHandler *m, Out_CclsInheritanceHierarchy::Entry *entry, for (auto usr : entity.derived) { if (!seen.insert(usr).second) continue; - Out_CclsInheritanceHierarchy::Entry entry1; + Out_CclsInheritance::Entry entry1; entry1.id = std::to_string(usr); entry1.usr = usr; entry1.kind = entry->kind; @@ -100,7 +100,7 @@ bool ExpandHelper(MessageHandler *m, Out_CclsInheritanceHierarchy::Entry *entry, for (auto usr : def->bases) { if (!seen.insert(usr).second) continue; - Out_CclsInheritanceHierarchy::Entry entry1; + Out_CclsInheritance::Entry entry1; entry1.id = std::to_string(usr); entry1.usr = usr; entry1.kind = entry->kind; @@ -114,7 +114,7 @@ bool ExpandHelper(MessageHandler *m, Out_CclsInheritanceHierarchy::Entry *entry, return true; } -bool Expand(MessageHandler *m, Out_CclsInheritanceHierarchy::Entry *entry, +bool Expand(MessageHandler *m, Out_CclsInheritance::Entry *entry, bool derived, bool qualified, int levels) { if (entry->kind == SymbolKind::Func) return ExpandHelper(m, entry, derived, qualified, levels, @@ -124,13 +124,13 @@ bool Expand(MessageHandler *m, Out_CclsInheritanceHierarchy::Entry *entry, m->db->Type(entry->usr)); } -struct Handler_CclsInheritanceHierarchy - : BaseMessageHandler { +struct Handler_CclsInheritance + : BaseMessageHandler { MethodType GetMethodType() const override { return kMethodType; } - std::optional + std::optional BuildInitial(SymbolRef sym, bool derived, bool qualified, int levels) { - Out_CclsInheritanceHierarchy::Entry entry; + Out_CclsInheritance::Entry entry; entry.id = std::to_string(sym.usr); entry.usr = sym.usr; entry.kind = sym.kind; @@ -138,18 +138,18 @@ struct Handler_CclsInheritanceHierarchy return entry; } - void Run(In_CclsInheritanceHierarchy *request) override { + void Run(In_CclsInheritance *request) override { auto ¶ms = request->params; - Out_CclsInheritanceHierarchy out; + Out_CclsInheritance out; out.id = request->id; - if (!params.flat && params.id.size()) { + if (params.id.size()) { try { params.usr = std::stoull(params.id); } catch (...) { return; } - Out_CclsInheritanceHierarchy::Entry entry; + Out_CclsInheritance::Entry entry; entry.id = std::to_string(params.usr); entry.usr = params.usr; entry.kind = params.kind; @@ -172,31 +172,17 @@ struct Handler_CclsInheritanceHierarchy } } - if (!params.flat) { + if (params.hierarchy) { pipeline::WriteStdout(kMethodType, out); return; } Out_LocationList out1; out1.id = request->id; - if (out.result) { - std::queue q; - for (auto &entry1 : out.result->children) - q.push(&entry1); - while (q.size()) { - auto *entry = q.front(); - q.pop(); - if (entry->location.uri.raw_uri.size()) - out1.result.push_back({entry->location}); - for (auto &entry1 : entry->children) - q.push(&entry1); - } - std::sort(out1.result.begin(), out1.result.end()); - out1.result.erase(std::unique(out1.result.begin(), out1.result.end()), - out1.result.end()); - } + if (out.result) + FlattenHierarchy(*out.result, out1); pipeline::WriteStdout(kMethodType, out1); } }; -REGISTER_MESSAGE_HANDLER(Handler_CclsInheritanceHierarchy); +REGISTER_MESSAGE_HANDLER(Handler_CclsInheritance); } // namespace diff --git a/src/messages/ccls_memberHierarchy.cc b/src/messages/ccls_member.cc similarity index 77% rename from src/messages/ccls_memberHierarchy.cc rename to src/messages/ccls_member.cc index 7264b1a5..f012ca28 100644 --- a/src/messages/ccls_memberHierarchy.cc +++ b/src/messages/ccls_member.cc @@ -1,6 +1,7 @@ // Copyright 2017-2018 ccls Authors // SPDX-License-Identifier: Apache-2.0 +#include "hierarchy.hh" #include "message_handler.h" #include "pipeline.hh" #include "query_utils.h" @@ -9,13 +10,12 @@ using namespace ccls; #include using namespace clang; -#include #include namespace { -MethodType kMethodType = "$ccls/memberHierarchy"; +MethodType kMethodType = "$ccls/member"; -struct In_CclsMemberHierarchy : public RequestInMessage { +struct In_CclsMember : public RequestInMessage { MethodType GetMethodType() const override { return kMethodType; } struct Params { @@ -30,16 +30,16 @@ struct In_CclsMemberHierarchy : public RequestInMessage { bool qualified = false; int levels = 1; - bool flat = false; + bool hierarchy = false; } params; }; -MAKE_REFLECT_STRUCT(In_CclsMemberHierarchy::Params, textDocument, position, id, - qualified, levels, flat); -MAKE_REFLECT_STRUCT(In_CclsMemberHierarchy, id, params); -REGISTER_IN_MESSAGE(In_CclsMemberHierarchy); +MAKE_REFLECT_STRUCT(In_CclsMember::Params, textDocument, position, id, + qualified, levels, hierarchy); +MAKE_REFLECT_STRUCT(In_CclsMember, id, params); +REGISTER_IN_MESSAGE(In_CclsMember); -struct Out_CclsMemberHierarchy : public lsOutMessage { +struct Out_CclsMember : public lsOutMessage { struct Entry { Usr usr; std::string id; @@ -55,21 +55,21 @@ struct Out_CclsMemberHierarchy : public lsOutMessage { lsRequestId id; std::optional result; }; -MAKE_REFLECT_STRUCT(Out_CclsMemberHierarchy::Entry, id, name, fieldName, +MAKE_REFLECT_STRUCT(Out_CclsMember::Entry, id, name, fieldName, location, numChildren, children); -MAKE_REFLECT_STRUCT_MANDATORY_OPTIONAL(Out_CclsMemberHierarchy, jsonrpc, id, +MAKE_REFLECT_STRUCT_MANDATORY_OPTIONAL(Out_CclsMember, jsonrpc, id, result); -bool Expand(MessageHandler *m, Out_CclsMemberHierarchy::Entry *entry, +bool Expand(MessageHandler *m, Out_CclsMember::Entry *entry, bool qualified, int levels); // Add a field to |entry| which is a Func/Type. -void DoField(MessageHandler *m, Out_CclsMemberHierarchy::Entry *entry, +void DoField(MessageHandler *m, Out_CclsMember::Entry *entry, const QueryVar &var, int64_t offset, bool qualified, int levels) { const QueryVar::Def *def1 = var.AnyDef(); if (!def1) return; - Out_CclsMemberHierarchy::Entry entry1; + Out_CclsMember::Entry entry1; // With multiple inheritance, the offset is incorrect. if (offset >= 0) { if (offset / 8 < 10) @@ -106,7 +106,7 @@ void DoField(MessageHandler *m, Out_CclsMemberHierarchy::Entry *entry, } // Expand a type node by adding members recursively to it. -bool Expand(MessageHandler *m, Out_CclsMemberHierarchy::Entry *entry, +bool Expand(MessageHandler *m, Out_CclsMember::Entry *entry, bool qualified, int levels) { if (0 < entry->usr && entry->usr <= BuiltinType::LastKind) { entry->name = ClangBuiltinTypeName(int(entry->usr)); @@ -127,15 +127,16 @@ bool Expand(MessageHandler *m, Out_CclsMemberHierarchy::Entry *entry, const auto *def = stack.back()->AnyDef(); stack.pop_back(); if (def) { - EachDefinedType(m->db, def->bases, [&](QueryType &type1) { - if (!seen.count(type1.usr)) { + for (Usr usr : def->bases) { + auto &type1 = m->db->Type(usr); + if (type1.def.size()) { seen.insert(type1.usr); stack.push_back(&type1); } - }); + } if (def->alias_of) { const QueryType::Def *def1 = m->db->Type(def->alias_of).AnyDef(); - Out_CclsMemberHierarchy::Entry entry1; + Out_CclsMember::Entry entry1; entry1.id = std::to_string(def->alias_of); entry1.usr = def->alias_of; if (def1 && def1->spell) { @@ -173,11 +174,11 @@ bool Expand(MessageHandler *m, Out_CclsMemberHierarchy::Entry *entry, return true; } -struct Handler_CclsMemberHierarchy - : BaseMessageHandler { +struct Handler_CclsMember + : BaseMessageHandler { MethodType GetMethodType() const override { return kMethodType; } - std::optional + std::optional BuildInitial(SymbolKind kind, Usr root_usr, bool qualified, int levels) { switch (kind) { default: @@ -187,7 +188,7 @@ struct Handler_CclsMemberHierarchy if (!def) return {}; - Out_CclsMemberHierarchy::Entry entry; + Out_CclsMember::Entry entry; // Not type, |id| is invalid. entry.name = def->Name(qualified); if (def->spell) { @@ -195,9 +196,11 @@ struct Handler_CclsMemberHierarchy GetLsLocation(db, working_files, *def->spell)) entry.location = *loc; } - EachDefinedVar(db, def->vars, [&](QueryVar &var) { - DoField(this, &entry, var, -1, qualified, levels - 1); - }); + for (Usr usr : def->vars) { + auto &var = db->Var(usr); + if (var.def.size()) + DoField(this, &entry, var, -1, qualified, levels - 1); + } return entry; } case SymbolKind::Type: { @@ -205,7 +208,7 @@ struct Handler_CclsMemberHierarchy if (!def) return {}; - Out_CclsMemberHierarchy::Entry entry; + Out_CclsMember::Entry entry; entry.id = std::to_string(root_usr); entry.usr = root_usr; if (def->spell) { @@ -219,9 +222,9 @@ struct Handler_CclsMemberHierarchy } } - void Run(In_CclsMemberHierarchy *request) override { + void Run(In_CclsMember *request) override { auto ¶ms = request->params; - Out_CclsMemberHierarchy out; + Out_CclsMember out; out.id = request->id; if (params.id.size()) { @@ -230,7 +233,7 @@ struct Handler_CclsMemberHierarchy } catch (...) { return; } - Out_CclsMemberHierarchy::Entry entry; + Out_CclsMember::Entry entry; entry.id = std::to_string(params.usr); entry.usr = params.usr; // entry.name is empty as it is known by the client. @@ -265,31 +268,17 @@ struct Handler_CclsMemberHierarchy } } - if (!params.flat) { + if (params.hierarchy) { pipeline::WriteStdout(kMethodType, out); return; } Out_LocationList out1; out1.id = request->id; - if (out.result) { - std::queue q; - for (auto &entry1 : out.result->children) - q.push(&entry1); - while (q.size()) { - auto *entry = q.front(); - q.pop(); - if (entry->location.uri.raw_uri.size()) - out1.result.push_back({entry->location}); - for (auto &entry1 : entry->children) - q.push(&entry1); - } - std::sort(out1.result.begin(), out1.result.end()); - out1.result.erase(std::unique(out1.result.begin(), out1.result.end()), - out1.result.end()); - } + if (out.result) + FlattenHierarchy(*out.result, out1); pipeline::WriteStdout(kMethodType, out1); } }; -REGISTER_MESSAGE_HANDLER(Handler_CclsMemberHierarchy); +REGISTER_MESSAGE_HANDLER(Handler_CclsMember); } // namespace diff --git a/src/query_utils.cc b/src/query_utils.cc index bacffa11..85f61e80 100644 --- a/src/query_utils.cc +++ b/src/query_utils.cc @@ -155,18 +155,6 @@ std::vector GetUsesForAllDerived(DB *db, QueryFunc &root) { return ret; } -std::optional GetLsPosition(WorkingFile *wfile, - const Position &position) { - if (!wfile || wfile->index_lines.empty()) - return lsPosition{position.line, position.column}; - - int column = position.column; - if (std::optional start = - wfile->GetBufferPosFromIndexPos(position.line, &column, false)) - return lsPosition{*start, column}; - return std::nullopt; -} - std::optional GetLsRange(WorkingFile *wfile, const Range &location) { if (!wfile || wfile->index_lines.empty()) diff --git a/src/query_utils.h b/src/query_utils.h index 6bf0a70a..c5e325c0 100644 --- a/src/query_utils.h +++ b/src/query_utils.h @@ -22,8 +22,6 @@ std::vector GetNonDefDeclarations(DB *db, SymbolIdx sym); std::vector GetUsesForAllBases(DB *db, QueryFunc &root); std::vector GetUsesForAllDerived(DB *db, QueryFunc &root); -std::optional GetLsPosition(WorkingFile *working_file, - const Position &position); std::optional GetLsRange(WorkingFile *working_file, const Range &location); lsDocumentUri GetLsDocumentUri(DB *db, int file_id, std::string *path); @@ -93,21 +91,3 @@ void EachDefinedFunc(DB *db, const std::vector &usrs, Fn &&fn) { fn(obj); } } - -template -void EachDefinedType(DB *db, const std::vector &usrs, Fn &&fn) { - for (Usr usr : usrs) { - auto &obj = db->Type(usr); - if (!obj.def.empty()) - fn(obj); - } -} - -template -void EachDefinedVar(DB *db, const std::vector &usrs, Fn &&fn) { - for (Usr usr : usrs) { - auto &obj = db->Var(usr); - if (!obj.def.empty()) - fn(obj); - } -}