mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
vscode: renmed ArtifactMetadata -> ArtifactReleaseInfo, languageServer -> langServer
This commit is contained in:
parent
9ba801befd
commit
f61134e198
4 changed files with 11 additions and 11 deletions
|
@ -2,7 +2,7 @@ import * as lc from 'vscode-languageclient';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
import { Config } from './config';
|
import { Config } from './config';
|
||||||
import { ensureLanguageServerBinary } from './installation/language_server';
|
import { ensureLangServerBinary } from './installation/lang_server';
|
||||||
import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
|
import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
|
||||||
|
|
||||||
export async function createClient(config: Config): Promise<null | lc.LanguageClient> {
|
export async function createClient(config: Config): Promise<null | lc.LanguageClient> {
|
||||||
|
@ -11,7 +11,7 @@ export async function createClient(config: Config): Promise<null | lc.LanguageCl
|
||||||
// It might be a good idea to test if the uri points to a file.
|
// It might be a good idea to test if the uri points to a file.
|
||||||
const workspaceFolderPath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.';
|
const workspaceFolderPath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath ?? '.';
|
||||||
|
|
||||||
const langServerPath = await ensureLanguageServerBinary(config.langServerBinarySource);
|
const langServerPath = await ensureLangServerBinary(config.langServerBinarySource);
|
||||||
if (!langServerPath) return null;
|
if (!langServerPath) return null;
|
||||||
|
|
||||||
const run: lc.Executable = {
|
const run: lc.Executable = {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import fetch from "node-fetch";
|
import fetch from "node-fetch";
|
||||||
import { GithubRepo, ArtifactMetadata } from "./interfaces";
|
import { GithubRepo, ArtifactReleaseInfo } from "./interfaces";
|
||||||
|
|
||||||
const GITHUB_API_ENDPOINT_URL = "https://api.github.com";
|
const GITHUB_API_ENDPOINT_URL = "https://api.github.com";
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ const GITHUB_API_ENDPOINT_URL = "https://api.github.com";
|
||||||
* Fetches the latest release from GitHub `repo` and returns metadata about
|
* Fetches the latest release from GitHub `repo` and returns metadata about
|
||||||
* `artifactFileName` shipped with this release or `null` if no such artifact was published.
|
* `artifactFileName` shipped with this release or `null` if no such artifact was published.
|
||||||
*/
|
*/
|
||||||
export async function fetchLatestArtifactMetadata(
|
export async function fetchLatestArtifactReleaseInfo(
|
||||||
repo: GithubRepo, artifactFileName: string
|
repo: GithubRepo, artifactFileName: string
|
||||||
): Promise<null | ArtifactMetadata> {
|
): Promise<null | ArtifactReleaseInfo> {
|
||||||
|
|
||||||
const repoOwner = encodeURIComponent(repo.owner);
|
const repoOwner = encodeURIComponent(repo.owner);
|
||||||
const repoName = encodeURIComponent(repo.name);
|
const repoName = encodeURIComponent(repo.name);
|
|
@ -6,7 +6,7 @@ export interface GithubRepo {
|
||||||
/**
|
/**
|
||||||
* Metadata about particular artifact retrieved from GitHub releases.
|
* Metadata about particular artifact retrieved from GitHub releases.
|
||||||
*/
|
*/
|
||||||
export interface ArtifactMetadata {
|
export interface ArtifactReleaseInfo {
|
||||||
releaseName: string;
|
releaseName: string;
|
||||||
downloadUrl: string;
|
downloadUrl: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,13 @@ import { spawnSync } from "child_process";
|
||||||
import { throttle } from "throttle-debounce";
|
import { throttle } from "throttle-debounce";
|
||||||
|
|
||||||
import { BinarySource } from "./interfaces";
|
import { BinarySource } from "./interfaces";
|
||||||
import { fetchLatestArtifactMetadata } from "./fetch_latest_artifact_metadata";
|
import { fetchLatestArtifactReleaseInfo } from "./fetch_latest_artifact_release_info";
|
||||||
import { downloadFile } from "./download_file";
|
import { downloadFile } from "./download_file";
|
||||||
|
|
||||||
export async function downloadLatestLanguageServer(
|
export async function downloadLatestLangServer(
|
||||||
{file: artifactFileName, dir: installationDir, repo}: BinarySource.GithubRelease
|
{file: artifactFileName, dir: installationDir, repo}: BinarySource.GithubRelease
|
||||||
) {
|
) {
|
||||||
const { releaseName, downloadUrl } = (await fetchLatestArtifactMetadata(
|
const { releaseName, downloadUrl } = (await fetchLatestArtifactReleaseInfo(
|
||||||
repo, artifactFileName
|
repo, artifactFileName
|
||||||
))!;
|
))!;
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ export async function downloadLatestLanguageServer(
|
||||||
);
|
);
|
||||||
console.timeEnd("Downloading ra_lsp_server");
|
console.timeEnd("Downloading ra_lsp_server");
|
||||||
}
|
}
|
||||||
export async function ensureLanguageServerBinary(
|
export async function ensureLangServerBinary(
|
||||||
langServerSource: null | BinarySource
|
langServerSource: null | BinarySource
|
||||||
): Promise<null | string> {
|
): Promise<null | string> {
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ export async function ensureLanguageServerBinary(
|
||||||
if (userResponse !== "Download now") return null;
|
if (userResponse !== "Download now") return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await downloadLatestLanguageServer(langServerSource);
|
await downloadLatestLangServer(langServerSource);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
`Failed to download language server from ${langServerSource.repo.name} ` +
|
`Failed to download language server from ${langServerSource.repo.name} ` +
|
Loading…
Reference in a new issue