mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-29 11:01:57 +00:00
Reformat
This commit is contained in:
parent
af3c09d00d
commit
db7e25c542
@ -94,7 +94,7 @@ lsCompletionItemKind GetCompletionKind(CXCursorKind cursor_kind) {
|
|||||||
return lsCompletionItemKind::Method;
|
return lsCompletionItemKind::Method;
|
||||||
|
|
||||||
case CXCursor_FunctionTemplate:
|
case CXCursor_FunctionTemplate:
|
||||||
return lsCompletionItemKind::Function;
|
return lsCompletionItemKind::Function;
|
||||||
|
|
||||||
case CXCursor_Constructor:
|
case CXCursor_Constructor:
|
||||||
case CXCursor_Destructor:
|
case CXCursor_Destructor:
|
||||||
@ -186,7 +186,7 @@ void BuildCompletionItemTexts(std::vector<lsCompletionItem>& out,
|
|||||||
case CXCompletionChunk_Equal: text = '='; break;
|
case CXCompletionChunk_Equal: text = '='; break;
|
||||||
case CXCompletionChunk_HorizontalSpace: text = ' '; break;
|
case CXCompletionChunk_HorizontalSpace: text = ' '; break;
|
||||||
case CXCompletionChunk_VerticalSpace: text = ' '; break;
|
case CXCompletionChunk_VerticalSpace: text = ' '; break;
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
case CXCompletionChunk_ResultType:
|
case CXCompletionChunk_ResultType:
|
||||||
result_type =
|
result_type =
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
#include "clang_index.h"
|
#include "clang_index.h"
|
||||||
#include "clang_translation_unit.h"
|
#include "clang_translation_unit.h"
|
||||||
|
#include "lru_cache.h"
|
||||||
#include "lsp_completion.h"
|
#include "lsp_completion.h"
|
||||||
#include "lsp_diagnostic.h"
|
#include "lsp_diagnostic.h"
|
||||||
#include "lru_cache.h"
|
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "threaded_queue.h"
|
#include "threaded_queue.h"
|
||||||
#include "working_files.h"
|
#include "working_files.h"
|
||||||
|
@ -29,7 +29,7 @@ class ClangType {
|
|||||||
// NOTE: This will return false for pointed types. Should we call
|
// NOTE: This will return false for pointed types. Should we call
|
||||||
// strip_qualifiers for the user?
|
// strip_qualifiers for the user?
|
||||||
return cx_type.kind >= CXType_FirstBuiltin &&
|
return cx_type.kind >= CXType_FirstBuiltin &&
|
||||||
cx_type.kind <= CXType_LastBuiltin;
|
cx_type.kind <= CXType_LastBuiltin;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClangCursor get_declaration() const;
|
ClangCursor get_declaration() const;
|
||||||
|
@ -493,16 +493,16 @@ Use SetUse(IndexFile* db, Range range, ClangCursor parent, Role role) {
|
|||||||
|
|
||||||
const char* GetAnonName(CXCursorKind kind) {
|
const char* GetAnonName(CXCursorKind kind) {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case CXCursor_ClassDecl:
|
case CXCursor_ClassDecl:
|
||||||
return "(anon class)";
|
return "(anon class)";
|
||||||
case CXCursor_EnumDecl:
|
case CXCursor_EnumDecl:
|
||||||
return "(anon enum)";
|
return "(anon enum)";
|
||||||
case CXCursor_StructDecl:
|
case CXCursor_StructDecl:
|
||||||
return "(anon struct)";
|
return "(anon struct)";
|
||||||
case CXCursor_UnionDecl:
|
case CXCursor_UnionDecl:
|
||||||
return "(anon union)";
|
return "(anon union)";
|
||||||
default:
|
default:
|
||||||
return "(anon)";
|
return "(anon)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -779,7 +779,7 @@ void Uniquify(std::vector<Use>& uses) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIXME Reference: set id in call sites and remove this
|
// FIXME Reference: set id in call sites and remove this
|
||||||
//void AddUse(std::vector<Use>& values, Range value) {
|
// void AddUse(std::vector<Use>& values, Range value) {
|
||||||
// values.push_back(
|
// values.push_back(
|
||||||
// Use(value, Id<void>(), SymbolKind::File, Role::Reference, {}));
|
// Use(value, Id<void>(), SymbolKind::File, Role::Reference, {}));
|
||||||
//}
|
//}
|
||||||
@ -1811,8 +1811,8 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
|||||||
// TODO: For type section, verify if this ever runs for non definitions?
|
// TODO: For type section, verify if this ever runs for non definitions?
|
||||||
// if (!decl->isRedeclaration) {
|
// if (!decl->isRedeclaration) {
|
||||||
|
|
||||||
SetTypeName(type, cursor, decl->semanticContainer,
|
SetTypeName(type, cursor, decl->semanticContainer, decl->entityInfo->name,
|
||||||
decl->entityInfo->name, param);
|
param);
|
||||||
type->def.kind = GetSymbolKind(decl->entityInfo->kind);
|
type->def.kind = GetSymbolKind(decl->entityInfo->kind);
|
||||||
if (param->config->index.comments)
|
if (param->config->index.comments)
|
||||||
type->def.comments = cursor.get_comments();
|
type->def.comments = cursor.get_comments();
|
||||||
|
@ -177,7 +177,7 @@ const char* ClangBuiltinTypeName(CXTypeKind kind) {
|
|||||||
#endif
|
#endif
|
||||||
case CXType_NullPtr: return "nullptr";
|
case CXType_NullPtr: return "nullptr";
|
||||||
default: return "";
|
default: return "";
|
||||||
// clang-format on
|
// clang-format on
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
#include "import_pipeline.h"
|
#include "import_pipeline.h"
|
||||||
#include "include_complete.h"
|
#include "include_complete.h"
|
||||||
#include "indexer.h"
|
#include "indexer.h"
|
||||||
#include "lsp_diagnostic.h"
|
|
||||||
#include "lex_utils.h"
|
#include "lex_utils.h"
|
||||||
#include "lru_cache.h"
|
#include "lru_cache.h"
|
||||||
|
#include "lsp_diagnostic.h"
|
||||||
#include "match.h"
|
#include "match.h"
|
||||||
#include "message_handler.h"
|
#include "message_handler.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
@ -196,7 +196,8 @@ void RunQueryDbThread(const std::string& bin_name,
|
|||||||
Out_Error out;
|
Out_Error out;
|
||||||
out.id = id;
|
out.id = id;
|
||||||
out.error.code = lsErrorCodes::InternalError;
|
out.error.code = lsErrorCodes::InternalError;
|
||||||
out.error.message = "Dropping completion request; a newer request "
|
out.error.message =
|
||||||
|
"Dropping completion request; a newer request "
|
||||||
"has come in that will be serviced instead.";
|
"has come in that will be serviced instead.";
|
||||||
QueueManager::WriteStdout(IpcId::Unknown, out);
|
QueueManager::WriteStdout(IpcId::Unknown, out);
|
||||||
}
|
}
|
||||||
|
@ -238,9 +238,7 @@ MAKE_REFLECT_STRUCT(Config::Diagnostics,
|
|||||||
frequencyMs,
|
frequencyMs,
|
||||||
onParse,
|
onParse,
|
||||||
whitelist)
|
whitelist)
|
||||||
MAKE_REFLECT_STRUCT(Config::Highlight,
|
MAKE_REFLECT_STRUCT(Config::Highlight, blacklist, whitelist)
|
||||||
blacklist,
|
|
||||||
whitelist)
|
|
||||||
MAKE_REFLECT_STRUCT(Config::Index,
|
MAKE_REFLECT_STRUCT(Config::Index,
|
||||||
attributeMakeCallsToCtor,
|
attributeMakeCallsToCtor,
|
||||||
blacklist,
|
blacklist,
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
void DiagnosticsEngine::Init(Config* config) {
|
void DiagnosticsEngine::Init(Config* config) {
|
||||||
frequencyMs_ = config->diagnostics.frequencyMs;
|
frequencyMs_ = config->diagnostics.frequencyMs;
|
||||||
match_ = std::make_unique<GroupMatch>(config->diagnostics.whitelist,
|
match_ = std::make_unique<GroupMatch>(config->diagnostics.whitelist,
|
||||||
config->diagnostics.blacklist);
|
config->diagnostics.blacklist);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiagnosticsEngine::Publish(WorkingFiles* working_files,
|
void DiagnosticsEngine::Publish(WorkingFiles* working_files,
|
||||||
@ -15,12 +15,14 @@ void DiagnosticsEngine::Publish(WorkingFiles* working_files,
|
|||||||
std::vector<lsDiagnostic> diagnostics) {
|
std::vector<lsDiagnostic> diagnostics) {
|
||||||
// Cache diagnostics so we can show fixits.
|
// Cache diagnostics so we can show fixits.
|
||||||
working_files->DoActionOnFile(path, [&](WorkingFile* working_file) {
|
working_files->DoActionOnFile(path, [&](WorkingFile* working_file) {
|
||||||
if (working_file)
|
if (working_file)
|
||||||
working_file->diagnostics_ = diagnostics;
|
working_file->diagnostics_ = diagnostics;
|
||||||
});
|
});
|
||||||
|
|
||||||
int64_t now = std::chrono::duration_cast<std::chrono::milliseconds>(
|
int64_t now =
|
||||||
std::chrono::high_resolution_clock::now().time_since_epoch()).count();
|
std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
|
std::chrono::high_resolution_clock::now().time_since_epoch())
|
||||||
|
.count();
|
||||||
if (frequencyMs_ >= 0 && (nextPublish_ <= now || diagnostics.empty()) &&
|
if (frequencyMs_ >= 0 && (nextPublish_ <= now || diagnostics.empty()) &&
|
||||||
match_->IsMatch(path)) {
|
match_->IsMatch(path)) {
|
||||||
nextPublish_ = now + frequencyMs_;
|
nextPublish_ = now + frequencyMs_;
|
||||||
|
@ -43,7 +43,7 @@ void CalculateRoles(std::string_view s, int roles[], int* class_set) {
|
|||||||
}
|
}
|
||||||
roles[s.size() - 1] = fn();
|
roles[s.size() - 1] = fn();
|
||||||
}
|
}
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
int FuzzyMatcher::MissScore(int j, bool last) {
|
int FuzzyMatcher::MissScore(int j, bool last) {
|
||||||
int s = last ? -20 : 0;
|
int s = last ? -20 : 0;
|
||||||
@ -152,7 +152,8 @@ TEST_SUITE("fuzzy_match") {
|
|||||||
Ranks("ab", {"ab", "aoo_boo", "acb"});
|
Ranks("ab", {"ab", "aoo_boo", "acb"});
|
||||||
Ranks("CC", {"CamelCase", "camelCase", "camelcase"});
|
Ranks("CC", {"CamelCase", "camelCase", "camelcase"});
|
||||||
Ranks("cC", {"camelCase", "CamelCase", "camelcase"});
|
Ranks("cC", {"camelCase", "CamelCase", "camelcase"});
|
||||||
Ranks("c c", {"camel case", "camelCase", "CamelCase", "camelcase", "camel ace"});
|
Ranks("c c",
|
||||||
|
{"camel case", "camelCase", "CamelCase", "camelcase", "camel ace"});
|
||||||
Ranks("Da.Te", {"Data.Text", "Data.Text.Lazy", "Data.Aeson.Encoding.text"});
|
Ranks("Da.Te", {"Data.Text", "Data.Text.Lazy", "Data.Aeson.Encoding.text"});
|
||||||
// prefix
|
// prefix
|
||||||
Ranks("is", {"isIEEE", "inSuf"});
|
Ranks("is", {"isIEEE", "inSuf"});
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class FuzzyMatcher {
|
class FuzzyMatcher {
|
||||||
public:
|
public:
|
||||||
constexpr static int kMaxPat = 100;
|
constexpr static int kMaxPat = 100;
|
||||||
constexpr static int kMaxText = 200;
|
constexpr static int kMaxText = 200;
|
||||||
// Negative but far from INT_MIN so that intermediate results are hard to
|
// Negative but far from INT_MIN so that intermediate results are hard to
|
||||||
@ -16,7 +16,7 @@ public:
|
|||||||
FuzzyMatcher(std::string_view pattern);
|
FuzzyMatcher(std::string_view pattern);
|
||||||
int Match(std::string_view text);
|
int Match(std::string_view text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string pat;
|
std::string pat;
|
||||||
std::string_view text;
|
std::string_view text;
|
||||||
int pat_set, text_set;
|
int pat_set, text_set;
|
||||||
|
@ -679,7 +679,7 @@ void QueryDb_DoIdMap(QueueManager* queue,
|
|||||||
|
|
||||||
auto id_map = std::make_unique<IdMap>(db, file->id_cache);
|
auto id_map = std::make_unique<IdMap>(db, file->id_cache);
|
||||||
return std::make_unique<Index_OnIdMapped::File>(std::move(file),
|
return std::make_unique<Index_OnIdMapped::File>(std::move(file),
|
||||||
std::move(id_map));
|
std::move(id_map));
|
||||||
};
|
};
|
||||||
response.current = make_map(std::move(request->current));
|
response.current = make_map(std::move(request->current));
|
||||||
response.previous = make_map(std::move(request->previous));
|
response.previous = make_map(std::move(request->previous));
|
||||||
|
@ -113,7 +113,7 @@ void IncludeComplete::Rescan() {
|
|||||||
if (!match_ && (!config_->completion.includeWhitelist.empty() ||
|
if (!match_ && (!config_->completion.includeWhitelist.empty() ||
|
||||||
!config_->completion.includeBlacklist.empty()))
|
!config_->completion.includeBlacklist.empty()))
|
||||||
match_ = std::make_unique<GroupMatch>(config_->completion.includeWhitelist,
|
match_ = std::make_unique<GroupMatch>(config_->completion.includeWhitelist,
|
||||||
config_->completion.includeBlacklist);
|
config_->completion.includeBlacklist);
|
||||||
|
|
||||||
is_scanning = true;
|
is_scanning = true;
|
||||||
WorkThread::StartThread("scan_includes", [this]() {
|
WorkThread::StartThread("scan_includes", [this]() {
|
||||||
@ -140,7 +140,8 @@ void IncludeComplete::InsertCompletionItem(const std::string& absolute_path,
|
|||||||
auto it = absolute_path_to_completion_item.find(absolute_path);
|
auto it = absolute_path_to_completion_item.find(absolute_path);
|
||||||
if (it == absolute_path_to_completion_item.end() ||
|
if (it == absolute_path_to_completion_item.end() ||
|
||||||
completion_items[it->second].detail.length() > item.detail.length()) {
|
completion_items[it->second].detail.length() > item.detail.length()) {
|
||||||
absolute_path_to_completion_item[absolute_path] = completion_items.size() - 1;
|
absolute_path_to_completion_item[absolute_path] =
|
||||||
|
completion_items.size() - 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
lsCompletionItem& inserted_item =
|
lsCompletionItem& inserted_item =
|
||||||
|
@ -180,10 +180,9 @@ struct TypeDefDefinitionData {
|
|||||||
|
|
||||||
bool operator==(const TypeDefDefinitionData& o) const {
|
bool operator==(const TypeDefDefinitionData& o) const {
|
||||||
return detailed_name == o.detailed_name && spell == o.spell &&
|
return detailed_name == o.detailed_name && spell == o.spell &&
|
||||||
extent == o.extent && alias_of == o.alias_of &&
|
extent == o.extent && alias_of == o.alias_of && bases == o.bases &&
|
||||||
bases == o.bases && types == o.types && funcs == o.funcs &&
|
types == o.types && funcs == o.funcs && vars == o.vars &&
|
||||||
vars == o.vars && kind == o.kind && hover == o.hover &&
|
kind == o.kind && hover == o.hover && comments == o.comments;
|
||||||
comments == o.comments;
|
|
||||||
}
|
}
|
||||||
bool operator!=(const TypeDefDefinitionData& o) const {
|
bool operator!=(const TypeDefDefinitionData& o) const {
|
||||||
return !(*this == o);
|
return !(*this == o);
|
||||||
@ -194,9 +193,7 @@ struct TypeDefDefinitionData {
|
|||||||
short_name_size);
|
short_name_size);
|
||||||
}
|
}
|
||||||
// Used by cquery_inheritance_hierarchy.cc:Expand generic lambda
|
// Used by cquery_inheritance_hierarchy.cc:Expand generic lambda
|
||||||
std::string_view DetailedName(bool) const {
|
std::string_view DetailedName(bool) const { return detailed_name; }
|
||||||
return detailed_name;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
template <typename TVisitor, typename Family>
|
template <typename TVisitor, typename Family>
|
||||||
void Reflect(TVisitor& visitor, TypeDefDefinitionData<Family>& value) {
|
void Reflect(TVisitor& visitor, TypeDefDefinitionData<Family>& value) {
|
||||||
|
@ -11,8 +11,10 @@ const char* IpcIdToString(IpcId id) {
|
|||||||
case IpcId::Exit:
|
case IpcId::Exit:
|
||||||
return "exit";
|
return "exit";
|
||||||
|
|
||||||
#define CASE(name, method) case IpcId::name: return method;
|
#define CASE(name, method) \
|
||||||
#include "methods.inc"
|
case IpcId::name: \
|
||||||
|
return method;
|
||||||
|
#include "methods.inc"
|
||||||
#undef CASE
|
#undef CASE
|
||||||
|
|
||||||
case IpcId::Unknown:
|
case IpcId::Unknown:
|
||||||
|
@ -14,7 +14,7 @@ enum class IpcId : int {
|
|||||||
Exit,
|
Exit,
|
||||||
|
|
||||||
#define CASE(x, _) x,
|
#define CASE(x, _) x,
|
||||||
#include "methods.inc"
|
#include "methods.inc"
|
||||||
#undef CASE
|
#undef CASE
|
||||||
|
|
||||||
// Internal implementation detail.
|
// Internal implementation detail.
|
||||||
|
@ -355,7 +355,8 @@ TEST_SUITE("LexWordAroundPos") {
|
|||||||
std::string content = " file:ns::_my_t5ype7 ";
|
std::string content = " file:ns::_my_t5ype7 ";
|
||||||
REQUIRE(LexIdentifierAroundPos(CharPos(content, 'f'), content) == "file");
|
REQUIRE(LexIdentifierAroundPos(CharPos(content, 'f'), content) == "file");
|
||||||
REQUIRE(LexIdentifierAroundPos(CharPos(content, 's'), content) == "ns");
|
REQUIRE(LexIdentifierAroundPos(CharPos(content, 's'), content) == "ns");
|
||||||
REQUIRE(LexIdentifierAroundPos(CharPos(content, 'y'), content) == "ns::_my_t5ype7");
|
REQUIRE(LexIdentifierAroundPos(CharPos(content, 'y'), content) ==
|
||||||
|
"ns::_my_t5ype7");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("dot, dash, colon are skipped") {
|
TEST_CASE("dot, dash, colon are skipped") {
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
#include "serializers/json.h"
|
#include "serializers/json.h"
|
||||||
|
|
||||||
#include <doctest/doctest.h>
|
#include <doctest/doctest.h>
|
||||||
#include <loguru.hpp>
|
|
||||||
#include <rapidjson/writer.h>
|
#include <rapidjson/writer.h>
|
||||||
|
#include <loguru.hpp>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -145,7 +145,7 @@ void EmitSemanticHighlighting(QueryDatabase* db,
|
|||||||
if (def->spell)
|
if (def->spell)
|
||||||
parent_kind = GetSymbolKind(db, *def->spell);
|
parent_kind = GetSymbolKind(db, *def->spell);
|
||||||
if (parent_kind == lsSymbolKind::Unknown) {
|
if (parent_kind == lsSymbolKind::Unknown) {
|
||||||
for (Use use: func.declarations) {
|
for (Use use : func.declarations) {
|
||||||
parent_kind = GetSymbolKind(db, use);
|
parent_kind = GetSymbolKind(db, use);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -27,15 +27,15 @@ struct CqueryBaseHandler : BaseMessageHandler<Ipc_CqueryBase> {
|
|||||||
FindSymbolsAtLocation(working_file, file, request->params.position)) {
|
FindSymbolsAtLocation(working_file, file, request->params.position)) {
|
||||||
if (sym.kind == SymbolKind::Type) {
|
if (sym.kind == SymbolKind::Type) {
|
||||||
if (const auto* def = db->GetType(sym).AnyDef())
|
if (const auto* def = db->GetType(sym).AnyDef())
|
||||||
out.result =
|
out.result = GetLsLocationExs(
|
||||||
GetLsLocationExs(db, working_files, GetDeclarations(db, def->bases),
|
db, working_files, GetDeclarations(db, def->bases),
|
||||||
config->xref.container, config->xref.maxNum);
|
config->xref.container, config->xref.maxNum);
|
||||||
break;
|
break;
|
||||||
} else if (sym.kind == SymbolKind::Func) {
|
} else if (sym.kind == SymbolKind::Func) {
|
||||||
if (const auto* def = db->GetFunc(sym).AnyDef())
|
if (const auto* def = db->GetFunc(sym).AnyDef())
|
||||||
out.result =
|
out.result = GetLsLocationExs(
|
||||||
GetLsLocationExs(db, working_files, GetDeclarations(db, def->bases),
|
db, working_files, GetDeclarations(db, def->bases),
|
||||||
config->xref.container, config->xref.maxNum);
|
config->xref.container, config->xref.maxNum);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,12 @@
|
|||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
enum class CallType : uint8_t { Direct = 0, Base = 1, Derived = 2, All = 1 | 2 };
|
enum class CallType : uint8_t {
|
||||||
|
Direct = 0,
|
||||||
|
Base = 1,
|
||||||
|
Derived = 2,
|
||||||
|
All = 1 | 2
|
||||||
|
};
|
||||||
MAKE_REFLECT_TYPE_PROXY(CallType);
|
MAKE_REFLECT_TYPE_PROXY(CallType);
|
||||||
|
|
||||||
bool operator&(CallType lhs, CallType rhs) {
|
bool operator&(CallType lhs, CallType rhs) {
|
||||||
@ -96,7 +101,8 @@ bool Expand(MessageHandler* m,
|
|||||||
if (const auto* def = func.AnyDef())
|
if (const auto* def = func.AnyDef())
|
||||||
for (SymbolRef ref : def->callees)
|
for (SymbolRef ref : def->callees)
|
||||||
if (ref.kind == SymbolKind::Func)
|
if (ref.kind == SymbolKind::Func)
|
||||||
handle(Use(ref.range, ref.id, ref.kind, ref.role, def->file), call_type);
|
handle(Use(ref.range, ref.id, ref.kind, ref.role, def->file),
|
||||||
|
call_type);
|
||||||
} else {
|
} else {
|
||||||
for (Use use : func.uses)
|
for (Use use : func.uses)
|
||||||
if (use.kind == SymbolKind::Func)
|
if (use.kind == SymbolKind::Func)
|
||||||
@ -165,7 +171,7 @@ struct CqueryCallHierarchyHandler
|
|||||||
entry.callType = CallType::Direct;
|
entry.callType = CallType::Direct;
|
||||||
if (def->spell) {
|
if (def->spell) {
|
||||||
if (optional<lsLocation> loc =
|
if (optional<lsLocation> loc =
|
||||||
GetLsLocation(db, working_files, *def->spell))
|
GetLsLocation(db, working_files, *def->spell))
|
||||||
entry.location = *loc;
|
entry.location = *loc;
|
||||||
}
|
}
|
||||||
Expand(this, &entry, callee, call_type, detailed_name, levels);
|
Expand(this, &entry, callee, call_type, detailed_name, levels);
|
||||||
@ -193,11 +199,11 @@ struct CqueryCallHierarchyHandler
|
|||||||
WorkingFile* working_file =
|
WorkingFile* working_file =
|
||||||
working_files->GetFileByFilename(file->def->path);
|
working_files->GetFileByFilename(file->def->path);
|
||||||
for (SymbolRef sym :
|
for (SymbolRef sym :
|
||||||
FindSymbolsAtLocation(working_file, file, params.position)) {
|
FindSymbolsAtLocation(working_file, file, params.position)) {
|
||||||
if (sym.kind == SymbolKind::Func) {
|
if (sym.kind == SymbolKind::Func) {
|
||||||
out.result =
|
out.result =
|
||||||
BuildInitial(QueryFuncId(sym.id), params.callee, params.callType,
|
BuildInitial(QueryFuncId(sym.id), params.callee, params.callType,
|
||||||
params.detailedName, params.levels);
|
params.detailedName, params.levels);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,15 +27,15 @@ struct CqueryDerivedHandler : BaseMessageHandler<Ipc_CqueryDerived> {
|
|||||||
FindSymbolsAtLocation(working_file, file, request->params.position)) {
|
FindSymbolsAtLocation(working_file, file, request->params.position)) {
|
||||||
if (sym.kind == SymbolKind::Type) {
|
if (sym.kind == SymbolKind::Type) {
|
||||||
QueryType& type = db->GetType(sym);
|
QueryType& type = db->GetType(sym);
|
||||||
out.result =
|
out.result = GetLsLocationExs(
|
||||||
GetLsLocationExs(db, working_files, GetDeclarations(db, type.derived),
|
db, working_files, GetDeclarations(db, type.derived),
|
||||||
config->xref.container, config->xref.maxNum);
|
config->xref.container, config->xref.maxNum);
|
||||||
break;
|
break;
|
||||||
} else if (sym.kind == SymbolKind::Func) {
|
} else if (sym.kind == SymbolKind::Func) {
|
||||||
QueryFunc& func = db->GetFunc(sym);
|
QueryFunc& func = db->GetFunc(sym);
|
||||||
out.result =
|
out.result = GetLsLocationExs(
|
||||||
GetLsLocationExs(db, working_files, GetDeclarations(db, func.derived),
|
db, working_files, GetDeclarations(db, func.derived),
|
||||||
config->xref.container, config->xref.maxNum);
|
config->xref.container, config->xref.maxNum);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,8 @@ struct Ipc_CqueryInheritanceHierarchy
|
|||||||
: public RequestMessage<Ipc_CqueryInheritanceHierarchy> {
|
: public RequestMessage<Ipc_CqueryInheritanceHierarchy> {
|
||||||
const static IpcId kIpcId = IpcId::CqueryInheritanceHierarchy;
|
const static IpcId kIpcId = IpcId::CqueryInheritanceHierarchy;
|
||||||
struct Params {
|
struct Params {
|
||||||
// If id+kind are specified, expand a node; otherwise textDocument+position should
|
// If id+kind are specified, expand a node; otherwise textDocument+position
|
||||||
// be specified for building the root and |levels| of nodes below.
|
// should be specified for building the root and |levels| of nodes below.
|
||||||
lsTextDocumentIdentifier textDocument;
|
lsTextDocumentIdentifier textDocument;
|
||||||
lsPosition position;
|
lsPosition position;
|
||||||
|
|
||||||
@ -161,8 +161,8 @@ struct CqueryInheritanceHierarchyHandler
|
|||||||
WorkingFile* working_file =
|
WorkingFile* working_file =
|
||||||
working_files->GetFileByFilename(file->def->path);
|
working_files->GetFileByFilename(file->def->path);
|
||||||
|
|
||||||
for (SymbolRef sym :
|
for (SymbolRef sym : FindSymbolsAtLocation(working_file, file,
|
||||||
FindSymbolsAtLocation(working_file, file, request->params.position)) {
|
request->params.position)) {
|
||||||
if (sym.kind == SymbolKind::Func || sym.kind == SymbolKind::Type) {
|
if (sym.kind == SymbolKind::Func || sym.kind == SymbolKind::Type) {
|
||||||
out.result = BuildInitial(sym, params.derived, params.detailedName,
|
out.result = BuildInitial(sym, params.derived, params.detailedName,
|
||||||
params.levels);
|
params.levels);
|
||||||
|
@ -75,7 +75,7 @@ void DoField(MessageHandler* m,
|
|||||||
entry1.fieldName = std::string(def1->ShortName());
|
entry1.fieldName = std::string(def1->ShortName());
|
||||||
if (def1->spell) {
|
if (def1->spell) {
|
||||||
if (optional<lsLocation> loc =
|
if (optional<lsLocation> loc =
|
||||||
GetLsLocation(m->db, m->working_files, *def1->spell))
|
GetLsLocation(m->db, m->working_files, *def1->spell))
|
||||||
entry1.location = *loc;
|
entry1.location = *loc;
|
||||||
}
|
}
|
||||||
if (def1->type) {
|
if (def1->type) {
|
||||||
@ -128,7 +128,7 @@ bool Expand(MessageHandler* m,
|
|||||||
if (def1 && def1->spell) {
|
if (def1 && def1->spell) {
|
||||||
// The declaration of target type.
|
// The declaration of target type.
|
||||||
if (optional<lsLocation> loc =
|
if (optional<lsLocation> loc =
|
||||||
GetLsLocation(m->db, m->working_files, *def1->spell))
|
GetLsLocation(m->db, m->working_files, *def1->spell))
|
||||||
entry1.location = *loc;
|
entry1.location = *loc;
|
||||||
} else if (def->spell) {
|
} else if (def->spell) {
|
||||||
// Builtin types have no declaration but the typedef declaration
|
// Builtin types have no declaration but the typedef declaration
|
||||||
@ -175,7 +175,7 @@ struct CqueryMemberHierarchyHandler
|
|||||||
entry.name = std::string(def->ShortName());
|
entry.name = std::string(def->ShortName());
|
||||||
if (def->spell) {
|
if (def->spell) {
|
||||||
if (optional<lsLocation> loc =
|
if (optional<lsLocation> loc =
|
||||||
GetLsLocation(db, working_files, *def->spell))
|
GetLsLocation(db, working_files, *def->spell))
|
||||||
entry.location = *loc;
|
entry.location = *loc;
|
||||||
}
|
}
|
||||||
EachDefinedEntity(db->vars, def->vars, [&](QueryVar& var) {
|
EachDefinedEntity(db->vars, def->vars, [&](QueryVar& var) {
|
||||||
@ -195,7 +195,7 @@ struct CqueryMemberHierarchyHandler
|
|||||||
entry.id = root_id;
|
entry.id = root_id;
|
||||||
if (def->spell) {
|
if (def->spell) {
|
||||||
if (optional<lsLocation> loc =
|
if (optional<lsLocation> loc =
|
||||||
GetLsLocation(db, working_files, *def->spell))
|
GetLsLocation(db, working_files, *def->spell))
|
||||||
entry.location = *loc;
|
entry.location = *loc;
|
||||||
}
|
}
|
||||||
Expand(this, &entry, detailed_name, levels);
|
Expand(this, &entry, detailed_name, levels);
|
||||||
@ -220,27 +220,27 @@ struct CqueryMemberHierarchyHandler
|
|||||||
params.textDocument.uri.GetPath(), &file))
|
params.textDocument.uri.GetPath(), &file))
|
||||||
return;
|
return;
|
||||||
WorkingFile* working_file =
|
WorkingFile* working_file =
|
||||||
working_files->GetFileByFilename(file->def->path);
|
working_files->GetFileByFilename(file->def->path);
|
||||||
for (SymbolRef sym :
|
for (SymbolRef sym :
|
||||||
FindSymbolsAtLocation(working_file, file, params.position)) {
|
FindSymbolsAtLocation(working_file, file, params.position)) {
|
||||||
switch (sym.kind) {
|
switch (sym.kind) {
|
||||||
case SymbolKind::Func:
|
case SymbolKind::Func:
|
||||||
out.result = BuildInitial(QueryFuncId(sym.id), params.detailedName,
|
out.result = BuildInitial(QueryFuncId(sym.id), params.detailedName,
|
||||||
params.levels);
|
|
||||||
break;
|
|
||||||
case SymbolKind::Type:
|
|
||||||
out.result = BuildInitial(QueryTypeId(sym.id), params.detailedName,
|
|
||||||
params.levels);
|
|
||||||
break;
|
|
||||||
case SymbolKind::Var: {
|
|
||||||
const QueryVar::Def* def = db->GetVar(sym).AnyDef();
|
|
||||||
if (def && def->type)
|
|
||||||
out.result = BuildInitial(QueryTypeId(*def->type), params.detailedName,
|
|
||||||
params.levels);
|
params.levels);
|
||||||
break;
|
break;
|
||||||
}
|
case SymbolKind::Type:
|
||||||
default:
|
out.result = BuildInitial(QueryTypeId(sym.id), params.detailedName,
|
||||||
continue;
|
params.levels);
|
||||||
|
break;
|
||||||
|
case SymbolKind::Var: {
|
||||||
|
const QueryVar::Def* def = db->GetVar(sym).AnyDef();
|
||||||
|
if (def && def->type)
|
||||||
|
out.result = BuildInitial(QueryTypeId(*def->type),
|
||||||
|
params.detailedName, params.levels);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -441,8 +441,8 @@ struct TextDocumentCodeActionHandler
|
|||||||
// For error diagnostics, provide an action to resolve an include.
|
// For error diagnostics, provide an action to resolve an include.
|
||||||
// TODO: find a way to index diagnostic contents so line numbers
|
// TODO: find a way to index diagnostic contents so line numbers
|
||||||
// don't get mismatched when actively editing a file.
|
// don't get mismatched when actively editing a file.
|
||||||
std::string_view include_query =
|
std::string_view include_query = LexIdentifierAroundPos(
|
||||||
LexIdentifierAroundPos(diag.range.start, working_file->buffer_content);
|
diag.range.start, working_file->buffer_content);
|
||||||
if (diag.severity == lsDiagnosticSeverity::Error &&
|
if (diag.severity == lsDiagnosticSeverity::Error &&
|
||||||
!include_query.empty()) {
|
!include_query.empty()) {
|
||||||
const size_t kMaxResults = 20;
|
const size_t kMaxResults = 20;
|
||||||
|
@ -118,9 +118,11 @@ struct TextDocumentCodeLensHandler
|
|||||||
AddCodeLens("ref", "refs", &common, OffsetStartColumn(use, 0),
|
AddCodeLens("ref", "refs", &common, OffsetStartColumn(use, 0),
|
||||||
type.uses, true /*force_display*/);
|
type.uses, true /*force_display*/);
|
||||||
AddCodeLens("derived", "derived", &common, OffsetStartColumn(use, 1),
|
AddCodeLens("derived", "derived", &common, OffsetStartColumn(use, 1),
|
||||||
GetDeclarations(db, type.derived), false /*force_display*/);
|
GetDeclarations(db, type.derived),
|
||||||
|
false /*force_display*/);
|
||||||
AddCodeLens("var", "vars", &common, OffsetStartColumn(use, 2),
|
AddCodeLens("var", "vars", &common, OffsetStartColumn(use, 2),
|
||||||
GetDeclarations(db, type.instances), false /*force_display*/);
|
GetDeclarations(db, type.instances),
|
||||||
|
false /*force_display*/);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SymbolKind::Func: {
|
case SymbolKind::Func: {
|
||||||
@ -164,9 +166,9 @@ struct TextDocumentCodeLensHandler
|
|||||||
false /*force_display*/);
|
false /*force_display*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddCodeLens("derived", "derived", &common,
|
AddCodeLens(
|
||||||
OffsetStartColumn(use, offset++),
|
"derived", "derived", &common, OffsetStartColumn(use, offset++),
|
||||||
GetDeclarations(db, func.derived), false /*force_display*/);
|
GetDeclarations(db, func.derived), false /*force_display*/);
|
||||||
|
|
||||||
// "Base"
|
// "Base"
|
||||||
if (def->bases.size() == 1) {
|
if (def->bases.size() == 1) {
|
||||||
@ -193,7 +195,8 @@ struct TextDocumentCodeLensHandler
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
AddCodeLens("base", "base", &common, OffsetStartColumn(use, 1),
|
AddCodeLens("base", "base", &common, OffsetStartColumn(use, 1),
|
||||||
GetDeclarations(db, def->bases), false /*force_display*/);
|
GetDeclarations(db, def->bases),
|
||||||
|
false /*force_display*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -197,10 +197,10 @@ void FilterAndSortCompletionResponse(
|
|||||||
: FuzzyMatcher::kMinScore;
|
: FuzzyMatcher::kMinScore;
|
||||||
}
|
}
|
||||||
items.erase(std::remove_if(items.begin(), items.end(),
|
items.erase(std::remove_if(items.begin(), items.end(),
|
||||||
[](const lsCompletionItem& item) {
|
[](const lsCompletionItem& item) {
|
||||||
return item.score_ <= FuzzyMatcher::kMinScore;
|
return item.score_ <= FuzzyMatcher::kMinScore;
|
||||||
}),
|
}),
|
||||||
items.end());
|
items.end());
|
||||||
std::sort(items.begin(), items.end(),
|
std::sort(items.begin(), items.end(),
|
||||||
[](const lsCompletionItem& lhs, const lsCompletionItem& rhs) {
|
[](const lsCompletionItem& lhs, const lsCompletionItem& rhs) {
|
||||||
if (lhs.score_ != rhs.score_)
|
if (lhs.score_ != rhs.score_)
|
||||||
@ -300,7 +300,7 @@ struct TextDocumentCompletionHandler : MessageHandler {
|
|||||||
|
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(
|
std::unique_lock<std::mutex> lock(
|
||||||
include_complete->completion_items_mutex, std::defer_lock);
|
include_complete->completion_items_mutex, std::defer_lock);
|
||||||
if (include_complete->is_scanning)
|
if (include_complete->is_scanning)
|
||||||
lock.lock();
|
lock.lock();
|
||||||
std::string quote = result.match[5];
|
std::string quote = result.match[5];
|
||||||
@ -314,7 +314,7 @@ struct TextDocumentCompletionHandler : MessageHandler {
|
|||||||
item.filterText = item.label;
|
item.filterText = item.label;
|
||||||
|
|
||||||
FilterAndSortCompletionResponse(&out, result.pattern,
|
FilterAndSortCompletionResponse(&out, result.pattern,
|
||||||
config->completion.filterAndSort);
|
config->completion.filterAndSort);
|
||||||
DecorateIncludePaths(result.match, &out.result.items);
|
DecorateIncludePaths(result.match, &out.result.items);
|
||||||
|
|
||||||
for (lsCompletionItem& item : out.result.items) {
|
for (lsCompletionItem& item : out.result.items) {
|
||||||
|
@ -156,8 +156,7 @@ struct TextDocumentDefinitionHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (best_i != -1) {
|
if (best_i != -1) {
|
||||||
Maybe<Use> use =
|
Maybe<Use> use = GetDefinitionSpell(db, db->symbols[best_i]);
|
||||||
GetDefinitionSpell(db, db->symbols[best_i]);
|
|
||||||
assert(use);
|
assert(use);
|
||||||
if (auto ls_loc = GetLsLocationEx(db, working_files, *use,
|
if (auto ls_loc = GetLsLocationEx(db, working_files, *use,
|
||||||
config->xref.container))
|
config->xref.container))
|
||||||
|
@ -45,7 +45,8 @@ struct TextDocumentDocumentSymbolHandler
|
|||||||
if (sym.kind == SymbolKind::Var) {
|
if (sym.kind == SymbolKind::Var) {
|
||||||
QueryVar& var = db->GetVar(sym);
|
QueryVar& var = db->GetVar(sym);
|
||||||
auto* def = var.AnyDef();
|
auto* def = var.AnyDef();
|
||||||
if (!def || !def->spell) continue;
|
if (!def || !def->spell)
|
||||||
|
continue;
|
||||||
// Ignore local variables.
|
// Ignore local variables.
|
||||||
if (def->spell->kind == SymbolKind::Func &&
|
if (def->spell->kind == SymbolKind::Func &&
|
||||||
def->storage != StorageClass::Static &&
|
def->storage != StorageClass::Static &&
|
||||||
|
@ -22,21 +22,21 @@ MAKE_REFLECT_STRUCT(Out_TextDocumentTypeDefinition, jsonrpc, id, result);
|
|||||||
struct TextDocumentTypeDefinitionHandler
|
struct TextDocumentTypeDefinitionHandler
|
||||||
: BaseMessageHandler<Ipc_TextDocumentTypeDefinition> {
|
: BaseMessageHandler<Ipc_TextDocumentTypeDefinition> {
|
||||||
void Run(Ipc_TextDocumentTypeDefinition* request) override {
|
void Run(Ipc_TextDocumentTypeDefinition* request) override {
|
||||||
QueryFile* file;
|
QueryFile* file;
|
||||||
if (!FindFileOrFail(db, project, request->id,
|
if (!FindFileOrFail(db, project, request->id,
|
||||||
request->params.textDocument.uri.GetPath(), &file,
|
request->params.textDocument.uri.GetPath(), &file,
|
||||||
nullptr)) {
|
nullptr)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WorkingFile* working_file =
|
WorkingFile* working_file =
|
||||||
working_files->GetFileByFilename(file->def->path);
|
working_files->GetFileByFilename(file->def->path);
|
||||||
|
|
||||||
Out_TextDocumentTypeDefinition out;
|
Out_TextDocumentTypeDefinition out;
|
||||||
out.id = request->id;
|
out.id = request->id;
|
||||||
for (SymbolRef sym :
|
for (SymbolRef sym :
|
||||||
FindSymbolsAtLocation(working_file, file, request->params.position)) {
|
FindSymbolsAtLocation(working_file, file, request->params.position)) {
|
||||||
Id<void> id = sym.id;
|
Id<void> id = sym.id;
|
||||||
switch (sym.kind) {
|
switch (sym.kind) {
|
||||||
case SymbolKind::Var: {
|
case SymbolKind::Var: {
|
||||||
const QueryVar::Def* def = db->GetVar(sym).AnyDef();
|
const QueryVar::Def* def = db->GetVar(sym).AnyDef();
|
||||||
if (!def || !def->type)
|
if (!def || !def->type)
|
||||||
@ -56,10 +56,10 @@ struct TextDocumentTypeDefinitionHandler
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QueueManager::WriteStdout(IpcId::TextDocumentTypeDefinition, out);
|
QueueManager::WriteStdout(IpcId::TextDocumentTypeDefinition, out);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
REGISTER_MESSAGE_HANDLER(TextDocumentTypeDefinitionHandler);
|
REGISTER_MESSAGE_HANDLER(TextDocumentTypeDefinitionHandler);
|
||||||
|
@ -25,11 +25,11 @@ struct WorkspaceDidChangeConfigurationHandler
|
|||||||
Timer time;
|
Timer time;
|
||||||
project->Load(config, config->projectRoot);
|
project->Load(config, config->projectRoot);
|
||||||
time.ResetAndPrint("[perf] Loaded compilation entries (" +
|
time.ResetAndPrint("[perf] Loaded compilation entries (" +
|
||||||
std::to_string(project->entries.size()) + " files)");
|
std::to_string(project->entries.size()) + " files)");
|
||||||
|
|
||||||
time.Reset();
|
time.Reset();
|
||||||
project->Index(config, QueueManager::instance(), working_files,
|
project->Index(config, QueueManager::instance(), working_files,
|
||||||
std::monostate());
|
std::monostate());
|
||||||
time.ResetAndPrint(
|
time.ResetAndPrint(
|
||||||
"[perf] Dispatched workspace/didChangeConfiguration index requests");
|
"[perf] Dispatched workspace/didChangeConfiguration index requests");
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,8 @@ struct WorkspaceSymbolHandler : BaseMessageHandler<Ipc_WorkspaceSymbol> {
|
|||||||
|
|
||||||
for (int i = 0; i < (int)db->symbols.size(); ++i) {
|
for (int i = 0; i < (int)db->symbols.size(); ++i) {
|
||||||
std::string_view detailed_name = db->GetSymbolDetailedName(i);
|
std::string_view detailed_name = db->GetSymbolDetailedName(i);
|
||||||
if (CaseFoldingSubsequenceMatch(query_without_space, detailed_name).first) {
|
if (CaseFoldingSubsequenceMatch(query_without_space, detailed_name)
|
||||||
|
.first) {
|
||||||
// Do not show the same entry twice.
|
// Do not show the same entry twice.
|
||||||
if (!inserted_results.insert(std::string(detailed_name)).second)
|
if (!inserted_results.insert(std::string(detailed_name)).second)
|
||||||
continue;
|
continue;
|
||||||
|
@ -89,8 +89,7 @@ std::vector<std::string> kPathArgs = {
|
|||||||
"-I", "-iquote", "-isystem", "--sysroot=",
|
"-I", "-iquote", "-isystem", "--sysroot=",
|
||||||
"-isysroot", "-gcc-toolchain", "-include-pch", "-iframework",
|
"-isysroot", "-gcc-toolchain", "-include-pch", "-iframework",
|
||||||
"-F", "-imacros", "-include", "/I",
|
"-F", "-imacros", "-include", "/I",
|
||||||
"-idirafter"
|
"-idirafter"};
|
||||||
};
|
|
||||||
|
|
||||||
// Arguments which always require an absolute path, ie, clang -working-directory
|
// Arguments which always require an absolute path, ie, clang -working-directory
|
||||||
// does not work as expected. Argument processing assumes that this is a subset
|
// does not work as expected. Argument processing assumes that this is a subset
|
||||||
@ -431,7 +430,7 @@ std::vector<Project::Entry> LoadCompilationEntriesFromDirectory(
|
|||||||
comp_db_dir.c_str(), &cx_db_load_error);
|
comp_db_dir.c_str(), &cx_db_load_error);
|
||||||
if (!config->compilationDatabaseCommand.empty()) {
|
if (!config->compilationDatabaseCommand.empty()) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// TODO
|
// TODO
|
||||||
#else
|
#else
|
||||||
unlink((comp_db_dir + "/compile_commands.json").c_str());
|
unlink((comp_db_dir + "/compile_commands.json").c_str());
|
||||||
rmdir(comp_db_dir.c_str());
|
rmdir(comp_db_dir.c_str());
|
||||||
|
@ -38,10 +38,10 @@ struct Project {
|
|||||||
// compile_commands.json in it, otherwise they are retrieved in
|
// compile_commands.json in it, otherwise they are retrieved in
|
||||||
// |root_directory|.
|
// |root_directory|.
|
||||||
// For .cquery, recursive directory listing is used and files with known
|
// For .cquery, recursive directory listing is used and files with known
|
||||||
// suffixes are indexed. .cquery files can exist in subdirectories and they will affect
|
// suffixes are indexed. .cquery files can exist in subdirectories and they
|
||||||
// flags in their subtrees (relative paths are relative to the project root,
|
// will affect flags in their subtrees (relative paths are relative to the
|
||||||
// not subdirectories).
|
// project root, not subdirectories). For compile_commands.json, its entries
|
||||||
// For compile_commands.json, its entries are indexed.
|
// are indexed.
|
||||||
void Load(Config* config, const std::string& root_directory);
|
void Load(Config* config, const std::string& root_directory);
|
||||||
|
|
||||||
// Lookup the CompilationEntry for |filename|. If no entry was found this
|
// Lookup the CompilationEntry for |filename|. If no entry was found this
|
||||||
|
@ -100,8 +100,7 @@ std::vector<Use> GetDeclarations(QueryDatabase* db,
|
|||||||
return GetDeclarations(db->vars, ids);
|
return GetDeclarations(db->vars, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Use> GetNonDefDeclarations(QueryDatabase* db,
|
std::vector<Use> GetNonDefDeclarations(QueryDatabase* db, SymbolIdx sym) {
|
||||||
SymbolIdx sym) {
|
|
||||||
switch (sym.kind) {
|
switch (sym.kind) {
|
||||||
case SymbolKind::Func:
|
case SymbolKind::Func:
|
||||||
return db->GetFunc(sym).declarations;
|
return db->GetFunc(sym).declarations;
|
||||||
|
@ -10,10 +10,14 @@ Maybe<Use> GetDefinitionExtent(QueryDatabase* db, SymbolIdx sym);
|
|||||||
Maybe<QueryFileId> GetDeclarationFileForSymbol(QueryDatabase* db,
|
Maybe<QueryFileId> GetDeclarationFileForSymbol(QueryDatabase* db,
|
||||||
SymbolIdx sym);
|
SymbolIdx sym);
|
||||||
|
|
||||||
// Get defining declaration (if exists) or an arbitrary declaration (otherwise) for each id.
|
// Get defining declaration (if exists) or an arbitrary declaration (otherwise)
|
||||||
std::vector<Use> GetDeclarations(QueryDatabase* db, const std::vector<QueryFuncId>& ids);
|
// for each id.
|
||||||
std::vector<Use> GetDeclarations(QueryDatabase* db, const std::vector<QueryTypeId>& ids);
|
std::vector<Use> GetDeclarations(QueryDatabase* db,
|
||||||
std::vector<Use> GetDeclarations(QueryDatabase* db, const std::vector<QueryVarId>& ids);
|
const std::vector<QueryFuncId>& ids);
|
||||||
|
std::vector<Use> GetDeclarations(QueryDatabase* db,
|
||||||
|
const std::vector<QueryTypeId>& ids);
|
||||||
|
std::vector<Use> GetDeclarations(QueryDatabase* db,
|
||||||
|
const std::vector<QueryVarId>& ids);
|
||||||
|
|
||||||
// Get non-defining declarations.
|
// Get non-defining declarations.
|
||||||
std::vector<Use> GetNonDefDeclarations(QueryDatabase* db, SymbolIdx sym);
|
std::vector<Use> GetNonDefDeclarations(QueryDatabase* db, SymbolIdx sym);
|
||||||
@ -78,7 +82,10 @@ void EachEntityDef(QueryDatabase* db, SymbolIdx sym, Fn&& fn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Fn>
|
template <typename Fn>
|
||||||
void EachOccurrence(QueryDatabase* db, SymbolIdx sym, bool include_decl, Fn&& fn) {
|
void EachOccurrence(QueryDatabase* db,
|
||||||
|
SymbolIdx sym,
|
||||||
|
bool include_decl,
|
||||||
|
Fn&& fn) {
|
||||||
WithEntity(db, sym, [&](const auto& entity) {
|
WithEntity(db, sym, [&](const auto& entity) {
|
||||||
for (Use use : entity.uses)
|
for (Use use : entity.uses)
|
||||||
fn(use);
|
fn(use);
|
||||||
|
@ -81,7 +81,7 @@ struct Index_OnIndexed {
|
|||||||
class QueueManager {
|
class QueueManager {
|
||||||
static std::unique_ptr<QueueManager> instance_;
|
static std::unique_ptr<QueueManager> instance_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QueueManager* instance() { return instance_.get(); }
|
static QueueManager* instance() { return instance_.get(); }
|
||||||
static void Init(MultiQueueWaiter* querydb_waiter,
|
static void Init(MultiQueueWaiter* querydb_waiter,
|
||||||
MultiQueueWaiter* indexer_waiter,
|
MultiQueueWaiter* indexer_waiter,
|
||||||
|
@ -62,7 +62,7 @@ SemanticHighlightSymbolCache::SemanticHighlightSymbolCache()
|
|||||||
|
|
||||||
void SemanticHighlightSymbolCache::Init(Config* config) {
|
void SemanticHighlightSymbolCache::Init(Config* config) {
|
||||||
match_ = std::make_unique<GroupMatch>(config->highlight.whitelist,
|
match_ = std::make_unique<GroupMatch>(config->highlight.whitelist,
|
||||||
config->highlight.blacklist);
|
config->highlight.blacklist);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<SemanticHighlightSymbolCache::Entry>
|
std::shared_ptr<SemanticHighlightSymbolCache::Entry>
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <doctest/doctest.h>
|
#include <doctest/doctest.h>
|
||||||
#include <loguru/loguru.hpp>
|
|
||||||
#include <rapidjson/document.h>
|
#include <rapidjson/document.h>
|
||||||
#include <rapidjson/prettywriter.h>
|
#include <rapidjson/prettywriter.h>
|
||||||
#include <rapidjson/stringbuffer.h>
|
#include <rapidjson/stringbuffer.h>
|
||||||
#include <rapidjson/writer.h>
|
#include <rapidjson/writer.h>
|
||||||
|
#include <loguru/loguru.hpp>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -32,12 +32,8 @@ template <typename... Queue>
|
|||||||
struct MultiQueueLock {
|
struct MultiQueueLock {
|
||||||
MultiQueueLock(Queue... lockable) : tuple_{lockable...} { lock(); }
|
MultiQueueLock(Queue... lockable) : tuple_{lockable...} { lock(); }
|
||||||
~MultiQueueLock() { unlock(); }
|
~MultiQueueLock() { unlock(); }
|
||||||
void lock() {
|
void lock() { lock_impl(typename std::index_sequence_for<Queue...>{}); }
|
||||||
lock_impl(typename std::index_sequence_for<Queue...>{});
|
void unlock() { unlock_impl(typename std::index_sequence_for<Queue...>{}); }
|
||||||
}
|
|
||||||
void unlock() {
|
|
||||||
unlock_impl(typename std::index_sequence_for<Queue...>{});
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <size_t... Is>
|
template <size_t... Is>
|
||||||
|
Loading…
Reference in New Issue
Block a user