mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SourceKit][SymbolGraph] Add a 'ParentContexts' field the CursorInfo response
When the SymbolGraph json is requested via (key.retrieve_symbol_graph: 1) this adds
a new field in the response that lists all the parent contexts of the symbol under
the cursor with their symbol graph kind and name, and their USR:
key.parent_contexts: [
{
key.kind: "swift.struct",
key.name: "Parent",
key.usr: "s:27cursor_symbol_graph_parents6ParentV"
},
...
]
}
Resolves rdar://problem/73904365
This commit is contained in:
@@ -104,7 +104,8 @@ int symbolgraphgen::
|
||||
printSymbolGraphForDecl(const ValueDecl *D, Type BaseTy,
|
||||
bool InSynthesizedExtension,
|
||||
const SymbolGraphOptions &Options,
|
||||
llvm::raw_ostream &OS) {
|
||||
llvm::raw_ostream &OS,
|
||||
SmallVectorImpl<PathComponent> &ParentContexts) {
|
||||
if (!Symbol::supportsKind(D->getKind()))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
@@ -119,6 +120,11 @@ printSymbolGraphForDecl(const ValueDecl *D, Type BaseTy,
|
||||
: nullptr;
|
||||
|
||||
Symbol MySym(&Graph, D, NTD, BaseTy);
|
||||
|
||||
MySym.getPathComponents(ParentContexts);
|
||||
assert(!ParentContexts.empty() && "doesn't have node for MySym?");
|
||||
ParentContexts.pop_back();
|
||||
|
||||
Graph.recordNode(MySym);
|
||||
Graph.serialize(JOS);
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user