Skip to content

Commit

Permalink
feat: add rust-analyzer.viewCrateGraph
Browse files Browse the repository at this point in the history
  • Loading branch information
fannheyward committed May 12, 2021
1 parent c59b619 commit 198bf44
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 37 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ You can use these commands by `:CocCommand XYZ`.
| rust-analyzer.toggleInlayHints | Toggle inlay hints on/off |
| rust-analyzer.upgrade | Download latest `rust-analyzer` from [GitHub release](https://github.com/rust-analyzer/rust-analyzer/releases) |
| rust-analyzer.viewHir | View Hir |
| rust-analyzer.viewCrateGraph | View Crate Graph |

## Highlight Group

Expand Down
12 changes: 9 additions & 3 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export function run(ctx: Ctx): Cmd {
const runnable = await fetchRunnable(ctx);
if (!runnable) return;

await (runSingle(ctx)(runnable));
await runSingle(ctx)(runnable);
};
}

Expand All @@ -236,7 +236,7 @@ export function debug(ctx: Ctx): Cmd {
const runnable = await fetchRunnable(ctx);
if (!runnable) return;

await (debugSingle(ctx)(runnable));
await debugSingle(ctx)(runnable);
};
}

Expand Down Expand Up @@ -634,7 +634,7 @@ function moveItem(ctx: Ctx, direction: ra.Direction): Cmd {
if (!range) range = Range.create(position, position);
const params: ra.MoveItemParams = {
direction,
textDocument: { uri: document.uri},
textDocument: { uri: document.uri },
range,
};
const edits = await ctx.client.sendRequest(ra.moveItem, params);
Expand All @@ -655,3 +655,9 @@ export function moveItemDown(ctx: Ctx): Cmd {
return moveItem(ctx, ra.Direction.Down);
}

export function viewCrateGraph(ctx: Ctx): Cmd {
return async () => {
const svg = await ctx.client.sendRequest(ra.viewCrateGraph);
window.echoLines([svg]);
};
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
ctx.registerCommand('openCargoToml', cmds.openCargoToml);
ctx.registerCommand('serverVersion', cmds.serverVersion);
ctx.registerCommand('analyzerStatus', cmds.analyzerStatus);
ctx.registerCommand('viewCrateGraph', cmds.viewCrateGraph);
ctx.registerCommand('reloadWorkspace', cmds.reloadWorkspace);
ctx.registerCommand('toggleInlayHints', cmds.toggleInlayHints);
ctx.registerCommand('echoRunCommandLine', cmds.echoRunCommandLine);
Expand Down
2 changes: 2 additions & 0 deletions src/lsp_ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export const syntaxTree = new lc.RequestType<SyntaxTreeParams, string, void>('ru

export const viewHir = new lc.RequestType<lc.TextDocumentPositionParams, string, void>('rust-analyzer/viewHir');

export const viewCrateGraph = new lc.RequestType0<string, void>('rust-analyzer/viewCrateGraph');

export interface ExpandMacroParams {
textDocument: lc.TextDocumentIdentifier;
position: lc.Position;
Expand Down
34 changes: 0 additions & 34 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,6 @@
"@typescript-eslint/typescript-estree" "4.23.0"
debug "^4.1.1"

"@typescript-eslint/scope-manager@4.22.1":
version "4.22.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.22.1.tgz#5bb357f94f9cd8b94e6be43dd637eb73b8f355b4"
integrity sha512-d5bAiPBiessSmNi8Amq/RuLslvcumxLmyhf1/Xa9IuaoFJ0YtshlJKxhlbY7l2JdEk3wS0EnmnfeJWSvADOe0g==
dependencies:
"@typescript-eslint/types" "4.22.1"
"@typescript-eslint/visitor-keys" "4.22.1"

"@typescript-eslint/scope-manager@4.23.0":
version "4.23.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.23.0.tgz#8792ef7eacac122e2ec8fa2d30a59b8d9a1f1ce4"
Expand All @@ -139,29 +131,11 @@
"@typescript-eslint/types" "4.23.0"
"@typescript-eslint/visitor-keys" "4.23.0"

"@typescript-eslint/types@4.22.1":
version "4.22.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.22.1.tgz#bf99c6cec0b4a23d53a61894816927f2adad856a"
integrity sha512-2HTkbkdAeI3OOcWbqA8hWf/7z9c6gkmnWNGz0dKSLYLWywUlkOAQ2XcjhlKLj5xBFDf8FgAOF5aQbnLRvgNbCw==

"@typescript-eslint/types@4.23.0":
version "4.23.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.23.0.tgz#da1654c8a5332f4d1645b2d9a1c64193cae3aa3b"
integrity sha512-oqkNWyG2SLS7uTWLZf6Sr7Dm02gA5yxiz1RP87tvsmDsguVATdpVguHr4HoGOcFOpCvx9vtCSCyQUGfzq28YCw==

"@typescript-eslint/typescript-estree@4.22.1":
version "4.22.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.22.1.tgz#dca379eead8cdfd4edc04805e83af6d148c164f9"
integrity sha512-p3We0pAPacT+onSGM+sPR+M9CblVqdA9F1JEdIqRVlxK5Qth4ochXQgIyb9daBomyQKAXbygxp1aXQRV0GC79A==
dependencies:
"@typescript-eslint/types" "4.22.1"
"@typescript-eslint/visitor-keys" "4.22.1"
debug "^4.1.1"
globby "^11.0.1"
is-glob "^4.0.1"
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/typescript-estree@4.23.0":
version "4.23.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.23.0.tgz#0753b292097523852428a6f5a1aa8ccc1aae6cd9"
Expand All @@ -175,14 +149,6 @@
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/visitor-keys@4.22.1":
version "4.22.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.22.1.tgz#6045ae25a11662c671f90b3a403d682dfca0b7a6"
integrity sha512-WPkOrIRm+WCLZxXQHCi+WG8T2MMTUFR70rWjdWYddLT7cEfb2P4a3O/J2U1FBVsSFTocXLCoXWY6MZGejeStvQ==
dependencies:
"@typescript-eslint/types" "4.22.1"
eslint-visitor-keys "^2.0.0"

"@typescript-eslint/visitor-keys@4.23.0":
version "4.23.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.23.0.tgz#7215cc977bd3b4ef22467b9023594e32f9e4e455"
Expand Down

0 comments on commit 198bf44

Please sign in to comment.