From 1ae97c64ed5a73878ecbf09411a21b0a4b5b589d Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 29 Aug 2018 21:20:27 -0700 Subject: [PATCH] detailed_name: "{\n}" -> "{}" ; completion --- index_tests/enums/enum_class_decl.cc | 2 +- index_tests/enums/enum_decl.cc | 2 +- index_tests/enums/enum_inherit.cc | 4 ++-- index_tests/enums/enum_usage.cc | 2 +- index_tests/foobar.cc | 4 ++-- index_tests/multi_file/funky_enum.cc | 2 +- index_tests/multi_file/impl.cc | 2 +- index_tests/namespaces/function_declaration.cc | 2 +- index_tests/namespaces/function_definition.cc | 2 +- index_tests/namespaces/method_declaration.cc | 2 +- index_tests/namespaces/method_definition.cc | 2 +- index_tests/namespaces/method_inline_declaration.cc | 2 +- index_tests/namespaces/namespace_alias.cc | 6 +++--- index_tests/namespaces/namespace_reference.cc | 2 +- index_tests/outline/static_function_in_type.cc | 4 ++-- index_tests/templates/implicit_variable_instantiation.cc | 4 ++-- ...template_class_template_func_usage_folded_into_one.cc | 2 +- .../namespace_template_type_usage_folded_into_one.cc | 2 +- index_tests/templates/specialization.cc | 2 +- .../template_class_type_usage_folded_into_one.cc | 4 ++-- .../templates/template_var_usage_folded_into_one.cc | 4 ++-- index_tests/usage/var_usage_cstyle_cast.cc | 2 +- src/clang_complete.cc | 9 +++++---- src/indexer.cc | 6 ++++++ 24 files changed, 41 insertions(+), 34 deletions(-) diff --git a/index_tests/enums/enum_class_decl.cc b/index_tests/enums/enum_class_decl.cc index 34a1c978..3f3f78ca 100644 --- a/index_tests/enums/enum_class_decl.cc +++ b/index_tests/enums/enum_class_decl.cc @@ -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, diff --git a/index_tests/enums/enum_decl.cc b/index_tests/enums/enum_decl.cc index 3b28d1aa..6e44da9b 100644 --- a/index_tests/enums/enum_decl.cc +++ b/index_tests/enums/enum_decl.cc @@ -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, diff --git a/index_tests/enums/enum_inherit.cc b/index_tests/enums/enum_inherit.cc index 195b93d9..08d84087 100644 --- a/index_tests/enums/enum_inherit.cc +++ b/index_tests/enums/enum_inherit.cc @@ -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, diff --git a/index_tests/enums/enum_usage.cc b/index_tests/enums/enum_usage.cc index 2d602b45..bcee0c00 100644 --- a/index_tests/enums/enum_usage.cc +++ b/index_tests/enums/enum_usage.cc @@ -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, diff --git a/index_tests/foobar.cc b/index_tests/foobar.cc index b1e571d1..f5d2e47b 100644 --- a/index_tests/foobar.cc +++ b/index_tests/foobar.cc @@ -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, diff --git a/index_tests/multi_file/funky_enum.cc b/index_tests/multi_file/funky_enum.cc index c76b4d47..69f5ebdc 100644 --- a/index_tests/multi_file/funky_enum.cc +++ b/index_tests/multi_file/funky_enum.cc @@ -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, diff --git a/index_tests/multi_file/impl.cc b/index_tests/multi_file/impl.cc index cc53dabf..12a625b3 100644 --- a/index_tests/multi_file/impl.cc +++ b/index_tests/multi_file/impl.cc @@ -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, diff --git a/index_tests/namespaces/function_declaration.cc b/index_tests/namespaces/function_declaration.cc index 2438c99c..ec694bc9 100644 --- a/index_tests/namespaces/function_declaration.cc +++ b/index_tests/namespaces/function_declaration.cc @@ -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, diff --git a/index_tests/namespaces/function_definition.cc b/index_tests/namespaces/function_definition.cc index 7afe9d29..ce784555 100644 --- a/index_tests/namespaces/function_definition.cc +++ b/index_tests/namespaces/function_definition.cc @@ -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, diff --git a/index_tests/namespaces/method_declaration.cc b/index_tests/namespaces/method_declaration.cc index 48a8456e..de02f813 100644 --- a/index_tests/namespaces/method_declaration.cc +++ b/index_tests/namespaces/method_declaration.cc @@ -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, diff --git a/index_tests/namespaces/method_definition.cc b/index_tests/namespaces/method_definition.cc index 2506e411..5a25f7a9 100644 --- a/index_tests/namespaces/method_definition.cc +++ b/index_tests/namespaces/method_definition.cc @@ -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, diff --git a/index_tests/namespaces/method_inline_declaration.cc b/index_tests/namespaces/method_inline_declaration.cc index 55c95118..b4029c5f 100644 --- a/index_tests/namespaces/method_inline_declaration.cc +++ b/index_tests/namespaces/method_inline_declaration.cc @@ -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, diff --git a/index_tests/namespaces/namespace_alias.cc b/index_tests/namespaces/namespace_alias.cc index b659f553..314890b8 100644 --- a/index_tests/namespaces/namespace_alias.cc +++ b/index_tests/namespaces/namespace_alias.cc @@ -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, diff --git a/index_tests/namespaces/namespace_reference.cc b/index_tests/namespaces/namespace_reference.cc index 16949403..09919e03 100644 --- a/index_tests/namespaces/namespace_reference.cc +++ b/index_tests/namespaces/namespace_reference.cc @@ -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, diff --git a/index_tests/outline/static_function_in_type.cc b/index_tests/outline/static_function_in_type.cc index 89842296..9826edca 100644 --- a/index_tests/outline/static_function_in_type.cc +++ b/index_tests/outline/static_function_in_type.cc @@ -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, diff --git a/index_tests/templates/implicit_variable_instantiation.cc b/index_tests/templates/implicit_variable_instantiation.cc index db370e9f..36a97821 100644 --- a/index_tests/templates/implicit_variable_instantiation.cc +++ b/index_tests/templates/implicit_variable_instantiation.cc @@ -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, diff --git a/index_tests/templates/namespace_template_class_template_func_usage_folded_into_one.cc b/index_tests/templates/namespace_template_class_template_func_usage_folded_into_one.cc index 073ba344..d0fb3cb4 100644 --- a/index_tests/templates/namespace_template_class_template_func_usage_folded_into_one.cc +++ b/index_tests/templates/namespace_template_class_template_func_usage_folded_into_one.cc @@ -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, diff --git a/index_tests/templates/namespace_template_type_usage_folded_into_one.cc b/index_tests/templates/namespace_template_type_usage_folded_into_one.cc index 5b141b39..0476c03a 100644 --- a/index_tests/templates/namespace_template_type_usage_folded_into_one.cc +++ b/index_tests/templates/namespace_template_type_usage_folded_into_one.cc @@ -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, diff --git a/index_tests/templates/specialization.cc b/index_tests/templates/specialization.cc index f5ca0f26..7b8960c1 100644 --- a/index_tests/templates/specialization.cc +++ b/index_tests/templates/specialization.cc @@ -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, diff --git a/index_tests/templates/template_class_type_usage_folded_into_one.cc b/index_tests/templates/template_class_type_usage_folded_into_one.cc index 0dbec81c..7115ebc9 100644 --- a/index_tests/templates/template_class_type_usage_folded_into_one.cc +++ b/index_tests/templates/template_class_type_usage_folded_into_one.cc @@ -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, diff --git a/index_tests/templates/template_var_usage_folded_into_one.cc b/index_tests/templates/template_var_usage_folded_into_one.cc index e325205d..844baece 100644 --- a/index_tests/templates/template_var_usage_folded_into_one.cc +++ b/index_tests/templates/template_var_usage_folded_into_one.cc @@ -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, diff --git a/index_tests/usage/var_usage_cstyle_cast.cc b/index_tests/usage/var_usage_cstyle_cast.cc index 1233becc..09991182 100644 --- a/index_tests/usage/var_usage_cstyle_cast.cc +++ b/index_tests/usage/var_usage_cstyle_cast.cc @@ -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, diff --git a/src/clang_complete.cc b/src/clang_complete.cc index c062071b..3cd01988 100644 --- a/src/clang_complete.cc +++ b/src/clang_complete.cc @@ -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; diff --git a/src/indexer.cc b/src/indexer.cc index d0893657..5c899342 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -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])) ||