Index type description for function parameters.

This commit is contained in:
Jacob Dufault 2017-11-06 23:53:59 -08:00
parent 6d2af96c16
commit 9cb4008023
31 changed files with 53 additions and 0 deletions

View File

@ -1009,6 +1009,19 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
AddDeclTypeUsages(db, decl_cursor, decl->semanticContainer, AddDeclTypeUsages(db, decl_cursor, decl->semanticContainer,
decl->lexicalContainer); decl->lexicalContainer);
// Add parameter list if we haven't seen this function before.
//
// note: If the function has no parameters, this block will be rerun
// every time we see the function. Performance should hopefully be fine
// but it may be a possible optimization.
if (func->parameter_type_descriptions.empty()) {
for (clang::Cursor arg : decl_cursor.get_arguments()) {
if (arg.get_kind() == CXCursor_ParmDecl) {
func->parameter_type_descriptions.push_back(arg.get_type_description());
}
}
}
// Add definition or declaration. This is a bit tricky because we treat // Add definition or declaration. This is a bit tricky because we treat
// template specializations as declarations, even though they are // template specializations as declarations, even though they are
// technically definitions. // technically definitions.

View File

@ -329,6 +329,12 @@ struct IndexFunc {
std::vector<Range> param_spellings; std::vector<Range> param_spellings;
}; };
// Type description for each parameter. This is stored in the sharable
// section (instead of the def) because it is while indexing cross-refs for
// constructors, which means the def may not yet be available if the function
// is forward-declared.
std::vector<std::string> parameter_type_descriptions;
// Places the function is forward-declared. // Places the function is forward-declared.
std::vector<Declaration> declarations; std::vector<Declaration> declarations;

View File

