mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-29 19:07:08 +00:00
Add kind to Out_CqueryPublishSemanticHighlighting
This commit is contained in:
parent
c3136122ad
commit
c4935fb367
@ -1084,7 +1084,9 @@ struct Out_CqueryPublishSemanticHighlighting
|
|||||||
enum class SymbolType { Type = 0, Function, Variable };
|
enum class SymbolType { Type = 0, Function, Variable };
|
||||||
struct Symbol {
|
struct Symbol {
|
||||||
int stableId = 0;
|
int stableId = 0;
|
||||||
|
// TODO Deprecate |type| in favor of fine-grained |kind|.
|
||||||
SymbolType type = SymbolType::Type;
|
SymbolType type = SymbolType::Type;
|
||||||
|
int kind;
|
||||||
bool isTypeMember = false;
|
bool isTypeMember = false;
|
||||||
std::vector<lsRange> ranges;
|
std::vector<lsRange> ranges;
|
||||||
};
|
};
|
||||||
@ -1098,6 +1100,7 @@ struct Out_CqueryPublishSemanticHighlighting
|
|||||||
MAKE_REFLECT_TYPE_PROXY(Out_CqueryPublishSemanticHighlighting::SymbolType, int);
|
MAKE_REFLECT_TYPE_PROXY(Out_CqueryPublishSemanticHighlighting::SymbolType, int);
|
||||||
MAKE_REFLECT_STRUCT(Out_CqueryPublishSemanticHighlighting::Symbol,
|
MAKE_REFLECT_STRUCT(Out_CqueryPublishSemanticHighlighting::Symbol,
|
||||||
type,
|
type,
|
||||||
|
kind,
|
||||||
isTypeMember,
|
isTypeMember,
|
||||||
stableId,
|
stableId,
|
||||||
ranges);
|
ranges);
|
||||||
|
@ -126,6 +126,7 @@ void EmitSemanticHighlighting(QueryDatabase* db,
|
|||||||
for (SymbolRef sym : file->def->all_symbols) {
|
for (SymbolRef sym : file->def->all_symbols) {
|
||||||
std::string detailed_name;
|
std::string detailed_name;
|
||||||
bool is_type_member = false;
|
bool is_type_member = false;
|
||||||
|
ClangSymbolKind kind = ClangSymbolKind::Unknown;
|
||||||
// This switch statement also filters out symbols that are not highlighted.
|
// This switch statement also filters out symbols that are not highlighted.
|
||||||
switch (sym.idx.kind) {
|
switch (sym.idx.kind) {
|
||||||
case SymbolKind::Func: {
|
case SymbolKind::Func: {
|
||||||
@ -134,6 +135,7 @@ void EmitSemanticHighlighting(QueryDatabase* db,
|
|||||||
continue; // applies to for loop
|
continue; // applies to for loop
|
||||||
if (func->def->is_operator)
|
if (func->def->is_operator)
|
||||||
continue; // applies to for loop
|
continue; // applies to for loop
|
||||||
|
kind = func->def->kind;
|
||||||
is_type_member = func->def->declaring_type.has_value();
|
is_type_member = func->def->declaring_type.has_value();
|
||||||
detailed_name = func->def->short_name;
|
detailed_name = func->def->short_name;
|
||||||
|
|
||||||
@ -159,19 +161,7 @@ void EmitSemanticHighlighting(QueryDatabase* db,
|
|||||||
QueryVar* var = &db->vars[sym.idx.idx];
|
QueryVar* var = &db->vars[sym.idx.idx];
|
||||||
if (!var->def)
|
if (!var->def)
|
||||||
continue; // applies to for loop
|
continue; // applies to for loop
|
||||||
switch (var->def->kind) {
|
kind = var->def->kind;
|
||||||
// TODO
|
|
||||||
case ClangSymbolKind::EnumConstant:
|
|
||||||
case ClangSymbolKind::Field:
|
|
||||||
case ClangSymbolKind::Macro:
|
|
||||||
case ClangSymbolKind::Module:
|
|
||||||
case ClangSymbolKind::Parameter:
|
|
||||||
case ClangSymbolKind::StaticProperty:
|
|
||||||
case ClangSymbolKind::Variable:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
continue; // applies to for loop
|
|
||||||
}
|
|
||||||
is_type_member = var->def->declaring_type.has_value();
|
is_type_member = var->def->declaring_type.has_value();
|
||||||
detailed_name = var->def->short_name;
|
detailed_name = var->def->short_name;
|
||||||
break;
|
break;
|
||||||
@ -180,6 +170,7 @@ void EmitSemanticHighlighting(QueryDatabase* db,
|
|||||||
QueryType* type = &db->types[sym.idx.idx];
|
QueryType* type = &db->types[sym.idx.idx];
|
||||||
if (!type->def)
|
if (!type->def)
|
||||||
continue; // applies to for loop
|
continue; // applies to for loop
|
||||||
|
kind = type->def->kind;
|
||||||
detailed_name = type->def->detailed_name;
|
detailed_name = type->def->detailed_name;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -196,6 +187,7 @@ void EmitSemanticHighlighting(QueryDatabase* db,
|
|||||||
Out_CqueryPublishSemanticHighlighting::Symbol symbol;
|
Out_CqueryPublishSemanticHighlighting::Symbol symbol;
|
||||||
symbol.stableId =
|
symbol.stableId =
|
||||||
semantic_cache_for_file->GetStableId(sym.idx.kind, detailed_name);
|
semantic_cache_for_file->GetStableId(sym.idx.kind, detailed_name);
|
||||||
|
symbol.kind = static_cast<int>(kind);
|
||||||
symbol.type = map_symbol_kind_to_symbol_type(sym.idx.kind);
|
symbol.type = map_symbol_kind_to_symbol_type(sym.idx.kind);
|
||||||
symbol.isTypeMember = is_type_member;
|
symbol.isTypeMember = is_type_member;
|
||||||
symbol.ranges.push_back(*loc);
|
symbol.ranges.push_back(*loc);
|
||||||
|
Loading…
Reference in New Issue
Block a user