detailed_name: "{\n}" -> "{}" ; completion

This commit is contained in:
Fangrui Song 2018-08-29 21:20:27 -07:00
parent 74790e2421
commit 1ae97c64ed
24 changed files with 41 additions and 34 deletions

View File

@ -29,7 +29,7 @@ OUTPUT:
"uses": []
}, {
"usr": 16985894625255407295,
"detailed_name": "enum class Foo : uint8_t {\n}",
"detailed_name": "enum class Foo : uint8_t {}",
"qual_name_offset": 11,
"short_name": "Foo",
"kind": 10,

View File

@ -11,7 +11,7 @@ OUTPUT:
"usr2func": [],
"usr2type": [{
"usr": 16985894625255407295,
"detailed_name": "enum Foo {\n}",
"detailed_name": "enum Foo {}",
"qual_name_offset": 5,
"short_name": "Foo",
"kind": 10,

View File

@ -18,7 +18,7 @@ OUTPUT:
"usr2func": [],
"usr2type": [{
"usr": 2986879766914123941,
"detailed_name": "enum class E : int32_t {\n}",
"detailed_name": "enum class E : int32_t {}",
"qual_name_offset": 11,
"short_name": "E",
"kind": 10,
@ -52,7 +52,7 @@ OUTPUT:
"uses": []
}, {
"usr": 16985894625255407295,
"detailed_name": "enum Foo : int {\n}",
"detailed_name": "enum Foo : int {}",
"qual_name_offset": 5,
"short_name": "Foo",
"kind": 10,

View File

@ -13,7 +13,7 @@ OUTPUT:
"usr2func": [],
"usr2type": [{
"usr": 16985894625255407295,
"detailed_name": "enum class Foo : int {\n}",
"detailed_name": "enum class Foo : int {}",
"qual_name_offset": 11,
"short_name": "Foo",
"kind": 10,

View File

@ -16,7 +16,7 @@ OUTPUT:
"usr2func": [],
"usr2type": [{
"usr": 6697181287623958829,
"detailed_name": "enum A {\n}",
"detailed_name": "enum A {}",
"qual_name_offset": 5,
"short_name": "A",
"kind": 10,
@ -84,7 +84,7 @@ OUTPUT:
"uses": []
}, {
"usr": 13892793056005362145,
"detailed_name": "enum B {\n}",
"detailed_name": "enum B {}",
"qual_name_offset": 5,
"short_name": "B",
"kind": 10,

View File

@ -81,7 +81,7 @@ OUTPUT: funky_enum.cc
"usr2func": [],
"usr2type": [{
"usr": 16985894625255407295,
"detailed_name": "enum Foo {\n}",
"detailed_name": "enum Foo {}",
"qual_name_offset": 5,
"short_name": "Foo",
"kind": 10,

View File

@ -76,7 +76,7 @@ OUTPUT: header.h
"uses": []
}, {
"usr": 4481210672785600703,
"detailed_name": "enum Foo3 {\n}",
"detailed_name": "enum Foo3 {}",
"qual_name_offset": 5,
"short_name": "Foo3",
"kind": 10,

View File

@ -23,7 +23,7 @@ OUTPUT:
}],
"usr2type": [{
"usr": 2029211996748007610,
"detailed_name": "namespace hello {\n}",
"detailed_name": "namespace hello {}",
"qual_name_offset": 10,
"short_name": "hello",
"kind": 3,

View File

@ -25,7 +25,7 @@ OUTPUT:
}],
"usr2type": [{
"usr": 2029211996748007610,
"detailed_name": "namespace hello {\n}",
"detailed_name": "namespace hello {}",
"qual_name_offset": 10,
"short_name": "hello",
"kind": 3,

View File

@ -25,7 +25,7 @@ OUTPUT:
}],
"usr2type": [{
"usr": 2029211996748007610,
"detailed_name": "namespace hello {\n}",
"detailed_name": "namespace hello {}",
"qual_name_offset": 10,
"short_name": "hello",
"kind": 3,

View File

@ -29,7 +29,7 @@ OUTPUT:
}],
"usr2type": [{
"usr": 2029211996748007610,
"detailed_name": "namespace hello {\n}",
"detailed_name": "namespace hello {}",
"qual_name_offset": 10,
"short_name": "hello",
"kind": 3,

View File

@ -27,7 +27,7 @@ OUTPUT:
}],
"usr2type": [{
"usr": 2029211996748007610,
"detailed_name": "namespace hello {\n}",
"detailed_name": "namespace hello {}",
"qual_name_offset": 10,
"short_name": "hello",
"kind": 3,

View File

@ -51,7 +51,7 @@ OUTPUT:
"uses": []
}, {
"usr": 926793467007732869,
"detailed_name": "namespace foo {\n}",
"detailed_name": "namespace foo {}",
"qual_name_offset": 10,
"short_name": "foo",
"kind": 3,
@ -81,7 +81,7 @@ OUTPUT:
"uses": ["13:11-13:14|10818727483146447186|3|4"]
}, {
"usr": 14450849931009540802,
"detailed_name": "namespace foo::bar::baz {\n}",
"detailed_name": "namespace foo::bar::baz {}",
"qual_name_offset": 10,
"short_name": "baz",
"kind": 3,
@ -99,7 +99,7 @@ OUTPUT:
"uses": ["9:27-9:30|0|1|4", "12:21-12:24|10818727483146447186|3|4"]
}, {
"usr": 17805385787823406700,
"detailed_name": "namespace foo::bar {\n}",
"detailed_name": "namespace foo::bar {}",
"qual_name_offset": 10,
"short_name": "bar",
"kind": 3,

View File

@ -62,7 +62,7 @@ OUTPUT:
"uses": []
}, {
"usr": 11072669167287398027,
"detailed_name": "namespace ns {\n}",
"detailed_name": "namespace ns {}",
"qual_name_offset": 10,
"short_name": "ns",
"kind": 3,

View File

@ -42,7 +42,7 @@ OUTPUT: static_function_in_type.h
"uses": ["6:24-6:31|17262466801709381811|2|4"]
}, {
"usr": 11072669167287398027,
"detailed_name": "namespace ns {\n}",
"detailed_name": "namespace ns {}",
"qual_name_offset": 10,
"short_name": "ns",
"kind": 3,
@ -116,7 +116,7 @@ OUTPUT: static_function_in_type.cc
"uses": ["5:20-5:27|11072669167287398027|2|4"]
}, {
"usr": 11072669167287398027,
"detailed_name": "namespace ns {\n}",
"detailed_name": "namespace ns {}",
"qual_name_offset": 10,
"short_name": "ns",
"kind": 3,

View File

@ -37,7 +37,7 @@ OUTPUT:
"uses": []
}, {
"usr": 1532099849728741556,
"detailed_name": "enum ns::VarType {\n}",
"detailed_name": "enum ns::VarType {}",
"qual_name_offset": 5,
"short_name": "VarType",
"kind": 10,
@ -54,7 +54,7 @@ OUTPUT:
"uses": ["6:22-6:29|12688716854043726585|2|4", "6:44-6:51|12688716854043726585|2|4", "10:18-10:25|11072669167287398027|2|4"]
}, {
"usr": 11072669167287398027,
"detailed_name": "namespace ns {\n}",
"detailed_name": "namespace ns {}",
"qual_name_offset": 10,
"short_name": "ns",
"kind": 3,

View File

@ -49,7 +49,7 @@ OUTPUT:
"uses": []
}, {
"usr": 11072669167287398027,
"detailed_name": "namespace ns {\n}",
"detailed_name": "namespace ns {}",
"qual_name_offset": 10,
"short_name": "ns",
"kind": 3,

View File

@ -48,7 +48,7 @@ OUTPUT:
"uses": []
}, {
"usr": 11072669167287398027,
"detailed_name": "namespace ns {\n}",
"detailed_name": "namespace ns {}",
"qual_name_offset": 10,
"short_name": "ns",
"kind": 3,

View File

@ -204,7 +204,7 @@ OUTPUT:
"uses": ["21:16-21:22|0|1|4", "30:1-30:7|0|1|4", "32:1-32:7|0|1|4"]
}, {
"usr": 9201299975592934124,
"detailed_name": "enum Enum {\n}",
"detailed_name": "enum Enum {}",
"qual_name_offset": 5,
"short_name": "Enum",
"kind": 10,

View File

@ -35,7 +35,7 @@ OUTPUT:
"usr2func": [],
"usr2type": [{
"usr": 6697181287623958829,
"detailed_name": "enum A {\n}",
"detailed_name": "enum A {}",
"qual_name_offset": 5,
"short_name": "A",
"kind": 10,
@ -86,7 +86,7 @@ OUTPUT:
"uses": ["9:1-9:4|0|1|4", "10:1-10:4|0|1|4"]
}, {
"usr": 13892793056005362145,
"detailed_name": "enum B {\n}",
"detailed_name": "enum B {}",
"qual_name_offset": 5,
"short_name": "B",
"kind": 10,

View File

@ -38,7 +38,7 @@ OUTPUT:
"usr2func": [],
"usr2type": [{
"usr": 6697181287623958829,
"detailed_name": "enum A {\n}",
"detailed_name": "enum A {}",
"qual_name_offset": 5,
"short_name": "A",
"kind": 10,
@ -72,7 +72,7 @@ OUTPUT:
"uses": []
}, {
"usr": 13892793056005362145,
"detailed_name": "enum B {\n}",
"detailed_name": "enum B {}",
"qual_name_offset": 5,
"short_name": "B",
"kind": 10,

View File

@ -15,7 +15,7 @@ OUTPUT:
"usr2func": [],
"usr2type": [{
"usr": 5792006888140599735,
"detailed_name": "enum VarType {\n}",
"detailed_name": "enum VarType {}",
"qual_name_offset": 5,
"short_name": "VarType",
"kind": 10,

View File

@ -354,14 +354,15 @@ public:
unsigned NumResults) override {
ls_items.reserve(NumResults);
for (unsigned i = 0; i != NumResults; i++) {
if (Results[i].Availability == CXAvailability_NotAccessible ||
Results[i].Availability == CXAvailability_NotAvailable)
auto &R = Results[i];
if (R.Availability == CXAvailability_NotAccessible ||
R.Availability == CXAvailability_NotAvailable)
continue;
CodeCompletionString *CCS = Results[i].CreateCodeCompletionString(
CodeCompletionString *CCS = R.CreateCodeCompletionString(
S, Context, getAllocator(), getCodeCompletionTUInfo(),
includeBriefComments());
lsCompletionItem ls_item;
ls_item.kind = GetCompletionKind(Results[i].CursorKind);
ls_item.kind = GetCompletionKind(R.CursorKind);
if (const char *brief = CCS->getBriefComment())
ls_item.documentation = brief;

View File

@ -462,6 +462,12 @@ public:
std::string name = OS.str();
SimplifyAnonymous(name);
// Remove \n in DeclPrinter.cpp "{\n" + if(!TerseOutput)something + "}"
for (std::string::size_type i = 0;;) {
if ((i = name.find("{\n}", i)) == std::string::npos)
break;
name.replace(i, 3, "{}");
}
auto i = name.find(short_name);
if (short_name.size())
while (i != std::string::npos && ((i && isalnum(name[i - 1])) ||