@ -86,6 +86,7 @@ void Reflect(TVisitor& visitor, IndexFunc& value) {
REFLECT_MEMBER2("usr", value.def.usr); REFLECT_MEMBER2("usr", value.def.usr);
REFLECT_MEMBER2("short_name", value.def.short_name); REFLECT_MEMBER2("short_name", value.def.short_name);
REFLECT_MEMBER2("detailed_name", value.def.detailed_name); REFLECT_MEMBER2("detailed_name", value.def.detailed_name);
REFLECT_MEMBER2("parameter_type_descriptions", value.parameter_type_descriptions);
REFLECT_MEMBER2("declarations", value.declarations); REFLECT_MEMBER2("declarations", value.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);

View File

@ -12,6 +12,7 @@ OUTPUT:
"usr": "c:@F@foo#I#I#", "usr": "c:@F@foo#I#I#",
"short_name": "foo", "short_name": "foo",
"detailed_name": "int foo(int, int)", "detailed_name": "int foo(int, int)",
"parameter_type_descriptions": ["int", "int"],
"declarations": [{ "declarations": [{
"spelling": "1:5-1:8", "spelling": "1:5-1:8",
"extent": "1:1-1:18", "extent": "1:1-1:18",

View File

@ -8,6 +8,7 @@ OUTPUT:
"usr": "c:@F@foo#I#I#", "usr": "c:@F@foo#I#I#",
"short_name": "foo", "short_name": "foo",
"detailed_name": "void foo(int, int)", "detailed_name": "void foo(int, int)",
"parameter_type_descriptions": ["int", "int"],
"declarations": [{ "declarations": [{
"spelling": "1:6-1:9", "spelling": "1:6-1:9",
"extent": "1:1-1:23", "extent": "1:1-1:23",

View File

@ -25,6 +25,7 @@ OUTPUT:
"usr": "c:@S@Foo@F@Foo#&&$@S@Foo#", "usr": "c:@S@Foo@F@Foo#&&$@S@Foo#",
"short_name": "Foo", "short_name": "Foo",
"detailed_name": "void Foo::Foo(Foo &&)", "detailed_name": "void Foo::Foo(Foo &&)",
"parameter_type_descriptions": ["Foo &&"],
"definition_spelling": "5:12-5:15", "definition_spelling": "5:12-5:15",
"definition_extent": "5:12-5:16", "definition_extent": "5:12-5:16",
"declaring_type": 0 "declaring_type": 0

View File

@ -10,6 +10,7 @@ OUTPUT:
"usr": "c:@N@hello@F@foo#I#I#", "usr": "c:@N@hello@F@foo#I#I#",
"short_name": "foo", "short_name": "foo",
"detailed_name": "void hello::foo(int, int)", "detailed_name": "void hello::foo(int, int)",
"parameter_type_descriptions": ["int", "int"],
"declarations": [{ "declarations": [{
"spelling": "2:6-2:9", "spelling": "2:6-2:9",
"extent": "2:1-2:23", "extent": "2:1-2:23",

View File

@ -17,6 +17,7 @@ OUTPUT:
"usr": "c:@N@ns@F@Accept#I#", "usr": "c:@N@ns@F@Accept#I#",
"short_name": "Accept", "short_name": "Accept",
"detailed_name": "void ns::Accept(int)", "detailed_name": "void ns::Accept(int)",
"parameter_type_descriptions": ["int"],
"definition_spelling": "3:8-3:14", "definition_spelling": "3:8-3:14",
"definition_extent": "3:3-3:24", "definition_extent": "3:3-3:24",
"callers": ["1@7:7-7:13", "1@9:3-9:9"] "callers": ["1@7:7-7:13", "1@9:3-9:9"]

View File

@ -47,6 +47,7 @@ OUTPUT:
"usr": "c:@F@LoadCompilationEntriesFromDirectory#&1$@N@std@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C#", "usr": "c:@F@LoadCompilationEntriesFromDirectory#&1$@N@std@S@basic_string>#C#$@N@std@S@char_traits>#C#$@N@std@S@allocator>#C#",
"short_name": "LoadCompilationEntriesFromDirectory", "short_name": "LoadCompilationEntriesFromDirectory",
"detailed_name": "std::vector<CompilationEntry> LoadCompilationEntriesFromDirectory(const std::string &)", "detailed_name": "std::vector<CompilationEntry> LoadCompilationEntriesFromDirectory(const std::string &)",
"parameter_type_descriptions": ["const std::string &"],
"declarations": [{ "declarations": [{
"spelling": "12:31-12:66", "spelling": "12:31-12:66",
"extent": "12:1-12:104", "extent": "12:1-12:104",

View File

@ -33,6 +33,7 @@ OUTPUT:
"usr": "c:@S@Foo@F@Bar#&$@S@Template>#d#", "usr": "c:@S@Foo@F@Bar#&$@S@Template>#d#",
"short_name": "Bar", "short_name": "Bar",
"detailed_name": "void Foo::Bar(Template<double> &)", "detailed_name": "void Foo::Bar(Template<double> &)",
"parameter_type_descriptions": ["Template<double> &"],
"declarations": [{ "declarations": [{
"spelling": "5:8-5:11", "spelling": "5:8-5:11",
"extent": "5:3-5:30", "extent": "5:3-5:30",

View File

@ -30,6 +30,7 @@ OUTPUT:
"usr": "c:@F@act#*$@U@Foo#", "usr": "c:@F@act#*$@U@Foo#",
"short_name": "act", "short_name": "act",
"detailed_name": "void act(Foo *)", "detailed_name": "void act(Foo *)",
"parameter_type_descriptions": ["Foo *"],
"definition_spelling": "8:6-8:9", "definition_spelling": "8:6-8:9",
"definition_extent": "8:1-10:2" "definition_extent": "8:1-10:2"
}], }],

View File

@ -14,6 +14,7 @@ OUTPUT:
"usr": "c:@F@called#b#b#", "usr": "c:@F@called#b#b#",
"short_name": "called", "short_name": "called",
"detailed_name": "bool called(bool, bool)", "detailed_name": "bool called(bool, bool)",
"parameter_type_descriptions": ["bool", "bool"],
"declarations": [{ "declarations": [{
"spelling": "3:6-3:12", "spelling": "3:6-3:12",
"extent": "3:1-3:28", "extent": "3:1-3:28",

View File

@ -26,6 +26,7 @@ OUTPUT:
"usr": "c:@S@Wrapper@F@Wrapper#I#", "usr": "c:@S@Wrapper@F@Wrapper#I#",
"short_name": "Wrapper", "short_name": "Wrapper",
"detailed_name": "void Wrapper::Wrapper(int)", "detailed_name": "void Wrapper::Wrapper(int)",
"parameter_type_descriptions": ["int"],
"declarations": [{ "declarations": [{
"spelling": "2:3-2:10", "spelling": "2:3-2:10",
"extent": "2:3-2:17", "extent": "2:3-2:17",

View File

@ -15,6 +15,7 @@ OUTPUT:
"usr": "c:@F@consume#*v#", "usr": "c:@F@consume#*v#",
"short_name": "consume", "short_name": "consume",
"detailed_name": "void consume(void *)", "detailed_name": "void consume(void *)",
"parameter_type_descriptions": ["void *"],
"definition_spelling": "1:6-1:13", "definition_spelling": "1:6-1:13",
"definition_extent": "1:1-1:23", "definition_extent": "1:1-1:23",
"callers": ["2@7:3-7:10"] "callers": ["2@7:3-7:10"]

View File

@ -14,6 +14,7 @@ OUTPUT:
"usr": "c:@FT@>1#Taccept#t0.0#v#", "usr": "c:@FT@>1#Taccept#t0.0#v#",
"short_name": "accept", "short_name": "accept",
"detailed_name": "void accept(T)", "detailed_name": "void accept(T)",
"parameter_type_descriptions": ["T"],
"declarations": [{ "declarations": [{
"spelling": "2:6-2:12", "spelling": "2:6-2:12",
"extent": "2:1-2:15", "extent": "2:1-2:15",

View File

@ -110,6 +110,7 @@ OUTPUT:
"usr": "c:@F@as_return_type#*$@S@unique_ptr>#$@S@S1#$@S@S2#", "usr": "c:@F@as_return_type#*$@S@unique_ptr>#$@S@S1#$@S@S2#",
"short_name": "as_return_type", "short_name": "as_return_type",
"detailed_name": "unique_ptr<unique_ptr<S1, S2>, S2> *as_return_type(unique_ptr<S1, S2> *)", "detailed_name": "unique_ptr<unique_ptr<S1, S2>, S2> *as_return_type(unique_ptr<S1, S2> *)",
"parameter_type_descriptions": ["unique_ptr<S1, S2> *"],
"definition_spelling": "33:37-33:51", "definition_spelling": "33:37-33:51",
"definition_extent": "33:1-33:92" "definition_extent": "33:1-33:92"
}, { }, {
@ -117,6 +118,7 @@ OUTPUT:
"usr": "c:@F@no_return_type#I#", "usr": "c:@F@no_return_type#I#",
"short_name": "no_return_type", "short_name": "no_return_type",
"detailed_name": "void no_return_type(int)", "detailed_name": "void no_return_type(int)",
"parameter_type_descriptions": ["int"],
"definition_spelling": "40:6-40:20", "definition_spelling": "40:6-40:20",
"definition_extent": "40:1-40:28" "definition_extent": "40:1-40:28"
}, { }, {

View File

@ -26,6 +26,7 @@ OUTPUT:
"usr": "c:@F@foo#*$@S@ForwardType#$@S@ImplementedType#", "usr": "c:@F@foo#*$@S@ForwardType#$@S@ImplementedType#",
"short_name": "foo", "short_name": "foo",
"detailed_name": "void foo(ForwardType *, ImplementedType)", "detailed_name": "void foo(ForwardType *, ImplementedType)",
"parameter_type_descriptions": ["ForwardType *", "ImplementedType"],
"definition_spelling": "4:6-4:9", "definition_spelling": "4:6-4:9",
"definition_extent": "4:1-4:47" "definition_extent": "4:1-4:47"
}], }],

View File

@ -22,6 +22,7 @@ OUTPUT:
"usr": "c:@F@foo#*$@S@Foo#S0_#", "usr": "c:@F@foo#*$@S@Foo#S0_#",
"short_name": "foo", "short_name": "foo",
"detailed_name": "void foo(Foo *, Foo *)", "detailed_name": "void foo(Foo *, Foo *)",
"parameter_type_descriptions": ["Foo *", "Foo *"],
"declarations": [{ "declarations": [{
"spelling": "3:6-3:9", "spelling": "3:6-3:9",
"extent": "3:1-3:23", "extent": "3:1-3:23",

View File

@ -13,6 +13,7 @@ OUTPUT:
"usr": "c:@F@foo#*$@S@ForwardType#", "usr": "c:@F@foo#*$@S@ForwardType#",
"short_name": "foo", "short_name": "foo",
"detailed_name": "void foo(ForwardType *)", "detailed_name": "void foo(ForwardType *)",
"parameter_type_descriptions": ["ForwardType *"],
"definition_spelling": "2:6-2:9", "definition_spelling": "2:6-2:9",
"definition_extent": "2:1-2:26" "definition_extent": "2:1-2:26"
}] }]

View File

@ -24,6 +24,7 @@ OUTPUT:
"usr": "c:@F@foo#&$@S@Type#&1S1_#", "usr": "c:@F@foo#&$@S@Type#&1S1_#",
"short_name": "foo", "short_name": "foo",
"detailed_name": "void foo(Type &, const Type &)", "detailed_name": "void foo(Type &, const Type &)",
"parameter_type_descriptions": ["Type &", "const Type &"],
"definition_spelling": "3:6-3:9", "definition_spelling": "3:6-3:9",
"definition_extent": "3:1-8:2" "definition_extent": "3:1-8:2"
}], }],

View File

@ -55,6 +55,7 @@ OUTPUT:
"usr": "c:@S@Foo@F@Get#I#", "usr": "c:@S@Foo@F@Get#I#",
"short_name": "Get", "short_name": "Get",
"detailed_name": "Type *Foo::Get(int)", "detailed_name": "Type *Foo::Get(int)",
"parameter_type_descriptions": ["int"],
"declarations": [{ "declarations": [{
"spelling": "8:9-8:12", "spelling": "8:9-8:12",
"extent": "8:3-8:17", "extent": "8:3-8:17",

View File

@ -57,6 +57,7 @@ OUTPUT:
"usr": "c:@F@accept#*$@S@Foo#", "usr": "c:@F@accept#*$@S@Foo#",
"short_name": "accept", "short_name": "accept",
"detailed_name": "void accept(Foo *)", "detailed_name": "void accept(Foo *)",
"parameter_type_descriptions": ["Foo *"],
"definition_spelling": "7:6-7:12", "definition_spelling": "7:6-7:12",
"definition_extent": "7:1-7:21" "definition_extent": "7:1-7:21"
}, { }, {
@ -64,6 +65,7 @@ OUTPUT:
"usr": "c:@F@accept1#**$@S@Foo#", "usr": "c:@F@accept1#**$@S@Foo#",
"short_name": "accept1", "short_name": "accept1",
"detailed_name": "void accept1(Foo1 *)", "detailed_name": "void accept1(Foo1 *)",
"parameter_type_descriptions": ["Foo1 *"],
"definition_spelling": "8:6-8:13", "definition_spelling": "8:6-8:13",
"definition_extent": "8:1-8:23" "definition_extent": "8:1-8:23"
}, { }, {
@ -71,6 +73,7 @@ OUTPUT:
"usr": "c:@F@accept2#*$@S@Foo#", "usr": "c:@F@accept2#*$@S@Foo#",
"short_name": "accept2", "short_name": "accept2",
"detailed_name": "void accept2(Foo2 *)", "detailed_name": "void accept2(Foo2 *)",
"parameter_type_descriptions": ["Foo2 *"],
"definition_spelling": "9:6-9:13", "definition_spelling": "9:6-9:13",
"definition_extent": "9:1-9:23" "definition_extent": "9:1-9:23"
}, { }, {
@ -78,6 +81,7 @@ OUTPUT:
"usr": "c:@F@accept3#**$@S@Foo#", "usr": "c:@F@accept3#**$@S@Foo#",
"short_name": "accept3", "short_name": "accept3",
"detailed_name": "void accept3(Foo3 *)", "detailed_name": "void accept3(Foo3 *)",
"parameter_type_descriptions": ["Foo3 *"],
"definition_spelling": "10:6-10:13", "definition_spelling": "10:6-10:13",
"definition_extent": "10:1-10:23" "definition_extent": "10:1-10:23"
}] }]

View File

@ -32,6 +32,7 @@ OUTPUT:
"usr": "c:@F@called#I#", "usr": "c:@F@called#I#",
"short_name": "called", "short_name": "called",
"detailed_name": "void called(int)", "detailed_name": "void called(int)",
"parameter_type_descriptions": ["int"],
"declarations": [{ "declarations": [{
"spelling": "1:6-1:12", "spelling": "1:6-1:12",
"extent": "1:1-1:19", "extent": "1:1-1:19",

View File

@ -14,6 +14,7 @@ OUTPUT:
"usr": "c:@F@called#I#", "usr": "c:@F@called#I#",
"short_name": "called", "short_name": "called",
"detailed_name": "void called(int)", "detailed_name": "void called(int)",
"parameter_type_descriptions": ["int"],
"declarations": [{ "declarations": [{
"spelling": "1:6-1:12", "spelling": "1:6-1:12",
"extent": "1:1-1:19", "extent": "1:1-1:19",

View File

@ -36,6 +36,7 @@ OUTPUT:
"usr": "c:@F@accept#I#", "usr": "c:@F@accept#I#",
"short_name": "accept", "short_name": "accept",
"detailed_name": "void accept(int)", "detailed_name": "void accept(int)",
"parameter_type_descriptions": ["int"],
"declarations": [{ "declarations": [{
"spelling": "7:6-7:12", "spelling": "7:6-7:12",
"extent": "7:1-7:17", "extent": "7:1-7:17",
@ -48,6 +49,7 @@ OUTPUT:
"usr": "c:@F@accept#*I#", "usr": "c:@F@accept#*I#",
"short_name": "accept", "short_name": "accept",
"detailed_name": "void accept(int *)", "detailed_name": "void accept(int *)",
"parameter_type_descriptions": ["int *"],
"declarations": [{ "declarations": [{
"spelling": "8:6-8:12", "spelling": "8:6-8:12",
"extent": "8:1-8:18", "extent": "8:1-8:18",

View File

@ -25,6 +25,7 @@ OUTPUT:
"usr": "c:@F@accept#I#", "usr": "c:@F@accept#I#",
"short_name": "accept", "short_name": "accept",
"detailed_name": "void accept(int)", "detailed_name": "void accept(int)",
"parameter_type_descriptions": ["int"],
"declarations": [{ "declarations": [{
"spelling": "5:6-5:12", "spelling": "5:6-5:12",
"extent": "5:1-5:17", "extent": "5:1-5:17",

View File

@ -9,6 +9,7 @@ OUTPUT:
"usr": "c:@F@foo#I#", "usr": "c:@F@foo#I#",
"short_name": "foo", "short_name": "foo",
"detailed_name": "void foo(int)", "detailed_name": "void foo(int)",
"parameter_type_descriptions": ["int"],
"definition_spelling": "1:6-1:9", "definition_spelling": "1:6-1:9",
"definition_extent": "1:1-3:2" "definition_extent": "1:1-3:2"
}], }],

View File

@ -15,6 +15,7 @@ OUTPUT:
"usr": "c:@F@foo#I#", "usr": "c:@F@foo#I#",
"short_name": "foo", "short_name": "foo",
"detailed_name": "void foo(int)", "detailed_name": "void foo(int)",
"parameter_type_descriptions": ["int"],
"definition_spelling": "1:6-1:9", "definition_spelling": "1:6-1:9",
"definition_extent": "1:1-8:2" "definition_extent": "1:1-8:2"
}], }],

View File

@ -16,6 +16,7 @@ OUTPUT:
"usr": "c:@F@foo#*$@S@Foo#S0_#", "usr": "c:@F@foo#*$@S@Foo#S0_#",
"short_name": "foo", "short_name": "foo",
"detailed_name": "void foo(Foo *, Foo *)", "detailed_name": "void foo(Foo *, Foo *)",
"parameter_type_descriptions": ["Foo *", "Foo *"],
"definition_spelling": "3:6-3:9", "definition_spelling": "3:6-3:9",
"definition_extent": "3:1-3:30" "definition_extent": "3:1-3:30"
}], }],

View File

@ -7,6 +7,7 @@ OUTPUT:
"usr": "c:@F@foo#I#I#", "usr": "c:@F@foo#I#I#",
"short_name": "foo", "short_name": "foo",
"detailed_name": "void foo(int, int)", "detailed_name": "void foo(int, int)",
"parameter_type_descriptions": ["int", "int"],
"definition_spelling": "1:6-1:9", "definition_spelling": "1:6-1:9",
"definition_extent": "1:1-1:22" "definition_extent": "1:1-1:22"
}] }]

View File

@ -9,6 +9,7 @@ OUTPUT:
"usr": "c:@F@foo#I#", "usr": "c:@F@foo#I#",
"short_name": "foo", "short_name": "foo",
"detailed_name": "void foo(int)", "detailed_name": "void foo(int)",
"parameter_type_descriptions": ["int"],
"definition_spelling": "1:6-1:9", "definition_spelling": "1:6-1:9",
"definition_extent": "1:1-3:2" "definition_extent": "1:1-3:2"
}], }],