From 70a051e6877064dca71caa65f7b21ad2a7eb419a Mon Sep 17 00:00:00 2001 From: Heyward Fann Date: Fri, 2 Jul 2021 10:09:39 +0800 Subject: [PATCH] feat: rust-analyzer.viewFullCrateGraph --- README.md | 1 + package.json | 5 +++++ src/commands.ts | 9 ++++++++- src/index.ts | 1 + src/lsp_ext.ts | 6 +++++- 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b73b5edb..aec714f1 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ You can use these commands by `:CocCommand XYZ`. | 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 | +| rust-analyzer.viewFullCrateGraph | View Crate Graph (Full) | ## Highlight Group diff --git a/package.json b/package.json index 32f609d5..38431dfa 100644 --- a/package.json +++ b/package.json @@ -703,6 +703,11 @@ "title": "View Crate Graph", "category": "Rust Analyzer" }, + { + "command": "rust-analyzer.viewFullCrateGraph", + "title": "View Crate Graph (Full)", + "category": "Rust Analyzer" + }, { "command": "rust-analyzer.echoRunCommandLine", "title": "Echo Run Command Line", diff --git a/src/commands.ts b/src/commands.ts index dc751398..50c03c4d 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -657,7 +657,14 @@ export function moveItemDown(ctx: Ctx): Cmd { export function viewCrateGraph(ctx: Ctx): Cmd { return async () => { - const svg = await ctx.client.sendRequest(ra.viewCrateGraph); + const svg = await ctx.client.sendRequest(ra.viewCrateGraph, { full: false }); + window.echoLines([svg]); + }; +} + +export function viewFullCrateGraph(ctx: Ctx): Cmd { + return async () => { + const svg = await ctx.client.sendRequest(ra.viewCrateGraph, { full: true }); window.echoLines([svg]); }; } diff --git a/src/index.ts b/src/index.ts index db27c01d..3cb7116e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -67,6 +67,7 @@ export async function activate(context: ExtensionContext): Promise { ctx.registerCommand('serverVersion', cmds.serverVersion); ctx.registerCommand('analyzerStatus', cmds.analyzerStatus); ctx.registerCommand('viewCrateGraph', cmds.viewCrateGraph); + ctx.registerCommand('viewFullCrateGraph', cmds.viewFullCrateGraph); ctx.registerCommand('reloadWorkspace', cmds.reloadWorkspace); ctx.registerCommand('toggleInlayHints', cmds.toggleInlayHints); ctx.registerCommand('echoRunCommandLine', cmds.echoRunCommandLine); diff --git a/src/lsp_ext.ts b/src/lsp_ext.ts index 61499d21..2905f32e 100644 --- a/src/lsp_ext.ts +++ b/src/lsp_ext.ts @@ -33,7 +33,11 @@ export interface ViewItemTreeParams { export const viewItemTree = new lc.RequestType('rust-analyzer/viewItemTree'); -export const viewCrateGraph = new lc.RequestType0('rust-analyzer/viewCrateGraph'); +export interface ViewCrateGraphParams { + full: boolean; +} + +export const viewCrateGraph = new lc.RequestType('rust-analyzer/viewCrateGraph'); export interface ExpandMacroParams { textDocument: lc.TextDocumentIdentifier;