about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2022-07-17 18:05:55 +0200
committerBruno Ortiz <brunortiz11@gmail.com>2023-05-02 10:56:13 -0300
commit299382dacd53a4a19728d9e125cd490b1077c985 (patch)
treecf0164ba6c364ab33efe82a466d5cd25a58ec137
parent9533644ccfe9cbb2ded5bdd45c61dd30bcbab720 (diff)
downloadrust-299382dacd53a4a19728d9e125cd490b1077c985.tar.gz
rust-299382dacd53a4a19728d9e125cd490b1077c985.zip
WIP: Add lsp-ext scaffold
-rw-r--r--crates/rust-analyzer/src/main_loop.rs1
-rw-r--r--editors/code/src/dependencies_provider.ts10
-rw-r--r--editors/code/src/lsp_ext.ts16
3 files changed, 24 insertions, 3 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 7a81a18f4af..5d3aca29b53 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -655,6 +655,7 @@ impl GlobalState {
             .on_sync_mut::<lsp_ext::ReloadWorkspace>(handlers::handle_workspace_reload)
             .on_sync_mut::<lsp_ext::RebuildProcMacros>(handlers::handle_proc_macros_rebuild)
             .on_sync_mut::<lsp_ext::MemoryUsage>(handlers::handle_memory_usage)
+            .on_sync_mut::<lsp_ext::FetchDependencyGraph>(handlers::fetch_dependency_graph)
             .on_sync_mut::<lsp_ext::ShuffleCrateGraph>(handlers::handle_shuffle_crate_graph)
             .on_sync::<lsp_ext::JoinLines>(handlers::handle_join_lines)
             .on_sync::<lsp_ext::OnEnter>(handlers::handle_on_enter)
diff --git a/editors/code/src/dependencies_provider.ts b/editors/code/src/dependencies_provider.ts
index 18a96be1248..f2838af6e06 100644
--- a/editors/code/src/dependencies_provider.ts
+++ b/editors/code/src/dependencies_provider.ts
@@ -4,6 +4,9 @@ import * as fs from "fs";
 import { CtxInit } from "./ctx";
 import * as ra from "./lsp_ext";
 import { FetchDependencyGraphResult } from "./lsp_ext";
+import { Ctx } from "./ctx";
+import { setFlagsFromString } from "v8";
+import * as ra from "./lsp_ext";
 
 
 
@@ -13,9 +16,8 @@ export class RustDependenciesProvider
 
     dependenciesMap: { [id: string]: Dependency | DependencyFile };ctx: CtxInit;
 
-    constructor(
-        private readonly workspaceRoot: string,ctx: CtxInit) {
-    this.dependenciesMap = {};
+    constructor(private readonly workspaceRoot: string,ctx: CtxInit) {
+        this.dependenciesMap = {};
         this.ctx = ctx;
     }
 
@@ -78,6 +80,8 @@ export class RustDependenciesProvider
     }
 
     private async getRootDependencies(): Promise<Dependency[]> {
+        const crates = await this.ctx.client.sendRequest(ra.fetchDependencyGraph, {});
+
         const dependenciesResult: FetchDependencyGraphResult = await this.ctx.client.sendRequest(ra.fetchDependencyGraph, {});
         const crates = dependenciesResult.crates;
         const deps = crates.map((crate) => {
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts
index 1a887b37201..f066a1c6548 100644
--- a/editors/code/src/lsp_ext.ts
+++ b/editors/code/src/lsp_ext.ts
@@ -86,6 +86,22 @@ export const fetchDependencyGraph = new lc.RequestType<
     void
 >("rust-analyzer/fetchDependencyGraph");
 
+export interface FetchDependencyGraphParams {}
+
+export interface FetchDependencyGraphResult {
+    crates: {
+        name: string;
+        version: string;
+        path: string;
+    }[];
+}
+
+export const fetchDependencyGraph = new lc.RequestType<
+    FetchDependencyGraphParams,
+    FetchDependencyGraphResult,
+    void
+>("rust-analyzer/fetchDependencyGraph");
+
 export type ExpandMacroParams = {
     textDocument: lc.TextDocumentIdentifier;
     position: lc.Position;