/
types.ts
82 lines (71 loc) · 1.92 KB
/
types.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { Mapping } from '@volar/source-map';
import type * as ts from 'typescript/lib/tsserverlibrary';
export interface DocumentCapabilities {
diagnostic?: boolean,
foldingRange?: boolean,
documentFormatting?: boolean | {
initialIndentBracket?: [string, string],
},
documentSymbol?: boolean,
codeAction?: boolean,
inlayHint?: boolean,
}
export interface PositionCapabilities {
hover?: boolean,
references?: boolean,
definition?: boolean,
rename?: boolean | {
normalize?(newName: string): string,
apply?(newName: string): string,
},
completion?: boolean | {
additional?: boolean,
autoImportOnly?: boolean,
},
diagnostic?: boolean,
semanticTokens?: boolean,
// TODO
referencesCodeLens?: boolean,
displayWithLink?: boolean,
}
export interface TeleportCapabilities {
references?: boolean,
definition?: boolean,
rename?: boolean,
}
export interface TeleportMappingData {
toSourceCapabilities: TeleportCapabilities,
toGenedCapabilities: TeleportCapabilities,
}
export interface TextRange {
start: number,
end: number,
}
export interface SourceFile {
fileName: string,
text: string,
embeddeds: EmbeddedFile[],
}
export enum EmbeddedFileKind {
TextFile = 0,
TypeScriptHostFile = 1,
}
export interface EmbeddedFile {
fileName: string,
text: string,
kind: EmbeddedFileKind,
capabilities: DocumentCapabilities,
mappings: Mapping<PositionCapabilities>[],
teleportMappings?: Mapping<TeleportMappingData>[],
embeddeds: EmbeddedFile[],
}
export interface LanguageModule<T extends SourceFile = SourceFile> {
createSourceFile(fileName: string, snapshot: ts.IScriptSnapshot): T | undefined;
updateSourceFile(sourceFile: T, snapshot: ts.IScriptSnapshot): void;
proxyLanguageServiceHost?(host: LanguageServiceHost): Partial<LanguageServiceHost>;
}
export type LanguageServiceHost = ts.LanguageServiceHost & {
getTypeScriptModule(): typeof import('typescript/lib/tsserverlibrary');
isTsPlugin?: boolean,
isTsc?: boolean,
};