mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-19 03:55:49 +00:00
Work around SIGSEGV and simplify SymbolIdx
This commit is contained in:
parent
fd803ffb84
commit
aa125e34f3
@ -171,7 +171,7 @@ void EmitSemanticHighlighting(QueryDatabase* db,
|
|||||||
|
|
||||||
optional<lsRange> loc = GetLsRange(working_file, sym.range);
|
optional<lsRange> loc = GetLsRange(working_file, sym.range);
|
||||||
if (loc) {
|
if (loc) {
|
||||||
auto key = SymbolIdx(sym.kind, RawId(sym.id));
|
auto key = SymbolIdx{RawId(sym.id), sym.kind};
|
||||||
auto it = grouped_symbols.find(key);
|
auto it = grouped_symbols.find(key);
|
||||||
if (it != grouped_symbols.end()) {
|
if (it != grouped_symbols.end()) {
|
||||||
it->second.ranges.push_back(*loc);
|
it->second.ranges.push_back(*loc);
|
||||||
|
@ -1003,7 +1003,7 @@ void QueryDatabase::UpdateSymbols(Maybe<Id<void>>* symbol_idx,
|
|||||||
RawId idx) {
|
RawId idx) {
|
||||||
if (!symbol_idx->has_value()) {
|
if (!symbol_idx->has_value()) {
|
||||||
*symbol_idx = Id<void>(symbols.size());
|
*symbol_idx = Id<void>(symbols.size());
|
||||||
symbols.push_back(SymbolIdx(kind, idx));
|
symbols.push_back(SymbolIdx{idx, kind});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,13 +47,8 @@ MAKE_REFLECT_STRUCT(QueryLocation, range, path, role);
|
|||||||
MAKE_HASHABLE(QueryLocation, t.range, t.path, t.role);
|
MAKE_HASHABLE(QueryLocation, t.range, t.path, t.role);
|
||||||
|
|
||||||
struct SymbolIdx {
|
struct SymbolIdx {
|
||||||
SymbolKind kind;
|
|
||||||
RawId idx;
|
RawId idx;
|
||||||
|
SymbolKind kind;
|
||||||
SymbolIdx()
|
|
||||||
: kind(SymbolKind::Invalid),
|
|
||||||
idx(RawId(-1)) {} // Default ctor needed by stdlib. Do not use.
|
|
||||||
SymbolIdx(SymbolKind kind, RawId idx) : kind(kind), idx(idx) {}
|
|
||||||
|
|
||||||
bool operator==(const SymbolIdx& o) const {
|
bool operator==(const SymbolIdx& o) const {
|
||||||
return kind == o.kind && idx == o.idx;
|
return kind == o.kind && idx == o.idx;
|
||||||
@ -78,7 +73,7 @@ struct SymbolRef : Reference {
|
|||||||
: Reference{Range(), Id<void>(si.idx), si.kind, SymbolRole::None} {}
|
: Reference{Range(), Id<void>(si.idx), si.kind, SymbolRole::None} {}
|
||||||
|
|
||||||
RawId Idx() const { return RawId(id); }
|
RawId Idx() const { return RawId(id); }
|
||||||
operator SymbolIdx() const { return SymbolIdx(kind, Idx()); }
|
operator SymbolIdx() const { return SymbolIdx{Idx(), kind, }; }
|
||||||
QueryFunc& Func(QueryDatabase* db) const;
|
QueryFunc& Func(QueryDatabase* db) const;
|
||||||
QueryType& Type(QueryDatabase* db) const;
|
QueryType& Type(QueryDatabase* db) const;
|
||||||
QueryVar& Var(QueryDatabase* db) const;
|
QueryVar& Var(QueryDatabase* db) const;
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "queue_manager.h"
|
#include "queue_manager.h"
|
||||||
|
|
||||||
|
#include <loguru.hpp>
|
||||||
|
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
@ -367,7 +369,10 @@ optional<lsLocation> GetLsLocation(QueryDatabase* db,
|
|||||||
WorkingFiles* working_files,
|
WorkingFiles* working_files,
|
||||||
Reference ref) {
|
Reference ref) {
|
||||||
std::string path;
|
std::string path;
|
||||||
lsDocumentUri uri = GetLsDocumentUri(db, GetFileId(db, ref), &path);
|
QueryFileId file_id = GetFileId(db, ref);
|
||||||
|
if (!file_id.HasValue())
|
||||||
|
return nullopt;
|
||||||
|
lsDocumentUri uri = GetLsDocumentUri(db, file_id, &path);
|
||||||
optional<lsRange> range =
|
optional<lsRange> range =
|
||||||
GetLsRange(working_files->GetFileByFilename(path), ref.range);
|
GetLsRange(working_files->GetFileByFilename(path), ref.range);
|
||||||
if (!range)
|
if (!range)
|
||||||
|
Loading…
Reference in New Issue
Block a user