-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathdefinitionUtils.ts
38 lines (33 loc) · 1.07 KB
/
definitionUtils.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
import * as acdl from "@alexa/acdl";
import {uinteger} from "vscode-languageclient";
import {SourceLocation} from "@alexa/acdl";
import {Position} from "vscode-languageserver/node";
export function createMockNode<T>(typeStr: string, name: string, uri: string, loc: acdl.SourceLocation | undefined): T {
return {
loc,
kind: typeStr,
name: {name, uri, loc} as acdl.Name,
} as unknown as T;
}
export function createSrcLocation(
startLine: uinteger,
startCharacter: uinteger,
endLine: uinteger,
endCharacter: uinteger,
): SourceLocation {
return {
begin: {line: startLine, character: startCharacter},
end: {line: endLine, character: endCharacter},
};
}
export function createMockTypeChecker(): acdl.TypeChecker {
return {
lookupName: () => {},
} as unknown as acdl.TypeChecker;
}
export function convertACDLToVSCodeSrcPosition(line: number, char: number): Position {
return {line: line - 1, character: char};
}
export function convertVSCodeToACDLSrcPosition(line: number, char: number): Position {
return {line: line + 1, character: char};
}