forked from OSchip/llvm-project
[clangd] Remember to serialize symbol origin in YAML.
llvm-svn: 342730
This commit is contained in:
parent
366ba73018
commit
c275fb2a5d
|
@ -27,6 +27,7 @@ namespace yaml {
|
|||
|
||||
using clang::clangd::Symbol;
|
||||
using clang::clangd::SymbolID;
|
||||
using clang::clangd::SymbolOrigin;
|
||||
using clang::clangd::SymbolLocation;
|
||||
using clang::index::SymbolInfo;
|
||||
using clang::index::SymbolKind;
|
||||
|
@ -65,6 +66,17 @@ struct NormalizedSymbolFlag {
|
|||
uint8_t Flag = 0;
|
||||
};
|
||||
|
||||
struct NormalizedSymbolOrigin {
|
||||
NormalizedSymbolOrigin(IO &) {}
|
||||
NormalizedSymbolOrigin(IO &, SymbolOrigin O) {
|
||||
Origin = static_cast<uint8_t>(O);
|
||||
}
|
||||
|
||||
SymbolOrigin denormalize(IO &) { return static_cast<SymbolOrigin>(Origin); }
|
||||
|
||||
uint8_t Origin = 0;
|
||||
};
|
||||
|
||||
template <> struct MappingTraits<SymbolLocation::Position> {
|
||||
static void mapping(IO &IO, SymbolLocation::Position &Value) {
|
||||
IO.mapRequired("Line", Value.Line);
|
||||
|
@ -102,6 +114,8 @@ template <> struct MappingTraits<Symbol> {
|
|||
MappingNormalization<NormalizedSymbolID, SymbolID> NSymbolID(IO, Sym.ID);
|
||||
MappingNormalization<NormalizedSymbolFlag, Symbol::SymbolFlag> NSymbolFlag(
|
||||
IO, Sym.Flags);
|
||||
MappingNormalization<NormalizedSymbolOrigin, SymbolOrigin> NSymbolOrigin(
|
||||
IO, Sym.Origin);
|
||||
IO.mapRequired("ID", NSymbolID->HexString);
|
||||
IO.mapRequired("Name", Sym.Name);
|
||||
IO.mapRequired("Scope", Sym.Scope);
|
||||
|
@ -110,6 +124,7 @@ template <> struct MappingTraits<Symbol> {
|
|||
SymbolLocation());
|
||||
IO.mapOptional("Definition", Sym.Definition, SymbolLocation());
|
||||
IO.mapOptional("References", Sym.References, 0u);
|
||||
IO.mapOptional("Origin", NSymbolOrigin->Origin);
|
||||
IO.mapOptional("Flags", NSymbolFlag->Flag);
|
||||
IO.mapOptional("Signature", Sym.Signature);
|
||||
IO.mapOptional("CompletionSnippetSuffix", Sym.CompletionSnippetSuffix);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "index/Index.h"
|
||||
#include "index/Serialization.h"
|
||||
#include "index/SymbolYAML.h"
|
||||
#include "llvm/Support/ScopedPrinter.h"
|
||||
|
@ -35,6 +36,7 @@ CanonicalDeclaration:
|
|||
End:
|
||||
Line: 1
|
||||
Column: 1
|
||||
Origin: 4
|
||||
Flags: 1
|
||||
Documentation: 'Foo doc'
|
||||
ReturnType: 'int'
|
||||
|
@ -82,6 +84,7 @@ TEST(SerializationTest, YAMLConversions) {
|
|||
EXPECT_EQ(Sym1.Documentation, "Foo doc");
|
||||
EXPECT_EQ(Sym1.ReturnType, "int");
|
||||
EXPECT_EQ(Sym1.CanonicalDeclaration.FileURI, "file:///path/foo.h");
|
||||
EXPECT_EQ(Sym1.Origin, SymbolOrigin::Static);
|
||||
EXPECT_TRUE(Sym1.Flags & Symbol::IndexedForCodeCompletion);
|
||||
EXPECT_FALSE(Sym1.Flags & Symbol::Deprecated);
|
||||
EXPECT_THAT(Sym1.IncludeHeaders,
|
||||
|
|
Loading…
Reference in New Issue