mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-31 09:50:26 +00:00
Index type description for function parameters.
This commit is contained in:
parent
6d2af96c16
commit
9cb4008023
@ -1009,6 +1009,19 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
||||
AddDeclTypeUsages(db, decl_cursor, decl->semanticContainer,
|
||||
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
|
||||
// template specializations as declarations, even though they are
|
||||
// technically definitions.
|
||||
|
@ -329,6 +329,12 @@ struct IndexFunc {
|
||||
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.
|
||||
std::vector<Declaration> declarations;
|
||||
|
||||
|
@ -86,6 +86,7 @@ void Reflect(TVisitor& visitor, IndexFunc& value) {
|
||||
REFLECT_MEMBER2("usr", value.def.usr);
|
||||
REFLECT_MEMBER2("short_name", value.def.short_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("definition_spelling", value.def.definition_spelling);
|
||||
REFLECT_MEMBER2("definition_extent", value.def.definition_extent);
|
||||
|
@ -12,6 +12,7 @@ OUTPUT:
|
||||
"usr": "c:@F@foo#I#I#",
|
||||
"short_name": "foo",
|
||||
"detailed_name": "int foo(int, int)",
|
||||
"parameter_type_descriptions": ["int", "int"],
|
||||
"declarations": [{
|
||||
"spelling": "1:5-1:8",
|
||||
"extent": "1:1-1:18",
|
||||
|
@ -8,6 +8,7 @@ OUTPUT:
|
||||
"usr": "c:@F@foo#I#I#",
|
||||
"short_name": "foo",
|
||||
"detailed_name": "void foo(int, int)",
|
||||
"parameter_type_descriptions": ["int", "int"],
|
||||
"declarations": [{
|
||||
"spelling": "1:6-1:9",
|
||||
"extent": "1:1-1:23",
|
||||
|
@ -25,6 +25,7 @@ OUTPUT:
|
||||
"usr": "c:@S@Foo@F@Foo#&&$@S@Foo#",
|
||||
"short_name": "Foo",
|
||||
"detailed_name": "void Foo::Foo(Foo &&)",
|
||||
"parameter_type_descriptions": ["Foo &&"],
|
||||
"definition_spelling": "5:12-5:15",
|
||||
"definition_extent": "5:12-5:16",
|
||||
"declaring_type": 0
|
||||
|
@ -10,6 +10,7 @@ OUTPUT:
|
||||
"usr": "c:@N@hello@F@foo#I#I#",
|
||||
"short_name": "foo",
|
||||
"detailed_name": "void hello::foo(int, int)",
|
||||
"parameter_type_descriptions": ["int", "int"],
|
||||
"declarations": [{
|
||||
"spelling": "2:6-2:9",
|
||||
"extent": "2:1-2:23",
|
||||
|
@ -17,6 +17,7 @@ OUTPUT:
|
||||
"usr": "c:@N@ns@F@Accept#I#",
|
||||
"short_name": "Accept",
|
||||
"detailed_name": "void ns::Accept(int)",
|
||||
"parameter_type_descriptions": ["int"],
|
||||
"definition_spelling": "3:8-3:14",
|
||||
"definition_extent": "3:3-3:24",
|
||||
"callers": ["1@7:7-7:13", "1@9:3-9:9"]
|
||||
|
@ -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#",
|
||||
"short_name": "LoadCompilationEntriesFromDirectory",
|
||||
"detailed_name": "std::vector<CompilationEntry> LoadCompilationEntriesFromDirectory(const std::string &)",
|
||||
"parameter_type_descriptions": ["const std::string &"],
|
||||
"declarations": [{
|
||||
"spelling": "12:31-12:66",
|
||||
"extent": "12:1-12:104",
|
||||
|
@ -33,6 +33,7 @@ OUTPUT:
|
||||
"usr": "c:@S@Foo@F@Bar#&$@S@Template>#d#",
|
||||
"short_name": "Bar",
|
||||
"detailed_name": "void Foo::Bar(Template<double> &)",
|
||||
"parameter_type_descriptions": ["Template<double> &"],
|
||||
"declarations": [{
|
||||
"spelling": "5:8-5:11",
|
||||
"extent": "5:3-5:30",
|
||||
|
@ -30,6 +30,7 @@ OUTPUT:
|
||||
"usr": "c:@F@act#*$@U@Foo#",
|
||||
"short_name": "act",
|
||||
"detailed_name": "void act(Foo *)",
|
||||
"parameter_type_descriptions": ["Foo *"],
|
||||
"definition_spelling": "8:6-8:9",
|
||||
"definition_extent": "8:1-10:2"
|
||||
}],
|
||||
|
@ -14,6 +14,7 @@ OUTPUT:
|
||||
"usr": "c:@F@called#b#b#",
|
||||
"short_name": "called",
|
||||
"detailed_name": "bool called(bool, bool)",
|
||||
"parameter_type_descriptions": ["bool", "bool"],
|
||||
"declarations": [{
|
||||
"spelling": "3:6-3:12",
|
||||
"extent": "3:1-3:28",
|
||||
|
@ -26,6 +26,7 @@ OUTPUT:
|
||||
"usr": "c:@S@Wrapper@F@Wrapper#I#",
|
||||
"short_name": "Wrapper",
|
||||
"detailed_name": "void Wrapper::Wrapper(int)",
|
||||
"parameter_type_descriptions": ["int"],
|
||||
"declarations": [{
|
||||
"spelling": "2:3-2:10",
|
||||
"extent": "2:3-2:17",
|
||||
|
@ -15,6 +15,7 @@ OUTPUT:
|
||||
"usr": "c:@F@consume#*v#",
|
||||
"short_name": "consume",
|
||||
"detailed_name": "void consume(void *)",
|
||||
"parameter_type_descriptions": ["void *"],
|
||||
"definition_spelling": "1:6-1:13",
|
||||
"definition_extent": "1:1-1:23",
|
||||
"callers": ["2@7:3-7:10"]
|
||||
|
@ -14,6 +14,7 @@ OUTPUT:
|
||||
"usr": "c:@FT@>1#Taccept#t0.0#v#",
|
||||
"short_name": "accept",
|
||||
"detailed_name": "void accept(T)",
|
||||
"parameter_type_descriptions": ["T"],
|
||||
"declarations": [{
|
||||
"spelling": "2:6-2:12",
|
||||
"extent": "2:1-2:15",
|
||||
|
@ -110,6 +110,7 @@ OUTPUT:
|
||||
"usr": "c:@F@as_return_type#*$@S@unique_ptr>#$@S@S1#$@S@S2#",
|
||||
"short_name": "as_return_type",
|
||||
"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_extent": "33:1-33:92"
|
||||
}, {
|
||||
@ -117,6 +118,7 @@ OUTPUT:
|
||||
"usr": "c:@F@no_return_type#I#",
|
||||
"short_name": "no_return_type",
|
||||
"detailed_name": "void no_return_type(int)",
|
||||
"parameter_type_descriptions": ["int"],
|
||||
"definition_spelling": "40:6-40:20",
|
||||
"definition_extent": "40:1-40:28"
|
||||
}, {
|
||||
|
@ -26,6 +26,7 @@ OUTPUT:
|
||||
"usr": "c:@F@foo#*$@S@ForwardType#$@S@ImplementedType#",
|
||||
"short_name": "foo",
|
||||
"detailed_name": "void foo(ForwardType *, ImplementedType)",
|
||||
"parameter_type_descriptions": ["ForwardType *", "ImplementedType"],
|
||||
"definition_spelling": "4:6-4:9",
|
||||
"definition_extent": "4:1-4:47"
|
||||
}],
|
||||
|
@ -22,6 +22,7 @@ OUTPUT:
|
||||
"usr": "c:@F@foo#*$@S@Foo#S0_#",
|
||||
"short_name": "foo",
|
||||
"detailed_name": "void foo(Foo *, Foo *)",
|
||||
"parameter_type_descriptions": ["Foo *", "Foo *"],
|
||||
"declarations": [{
|
||||
"spelling": "3:6-3:9",
|
||||
"extent": "3:1-3:23",
|
||||
|
@ -13,6 +13,7 @@ OUTPUT:
|
||||
"usr": "c:@F@foo#*$@S@ForwardType#",
|
||||
"short_name": "foo",
|
||||
"detailed_name": "void foo(ForwardType *)",
|
||||
"parameter_type_descriptions": ["ForwardType *"],
|
||||
"definition_spelling": "2:6-2:9",
|
||||
"definition_extent": "2:1-2:26"
|
||||
}]
|
||||
|
@ -24,6 +24,7 @@ OUTPUT:
|
||||
"usr": "c:@F@foo#&$@S@Type#&1S1_#",
|
||||
"short_name": "foo",
|
||||
"detailed_name": "void foo(Type &, const Type &)",
|
||||
"parameter_type_descriptions": ["Type &", "const Type &"],
|
||||
"definition_spelling": "3:6-3:9",
|
||||
"definition_extent": "3:1-8:2"
|
||||
}],
|
||||
|
@ -55,6 +55,7 @@ OUTPUT:
|
||||
"usr": "c:@S@Foo@F@Get#I#",
|
||||
"short_name": "Get",
|
||||
"detailed_name": "Type *Foo::Get(int)",
|
||||
"parameter_type_descriptions": ["int"],
|
||||
"declarations": [{
|
||||
"spelling": "8:9-8:12",
|
||||
"extent": "8:3-8:17",
|
||||
|
@ -57,6 +57,7 @@ OUTPUT:
|
||||
"usr": "c:@F@accept#*$@S@Foo#",
|
||||
"short_name": "accept",
|
||||
"detailed_name": "void accept(Foo *)",
|
||||
"parameter_type_descriptions": ["Foo *"],
|
||||
"definition_spelling": "7:6-7:12",
|
||||
"definition_extent": "7:1-7:21"
|
||||
}, {
|
||||
@ -64,6 +65,7 @@ OUTPUT:
|
||||
"usr": "c:@F@accept1#**$@S@Foo#",
|
||||
"short_name": "accept1",
|
||||
"detailed_name": "void accept1(Foo1 *)",
|
||||
"parameter_type_descriptions": ["Foo1 *"],
|
||||
"definition_spelling": "8:6-8:13",
|
||||
"definition_extent": "8:1-8:23"
|
||||
}, {
|
||||
@ -71,6 +73,7 @@ OUTPUT:
|
||||
"usr": "c:@F@accept2#*$@S@Foo#",
|
||||
"short_name": "accept2",
|
||||
"detailed_name": "void accept2(Foo2 *)",
|
||||
"parameter_type_descriptions": ["Foo2 *"],
|
||||
"definition_spelling": "9:6-9:13",
|
||||
"definition_extent": "9:1-9:23"
|
||||
}, {
|
||||
@ -78,6 +81,7 @@ OUTPUT:
|
||||
"usr": "c:@F@accept3#**$@S@Foo#",
|
||||
"short_name": "accept3",
|
||||
"detailed_name": "void accept3(Foo3 *)",
|
||||
"parameter_type_descriptions": ["Foo3 *"],
|
||||
"definition_spelling": "10:6-10:13",
|
||||
"definition_extent": "10:1-10:23"
|
||||
}]
|
||||
|
@ -32,6 +32,7 @@ OUTPUT:
|
||||
"usr": "c:@F@called#I#",
|
||||
"short_name": "called",
|
||||
"detailed_name": "void called(int)",
|
||||
"parameter_type_descriptions": ["int"],
|
||||
"declarations": [{
|
||||
"spelling": "1:6-1:12",
|
||||
"extent": "1:1-1:19",
|
||||
|
@ -14,6 +14,7 @@ OUTPUT:
|
||||
"usr": "c:@F@called#I#",
|
||||
"short_name": "called",
|
||||
"detailed_name": "void called(int)",
|
||||
"parameter_type_descriptions": ["int"],
|
||||
"declarations": [{
|
||||
"spelling": "1:6-1:12",
|
||||
"extent": "1:1-1:19",
|
||||
|
@ -36,6 +36,7 @@ OUTPUT:
|
||||
"usr": "c:@F@accept#I#",
|
||||
"short_name": "accept",
|
||||
"detailed_name": "void accept(int)",
|
||||
"parameter_type_descriptions": ["int"],
|
||||
"declarations": [{
|
||||
"spelling": "7:6-7:12",
|
||||
"extent": "7:1-7:17",
|
||||
@ -48,6 +49,7 @@ OUTPUT:
|
||||
"usr": "c:@F@accept#*I#",
|
||||
"short_name": "accept",
|
||||
"detailed_name": "void accept(int *)",
|
||||
"parameter_type_descriptions": ["int *"],
|
||||
"declarations": [{
|
||||
"spelling": "8:6-8:12",
|
||||
"extent": "8:1-8:18",
|
||||
|
@ -25,6 +25,7 @@ OUTPUT:
|
||||
"usr": "c:@F@accept#I#",
|
||||
"short_name": "accept",
|
||||
"detailed_name": "void accept(int)",
|
||||
"parameter_type_descriptions": ["int"],
|
||||
"declarations": [{
|
||||
"spelling": "5:6-5:12",
|
||||
"extent": "5:1-5:17",
|
||||
|
@ -9,6 +9,7 @@ OUTPUT:
|
||||
"usr": "c:@F@foo#I#",
|
||||
"short_name": "foo",
|
||||
"detailed_name": "void foo(int)",
|
||||
"parameter_type_descriptions": ["int"],
|
||||
"definition_spelling": "1:6-1:9",
|
||||
"definition_extent": "1:1-3:2"
|
||||
}],
|
||||
|
@ -15,6 +15,7 @@ OUTPUT:
|
||||
"usr": "c:@F@foo#I#",
|
||||
"short_name": "foo",
|
||||
"detailed_name": "void foo(int)",
|
||||
"parameter_type_descriptions": ["int"],
|
||||
"definition_spelling": "1:6-1:9",
|
||||
"definition_extent": "1:1-8:2"
|
||||
}],
|
||||
|
@ -16,6 +16,7 @@ OUTPUT:
|
||||
"usr": "c:@F@foo#*$@S@Foo#S0_#",
|
||||
"short_name": "foo",
|
||||
"detailed_name": "void foo(Foo *, Foo *)",
|
||||
"parameter_type_descriptions": ["Foo *", "Foo *"],
|
||||
"definition_spelling": "3:6-3:9",
|
||||
"definition_extent": "3:1-3:30"
|
||||
}],
|
||||
|
@ -7,6 +7,7 @@ OUTPUT:
|
||||
"usr": "c:@F@foo#I#I#",
|
||||
"short_name": "foo",
|
||||
"detailed_name": "void foo(int, int)",
|
||||
"parameter_type_descriptions": ["int", "int"],
|
||||
"definition_spelling": "1:6-1:9",
|
||||
"definition_extent": "1:1-1:22"
|
||||
}]
|
||||
|
@ -9,6 +9,7 @@ OUTPUT:
|
||||
"usr": "c:@F@foo#I#",
|
||||
"short_name": "foo",
|
||||
"detailed_name": "void foo(int)",
|
||||
"parameter_type_descriptions": ["int"],
|
||||
"definition_spelling": "1:6-1:9",
|
||||
"definition_extent": "1:1-3:2"
|
||||
}],
|
||||
|
Loading…
Reference in New Issue
Block a user