mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-16 17:58:16 +00:00
Merge #2986
2986: vscode extension cleanup: migrate to prefer-const tslint rule r=matklad a=Veetaha Co-authored-by: Veetaha <gerzoh1@gmail.com>
This commit is contained in:
commit
e72771ebc6
6 changed files with 11 additions and 10 deletions
|
@ -69,7 +69,7 @@ function loadThemeNamed(themeName: string): ColorTheme {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let themePaths = vscode.extensions.all
|
const themePaths = vscode.extensions.all
|
||||||
.filter(isTheme)
|
.filter(isTheme)
|
||||||
.flatMap(ext => {
|
.flatMap(ext => {
|
||||||
return ext.packageJSON.contributes.themes
|
return ext.packageJSON.contributes.themes
|
||||||
|
|
|
@ -21,7 +21,7 @@ function collectGarbage(ctx: Ctx): Cmd {
|
||||||
|
|
||||||
function showReferences(ctx: Ctx): Cmd {
|
function showReferences(ctx: Ctx): Cmd {
|
||||||
return (uri: string, position: lc.Position, locations: lc.Location[]) => {
|
return (uri: string, position: lc.Position, locations: lc.Location[]) => {
|
||||||
let client = ctx.client;
|
const client = ctx.client;
|
||||||
if (client) {
|
if (client) {
|
||||||
vscode.commands.executeCommand(
|
vscode.commands.executeCommand(
|
||||||
'editor.action.showReferences',
|
'editor.action.showReferences',
|
||||||
|
|
|
@ -20,7 +20,7 @@ export class Ctx {
|
||||||
}
|
}
|
||||||
|
|
||||||
async restartServer() {
|
async restartServer() {
|
||||||
let old = this.client;
|
const old = this.client;
|
||||||
if (old) {
|
if (old) {
|
||||||
await old.stop();
|
await old.stop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ export function activateHighlighting(ctx: Ctx) {
|
||||||
async (editor: vscode.TextEditor | undefined) => {
|
async (editor: vscode.TextEditor | undefined) => {
|
||||||
if (!editor || editor.document.languageId !== 'rust') return;
|
if (!editor || editor.document.languageId !== 'rust') return;
|
||||||
if (!ctx.config.highlightingOn) return;
|
if (!ctx.config.highlightingOn) return;
|
||||||
let client = ctx.client;
|
const client = ctx.client;
|
||||||
if (!client) return;
|
if (!client) return;
|
||||||
|
|
||||||
const params: lc.TextDocumentIdentifier = {
|
const params: lc.TextDocumentIdentifier = {
|
||||||
|
@ -106,7 +106,7 @@ class Highlighter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public setHighlights(editor: vscode.TextEditor, highlights: Decoration[]) {
|
public setHighlights(editor: vscode.TextEditor, highlights: Decoration[]) {
|
||||||
let client = this.ctx.client;
|
const client = this.ctx.client;
|
||||||
if (!client) return;
|
if (!client) return;
|
||||||
// Initialize decorations if necessary
|
// Initialize decorations if necessary
|
||||||
//
|
//
|
||||||
|
@ -175,7 +175,7 @@ function initDecorations(): Map<string, vscode.TextEditorDecorationType> {
|
||||||
const res = new Map();
|
const res = new Map();
|
||||||
TAG_TO_SCOPES.forEach((scopes, tag) => {
|
TAG_TO_SCOPES.forEach((scopes, tag) => {
|
||||||
if (!scopes) throw `unmapped tag: ${tag}`;
|
if (!scopes) throw `unmapped tag: ${tag}`;
|
||||||
let rule = theme.lookup(scopes);
|
const rule = theme.lookup(scopes);
|
||||||
const decor = createDecorationFromTextmate(rule);
|
const decor = createDecorationFromTextmate(rule);
|
||||||
res.set(tag, decor);
|
res.set(tag, decor);
|
||||||
});
|
});
|
||||||
|
|
|
@ -127,13 +127,13 @@ class HintsUpdater {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async queryHints(documentUri: string): Promise<InlayHint[] | null> {
|
private async queryHints(documentUri: string): Promise<InlayHint[] | null> {
|
||||||
let client = this.ctx.client;
|
const client = this.ctx.client;
|
||||||
if (!client) return null;
|
if (!client) return null;
|
||||||
const request: InlayHintsParams = {
|
const request: InlayHintsParams = {
|
||||||
textDocument: { uri: documentUri },
|
textDocument: { uri: documentUri },
|
||||||
};
|
};
|
||||||
let tokenSource = new vscode.CancellationTokenSource();
|
const tokenSource = new vscode.CancellationTokenSource();
|
||||||
let prev = this.pending.get(documentUri);
|
const prev = this.pending.get(documentUri);
|
||||||
if (prev) prev.cancel();
|
if (prev) prev.cancel();
|
||||||
this.pending.set(documentUri, tokenSource);
|
this.pending.set(documentUri, tokenSource);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
"semicolon": [
|
"semicolon": [
|
||||||
true,
|
true,
|
||||||
"always"
|
"always"
|
||||||
]
|
],
|
||||||
|
"prefer-const": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue