mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Apply tslint suggestions, round one
This commit is contained in:
parent
69de7e2fd7
commit
4d62cfccbb
16 changed files with 257 additions and 241 deletions
|
@ -1,11 +1,11 @@
|
|||
import * as vscode from 'vscode';
|
||||
import * as lc from 'vscode-languageclient'
|
||||
import * as lc from 'vscode-languageclient';
|
||||
|
||||
import { Server } from './server';
|
||||
|
||||
export interface Decoration {
|
||||
range: lc.Range,
|
||||
tag: string,
|
||||
range: lc.Range;
|
||||
tag: string;
|
||||
}
|
||||
|
||||
export class Highlighter {
|
||||
|
@ -14,17 +14,17 @@ export class Highlighter {
|
|||
this.decorations = {};
|
||||
}
|
||||
|
||||
removeHighlights() {
|
||||
for (let tag in this.decorations) {
|
||||
public removeHighlights() {
|
||||
for (const tag in this.decorations) {
|
||||
this.decorations[tag].dispose();
|
||||
}
|
||||
|
||||
this.decorations = {};
|
||||
}
|
||||
|
||||
setHighlights(
|
||||
public setHighlights(
|
||||
editor: vscode.TextEditor,
|
||||
highlights: Array<Decoration>
|
||||
highlights: Decoration[],
|
||||
) {
|
||||
// Initialize decorations if necessary
|
||||
//
|
||||
|
@ -34,45 +34,45 @@ export class Highlighter {
|
|||
this.initDecorations();
|
||||
}
|
||||
|
||||
let byTag: Map<string, vscode.Range[]> = new Map()
|
||||
for (let tag in this.decorations) {
|
||||
byTag.set(tag, [])
|
||||
const byTag: Map<string, vscode.Range[]> = new Map();
|
||||
for (const tag in this.decorations) {
|
||||
byTag.set(tag, []);
|
||||
}
|
||||
|
||||
for (let d of highlights) {
|
||||
for (const d of highlights) {
|
||||
if (!byTag.get(d.tag)) {
|
||||
console.log(`unknown tag ${d.tag}`)
|
||||
continue
|
||||
console.log(`unknown tag ${d.tag}`);
|
||||
continue;
|
||||
}
|
||||
byTag.get(d.tag)!.push(
|
||||
Server.client.protocol2CodeConverter.asRange(d.range)
|
||||
)
|
||||
Server.client.protocol2CodeConverter.asRange(d.range),
|
||||
);
|
||||
}
|
||||
|
||||
for (let tag of byTag.keys()) {
|
||||
let dec: vscode.TextEditorDecorationType = this.decorations[tag]
|
||||
let ranges = byTag.get(tag)!
|
||||
editor.setDecorations(dec, ranges)
|
||||
for (const tag of byTag.keys()) {
|
||||
const dec: vscode.TextEditorDecorationType = this.decorations[tag];
|
||||
const ranges = byTag.get(tag)!;
|
||||
editor.setDecorations(dec, ranges);
|
||||
}
|
||||
}
|
||||
|
||||
private initDecorations() {
|
||||
const decor = (obj: any) => vscode.window.createTextEditorDecorationType({ color: obj })
|
||||
const decor = (obj: any) => vscode.window.createTextEditorDecorationType({ color: obj });
|
||||
this.decorations = {
|
||||
background: decor("#3F3F3F"),
|
||||
background: decor('#3F3F3F'),
|
||||
error: vscode.window.createTextEditorDecorationType({
|
||||
borderColor: "red",
|
||||
borderStyle: "none none dashed none",
|
||||
borderColor: 'red',
|
||||
borderStyle: 'none none dashed none',
|
||||
}),
|
||||
comment: decor("#7F9F7F"),
|
||||
string: decor("#CC9393"),
|
||||
keyword: decor("#F0DFAF"),
|
||||
function: decor("#93E0E3"),
|
||||
parameter: decor("#94BFF3"),
|
||||
builtin: decor("#DD6718"),
|
||||
text: decor("#DCDCCC"),
|
||||
attribute: decor("#BFEBBF"),
|
||||
literal: decor("#DFAF8F"),
|
||||
}
|
||||
comment: decor('#7F9F7F'),
|
||||
string: decor('#CC9393'),
|
||||
keyword: decor('#F0DFAF'),
|
||||
function: decor('#93E0E3'),
|
||||
parameter: decor('#94BFF3'),
|
||||
builtin: decor('#DD6718'),
|
||||
text: decor('#DCDCCC'),
|
||||
attribute: decor('#BFEBBF'),
|
||||
literal: decor('#DFAF8F'),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue