10#include "llvm/Support/CommandLine.h"
11#include "llvm/Support/FileSystem.h"
12#include "llvm/Support/YAMLTraits.h"
13#include "llvm/Support/raw_ostream.h"
15using llvm::yaml::MappingTraits;
29 io.mapRequired(
"Contexts",
Symbol.Symbol.Contexts);
30 io.mapRequired(
"FilePath",
Symbol.Symbol.FilePath);
32 io.mapRequired(
"Seen",
Symbol.Signals.Seen);
33 io.mapRequired(
"Used",
Symbol.Signals.Used);
39 io.enumCase(value,
"Record", ContextType::Record);
40 io.enumCase(value,
"Namespace", ContextType::Namespace);
41 io.enumCase(value,
"EnumDecl", ContextType::EnumDecl);
45template <>
struct ScalarEnumerationTraits<
SymbolKind> {
47 io.enumCase(value,
"Variable", SymbolKind::Variable);
48 io.enumCase(value,
"Function", SymbolKind::Function);
49 io.enumCase(value,
"Class", SymbolKind::Class);
50 io.enumCase(value,
"TypedefName", SymbolKind::TypedefName);
51 io.enumCase(value,
"EnumDecl", SymbolKind::EnumDecl);
52 io.enumCase(value,
"EnumConstantDecl", SymbolKind::EnumConstantDecl);
53 io.enumCase(value,
"Macro", SymbolKind::Macro);
54 io.enumCase(value,
"Unknown", SymbolKind::Unknown);
60 io.mapRequired(
"ContextType", Context.first);
61 io.mapRequired(
"ContextName", Context.second);
69namespace find_all_symbols {
72 llvm::StringRef FilePath,
73 const std::vector<Context> &Contexts)
77 return std::tie(Name, Type, FilePath, Contexts) ==
78 std::tie(Symbol.Name, Symbol.Type, Symbol.FilePath, Symbol.Contexts);
82 return std::tie(Name, Type, FilePath, Contexts) <
83 std::tie(Symbol.Name, Symbol.Type, Symbol.FilePath, Symbol.Contexts);
87 std::string QualifiedName = Name;
88 for (
const auto &
Context : Contexts) {
89 if (
Context.first == ContextType::EnumDecl)
91 QualifiedName =
Context.second +
"::" + QualifiedName;
113 return std::tie(Symbol, Signals) == std::tie(RHS.
Symbol, RHS.
Signals);
118 llvm::yaml::Output yout(
OS);
119 for (
const auto &Symbol : Symbols) {
127 std::vector<SymbolAndSignals> Symbols;
128 llvm::yaml::Input yin(Yaml);
llvm::SmallString< 256U > Name
clang::find_all_symbols::SymbolInfo SymbolInfo
clang::find_all_symbols::SymbolInfo::SymbolKind SymbolKind
llvm::raw_string_ostream OS
Describes a named symbol from a header.
bool operator==(const SymbolInfo &Symbol) const
ContextType
The Context Type.
std::pair< ContextType, std::string > Context
A pair of <ContextType, ContextName>.
SymbolKind
The SymbolInfo Type.
std::string getQualifiedName() const
Get the fully-qualified symbol name.
bool operator<(const SymbolInfo &Symbol) const
std::map< SymbolInfo, Signals > SignalMap
bool WriteSymbolInfosToStream(llvm::raw_ostream &OS, const SymbolInfo::SignalMap &Symbols)
Write SymbolInfos to a stream (YAML format).
std::vector< SymbolAndSignals > ReadSymbolInfosFromYAML(llvm::StringRef Yaml)
Read SymbolInfos from a YAML document.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Some operations such as code completion produce a set of candidates.
The class presents a C++ symbol, e.g.
llvm::StringRef Type
Raw representation of the OpaqueType of the symbol, used for scoring purposes.
llvm::StringRef Name
The unqualified name of the symbol, e.g. "bar" (for ns::bar).
bool operator==(const SymbolAndSignals &RHS) const
SymbolInfo::Signals Signals
static void mapping(IO &io, SymbolAndSignals &Symbol)
static void mapping(IO &io, SymbolInfo::Context &Context)
static void enumeration(IO &io, ContextType &value)
static void enumeration(IO &io, SymbolKind &value)