-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathcodeLens.ts
57 lines (38 loc) · 1.27 KB
/
codeLens.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import path from 'path';
import {
CodeLens,
CodeLensProvider as CLP,
Range,
TextDocument,
EventEmitter as VsEventEmitter,
Event as VsEvent,
workspace
} from "vscode";
export class CodeLensProvider implements CLP {
private _onDidChangeCodeLenses: VsEventEmitter<void> = new VsEventEmitter<void>();
public readonly onDidChangeCodeLenses: VsEvent<void> = this._onDidChangeCodeLenses.event;
constructor() {
workspace.onDidChangeConfiguration((_) => {
this._onDidChangeCodeLenses.fire();
});
}
async provideCodeLenses(document: TextDocument): Promise<CodeLens[]> {
const codeLens: CodeLens[] = [];
const firstLine = new Range(0, 0, 0, 0);
const secondLine = new Range(1, 0, 0, 0);
const justFileName = path.parse(document.fileName).base;
if (justFileName === 'tmosXcRules.json') {
codeLens.push(
new CodeLens(
firstLine,
{
command: 'workbench.action.files.save',
title: '--- SAVE ---',
tooltip: 'Click to save diagnostic rules',
}
)
);
}
return codeLens;
}
}