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
@ -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"
|
||||||
|
@ -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();
|
||||||
|
@ -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,
|
||||||
|
@ -19,8 +19,10 @@ void DiagnosticsEngine::Publish(WorkingFiles* working_files,
|
|||||||
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;
|
||||||
|
@ -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,14 +27,14 @@ 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)
|
||||||
|
@ -27,14 +27,14 @@ 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);
|
||||||
|
@ -235,8 +235,8 @@ struct CqueryMemberHierarchyHandler
|
|||||||
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)
|
||||||
out.result = BuildInitial(QueryTypeId(*def->type), params.detailedName,
|
out.result = BuildInitial(QueryTypeId(*def->type),
|
||||||
params.levels);
|
params.detailedName, params.levels);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -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,8 +166,8 @@ 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"
|
||||||
@ -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;
|
||||||
|
@ -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 &&
|
||||||
|
@ -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
|
||||||
|
@ -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,
|
||||||
|
@ -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