3696: vscode: more type safety r=matklad a=Veetaha 3698: Consider references when applying postfix completions r=matklad a=SomeoneToIgnore Sometimes my RA debugging workflow breaks because `.dbg` is applied to the variable that is used later in the code. It's safer to consider the refences to avoid this for completions that may trigger the move. 3703: Don't try to enable proposed API's on stable r=matklad a=matklad bors r+ 🤖 Co-authored-by: veetaha <veetaha2@gmail.com> Co-authored-by: Kirill Bulatov <mail4score@gmail.com> Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
@@ -73,10 +73,18 @@
|
||||
"type": "string"
|
||||
},
|
||||
"args": {
|
||||
"type": "array"
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"env": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
".+": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,8 +99,10 @@ export async function createClient(config: Config, serverPath: string): Promise<
|
||||
// Note that while the CallHierarchyFeature is stable the LSP protocol is not.
|
||||
res.registerFeature(new CallHierarchyFeature(res));
|
||||
|
||||
if (config.highlightingSemanticTokens) {
|
||||
res.registerFeature(new SemanticTokensFeature(res));
|
||||
if (config.package.enableProposedApi) {
|
||||
if (config.highlightingSemanticTokens) {
|
||||
res.registerFeature(new SemanticTokensFeature(res));
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
@@ -38,17 +38,11 @@ export class Config {
|
||||
]
|
||||
.map(opt => `${this.rootSection}.${opt}`);
|
||||
|
||||
readonly packageJsonVersion: string = vscode
|
||||
.extensions
|
||||
.getExtension(this.extensionId)!
|
||||
.packageJSON
|
||||
.version;
|
||||
|
||||
readonly releaseTag: string | undefined = vscode
|
||||
.extensions
|
||||
.getExtension(this.extensionId)!
|
||||
.packageJSON
|
||||
.releaseTag ?? undefined;
|
||||
readonly package: {
|
||||
version: string;
|
||||
releaseTag: string | undefined;
|
||||
enableProposedApi: boolean | undefined;
|
||||
} = vscode.extensions.getExtension(this.extensionId)!.packageJSON;
|
||||
|
||||
private cfg!: vscode.WorkspaceConfiguration;
|
||||
|
||||
@@ -62,7 +56,7 @@ export class Config {
|
||||
const enableLogging = this.cfg.get("trace.extension") as boolean;
|
||||
log.setEnabled(enableLogging);
|
||||
log.debug(
|
||||
"Extension version:", this.packageJsonVersion,
|
||||
"Extension version:", this.package.version,
|
||||
"using configuration:", this.cfg
|
||||
);
|
||||
}
|
||||
|
||||
@@ -110,9 +110,9 @@ async function bootstrap(config: Config, state: PersistentState): Promise<string
|
||||
}
|
||||
|
||||
async function bootstrapExtension(config: Config, state: PersistentState): Promise<void> {
|
||||
if (config.releaseTag === undefined) return;
|
||||
if (config.package.releaseTag === undefined) return;
|
||||
if (config.channel === "stable") {
|
||||
if (config.releaseTag === NIGHTLY_TAG) {
|
||||
if (config.package.releaseTag === NIGHTLY_TAG) {
|
||||
vscode.window.showWarningMessage(`You are running a nightly version of rust-analyzer extension.
|
||||
To switch to stable, uninstall the extension and re-install it from the marketplace`);
|
||||
}
|
||||
@@ -185,7 +185,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string
|
||||
}
|
||||
return explicitPath;
|
||||
};
|
||||
if (config.releaseTag === undefined) return "rust-analyzer";
|
||||
if (config.package.releaseTag === undefined) return "rust-analyzer";
|
||||
|
||||
let binaryName: string | undefined = undefined;
|
||||
if (process.arch === "x64" || process.arch === "x32") {
|
||||
@@ -211,21 +211,21 @@ async function getServer(config: Config, state: PersistentState): Promise<string
|
||||
await state.updateServerVersion(undefined);
|
||||
}
|
||||
|
||||
if (state.serverVersion === config.packageJsonVersion) return dest;
|
||||
if (state.serverVersion === config.package.version) return dest;
|
||||
|
||||
if (config.askBeforeDownload) {
|
||||
const userResponse = await vscode.window.showInformationMessage(
|
||||
`Language server version ${config.packageJsonVersion} for rust-analyzer is not installed.`,
|
||||
`Language server version ${config.package.version} for rust-analyzer is not installed.`,
|
||||
"Download now"
|
||||
);
|
||||
if (userResponse !== "Download now") return dest;
|
||||
}
|
||||
|
||||
const release = await fetchRelease(config.releaseTag);
|
||||
const release = await fetchRelease(config.package.releaseTag);
|
||||
const artifact = release.assets.find(artifact => artifact.name === binaryName);
|
||||
assert(!!artifact, `Bad release: ${JSON.stringify(release)}`);
|
||||
|
||||
await download(artifact.browser_download_url, dest, "Downloading rust-analyzer server", { mode: 0o755 });
|
||||
await state.updateServerVersion(config.packageJsonVersion);
|
||||
await state.updateServerVersion(config.package.version);
|
||||
return dest;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user