diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2022-07-17 18:05:55 +0200 |
|---|---|---|
| committer | Bruno Ortiz <brunortiz11@gmail.com> | 2023-05-02 10:52:33 -0300 |
| commit | 1201b156d839ac5b5cc7bca1ea1c1f0cf6fbf6a9 (patch) | |
| tree | d64ab1169218c260ee18829c720fee9fc9eadc91 /editors/code | |
| parent | 16cba19ff3324c4703bf861b96af97bc622e1d6a (diff) | |
| download | rust-1201b156d839ac5b5cc7bca1ea1c1f0cf6fbf6a9.tar.gz rust-1201b156d839ac5b5cc7bca1ea1c1f0cf6fbf6a9.zip | |
WIP: Add lsp-ext scaffold
Diffstat (limited to 'editors/code')
| -rw-r--r-- | editors/code/src/dependencies_provider.ts | 9 | ||||
| -rw-r--r-- | editors/code/src/lsp_ext.ts | 16 |
2 files changed, 24 insertions, 1 deletions
diff --git a/editors/code/src/dependencies_provider.ts b/editors/code/src/dependencies_provider.ts index 777cb0d33a7..48d51523e86 100644 --- a/editors/code/src/dependencies_provider.ts +++ b/editors/code/src/dependencies_provider.ts @@ -3,6 +3,9 @@ import * as fspath from "path"; import * as fs from "fs"; import * as os from "os"; import { activeToolchain, Cargo, Crate, getRustcVersion } from "./toolchain"; +import { Ctx } from "./ctx"; +import { setFlagsFromString } from "v8"; +import * as ra from "./lsp_ext"; const debugOutput = vscode.window.createOutputChannel("Debug"); @@ -11,10 +14,12 @@ export class RustDependenciesProvider { cargo: Cargo; dependenciesMap: { [id: string]: Dependency | DependencyFile }; + ctx: Ctx; - constructor(private readonly workspaceRoot: string) { + constructor(private readonly workspaceRoot: string, ctx: Ctx) { this.cargo = new Cargo(this.workspaceRoot || ".", debugOutput); this.dependenciesMap = {}; + this.ctx = ctx; } private _onDidChangeTreeData: vscode.EventEmitter< @@ -76,6 +81,8 @@ export class RustDependenciesProvider } private async getRootDependencies(): Promise<Dependency[]> { + const crates = await this.ctx.client.sendRequest(ra.fetchDependencyGraph, {}); + const registryDir = fspath.join(os.homedir(), ".cargo", "registry", "src"); const basePath = fspath.join(registryDir, fs.readdirSync(registryDir)[0]); const deps = await this.getDepsInCartoTree(basePath); diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index 82955acf25e..1a887b37201 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts @@ -70,6 +70,22 @@ export const viewItemTree = new lc.RequestType<ViewItemTreeParams, string, void> export type AnalyzerStatusParams = { textDocument?: lc.TextDocumentIdentifier }; +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; |
