aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-14 23:05:12 +0000
committerGitHub <[email protected]>2020-02-14 23:05:12 +0000
commit58f4dcf79ecf3b8dcec83d46a27a29340900a0ef (patch)
treee40a833dd72df793cb3d81d298e4c5a2564ff552 /editors
parent9ba801befd70892bf40429512e890389171aa59f (diff)
parent80d5ba68da2785280cf154d5d812915b99fc0e87 (diff)
Merge #3152
3152: vscode: a couple of more intuitive names and shortening languageServer to langServer r=matklad a=Veetaha God, naming is so hard. I'd like to extract this change from upcomming "Download latest language server" command PR. Co-authored-by: Veetaha <[email protected]>
Diffstat (limited to 'editors')
-rw-r--r--editors/code/src/client.ts8
-rw-r--r--editors/code/src/config.ts12
-rw-r--r--editors/code/src/installation/fetch_latest_artifact_release_info.ts (renamed from editors/code/src/installation/fetch_latest_artifact_metadata.ts)6
-rw-r--r--editors/code/src/installation/interfaces.ts2
-rw-r--r--editors/code/src/installation/server.ts (renamed from editors/code/src/installation/language_server.ts)28
5 files changed, 28 insertions, 28 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index dcf9d0c06..12c97be2f 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -2,7 +2,7 @@ import * as lc from 'vscode-languageclient';
2import * as vscode from 'vscode'; 2import * as vscode from 'vscode';
3 3
4import { Config } from './config'; 4import { Config } from './config';
5import { ensureLanguageServerBinary } from './installation/language_server'; 5import { ensureServerBinary } from './installation/server';
6import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; 6import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
7 7
8export async function createClient(config: Config): Promise<null | lc.LanguageClient> { 8export async function createClient(config: Config): Promise<null | lc.LanguageClient> {
@@ -11,11 +11,11 @@ export async function createClient(config: Config): Promise<null | lc.LanguageCl
11 // It might be a good idea to test if the uri points to a file. 11 // It might be a good idea to test if the uri points to a file.
12 const workspaceFolderPath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.'; 12 const workspaceFolderPath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.';
13 13
14 const langServerPath = await ensureLanguageServerBinary(config.langServerBinarySource); 14 const serverPath = await ensureServerBinary(config.serverBinarySource);
15 if (!langServerPath) return null; 15 if (!serverPath) return null;
16 16
17 const run: lc.Executable = { 17 const run: lc.Executable = {
18 command: langServerPath, 18 command: serverPath,
19 options: { cwd: workspaceFolderPath }, 19 options: { cwd: workspaceFolderPath },
20 }; 20 };
21 const serverOptions: lc.ServerOptions = { 21 const serverOptions: lc.ServerOptions = {
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts
index 8cd89e119..7866ed7e1 100644
--- a/editors/code/src/config.ts
+++ b/editors/code/src/config.ts
@@ -68,7 +68,7 @@ export class Config {
68 * `platform` on GitHub releases. (It is also stored under the same name when 68 * `platform` on GitHub releases. (It is also stored under the same name when
69 * downloaded by the extension). 69 * downloaded by the extension).
70 */ 70 */
71 get prebuiltLangServerFileName(): null | string { 71 get prebuiltServerFileName(): null | string {
72 // See possible `arch` values here: 72 // See possible `arch` values here:
73 // https://nodejs.org/api/process.html#process_process_arch 73 // https://nodejs.org/api/process.html#process_process_arch
74 74
@@ -98,17 +98,17 @@ export class Config {
98 } 98 }
99 } 99 }
100 100
101 get langServerBinarySource(): null | BinarySource { 101 get serverBinarySource(): null | BinarySource {
102 const langServerPath = RA_LSP_DEBUG ?? this.cfg.get<null | string>("raLspServerPath"); 102 const serverPath = RA_LSP_DEBUG ?? this.cfg.get<null | string>("raLspServerPath");
103 103
104 if (langServerPath) { 104 if (serverPath) {
105 return { 105 return {
106 type: BinarySource.Type.ExplicitPath, 106 type: BinarySource.Type.ExplicitPath,
107 path: Config.replaceTildeWithHomeDir(langServerPath) 107 path: Config.replaceTildeWithHomeDir(serverPath)
108 }; 108 };
109 } 109 }
110 110
111 const prebuiltBinaryName = this.prebuiltLangServerFileName; 111 const prebuiltBinaryName = this.prebuiltServerFileName;
112 112
113 if (!prebuiltBinaryName) return null; 113 if (!prebuiltBinaryName) return null;
114 114
diff --git a/editors/code/src/installation/fetch_latest_artifact_metadata.ts b/editors/code/src/installation/fetch_latest_artifact_release_info.ts
index 7e3700603..29ee029a7 100644
--- a/editors/code/src/installation/fetch_latest_artifact_metadata.ts
+++ b/editors/code/src/installation/fetch_latest_artifact_release_info.ts
@@ -1,5 +1,5 @@
1import fetch from "node-fetch"; 1import fetch from "node-fetch";
2import { GithubRepo, ArtifactMetadata } from "./interfaces"; 2import { GithubRepo, ArtifactReleaseInfo } from "./interfaces";
3 3
4const GITHUB_API_ENDPOINT_URL = "https://api.github.com"; 4const GITHUB_API_ENDPOINT_URL = "https://api.github.com";
5 5
@@ -7,9 +7,9 @@ const GITHUB_API_ENDPOINT_URL = "https://api.github.com";
7 * Fetches the latest release from GitHub `repo` and returns metadata about 7 * Fetches the latest release from GitHub `repo` and returns metadata about
8 * `artifactFileName` shipped with this release or `null` if no such artifact was published. 8 * `artifactFileName` shipped with this release or `null` if no such artifact was published.
9 */ 9 */
10export async function fetchLatestArtifactMetadata( 10export async function fetchLatestArtifactReleaseInfo(
11 repo: GithubRepo, artifactFileName: string 11 repo: GithubRepo, artifactFileName: string
12): Promise<null | ArtifactMetadata> { 12): Promise<null | ArtifactReleaseInfo> {
13 13
14 const repoOwner = encodeURIComponent(repo.owner); 14 const repoOwner = encodeURIComponent(repo.owner);
15 const repoName = encodeURIComponent(repo.name); 15 const repoName = encodeURIComponent(repo.name);
diff --git a/editors/code/src/installation/interfaces.ts b/editors/code/src/installation/interfaces.ts
index 8039d0b90..93ea577d4 100644
--- a/editors/code/src/installation/interfaces.ts
+++ b/editors/code/src/installation/interfaces.ts
@@ -6,7 +6,7 @@ export interface GithubRepo {
6/** 6/**
7 * Metadata about particular artifact retrieved from GitHub releases. 7 * Metadata about particular artifact retrieved from GitHub releases.
8 */ 8 */
9export interface ArtifactMetadata { 9export interface ArtifactReleaseInfo {
10 releaseName: string; 10 releaseName: string;
11 downloadUrl: string; 11 downloadUrl: string;
12} 12}
diff --git a/editors/code/src/installation/language_server.ts b/editors/code/src/installation/server.ts
index 4797c3f01..406e2299c 100644
--- a/editors/code/src/installation/language_server.ts
+++ b/editors/code/src/installation/server.ts
@@ -7,13 +7,13 @@ import { spawnSync } from "child_process";
7import { throttle } from "throttle-debounce"; 7import { throttle } from "throttle-debounce";
8 8
9import { BinarySource } from "./interfaces"; 9import { BinarySource } from "./interfaces";
10import { fetchLatestArtifactMetadata } from "./fetch_latest_artifact_metadata"; 10import { fetchLatestArtifactReleaseInfo } from "./fetch_latest_artifact_release_info";
11import { downloadFile } from "./download_file"; 11import { downloadFile } from "./download_file";
12 12
13export async function downloadLatestLanguageServer( 13export async function downloadLatestServer(
14 {file: artifactFileName, dir: installationDir, repo}: BinarySource.GithubRelease 14 {file: artifactFileName, dir: installationDir, repo}: BinarySource.GithubRelease
15) { 15) {
16 const { releaseName, downloadUrl } = (await fetchLatestArtifactMetadata( 16 const { releaseName, downloadUrl } = (await fetchLatestArtifactReleaseInfo(
17 repo, artifactFileName 17 repo, artifactFileName
18 ))!; 18 ))!;
19 19
@@ -53,11 +53,11 @@ export async function downloadLatestLanguageServer(
53 ); 53 );
54 console.timeEnd("Downloading ra_lsp_server"); 54 console.timeEnd("Downloading ra_lsp_server");
55} 55}
56export async function ensureLanguageServerBinary( 56export async function ensureServerBinary(
57 langServerSource: null | BinarySource 57 serverSource: null | BinarySource
58): Promise<null | string> { 58): Promise<null | string> {
59 59
60 if (!langServerSource) { 60 if (!serverSource) {
61 vscode.window.showErrorMessage( 61 vscode.window.showErrorMessage(
62 "Unfortunately we don't ship binaries for your platform yet. " + 62 "Unfortunately we don't ship binaries for your platform yet. " +
63 "You need to manually clone rust-analyzer repository and " + 63 "You need to manually clone rust-analyzer repository and " +
@@ -69,21 +69,21 @@ export async function ensureLanguageServerBinary(
69 return null; 69 return null;
70 } 70 }
71 71
72 switch (langServerSource.type) { 72 switch (serverSource.type) {
73 case BinarySource.Type.ExplicitPath: { 73 case BinarySource.Type.ExplicitPath: {
74 if (isBinaryAvailable(langServerSource.path)) { 74 if (isBinaryAvailable(serverSource.path)) {
75 return langServerSource.path; 75 return serverSource.path;
76 } 76 }
77 77
78 vscode.window.showErrorMessage( 78 vscode.window.showErrorMessage(
79 `Unable to run ${langServerSource.path} binary. ` + 79 `Unable to run ${serverSource.path} binary. ` +
80 `To use the pre-built language server, set "rust-analyzer.raLspServerPath" ` + 80 `To use the pre-built language server, set "rust-analyzer.raLspServerPath" ` +
81 "value to `null` or remove it from the settings to use it by default." 81 "value to `null` or remove it from the settings to use it by default."
82 ); 82 );
83 return null; 83 return null;
84 } 84 }
85 case BinarySource.Type.GithubRelease: { 85 case BinarySource.Type.GithubRelease: {
86 const prebuiltBinaryPath = path.join(langServerSource.dir, langServerSource.file); 86 const prebuiltBinaryPath = path.join(serverSource.dir, serverSource.file);
87 87
88 if (isBinaryAvailable(prebuiltBinaryPath)) { 88 if (isBinaryAvailable(prebuiltBinaryPath)) {
89 return prebuiltBinaryPath; 89 return prebuiltBinaryPath;
@@ -97,10 +97,10 @@ export async function ensureLanguageServerBinary(
97 if (userResponse !== "Download now") return null; 97 if (userResponse !== "Download now") return null;
98 98
99 try { 99 try {
100 await downloadLatestLanguageServer(langServerSource); 100 await downloadLatestServer(serverSource);
101 } catch (err) { 101 } catch (err) {
102 vscode.window.showErrorMessage( 102 vscode.window.showErrorMessage(
103 `Failed to download language server from ${langServerSource.repo.name} ` + 103 `Failed to download language server from ${serverSource.repo.name} ` +
104 `GitHub repository: ${err.message}` 104 `GitHub repository: ${err.message}`
105 ); 105 );
106 106
@@ -122,7 +122,7 @@ export async function ensureLanguageServerBinary(
122 122
123 if (!isBinaryAvailable(prebuiltBinaryPath)) assert(false, 123 if (!isBinaryAvailable(prebuiltBinaryPath)) assert(false,
124 `Downloaded language server binary is not functional.` + 124 `Downloaded language server binary is not functional.` +
125 `Downloaded from: ${JSON.stringify(langServerSource)}` 125 `Downloaded from: ${JSON.stringify(serverSource)}`
126 ); 126 );
127 127
128 128