mirror of
https://github.com/MaskRay/ccls.git
synced 2025-02-21 16:09:40 +00:00
Change declaration to declarations in IndexVar
This commit is contained in:
parent
6b3673a438
commit
e892c23955
@ -561,7 +561,7 @@ void OnIndexReference_Function(IndexFile* db,
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// static
|
// static
|
||||||
int IndexFile::kCurrentVersion = 9;
|
int IndexFile::kCurrentVersion = 10;
|
||||||
|
|
||||||
IndexFile::IndexFile(const std::string& path,
|
IndexFile::IndexFile(const std::string& path,
|
||||||
const optional<std::string>& contents)
|
const optional<std::string>& contents)
|
||||||
@ -1431,8 +1431,7 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
|||||||
var->def.definition_spelling = decl_spell;
|
var->def.definition_spelling = decl_spell;
|
||||||
var->def.definition_extent = decl_cursor.get_extent();
|
var->def.definition_extent = decl_cursor.get_extent();
|
||||||
} else {
|
} else {
|
||||||
var->def.declaration = decl_spell;
|
var->def.declarations.push_back(decl_spell);
|
||||||
UniqueAdd(var->uses, decl_spell);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AddDeclInitializerUsages(db, decl_cursor);
|
AddDeclInitializerUsages(db, decl_cursor);
|
||||||
|
@ -373,7 +373,7 @@ struct VarDefDefinitionData {
|
|||||||
ClangStorageClass storage = ClangStorageClass::SC_Invalid;
|
ClangStorageClass storage = ClangStorageClass::SC_Invalid;
|
||||||
optional<std::string> hover;
|
optional<std::string> hover;
|
||||||
optional<std::string> comments;
|
optional<std::string> comments;
|
||||||
optional<Range> declaration;
|
std::vector<Range> declarations;
|
||||||
// TODO: definitions should be a list of ranges, since there can be more
|
// TODO: definitions should be a list of ranges, since there can be more
|
||||||
// than one - when??
|
// than one - when??
|
||||||
optional<Range> definition_spelling;
|
optional<Range> definition_spelling;
|
||||||
@ -397,7 +397,7 @@ struct VarDefDefinitionData {
|
|||||||
const VarDefDefinitionData<TypeId, FuncId, VarId, Range>& other) const {
|
const VarDefDefinitionData<TypeId, FuncId, VarId, Range>& other) const {
|
||||||
return short_name == other.short_name &&
|
return short_name == other.short_name &&
|
||||||
detailed_name == other.detailed_name && hover == other.hover &&
|
detailed_name == other.detailed_name && hover == other.hover &&
|
||||||
declaration == other.declaration &&
|
declarations.size() == other.declarations.size() &&
|
||||||
definition_spelling == other.definition_spelling &&
|
definition_spelling == other.definition_spelling &&
|
||||||
definition_extent == other.definition_extent &&
|
definition_extent == other.definition_extent &&
|
||||||
variable_type == other.variable_type &&
|
variable_type == other.variable_type &&
|
||||||
|
@ -83,7 +83,7 @@ optional<QueryVar::Def> ToQuery(const IdMap& id_map, const IndexVar::Def& var) {
|
|||||||
result.storage = var.storage;
|
result.storage = var.storage;
|
||||||
result.hover = var.hover;
|
result.hover = var.hover;
|
||||||
result.comments = var.comments;
|
result.comments = var.comments;
|
||||||
result.declaration = id_map.ToQuery(var.declaration);
|
result.declarations = id_map.ToQuery(var.declarations);
|
||||||
result.definition_spelling = id_map.ToQuery(var.definition_spelling);
|
result.definition_spelling = id_map.ToQuery(var.definition_spelling);
|
||||||
result.definition_extent = id_map.ToQuery(var.definition_extent);
|
result.definition_extent = id_map.ToQuery(var.definition_extent);
|
||||||
result.variable_type = id_map.ToQuery(var.variable_type);
|
result.variable_type = id_map.ToQuery(var.variable_type);
|
||||||
|
@ -203,8 +203,12 @@ std::vector<QueryLocation> GetUsesOfSymbol(QueryDatabase* db,
|
|||||||
case SymbolKind::Var: {
|
case SymbolKind::Var: {
|
||||||
QueryVar& var = db->vars[symbol.idx];
|
QueryVar& var = db->vars[symbol.idx];
|
||||||
std::vector<QueryLocation> ret = var.uses;
|
std::vector<QueryLocation> ret = var.uses;
|
||||||
if (include_decl && var.def && var.def->definition_spelling)
|
if (include_decl && var.def) {
|
||||||
ret.push_back(*var.def->definition_spelling);
|
if (var.def->definition_spelling)
|
||||||
|
ret.push_back(*var.def->definition_spelling);
|
||||||
|
ret.insert(ret.end(), var.def->declarations.begin(),
|
||||||
|
var.def->declarations.end());
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
case SymbolKind::File:
|
case SymbolKind::File:
|
||||||
@ -239,11 +243,8 @@ std::vector<QueryLocation> GetDeclarationsOfSymbolForGotoDefinition(
|
|||||||
}
|
}
|
||||||
case SymbolKind::Var: {
|
case SymbolKind::Var: {
|
||||||
QueryVar& var = db->vars[symbol.idx];
|
QueryVar& var = db->vars[symbol.idx];
|
||||||
if (var.def) {
|
if (var.def)
|
||||||
optional<QueryLocation> declaration = var.def->declaration;
|
return var.def->declarations;
|
||||||
if (declaration)
|
|
||||||
return {*declaration};
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -189,7 +189,7 @@ void Reflect(TVisitor& visitor, IndexVar& value) {
|
|||||||
REFLECT_MEMBER2("storage", value.def.storage);
|
REFLECT_MEMBER2("storage", value.def.storage);
|
||||||
REFLECT_MEMBER2("hover", value.def.hover);
|
REFLECT_MEMBER2("hover", value.def.hover);
|
||||||
REFLECT_MEMBER2("comments", value.def.comments);
|
REFLECT_MEMBER2("comments", value.def.comments);
|
||||||
REFLECT_MEMBER2("declaration", value.def.declaration);
|
REFLECT_MEMBER2("declarations", value.def.declarations);
|
||||||
REFLECT_MEMBER2("definition_spelling", value.def.definition_spelling);
|
REFLECT_MEMBER2("definition_spelling", value.def.definition_spelling);
|
||||||
REFLECT_MEMBER2("definition_extent", value.def.definition_extent);
|
REFLECT_MEMBER2("definition_extent", value.def.definition_extent);
|
||||||
REFLECT_MEMBER2("variable_type", value.def.variable_type);
|
REFLECT_MEMBER2("variable_type", value.def.variable_type);
|
||||||
|
Loading…
Reference in New Issue
Block a user