forked from OSchip/llvm-project
[clangd] Expose value of enumerators to Hover API. (not UI yet)
Summary: This is part of https://github.com/clangd/clangd/issues/180. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70209
This commit is contained in:
parent
058bc4c8d4
commit
37abeed814
|
@ -657,6 +657,10 @@ static HoverInfo getHoverContents(const Decl *D, const SymbolIndex *Index) {
|
|||
Init->getType());
|
||||
}
|
||||
}
|
||||
} else if (const auto *ECD = dyn_cast<EnumConstantDecl>(D)) {
|
||||
// Dependent enums (e.g. nested in template classes) don't have values yet.
|
||||
if (!ECD->getType()->isDependentType())
|
||||
HI.Value = ECD->getInitVal().toString(10);
|
||||
}
|
||||
|
||||
HI.Definition = printDefinition(D);
|
||||
|
|
|
@ -981,6 +981,19 @@ void foo())cpp";
|
|||
HI.NamespaceScope = "";
|
||||
HI.Value = "3";
|
||||
}},
|
||||
{R"cpp(
|
||||
enum Color { RED, GREEN, };
|
||||
Color x = [[GR^EEN]];
|
||||
)cpp",
|
||||
[](HoverInfo &HI) {
|
||||
HI.Name = "GREEN";
|
||||
HI.NamespaceScope = "";
|
||||
HI.LocalScope = "Color::";
|
||||
HI.Definition = "GREEN";
|
||||
HI.Kind = SymbolKind::EnumMember;
|
||||
HI.Type = "enum Color";
|
||||
HI.Value = "1";
|
||||
}},
|
||||
// FIXME: We should use the Decl referenced, even if it comes from an
|
||||
// implicit instantiation.
|
||||
{R"cpp(
|
||||
|
|
Loading…
Reference in New Issue