diff options
author | Zac Pullar-Strecker <[email protected]> | 2020-08-24 10:19:53 +0100 |
---|---|---|
committer | Zac Pullar-Strecker <[email protected]> | 2020-08-24 10:20:13 +0100 |
commit | 7bbca7a1b3f9293d2f5cc5745199bc5f8396f2f0 (patch) | |
tree | bdb47765991cb973b2cd5481a088fac636bd326c /editors/code | |
parent | ca464650eeaca6195891199a93f4f76cf3e7e697 (diff) | |
parent | e65d48d1fb3d4d91d9dc1148a7a836ff5c9a3c87 (diff) |
Merge remote-tracking branch 'upstream/master' into 503-hover-doc-links
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/.eslintignore | 3 | ||||
-rw-r--r-- | editors/code/package.json | 11 | ||||
-rw-r--r-- | editors/code/src/client.ts | 10 | ||||
-rw-r--r-- | editors/code/src/ctx.ts | 2 | ||||
-rw-r--r-- | editors/code/src/debug.ts | 12 | ||||
-rw-r--r-- | editors/code/src/lsp_ext.ts | 5 | ||||
-rw-r--r-- | editors/code/src/toolchain.ts | 4 | ||||
-rw-r--r-- | editors/code/src/util.ts | 7 |
8 files changed, 35 insertions, 19 deletions
diff --git a/editors/code/.eslintignore b/editors/code/.eslintignore new file mode 100644 index 000000000..3df5c860b --- /dev/null +++ b/editors/code/.eslintignore | |||
@@ -0,0 +1,3 @@ | |||
1 | node_modules | ||
2 | .eslintrc.js | ||
3 | rollup.config.js \ No newline at end of file | ||
diff --git a/editors/code/package.json b/editors/code/package.json index 1adf055d0..f079f73b8 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -592,6 +592,15 @@ | |||
592 | "default": true, | 592 | "default": true, |
593 | "markdownDescription": "Whether to show experimental rust-analyzer diagnostics that might have more false positives than usual." | 593 | "markdownDescription": "Whether to show experimental rust-analyzer diagnostics that might have more false positives than usual." |
594 | }, | 594 | }, |
595 | "rust-analyzer.diagnostics.disabled": { | ||
596 | "type": "array", | ||
597 | "uniqueItems": true, | ||
598 | "items": { | ||
599 | "type": "string" | ||
600 | }, | ||
601 | "description": "List of rust-analyzer diagnostics to disable", | ||
602 | "default": [] | ||
603 | }, | ||
595 | "rust-analyzer.diagnostics.warningsAsInfo": { | 604 | "rust-analyzer.diagnostics.warningsAsInfo": { |
596 | "type": "array", | 605 | "type": "array", |
597 | "uniqueItems": true, | 606 | "uniqueItems": true, |
@@ -607,7 +616,7 @@ | |||
607 | "items": { | 616 | "items": { |
608 | "type": "string" | 617 | "type": "string" |
609 | }, | 618 | }, |
610 | "description": "List of warnings warnings that should be displayed with hint severity.\nThe warnings will be indicated by faded text or three dots in code and will not show up in the problems panel.", | 619 | "description": "List of warnings that should be displayed with hint severity.\nThe warnings will be indicated by faded text or three dots in code and will not show up in the problems panel.", |
611 | "default": [] | 620 | "default": [] |
612 | } | 621 | } |
613 | } | 622 | } |
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 18948cb3c..f5db55b8c 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts | |||
@@ -4,7 +4,7 @@ import * as ra from '../src/lsp_ext'; | |||
4 | import * as Is from 'vscode-languageclient/lib/utils/is'; | 4 | import * as Is from 'vscode-languageclient/lib/utils/is'; |
5 | 5 | ||
6 | import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; | 6 | import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; |
7 | import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed'; | 7 | import { SemanticTokensFeature } from 'vscode-languageclient/lib/semanticTokens.proposed'; |
8 | import { assert } from './util'; | 8 | import { assert } from './util'; |
9 | 9 | ||
10 | function renderCommand(cmd: ra.CommandLink) { | 10 | function renderCommand(cmd: ra.CommandLink) { |
@@ -44,12 +44,6 @@ export function createClient(serverPath: string, cwd: string): lc.LanguageClient | |||
44 | diagnosticCollectionName: "rustc", | 44 | diagnosticCollectionName: "rustc", |
45 | traceOutputChannel, | 45 | traceOutputChannel, |
46 | middleware: { | 46 | middleware: { |
47 | // Workaround for https://github.com/microsoft/vscode-languageserver-node/issues/576 | ||
48 | async provideDocumentSemanticTokens(document: vscode.TextDocument, token: vscode.CancellationToken, next: DocumentSemanticsTokensSignature) { | ||
49 | const res = await next(document, token); | ||
50 | if (res === undefined) throw new Error('busy'); | ||
51 | return res; | ||
52 | }, | ||
53 | async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, _next: lc.ProvideHoverSignature) { | 47 | async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, _next: lc.ProvideHoverSignature) { |
54 | return client.sendRequest(lc.HoverRequest.type, client.code2ProtocolConverter.asTextDocumentPositionParams(document, position), token).then( | 48 | return client.sendRequest(lc.HoverRequest.type, client.code2ProtocolConverter.asTextDocumentPositionParams(document, position), token).then( |
55 | (result) => { | 49 | (result) => { |
@@ -135,7 +129,7 @@ export function createClient(serverPath: string, cwd: string): lc.LanguageClient | |||
135 | ); | 129 | ); |
136 | } | 130 | } |
137 | 131 | ||
138 | } as any | 132 | } |
139 | }; | 133 | }; |
140 | 134 | ||
141 | const client = new lc.LanguageClient( | 135 | const client = new lc.LanguageClient( |
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index 6e767babf..543f7e02e 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts | |||
@@ -36,7 +36,7 @@ export class Ctx { | |||
36 | 36 | ||
37 | res.pushCleanup(client.start()); | 37 | res.pushCleanup(client.start()); |
38 | await client.onReady(); | 38 | await client.onReady(); |
39 | client.onNotification(ra.status, (status) => res.setStatus(status)); | 39 | client.onNotification(ra.status, (params) => res.setStatus(params.status)); |
40 | return res; | 40 | return res; |
41 | } | 41 | } |
42 | 42 | ||
diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index bd92c5b6d..925126a16 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts | |||
@@ -87,9 +87,17 @@ async function getDebugConfiguration(ctx: Ctx, runnable: ra.Runnable): Promise<v | |||
87 | debugOutput.show(true); | 87 | debugOutput.show(true); |
88 | } | 88 | } |
89 | 89 | ||
90 | const wsFolder = path.normalize(vscode.workspace.workspaceFolders![0].uri.fsPath); // folder exists or RA is not active. | 90 | const isMultiFolderWorkspace = vscode.workspace.workspaceFolders!.length > 1; |
91 | const firstWorkspace = vscode.workspace.workspaceFolders![0]; // folder exists or RA is not active. | ||
92 | const workspace = !isMultiFolderWorkspace || !runnable.args.workspaceRoot ? | ||
93 | firstWorkspace : | ||
94 | vscode.workspace.workspaceFolders!.find(w => runnable.args.workspaceRoot?.includes(w.uri.fsPath)) || firstWorkspace; | ||
95 | |||
96 | const wsFolder = path.normalize(workspace.uri.fsPath); | ||
97 | const workspaceQualifier = isMultiFolderWorkspace ? `:${workspace.name}` : ''; | ||
91 | function simplifyPath(p: string): string { | 98 | function simplifyPath(p: string): string { |
92 | return path.normalize(p).replace(wsFolder, '${workspaceRoot}'); | 99 | // see https://github.com/rust-analyzer/rust-analyzer/pull/5513#issuecomment-663458818 for why this is needed |
100 | return path.normalize(p).replace(wsFolder, '${workspaceFolder' + workspaceQualifier + '}'); | ||
93 | } | 101 | } |
94 | 102 | ||
95 | const executable = await getDebugExecutable(runnable); | 103 | const executable = await getDebugExecutable(runnable); |
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index 494d51c83..8663737a6 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts | |||
@@ -8,7 +8,10 @@ export const analyzerStatus = new lc.RequestType<null, string, void>("rust-analy | |||
8 | export const memoryUsage = new lc.RequestType<null, string, void>("rust-analyzer/memoryUsage"); | 8 | export const memoryUsage = new lc.RequestType<null, string, void>("rust-analyzer/memoryUsage"); |
9 | 9 | ||
10 | export type Status = "loading" | "ready" | "invalid" | "needsReload"; | 10 | export type Status = "loading" | "ready" | "invalid" | "needsReload"; |
11 | export const status = new lc.NotificationType<Status>("rust-analyzer/status"); | 11 | export interface StatusParams { |
12 | status: Status; | ||
13 | } | ||
14 | export const status = new lc.NotificationType<StatusParams>("rust-analyzer/status"); | ||
12 | 15 | ||
13 | export const reloadWorkspace = new lc.RequestType<null, null, void>("rust-analyzer/reloadWorkspace"); | 16 | export const reloadWorkspace = new lc.RequestType<null, null, void>("rust-analyzer/reloadWorkspace"); |
14 | 17 | ||
diff --git a/editors/code/src/toolchain.ts b/editors/code/src/toolchain.ts index 80a7915e9..a5dc3cf0c 100644 --- a/editors/code/src/toolchain.ts +++ b/editors/code/src/toolchain.ts | |||
@@ -121,12 +121,12 @@ export class Cargo { | |||
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | /** Mirrors `ra_toolchain::cargo()` implementation */ | 124 | /** Mirrors `toolchain::cargo()` implementation */ |
125 | export function cargoPath(): string { | 125 | export function cargoPath(): string { |
126 | return getPathForExecutable("cargo"); | 126 | return getPathForExecutable("cargo"); |
127 | } | 127 | } |
128 | 128 | ||
129 | /** Mirrors `ra_toolchain::get_path_for_executable()` implementation */ | 129 | /** Mirrors `toolchain::get_path_for_executable()` implementation */ |
130 | export const getPathForExecutable = memoize( | 130 | export const getPathForExecutable = memoize( |
131 | // We apply caching to decrease file-system interactions | 131 | // We apply caching to decrease file-system interactions |
132 | (executableName: "cargo" | "rustc" | "rustup"): string => { | 132 | (executableName: "cargo" | "rustc" | "rustup"): string => { |
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index 970fedb37..ec2087502 100644 --- a/editors/code/src/util.ts +++ b/editors/code/src/util.ts | |||
@@ -25,7 +25,6 @@ export const log = new class { | |||
25 | debug(...msg: [unknown, ...unknown[]]): void { | 25 | debug(...msg: [unknown, ...unknown[]]): void { |
26 | if (!log.enabled) return; | 26 | if (!log.enabled) return; |
27 | log.write("DEBUG", ...msg); | 27 | log.write("DEBUG", ...msg); |
28 | log.output.toString(); | ||
29 | } | 28 | } |
30 | 29 | ||
31 | info(...msg: [unknown, ...unknown[]]): void { | 30 | info(...msg: [unknown, ...unknown[]]): void { |
@@ -64,7 +63,8 @@ export async function sendRequestWithRetry<TParam, TRet>( | |||
64 | param: TParam, | 63 | param: TParam, |
65 | token?: vscode.CancellationToken, | 64 | token?: vscode.CancellationToken, |
66 | ): Promise<TRet> { | 65 | ): Promise<TRet> { |
67 | for (const delay of [2, 4, 6, 8, 10, null]) { | 66 | // The sequence is `10 * (2 ** (2 * n))` where n is 1, 2, 3... |
67 | for (const delay of [40, 160, 640, 2560, 10240, null]) { | ||
68 | try { | 68 | try { |
69 | return await (token | 69 | return await (token |
70 | ? client.sendRequest(reqType, param, token) | 70 | ? client.sendRequest(reqType, param, token) |
@@ -84,8 +84,7 @@ export async function sendRequestWithRetry<TParam, TRet>( | |||
84 | log.warn("LSP request failed", { method: reqType.method, param, error }); | 84 | log.warn("LSP request failed", { method: reqType.method, param, error }); |
85 | throw error; | 85 | throw error; |
86 | } | 86 | } |
87 | 87 | await sleep(delay); | |
88 | await sleep(10 * (1 << delay)); | ||
89 | } | 88 | } |
90 | } | 89 | } |
91 | throw 'unreachable'; | 90 | throw 'unreachable'; |