Skip to content

Commit 299382d

Browse files
Veykrilbruno-ortiz
authored andcommitted
WIP: Add lsp-ext scaffold
1 parent 9533644 commit 299382d

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

crates/rust-analyzer/src/main_loop.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ impl GlobalState {
655655
.on_sync_mut::<lsp_ext::ReloadWorkspace>(handlers::handle_workspace_reload)
656656
.on_sync_mut::<lsp_ext::RebuildProcMacros>(handlers::handle_proc_macros_rebuild)
657657
.on_sync_mut::<lsp_ext::MemoryUsage>(handlers::handle_memory_usage)
658+
.on_sync_mut::<lsp_ext::FetchDependencyGraph>(handlers::fetch_dependency_graph)
658659
.on_sync_mut::<lsp_ext::ShuffleCrateGraph>(handlers::handle_shuffle_crate_graph)
659660
.on_sync::<lsp_ext::JoinLines>(handlers::handle_join_lines)
660661
.on_sync::<lsp_ext::OnEnter>(handlers::handle_on_enter)

editors/code/src/dependencies_provider.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import * as fs from "fs";
44
import { CtxInit } from "./ctx";
55
import * as ra from "./lsp_ext";
66
import { FetchDependencyGraphResult } from "./lsp_ext";
7+
import { Ctx } from "./ctx";
8+
import { setFlagsFromString } from "v8";
9+
import * as ra from "./lsp_ext";
710

811

912

@@ -13,9 +16,8 @@ export class RustDependenciesProvider
1316

1417
dependenciesMap: { [id: string]: Dependency | DependencyFile };ctx: CtxInit;
1518

16-
constructor(
17-
private readonly workspaceRoot: string,ctx: CtxInit) {
18-
this.dependenciesMap = {};
19+
constructor(private readonly workspaceRoot: string,ctx: CtxInit) {
20+
this.dependenciesMap = {};
1921
this.ctx = ctx;
2022
}
2123

@@ -78,6 +80,8 @@ export class RustDependenciesProvider
7880
}
7981

8082
private async getRootDependencies(): Promise<Dependency[]> {
83+
const crates = await this.ctx.client.sendRequest(ra.fetchDependencyGraph, {});
84+
8185
const dependenciesResult: FetchDependencyGraphResult = await this.ctx.client.sendRequest(ra.fetchDependencyGraph, {});
8286
const crates = dependenciesResult.crates;
8387
const deps = crates.map((crate) => {

editors/code/src/lsp_ext.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@ export const fetchDependencyGraph = new lc.RequestType<
8686
void
8787
>("rust-analyzer/fetchDependencyGraph");
8888

89+
export interface FetchDependencyGraphParams {}
90+
91+
export interface FetchDependencyGraphResult {
92+
crates: {
93+
name: string;
94+
version: string;
95+
path: string;
96+
}[];
97+
}
98+
99+
export const fetchDependencyGraph = new lc.RequestType<
100+
FetchDependencyGraphParams,
101+
FetchDependencyGraphResult,
102+
void
103+
>("rust-analyzer/fetchDependencyGraph");
104+
89105
export type ExpandMacroParams = {
90106
textDocument: lc.TextDocumentIdentifier;
91107
position: lc.Position;

0 commit comments

Comments
 (0)