-
Notifications
You must be signed in to change notification settings - Fork 3
/
scope-info.d.ts
47 lines (42 loc) · 1.11 KB
/
scope-info.d.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
import * as vscode from 'vscode'
/**
* A grammar
*/
export interface IGrammar {
/**
* Tokenize `lineText` using previous line state `prevState`.
*/
tokenizeLine(lineText: string, prevState: StackElement): ITokenizeLineResult;
}
export interface ITokenizeLineResult {
readonly tokens: IToken[];
/**
* The `prevState` to be passed on to the next line tokenization.
*/
readonly ruleStack: StackElement;
}
export interface IToken {
startIndex: number;
readonly endIndex: number;
readonly scopes: string[];
}
/**
* **IMPORTANT** - Immutable!
*/
export interface StackElement {
equals(other: StackElement): boolean;
}
export interface Token {
range: vscode.Range,
text: string,
scopes: string[];
}
export interface ScopeInfoAPI {
getScopeAt(document: vscode.TextDocument, position: vscode.Position) : Token|null;
getGrammar(scopeName: string) : Promise<IGrammar|null>;
getScopeForLanguage(language: string) : string|null;
}
export function activate() : Thenable<ScopeInfoAPI> {
const siExt = vscode.extensions.getExtension<ScopeInfoAPI>('siegebell.scope-info');
return siExt.activate();
}