Skip to content

Commit be4977d

Browse files
committed
Don't try to enable proposed API's on stable
1 parent f9494f1 commit be4977d

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

editors/code/src/client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ export async function createClient(config: Config, serverPath: string): Promise<
9999
// Note that while the CallHierarchyFeature is stable the LSP protocol is not.
100100
res.registerFeature(new CallHierarchyFeature(res));
101101

102-
if (config.highlightingSemanticTokens) {
103-
res.registerFeature(new SemanticTokensFeature(res));
102+
if (config.package.enableProposedApi) {
103+
if (config.highlightingSemanticTokens) {
104+
res.registerFeature(new SemanticTokensFeature(res));
105+
}
104106
}
105107

106108
return res;

editors/code/src/config.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,11 @@ export class Config {
3838
]
3939
.map(opt => `${this.rootSection}.${opt}`);
4040

41-
readonly packageJsonVersion: string = vscode
42-
.extensions
43-
.getExtension(this.extensionId)!
44-
.packageJSON
45-
.version;
46-
47-
readonly releaseTag: string | undefined = vscode
48-
.extensions
49-
.getExtension(this.extensionId)!
50-
.packageJSON
51-
.releaseTag ?? undefined;
41+
readonly package: {
42+
version: string;
43+
releaseTag: string | undefined;
44+
enableProposedApi: boolean | undefined;
45+
} = vscode.extensions.getExtension(this.extensionId)!.packageJSON;
5246

5347
private cfg!: vscode.WorkspaceConfiguration;
5448

@@ -62,7 +56,7 @@ export class Config {
6256
const enableLogging = this.cfg.get("trace.extension") as boolean;
6357
log.setEnabled(enableLogging);
6458
log.debug(
65-
"Extension version:", this.packageJsonVersion,
59+
"Extension version:", this.package.version,
6660
"using configuration:", this.cfg
6761
);
6862
}

editors/code/src/main.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ async function bootstrap(config: Config, state: PersistentState): Promise<string
110110
}
111111

112112
async function bootstrapExtension(config: Config, state: PersistentState): Promise<void> {
113-
if (config.releaseTag === undefined) return;
113+
if (config.package.releaseTag === undefined) return;
114114
if (config.channel === "stable") {
115-
if (config.releaseTag === NIGHTLY_TAG) {
115+
if (config.package.releaseTag === NIGHTLY_TAG) {
116116
vscode.window.showWarningMessage(`You are running a nightly version of rust-analyzer extension.
117117
To switch to stable, uninstall the extension and re-install it from the marketplace`);
118118
}
@@ -185,7 +185,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string
185185
}
186186
return explicitPath;
187187
};
188-
if (config.releaseTag === undefined) return "rust-analyzer";
188+
if (config.package.releaseTag === undefined) return "rust-analyzer";
189189

190190
let binaryName: string | undefined = undefined;
191191
if (process.arch === "x64" || process.arch === "x32") {
@@ -211,21 +211,21 @@ async function getServer(config: Config, state: PersistentState): Promise<string
211211
await state.updateServerVersion(undefined);
212212
}
213213

214-
if (state.serverVersion === config.packageJsonVersion) return dest;
214+
if (state.serverVersion === config.package.version) return dest;
215215

216216
if (config.askBeforeDownload) {
217217
const userResponse = await vscode.window.showInformationMessage(
218-
`Language server version ${config.packageJsonVersion} for rust-analyzer is not installed.`,
218+
`Language server version ${config.package.version} for rust-analyzer is not installed.`,
219219
"Download now"
220220
);
221221
if (userResponse !== "Download now") return dest;
222222
}
223223

224-
const release = await fetchRelease(config.releaseTag);
224+
const release = await fetchRelease(config.package.releaseTag);
225225
const artifact = release.assets.find(artifact => artifact.name === binaryName);
226226
assert(!!artifact, `Bad release: ${JSON.stringify(release)}`);
227227

228228
await download(artifact.browser_download_url, dest, "Downloading rust-analyzer server", { mode: 0o755 });
229-
await state.updateServerVersion(config.packageJsonVersion);
229+
await state.updateServerVersion(config.package.version);
230230
return dest;
231231
}

0 commit comments

Comments
 (0)