From f61134e1980580050f34701db3441081a5519e4c Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 15 Feb 2020 00:15:06 +0200 Subject: [PATCH 1/2] vscode: renmed ArtifactMetadata -> ArtifactReleaseInfo, languageServer -> langServer --- editors/code/src/client.ts | 4 ++-- ...tadata.ts => fetch_latest_artifact_release_info.ts} | 6 +++--- editors/code/src/installation/interfaces.ts | 2 +- .../{language_server.ts => lang_server.ts} | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) rename editors/code/src/installation/{fetch_latest_artifact_metadata.ts => fetch_latest_artifact_release_info.ts} (89%) rename editors/code/src/installation/{language_server.ts => lang_server.ts} (95%) diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index dcf9d0c0673..33d9b66dfbd 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -2,7 +2,7 @@ import * as lc from 'vscode-languageclient'; import * as vscode from 'vscode'; import { Config } from './config'; -import { ensureLanguageServerBinary } from './installation/language_server'; +import { ensureLangServerBinary } from './installation/lang_server'; import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; export async function createClient(config: Config): Promise { @@ -11,7 +11,7 @@ export async function createClient(config: Config): Promise { +): Promise { const repoOwner = encodeURIComponent(repo.owner); const repoName = encodeURIComponent(repo.name); diff --git a/editors/code/src/installation/interfaces.ts b/editors/code/src/installation/interfaces.ts index 8039d0b90f6..93ea577d4a6 100644 --- a/editors/code/src/installation/interfaces.ts +++ b/editors/code/src/installation/interfaces.ts @@ -6,7 +6,7 @@ export interface GithubRepo { /** * Metadata about particular artifact retrieved from GitHub releases. */ -export interface ArtifactMetadata { +export interface ArtifactReleaseInfo { releaseName: string; downloadUrl: string; } diff --git a/editors/code/src/installation/language_server.ts b/editors/code/src/installation/lang_server.ts similarity index 95% rename from editors/code/src/installation/language_server.ts rename to editors/code/src/installation/lang_server.ts index 4797c3f01ad..ccb936bf5ff 100644 --- a/editors/code/src/installation/language_server.ts +++ b/editors/code/src/installation/lang_server.ts @@ -7,13 +7,13 @@ import { spawnSync } from "child_process"; import { throttle } from "throttle-debounce"; import { BinarySource } from "./interfaces"; -import { fetchLatestArtifactMetadata } from "./fetch_latest_artifact_metadata"; +import { fetchLatestArtifactReleaseInfo } from "./fetch_latest_artifact_release_info"; import { downloadFile } from "./download_file"; -export async function downloadLatestLanguageServer( +export async function downloadLatestLangServer( {file: artifactFileName, dir: installationDir, repo}: BinarySource.GithubRelease ) { - const { releaseName, downloadUrl } = (await fetchLatestArtifactMetadata( + const { releaseName, downloadUrl } = (await fetchLatestArtifactReleaseInfo( repo, artifactFileName ))!; @@ -53,7 +53,7 @@ export async function downloadLatestLanguageServer( ); console.timeEnd("Downloading ra_lsp_server"); } -export async function ensureLanguageServerBinary( +export async function ensureLangServerBinary( langServerSource: null | BinarySource ): Promise { @@ -97,7 +97,7 @@ export async function ensureLanguageServerBinary( if (userResponse !== "Download now") return null; try { - await downloadLatestLanguageServer(langServerSource); + await downloadLatestLangServer(langServerSource); } catch (err) { vscode.window.showErrorMessage( `Failed to download language server from ${langServerSource.repo.name} ` + From 80d5ba68da2785280cf154d5d812915b99fc0e87 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 15 Feb 2020 00:42:32 +0200 Subject: [PATCH 2/2] vscode: renamed langServer to server --- editors/code/src/client.ts | 8 +++---- editors/code/src/config.ts | 12 +++++----- .../{lang_server.ts => server.ts} | 24 +++++++++---------- 3 files changed, 22 insertions(+), 22 deletions(-) rename editors/code/src/installation/{lang_server.ts => server.ts} (87%) diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 33d9b66dfbd..12c97be2fee 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -2,7 +2,7 @@ import * as lc from 'vscode-languageclient'; import * as vscode from 'vscode'; import { Config } from './config'; -import { ensureLangServerBinary } from './installation/lang_server'; +import { ensureServerBinary } from './installation/server'; import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; export async function createClient(config: Config): Promise { @@ -11,11 +11,11 @@ export async function createClient(config: Config): Promise("raLspServerPath"); + get serverBinarySource(): null | BinarySource { + const serverPath = RA_LSP_DEBUG ?? this.cfg.get("raLspServerPath"); - if (langServerPath) { + if (serverPath) { return { type: BinarySource.Type.ExplicitPath, - path: Config.replaceTildeWithHomeDir(langServerPath) + path: Config.replaceTildeWithHomeDir(serverPath) }; } - const prebuiltBinaryName = this.prebuiltLangServerFileName; + const prebuiltBinaryName = this.prebuiltServerFileName; if (!prebuiltBinaryName) return null; diff --git a/editors/code/src/installation/lang_server.ts b/editors/code/src/installation/server.ts similarity index 87% rename from editors/code/src/installation/lang_server.ts rename to editors/code/src/installation/server.ts index ccb936bf5ff..406e2299c3b 100644 --- a/editors/code/src/installation/lang_server.ts +++ b/editors/code/src/installation/server.ts @@ -10,7 +10,7 @@ import { BinarySource } from "./interfaces"; import { fetchLatestArtifactReleaseInfo } from "./fetch_latest_artifact_release_info"; import { downloadFile } from "./download_file"; -export async function downloadLatestLangServer( +export async function downloadLatestServer( {file: artifactFileName, dir: installationDir, repo}: BinarySource.GithubRelease ) { const { releaseName, downloadUrl } = (await fetchLatestArtifactReleaseInfo( @@ -53,11 +53,11 @@ export async function downloadLatestLangServer( ); console.timeEnd("Downloading ra_lsp_server"); } -export async function ensureLangServerBinary( - langServerSource: null | BinarySource +export async function ensureServerBinary( + serverSource: null | BinarySource ): Promise { - if (!langServerSource) { + if (!serverSource) { vscode.window.showErrorMessage( "Unfortunately we don't ship binaries for your platform yet. " + "You need to manually clone rust-analyzer repository and " + @@ -69,21 +69,21 @@ export async function ensureLangServerBinary( return null; } - switch (langServerSource.type) { + switch (serverSource.type) { case BinarySource.Type.ExplicitPath: { - if (isBinaryAvailable(langServerSource.path)) { - return langServerSource.path; + if (isBinaryAvailable(serverSource.path)) { + return serverSource.path; } vscode.window.showErrorMessage( - `Unable to run ${langServerSource.path} binary. ` + + `Unable to run ${serverSource.path} binary. ` + `To use the pre-built language server, set "rust-analyzer.raLspServerPath" ` + "value to `null` or remove it from the settings to use it by default." ); return null; } case BinarySource.Type.GithubRelease: { - const prebuiltBinaryPath = path.join(langServerSource.dir, langServerSource.file); + const prebuiltBinaryPath = path.join(serverSource.dir, serverSource.file); if (isBinaryAvailable(prebuiltBinaryPath)) { return prebuiltBinaryPath; @@ -97,10 +97,10 @@ export async function ensureLangServerBinary( if (userResponse !== "Download now") return null; try { - await downloadLatestLangServer(langServerSource); + await downloadLatestServer(serverSource); } catch (err) { vscode.window.showErrorMessage( - `Failed to download language server from ${langServerSource.repo.name} ` + + `Failed to download language server from ${serverSource.repo.name} ` + `GitHub repository: ${err.message}` ); @@ -122,7 +122,7 @@ export async function ensureLangServerBinary( if (!isBinaryAvailable(prebuiltBinaryPath)) assert(false, `Downloaded language server binary is not functional.` + - `Downloaded from: ${JSON.stringify(langServerSource)}` + `Downloaded from: ${JSON.stringify(serverSource)}` );