Skip to content

[SymbolGraph][CursorInfo] Add option to SourceKit's CursorInfo request to include the SymbolGraph JSON #34934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 12, 2020

Conversation

nathawes
Copy link
Contributor

@nathawes nathawes commented Dec 3, 2020

Adds a new key.retrieve_symbol_graph option to the request. When set to 1 the JSON for a SymbolGraph containing a single node corresponding to the symbol at the cursor position will be included in the response under key.symbol_graph.

This extends the SymbolGraph with a new entry point to get a graph for a single symbol, and to additionally support type substitution to match the existing CursorInfo behavior (e.g. so that when invoked on first in Array<Int>().first, the type is reported as Int? rather than Element?).

Resolves rdar://problem/70551509

@nathawes
Copy link
Contributor Author

nathawes commented Dec 3, 2020

@swift-ci Please Build Toolchain macOS Platform

@swift-ci
Copy link
Contributor

swift-ci commented Dec 3, 2020

macOS Toolchain
Download Toolchain
Git Sha - cee3e5af433d8008809e373d16fbcdf0aa4eb766

Install command
tar -zxf swift-PR-34934-801-osx.tar.gz --directory ~/

@nathawes
Copy link
Contributor Author

nathawes commented Dec 4, 2020

@swift-ci Please Build Toolchain macOS Platform

@swift-ci
Copy link
Contributor

swift-ci commented Dec 4, 2020

macOS Toolchain
Download Toolchain
Git Sha - 03b4b5d6c8365404534c21b599c7493a65a703f6

Install command
tar -zxf swift-PR-34934-803-osx.tar.gz --directory ~/

@nathawes nathawes force-pushed the cursor-info-symbol-graph branch from 03b4b5d to f955085 Compare December 10, 2020 21:43
@nathawes nathawes changed the title [Draft][SourceKit] Add option to include symbol graph json in Cursor info response [SymbolGraph][CursorInfo] Add option to SourceKit's CursorInfo request to include the SymbolGraph JSON Dec 10, 2020
@nathawes
Copy link
Contributor Author

@swift-ci please test

@nathawes
Copy link
Contributor Author

@swift-ci Please Build Toolchain macOS Platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - f955085f69ac7fe4b9f290a4329c7365696a3579

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - f955085f69ac7fe4b9f290a4329c7365696a3579

@nathawes nathawes force-pushed the cursor-info-symbol-graph branch 2 times, most recently from 5048823 to 1b21814 Compare December 10, 2020 23:32
Comment on lines 505 to 523
StringRef ModuleName = M.getNameStr();
SmallVector<Identifier, 4> Bystanders;

// If the decl is from a cross-import overlay module, report the overlay's
// declaring module as the owning module.
if (auto *Declaring = M.getDeclaringModuleIfCrossImportOverlay()) {
ModuleName = Declaring->getNameStr();
M.getRequiredBystandersIfCrossImportOverlay(Declaring, Bystanders);
}

OS.attribute("name", ModuleName);
if (!Bystanders.empty()) {
OS.attributeArray("bystanders", [&](){
for (auto &Id: Bystanders)
OS.value(Id.str());
});
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part will go away once #34922 lands.

@nathawes
Copy link
Contributor Author

@swift-ci please test

@nathawes
Copy link
Contributor Author

@swift-ci Please Build Toolchain macOS Platform

@nathawes nathawes marked this pull request as ready for review December 11, 2020 00:04
@nathawes nathawes requested a review from akyrtzi December 11, 2020 00:04
@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 1b21814976590aa4f68ce9b6b83db0e65a0612ef

@swift-ci
Copy link
Contributor

macOS Toolchain
Download Toolchain
Git Sha - 1b21814976590aa4f68ce9b6b83db0e65a0612ef

Install command
tar -zxf swift-PR-34934-805-osx.tar.gz --directory ~/

@nathawes nathawes force-pushed the cursor-info-symbol-graph branch from 1b21814 to 146fa18 Compare December 11, 2020 04:29
@nathawes
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 146fa1880a52308cc5aa86621d778c1dd6c00378

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 146fa1880a52308cc5aa86621d778c1dd6c00378

@nathawes
Copy link
Contributor Author

@swift-ci please test OS X Platform

@nathawes
Copy link
Contributor Author

@swift-ci please test Linux Platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 146fa1880a52308cc5aa86621d778c1dd6c00378

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 146fa1880a52308cc5aa86621d778c1dd6c00378

Copy link
Contributor

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symbol graph stuff looks good! One little nit in the new entry point, otherwise i think this is nice.

@nathawes nathawes force-pushed the cursor-info-symbol-graph branch from 146fa18 to ba47a58 Compare December 12, 2020 04:34
Nathan Hawes added 3 commits December 12, 2020 14:38
…t to include the SymbolGraph JSON

Adds a new 'key.retrieve_symbol_graph' option to the request. When set to 1 it
includes the JSON for a SymbolGraph containing a single node for the symbol at
the requested position.

This also extends the SymbolGraph library with a new entry point to get a graph
for a single symbol, and to additionally support type substitution to match the
existing CursorInfo behavior (e.g. so that when invoked on `first` in
`Array<Int>().first`, the type is given as `Int?` rather than `Element?`).

Resolves rdar://problem/70551509
…symbol_graph_objc.swift

It requires objc interop.
…cl entrypoint.

Change it to use EXIT_SUCCESS/FAILURE rather than a bool to match
emitSymbolGraphForModule.
@nathawes nathawes force-pushed the cursor-info-symbol-graph branch from ba47a58 to 968504d Compare December 12, 2020 04:49
@nathawes
Copy link
Contributor Author

@swift-ci please test

@nathawes
Copy link
Contributor Author

nathawes commented Dec 12, 2020

@akyrtzi I'm going to go ahead and merge this. If you have time to take a look still I'll address any comments you have in a follow-up PR.

@nathawes nathawes merged commit 632dfcf into swiftlang:main Dec 12, 2020
@nathawes nathawes deleted the cursor-info-symbol-graph branch December 12, 2020 08:37
@nathawes
Copy link
Contributor Author

@swift-ci Please Build Toolchain macOS Platform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants