diff --git a/clang-tools-extra/clangd/Hover.h b/clang-tools-extra/clangd/Hover.h --- a/clang-tools-extra/clangd/Hover.h +++ b/clang-tools-extra/clangd/Hover.h @@ -28,7 +28,7 @@ /// - template class Foo {}; struct Param { /// The pretty-printed parameter type, e.g. "int", or "typename" (in - /// TemplateParameters) + /// TemplateParameters), might be None for macro parameters. llvm::Optional Type; /// None for unnamed parameters. llvm::Optional Name; @@ -53,9 +53,7 @@ /// Name of the symbol, does not contain any "::". std::string Name; llvm::Optional SymRange; - /// Scope containing the symbol. e.g, "global namespace", "function x::Y" - /// - None for deduced types, e.g "auto", "decltype" keywords. - SymbolKind Kind; + index::SymbolKind Kind; std::string Documentation; /// Source code containing the definition of the symbol. std::string Definition; diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -20,6 +20,8 @@ #include "clang/AST/ASTTypeTraits.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/PrettyPrinter.h" +#include "clang/Index/IndexSymbol.h" +#include "llvm/Support/raw_ostream.h" namespace clang { namespace clangd { @@ -298,7 +300,7 @@ HI.Name = printName(Ctx, *ND); } - HI.Kind = indexSymbolKindToSymbolKind(index::getSymbolInfo(D).Kind); + HI.Kind = index::getSymbolInfo(D).Kind; // Fill in template params. if (const TemplateDecl *TD = D->getDescribedTemplate()) { @@ -347,7 +349,7 @@ OS.flush(); if (D) { - HI.Kind = indexSymbolKindToSymbolKind(index::getSymbolInfo(D).Kind); + HI.Kind = index::getSymbolInfo(D).Kind; enhanceFromIndex(HI, D, Index); } return HI; @@ -358,8 +360,7 @@ HoverInfo HI; SourceManager &SM = AST.getSourceManager(); HI.Name = Macro.Name; - HI.Kind = indexSymbolKindToSymbolKind( - index::getSymbolInfoForMacro(*Macro.Info).Kind); + HI.Kind = index::getSymbolInfoForMacro(*Macro.Info).Kind; // FIXME: Populate documentation // FIXME: Pupulate parameters diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp --- a/clang-tools-extra/clangd/unittests/HoverTests.cpp +++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -32,7 +32,7 @@ [](HoverInfo &HI) { HI.NamespaceScope = ""; HI.Name = "foo"; - HI.Kind = SymbolKind::Function; + HI.Kind = index::SymbolKind::Function; HI.Documentation = "Best foo ever."; HI.Definition = "void foo()"; HI.ReturnType = "void"; @@ -49,7 +49,7 @@ [](HoverInfo &HI) { HI.NamespaceScope = "ns1::ns2::"; HI.Name = "foo"; - HI.Kind = SymbolKind::Function; + HI.Kind = index::SymbolKind::Function; HI.Documentation = "Best foo ever."; HI.Definition = "void foo()"; HI.ReturnType = "void"; @@ -68,7 +68,7 @@ HI.NamespaceScope = "ns1::ns2::"; HI.LocalScope = "Foo::"; HI.Name = "bar"; - HI.Kind = SymbolKind::Field; + HI.Kind = index::SymbolKind::Field; HI.Definition = "int bar"; HI.Type = "int"; }}, @@ -86,7 +86,7 @@ HI.NamespaceScope = "ns1::ns2::"; HI.LocalScope = "Foo::foo::"; HI.Name = "bar"; - HI.Kind = SymbolKind::Variable; + HI.Kind = index::SymbolKind::Variable; HI.Definition = "int bar"; HI.Type = "int"; }}, @@ -102,7 +102,7 @@ HI.NamespaceScope = "ns1::(anonymous)::"; HI.LocalScope = "(anonymous struct)::"; HI.Name = "bar"; - HI.Kind = SymbolKind::Field; + HI.Kind = index::SymbolKind::Field; HI.Definition = "int bar"; HI.Type = "int"; }}, @@ -114,7 +114,7 @@ [](HoverInfo &HI) { HI.NamespaceScope = ""; HI.Name = "foo"; - HI.Kind = SymbolKind::Variable; + HI.Kind = index::SymbolKind::Variable; HI.Definition = "Foo foo = Foo(5)"; HI.Type = "Foo"; }}, @@ -126,7 +126,7 @@ [](HoverInfo &HI) { HI.NamespaceScope = ""; HI.Name = "vector"; - HI.Kind = SymbolKind::Class; + HI.Kind = index::SymbolKind::Class; HI.Definition = "template class vector {}"; HI.TemplateParameters = { {std::string("typename"), std::string("T"), llvm::None}, @@ -145,7 +145,7 @@ [](HoverInfo &HI) { HI.NamespaceScope = ""; HI.Name = "Foo"; - HI.Kind = SymbolKind::Class; + HI.Kind = index::SymbolKind::Class; HI.Definition = R"cpp(template