aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/highlighting.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/highlighting.ts')
-rw-r--r--editors/code/src/highlighting.ts66
1 files changed, 33 insertions, 33 deletions
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index 169ddb0df..71f8e5baa 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -1,11 +1,11 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient' 2import * as lc from 'vscode-languageclient';
3 3
4import { Server } from './server'; 4import { Server } from './server';
5 5
6export interface Decoration { 6export interface Decoration {
7 range: lc.Range, 7 range: lc.Range;
8 tag: string, 8 tag: string;
9} 9}
10 10
11export class Highlighter { 11export class Highlighter {
@@ -14,17 +14,17 @@ export class Highlighter {
14 this.decorations = {}; 14 this.decorations = {};
15 } 15 }
16 16
17 removeHighlights() { 17 public removeHighlights() {
18 for (let tag in this.decorations) { 18 for (const tag in this.decorations) {
19 this.decorations[tag].dispose(); 19 this.decorations[tag].dispose();
20 } 20 }
21 21
22 this.decorations = {}; 22 this.decorations = {};
23 } 23 }
24 24
25 setHighlights( 25 public setHighlights(
26 editor: vscode.TextEditor, 26 editor: vscode.TextEditor,
27 highlights: Array<Decoration> 27 highlights: Decoration[],
28 ) { 28 ) {
29 // Initialize decorations if necessary 29 // Initialize decorations if necessary
30 // 30 //
@@ -34,45 +34,45 @@ export class Highlighter {
34 this.initDecorations(); 34 this.initDecorations();
35 } 35 }
36 36
37 let byTag: Map<string, vscode.Range[]> = new Map() 37 const byTag: Map<string, vscode.Range[]> = new Map();
38 for (let tag in this.decorations) { 38 for (const tag in this.decorations) {
39 byTag.set(tag, []) 39 byTag.set(tag, []);
40 } 40 }
41 41
42 for (let d of highlights) { 42 for (const d of highlights) {
43 if (!byTag.get(d.tag)) { 43 if (!byTag.get(d.tag)) {
44 console.log(`unknown tag ${d.tag}`) 44 console.log(`unknown tag ${d.tag}`);
45 continue 45 continue;
46 } 46 }
47 byTag.get(d.tag)!.push( 47 byTag.get(d.tag)!.push(
48 Server.client.protocol2CodeConverter.asRange(d.range) 48 Server.client.protocol2CodeConverter.asRange(d.range),
49 ) 49 );
50 } 50 }
51 51
52 for (let tag of byTag.keys()) { 52 for (const tag of byTag.keys()) {
53 let dec: vscode.TextEditorDecorationType = this.decorations[tag] 53 const dec: vscode.TextEditorDecorationType = this.decorations[tag];
54 let ranges = byTag.get(tag)! 54 const ranges = byTag.get(tag)!;
55 editor.setDecorations(dec, ranges) 55 editor.setDecorations(dec, ranges);
56 } 56 }
57 } 57 }
58 58
59 private initDecorations() { 59 private initDecorations() {
60 const decor = (obj: any) => vscode.window.createTextEditorDecorationType({ color: obj }) 60 const decor = (obj: any) => vscode.window.createTextEditorDecorationType({ color: obj });
61 this.decorations = { 61 this.decorations = {
62 background: decor("#3F3F3F"), 62 background: decor('#3F3F3F'),
63 error: vscode.window.createTextEditorDecorationType({ 63 error: vscode.window.createTextEditorDecorationType({
64 borderColor: "red", 64 borderColor: 'red',
65 borderStyle: "none none dashed none", 65 borderStyle: 'none none dashed none',
66 }), 66 }),
67 comment: decor("#7F9F7F"), 67 comment: decor('#7F9F7F'),
68 string: decor("#CC9393"), 68 string: decor('#CC9393'),
69 keyword: decor("#F0DFAF"), 69 keyword: decor('#F0DFAF'),
70 function: decor("#93E0E3"), 70 function: decor('#93E0E3'),
71 parameter: decor("#94BFF3"), 71 parameter: decor('#94BFF3'),
72 builtin: decor("#DD6718"), 72 builtin: decor('#DD6718'),
73 text: decor("#DCDCCC"), 73 text: decor('#DCDCCC'),
74 attribute: decor("#BFEBBF"), 74 attribute: decor('#BFEBBF'),
75 literal: decor("#DFAF8F"), 75 literal: decor('#DFAF8F'),
76 } 76 };
77 } 77 }
78} 78}