Use symbol kind 'Parameter' for template parameters

Clients can distinguish between function and template parameters based
on storage class.
This commit is contained in:
Nathan Ridge 2018-02-01 23:07:11 -05:00 committed by Fangrui Song
parent ce6f1c7294
commit 74f9be1d6f
2 changed files with 5 additions and 0 deletions

View File

@ -38,6 +38,8 @@ enum class ClangSymbolKind : uint8_t {
Destructor, Destructor,
ConversionFunction, ConversionFunction,
// Used for both function and template parameters.
// Clients can differentiate based on StorageClass.
Parameter = 25, Parameter = 25,
Using, Using,
}; };

View File

@ -1197,6 +1197,7 @@ ClangCursor::VisitResult TemplateVisitor(ClangCursor cursor,
if (ref_index->def.detailed_name.empty()) { if (ref_index->def.detailed_name.empty()) {
ref_index->def.definition_spelling = ref_cursor.get_spelling_range(); ref_index->def.definition_spelling = ref_cursor.get_spelling_range();
ref_index->def.definition_extent = ref_cursor.get_extent(); ref_index->def.definition_extent = ref_cursor.get_extent();
ref_index->def.kind = ClangSymbolKind::Parameter;
SetVarDetail(ref_index, ref_cursor.get_spelling(), ref_cursor, SetVarDetail(ref_index, ref_cursor.get_spelling(), ref_cursor,
nullptr, true, db, data->param); nullptr, true, db, data->param);
@ -1252,6 +1253,7 @@ ClangCursor::VisitResult TemplateVisitor(ClangCursor cursor,
ref_index->def.detailed_name = ref_cursor.get_spelling(); ref_index->def.detailed_name = ref_cursor.get_spelling();
ref_index->def.short_name_offset = 0; ref_index->def.short_name_offset = 0;
ref_index->def.short_name_size = ref_index->def.detailed_name.size(); ref_index->def.short_name_size = ref_index->def.detailed_name.size();
ref_index->def.kind = ClangSymbolKind::Parameter;
} }
UniqueAdd(ref_index->uses, cursor.get_spelling_range()); UniqueAdd(ref_index->uses, cursor.get_spelling_range());
} }
@ -1273,6 +1275,7 @@ ClangCursor::VisitResult TemplateVisitor(ClangCursor cursor,
ref_index->def.detailed_name = ref_cursor.get_spelling(); ref_index->def.detailed_name = ref_cursor.get_spelling();
ref_index->def.short_name_offset = 0; ref_index->def.short_name_offset = 0;
ref_index->def.short_name_size = ref_index->def.detailed_name.size(); ref_index->def.short_name_size = ref_index->def.detailed_name.size();
ref_index->def.kind = ClangSymbolKind::Parameter;
} }
UniqueAdd(ref_index->uses, cursor.get_spelling_range()); UniqueAdd(ref_index->uses, cursor.get_spelling_range());
} }