@volar/typescript 1.11.1 → 2.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +5 -6
- package/index.js +5 -5
- package/lib/documentRegistry.d.ts +0 -1
- package/lib/node/decorateLanguageService.d.ts +3 -0
- package/lib/node/decorateLanguageService.js +660 -0
- package/lib/{serverPlugin.d.ts → node/decorateLanguageServiceHost.d.ts} +2 -7
- package/lib/{serverPlugin.js → node/decorateLanguageServiceHost.js} +21 -31
- package/lib/node/dedupe.d.ts +3 -0
- package/lib/node/dedupe.js +27 -0
- package/lib/protocol/createProject.d.ts +4 -0
- package/lib/protocol/createProject.js +321 -0
- package/lib/{sys.d.ts → protocol/createSys.d.ts} +1 -2
- package/lib/{sys.js → protocol/createSys.js} +8 -8
- package/lib/protocol/getProgram.d.ts +6 -0
- package/lib/{getProgram.js → protocol/getProgram.js} +17 -14
- package/lib/typescript/core.d.ts +0 -1
- package/lib/typescript/core.js +1 -0
- package/lib/typescript/corePublic.d.ts +0 -1
- package/lib/typescript/corePublic.js +1 -1
- package/lib/typescript/path.d.ts +0 -1
- package/lib/typescript/path.js +1 -0
- package/lib/typescript/types.d.ts +37 -38
- package/lib/typescript/utilities.d.ts +0 -1
- package/lib/typescript/utilities.js +1 -0
- package/package.json +4 -4
- package/lib/getProgram.d.ts +0 -4
- package/lib/languageService.d.ts +0 -4
- package/lib/languageService.js +0 -303
- package/lib/languageServiceHost.d.ts +0 -6
- package/lib/languageServiceHost.js +0 -296
|
@@ -4,13 +4,13 @@ export type Path = string & {
|
|
|
4
4
|
export declare const enum CharacterCodes {
|
|
5
5
|
nullCharacter = 0,
|
|
6
6
|
maxAsciiCharacter = 127,
|
|
7
|
-
lineFeed = 10
|
|
8
|
-
carriageReturn = 13
|
|
7
|
+
lineFeed = 10,// \n
|
|
8
|
+
carriageReturn = 13,// \r
|
|
9
9
|
lineSeparator = 8232,
|
|
10
10
|
paragraphSeparator = 8233,
|
|
11
11
|
nextLine = 133,
|
|
12
|
-
space = 32
|
|
13
|
-
nonBreakingSpace = 160
|
|
12
|
+
space = 32,// " "
|
|
13
|
+
nonBreakingSpace = 160,//
|
|
14
14
|
enQuad = 8192,
|
|
15
15
|
emQuad = 8193,
|
|
16
16
|
enSpace = 8194,
|
|
@@ -91,40 +91,39 @@ export declare const enum CharacterCodes {
|
|
|
91
91
|
X = 88,
|
|
92
92
|
Y = 89,
|
|
93
93
|
Z = 90,
|
|
94
|
-
ampersand = 38
|
|
95
|
-
asterisk = 42
|
|
96
|
-
at = 64
|
|
97
|
-
backslash = 92
|
|
98
|
-
backtick = 96
|
|
99
|
-
bar = 124
|
|
100
|
-
caret = 94
|
|
101
|
-
closeBrace = 125
|
|
102
|
-
closeBracket = 93
|
|
103
|
-
closeParen = 41
|
|
104
|
-
colon = 58
|
|
105
|
-
comma = 44,
|
|
106
|
-
dot = 46
|
|
107
|
-
doubleQuote = 34
|
|
108
|
-
equals = 61
|
|
109
|
-
exclamation = 33
|
|
110
|
-
greaterThan = 62
|
|
111
|
-
hash = 35
|
|
112
|
-
lessThan = 60
|
|
113
|
-
minus = 45
|
|
114
|
-
openBrace = 123
|
|
115
|
-
openBracket = 91
|
|
116
|
-
openParen = 40
|
|
117
|
-
percent = 37
|
|
118
|
-
plus = 43
|
|
119
|
-
question = 63
|
|
120
|
-
semicolon = 59
|
|
121
|
-
singleQuote = 39
|
|
122
|
-
slash = 47
|
|
123
|
-
tilde = 126
|
|
124
|
-
backspace = 8
|
|
125
|
-
formFeed = 12
|
|
94
|
+
ampersand = 38,// &
|
|
95
|
+
asterisk = 42,// *
|
|
96
|
+
at = 64,// @
|
|
97
|
+
backslash = 92,// \
|
|
98
|
+
backtick = 96,// `
|
|
99
|
+
bar = 124,// |
|
|
100
|
+
caret = 94,// ^
|
|
101
|
+
closeBrace = 125,// }
|
|
102
|
+
closeBracket = 93,// ]
|
|
103
|
+
closeParen = 41,// )
|
|
104
|
+
colon = 58,// :
|
|
105
|
+
comma = 44,// ,
|
|
106
|
+
dot = 46,// .
|
|
107
|
+
doubleQuote = 34,// "
|
|
108
|
+
equals = 61,// =
|
|
109
|
+
exclamation = 33,// !
|
|
110
|
+
greaterThan = 62,// >
|
|
111
|
+
hash = 35,// #
|
|
112
|
+
lessThan = 60,// <
|
|
113
|
+
minus = 45,// -
|
|
114
|
+
openBrace = 123,// {
|
|
115
|
+
openBracket = 91,// [
|
|
116
|
+
openParen = 40,// (
|
|
117
|
+
percent = 37,// %
|
|
118
|
+
plus = 43,// +
|
|
119
|
+
question = 63,// ?
|
|
120
|
+
semicolon = 59,// ;
|
|
121
|
+
singleQuote = 39,// '
|
|
122
|
+
slash = 47,// /
|
|
123
|
+
tilde = 126,// ~
|
|
124
|
+
backspace = 8,// \b
|
|
125
|
+
formFeed = 12,// \f
|
|
126
126
|
byteOrderMark = 65279,
|
|
127
|
-
tab = 9
|
|
127
|
+
tab = 9,// \t
|
|
128
128
|
verticalTab = 11
|
|
129
129
|
}
|
|
130
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -5,4 +5,3 @@ interface FileSystemEntries {
|
|
|
5
5
|
/** @param path directory of the tsconfig.json */
|
|
6
6
|
export declare function matchFiles(path: string, extensions: readonly string[] | undefined, excludes: readonly string[] | undefined, includes: readonly string[] | undefined, useCaseSensitiveFileNames: boolean, currentDirectory: string, depth: number | undefined, getFileSystemEntries: (path: string) => FileSystemEntries, realpath: (path: string) => string): string[];
|
|
7
7
|
export {};
|
|
8
|
-
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.matchFiles = void 0;
|
|
4
4
|
const core_1 = require("./core");
|
|
5
5
|
const path_1 = require("./path");
|
|
6
|
+
require("./types");
|
|
6
7
|
// KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink.
|
|
7
8
|
// ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked.
|
|
8
9
|
// Reserved characters, forces escaping of any non-word (or digit), non-whitespace character.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/typescript",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
"directory": "packages/typescript"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "
|
|
15
|
+
"@volar/language-core": "2.0.0-alpha.0",
|
|
16
16
|
"path-browserify": "^1.0.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/path-browserify": "latest",
|
|
20
|
-
"@volar/language-service": "
|
|
20
|
+
"@volar/language-service": "2.0.0-alpha.0"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "6a6be45a3b7983148d90541e7c68ef84c9155a7a"
|
|
23
23
|
}
|
package/lib/getProgram.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
import type * as embedded from '@volar/language-core';
|
|
3
|
-
export declare function getProgram(ts: typeof import('typescript/lib/tsserverlibrary'), core: embedded.LanguageContext, ls: ts.LanguageService, sys: ts.System): ts.Program;
|
|
4
|
-
//# sourceMappingURL=getProgram.d.ts.map
|
package/lib/languageService.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { VirtualFiles } from '@volar/language-core';
|
|
2
|
-
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
|
-
export declare function decorateLanguageService(virtualFiles: VirtualFiles, languageService: ts.LanguageService, isTsPlugin: boolean): void;
|
|
4
|
-
//# sourceMappingURL=languageService.d.ts.map
|
package/lib/languageService.js
DELETED
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decorateLanguageService = void 0;
|
|
4
|
-
const language_core_1 = require("@volar/language-core");
|
|
5
|
-
function decorateLanguageService(virtualFiles, languageService, isTsPlugin) {
|
|
6
|
-
const _organizeImports = languageService.organizeImports.bind(languageService);
|
|
7
|
-
const _getDefinitionAtPosition = languageService.getDefinitionAtPosition.bind(languageService);
|
|
8
|
-
const _getDefinitionAndBoundSpan = languageService.getDefinitionAndBoundSpan.bind(languageService);
|
|
9
|
-
const _getTypeDefinitionAtPosition = languageService.getTypeDefinitionAtPosition.bind(languageService);
|
|
10
|
-
const _getImplementationAtPosition = languageService.getImplementationAtPosition.bind(languageService);
|
|
11
|
-
const _getFileReferences = languageService.getFileReferences.bind(languageService);
|
|
12
|
-
const _findRenameLocations = languageService.findRenameLocations.bind(languageService);
|
|
13
|
-
const _getReferencesAtPosition = languageService.getReferencesAtPosition.bind(languageService);
|
|
14
|
-
const _findReferences = languageService.findReferences.bind(languageService);
|
|
15
|
-
languageService.organizeImports = organizeImports;
|
|
16
|
-
languageService.getDefinitionAtPosition = getDefinitionAtPosition;
|
|
17
|
-
languageService.getDefinitionAndBoundSpan = getDefinitionAndBoundSpan;
|
|
18
|
-
languageService.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition;
|
|
19
|
-
languageService.getImplementationAtPosition = getImplementationAtPosition;
|
|
20
|
-
languageService.findRenameLocations = findRenameLocations;
|
|
21
|
-
languageService.getReferencesAtPosition = getReferencesAtPosition;
|
|
22
|
-
languageService.getFileReferences = getFileReferences;
|
|
23
|
-
languageService.findReferences = findReferences;
|
|
24
|
-
// apis
|
|
25
|
-
function organizeImports(args, formatOptions, preferences) {
|
|
26
|
-
let edits = [];
|
|
27
|
-
const file = virtualFiles.getSource(args.fileName)?.root;
|
|
28
|
-
if (file) {
|
|
29
|
-
(0, language_core_1.forEachEmbeddedFile)(file, embeddedFile => {
|
|
30
|
-
if (embeddedFile.kind === language_core_1.FileKind.TypeScriptHostFile && embeddedFile.capabilities.codeAction) {
|
|
31
|
-
edits = edits.concat(_organizeImports({
|
|
32
|
-
...args,
|
|
33
|
-
fileName: embeddedFile.fileName,
|
|
34
|
-
}, formatOptions, preferences));
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
return _organizeImports(args, formatOptions, preferences);
|
|
40
|
-
}
|
|
41
|
-
return edits.map(transformFileTextChanges).filter(notEmpty);
|
|
42
|
-
}
|
|
43
|
-
function getReferencesAtPosition(fileName, position) {
|
|
44
|
-
return findLocations(fileName, position, 'references');
|
|
45
|
-
}
|
|
46
|
-
function getFileReferences(fileName) {
|
|
47
|
-
return findLocations(fileName, -1, 'fileReferences');
|
|
48
|
-
}
|
|
49
|
-
function getDefinitionAtPosition(fileName, position) {
|
|
50
|
-
return findLocations(fileName, position, 'definition');
|
|
51
|
-
}
|
|
52
|
-
function getTypeDefinitionAtPosition(fileName, position) {
|
|
53
|
-
return findLocations(fileName, position, 'typeDefinition');
|
|
54
|
-
}
|
|
55
|
-
function getImplementationAtPosition(fileName, position) {
|
|
56
|
-
return findLocations(fileName, position, 'implementation');
|
|
57
|
-
}
|
|
58
|
-
function findRenameLocations(fileName, position, findInStrings, findInComments, preferences) {
|
|
59
|
-
return findLocations(fileName, position, 'rename', findInStrings, findInComments, preferences);
|
|
60
|
-
}
|
|
61
|
-
function findLocations(fileName, position, mode, findInStrings = false, findInComments = false, preferences) {
|
|
62
|
-
const loopChecker = new Set();
|
|
63
|
-
let symbols = [];
|
|
64
|
-
withMirrors(fileName, position);
|
|
65
|
-
return symbols.map(s => transformDocumentSpanLike(s, mode === 'definition')).filter(notEmpty);
|
|
66
|
-
function withMirrors(fileName, position) {
|
|
67
|
-
if (loopChecker.has(fileName + ':' + position))
|
|
68
|
-
return;
|
|
69
|
-
loopChecker.add(fileName + ':' + position);
|
|
70
|
-
const _symbols = mode === 'definition' ? _getDefinitionAtPosition(fileName, position)
|
|
71
|
-
: mode === 'typeDefinition' ? _getTypeDefinitionAtPosition(fileName, position)
|
|
72
|
-
: mode === 'references' ? _getReferencesAtPosition(fileName, position)
|
|
73
|
-
: mode === 'fileReferences' ? _getFileReferences(fileName)
|
|
74
|
-
: mode === 'implementation' ? _getImplementationAtPosition(fileName, position)
|
|
75
|
-
: mode === 'rename' && preferences ? _findRenameLocations(fileName, position, findInStrings, findInComments, preferences)
|
|
76
|
-
: undefined;
|
|
77
|
-
if (!_symbols)
|
|
78
|
-
return;
|
|
79
|
-
symbols = symbols.concat(_symbols);
|
|
80
|
-
for (const ref of _symbols) {
|
|
81
|
-
loopChecker.add(ref.fileName + ':' + ref.textSpan.start);
|
|
82
|
-
const [virtualFile] = getVirtualFile(ref.fileName);
|
|
83
|
-
if (!virtualFile)
|
|
84
|
-
continue;
|
|
85
|
-
const mirrorMap = virtualFiles.getMirrorMap(virtualFile);
|
|
86
|
-
if (!mirrorMap)
|
|
87
|
-
continue;
|
|
88
|
-
for (const [mirrorOffset, data] of mirrorMap.findMirrorOffsets(ref.textSpan.start)) {
|
|
89
|
-
if ((mode === 'definition' || mode === 'typeDefinition' || mode === 'implementation') && !data.definition)
|
|
90
|
-
continue;
|
|
91
|
-
if ((mode === 'references') && !data.references)
|
|
92
|
-
continue;
|
|
93
|
-
if ((mode === 'rename') && !data.rename)
|
|
94
|
-
continue;
|
|
95
|
-
if (loopChecker.has(ref.fileName + ':' + mirrorOffset))
|
|
96
|
-
continue;
|
|
97
|
-
withMirrors(ref.fileName, mirrorOffset);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
function getDefinitionAndBoundSpan(fileName, position) {
|
|
103
|
-
const loopChecker = new Set();
|
|
104
|
-
let textSpan;
|
|
105
|
-
let symbols = [];
|
|
106
|
-
withMirrors(fileName, position);
|
|
107
|
-
if (!textSpan)
|
|
108
|
-
return;
|
|
109
|
-
return {
|
|
110
|
-
textSpan: textSpan,
|
|
111
|
-
definitions: symbols?.map(s => transformDocumentSpanLike(s, true)).filter(notEmpty),
|
|
112
|
-
};
|
|
113
|
-
function withMirrors(fileName, position) {
|
|
114
|
-
if (loopChecker.has(fileName + ':' + position))
|
|
115
|
-
return;
|
|
116
|
-
loopChecker.add(fileName + ':' + position);
|
|
117
|
-
const _symbols = _getDefinitionAndBoundSpan(fileName, position);
|
|
118
|
-
if (!_symbols)
|
|
119
|
-
return;
|
|
120
|
-
if (!textSpan) {
|
|
121
|
-
textSpan = _symbols.textSpan;
|
|
122
|
-
}
|
|
123
|
-
if (!_symbols.definitions)
|
|
124
|
-
return;
|
|
125
|
-
symbols = symbols.concat(_symbols.definitions);
|
|
126
|
-
for (const ref of _symbols.definitions) {
|
|
127
|
-
loopChecker.add(ref.fileName + ':' + ref.textSpan.start);
|
|
128
|
-
const [virtualFile] = getVirtualFile(ref.fileName);
|
|
129
|
-
if (!virtualFile)
|
|
130
|
-
continue;
|
|
131
|
-
const mirrorMap = virtualFiles.getMirrorMap(virtualFile);
|
|
132
|
-
if (!mirrorMap)
|
|
133
|
-
continue;
|
|
134
|
-
for (const [mirrorOffset, data] of mirrorMap.findMirrorOffsets(ref.textSpan.start)) {
|
|
135
|
-
if (!data.definition)
|
|
136
|
-
continue;
|
|
137
|
-
if (loopChecker.has(ref.fileName + ':' + mirrorOffset))
|
|
138
|
-
continue;
|
|
139
|
-
withMirrors(ref.fileName, mirrorOffset);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
function findReferences(fileName, position) {
|
|
145
|
-
const loopChecker = new Set();
|
|
146
|
-
let symbols = [];
|
|
147
|
-
withMirrors(fileName, position);
|
|
148
|
-
return symbols.map(s => transformReferencedSymbol(s)).filter(notEmpty);
|
|
149
|
-
function withMirrors(fileName, position) {
|
|
150
|
-
if (loopChecker.has(fileName + ':' + position))
|
|
151
|
-
return;
|
|
152
|
-
loopChecker.add(fileName + ':' + position);
|
|
153
|
-
const _symbols = _findReferences(fileName, position);
|
|
154
|
-
if (!_symbols)
|
|
155
|
-
return;
|
|
156
|
-
symbols = symbols.concat(_symbols);
|
|
157
|
-
for (const symbol of _symbols) {
|
|
158
|
-
for (const ref of symbol.references) {
|
|
159
|
-
loopChecker.add(ref.fileName + ':' + ref.textSpan.start);
|
|
160
|
-
const [virtualFile] = getVirtualFile(ref.fileName);
|
|
161
|
-
if (!virtualFile)
|
|
162
|
-
continue;
|
|
163
|
-
const mirrorMap = virtualFiles.getMirrorMap(virtualFile);
|
|
164
|
-
if (!mirrorMap)
|
|
165
|
-
continue;
|
|
166
|
-
for (const [mirrorOffset, data] of mirrorMap.findMirrorOffsets(ref.textSpan.start)) {
|
|
167
|
-
if (!data.references)
|
|
168
|
-
continue;
|
|
169
|
-
if (loopChecker.has(ref.fileName + ':' + mirrorOffset))
|
|
170
|
-
continue;
|
|
171
|
-
withMirrors(ref.fileName, mirrorOffset);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
// transforms
|
|
178
|
-
function transformFileTextChanges(changes) {
|
|
179
|
-
const [_, source] = getVirtualFile(changes.fileName);
|
|
180
|
-
if (source) {
|
|
181
|
-
return {
|
|
182
|
-
...changes,
|
|
183
|
-
fileName: source.fileName,
|
|
184
|
-
textChanges: changes.textChanges.map(c => {
|
|
185
|
-
const span = transformSpan(changes.fileName, c.span);
|
|
186
|
-
if (span) {
|
|
187
|
-
return {
|
|
188
|
-
...c,
|
|
189
|
-
span: span.textSpan,
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
}).filter(notEmpty),
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
return changes;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
function transformReferencedSymbol(symbol) {
|
|
200
|
-
const definition = transformDocumentSpanLike(symbol.definition, false);
|
|
201
|
-
const references = symbol.references.map(r => transformDocumentSpanLike(r, false)).filter(notEmpty);
|
|
202
|
-
if (definition) {
|
|
203
|
-
return {
|
|
204
|
-
definition,
|
|
205
|
-
references,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
else if (references.length) { // TODO: remove patching
|
|
209
|
-
return {
|
|
210
|
-
definition: {
|
|
211
|
-
...symbol.definition,
|
|
212
|
-
fileName: references[0].fileName,
|
|
213
|
-
textSpan: references[0].textSpan,
|
|
214
|
-
},
|
|
215
|
-
references,
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
function transformDocumentSpanLike(documentSpan, isDefinition) {
|
|
220
|
-
let textSpan = transformSpan(documentSpan.fileName, documentSpan.textSpan);
|
|
221
|
-
if (isDefinition && !textSpan) {
|
|
222
|
-
const [virtualFile, source] = getVirtualFile(documentSpan.fileName);
|
|
223
|
-
if (virtualFile && source) {
|
|
224
|
-
textSpan = {
|
|
225
|
-
fileName: source.fileName,
|
|
226
|
-
textSpan: { start: 0, length: 0 },
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
if (!textSpan)
|
|
231
|
-
return;
|
|
232
|
-
const contextSpan = transformSpan(documentSpan.fileName, documentSpan.contextSpan);
|
|
233
|
-
const originalTextSpan = transformSpan(documentSpan.originalFileName, documentSpan.originalTextSpan);
|
|
234
|
-
const originalContextSpan = transformSpan(documentSpan.originalFileName, documentSpan.originalContextSpan);
|
|
235
|
-
return {
|
|
236
|
-
...documentSpan,
|
|
237
|
-
fileName: textSpan.fileName,
|
|
238
|
-
textSpan: textSpan.textSpan,
|
|
239
|
-
contextSpan: contextSpan?.textSpan,
|
|
240
|
-
originalFileName: originalTextSpan?.fileName,
|
|
241
|
-
originalTextSpan: originalTextSpan?.textSpan,
|
|
242
|
-
originalContextSpan: originalContextSpan?.textSpan,
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
function transformSpan(fileName, textSpan) {
|
|
246
|
-
if (!fileName)
|
|
247
|
-
return;
|
|
248
|
-
if (!textSpan)
|
|
249
|
-
return;
|
|
250
|
-
const [virtualFile, source] = getVirtualFile(fileName);
|
|
251
|
-
if (virtualFile && source) {
|
|
252
|
-
if (isTsPlugin) {
|
|
253
|
-
textSpan = {
|
|
254
|
-
start: textSpan.start - source.snapshot.getLength(),
|
|
255
|
-
length: textSpan.length,
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
for (const [_, [sourceSnapshot, map]] of virtualFiles.getMaps(virtualFile)) {
|
|
259
|
-
if (source.snapshot !== sourceSnapshot)
|
|
260
|
-
continue;
|
|
261
|
-
const sourceLoc = map.toSourceOffset(textSpan.start);
|
|
262
|
-
if (sourceLoc) {
|
|
263
|
-
return {
|
|
264
|
-
fileName: source.fileName,
|
|
265
|
-
textSpan: {
|
|
266
|
-
start: sourceLoc[0],
|
|
267
|
-
length: textSpan.length,
|
|
268
|
-
},
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
return {
|
|
275
|
-
fileName,
|
|
276
|
-
textSpan,
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
function getVirtualFile(fileName) {
|
|
281
|
-
if (isTsPlugin) {
|
|
282
|
-
let result;
|
|
283
|
-
const source = virtualFiles.getSource(fileName);
|
|
284
|
-
if (source) {
|
|
285
|
-
(0, language_core_1.forEachEmbeddedFile)(source.root, file => {
|
|
286
|
-
const ext = file.fileName.replace(fileName, '');
|
|
287
|
-
if (file.kind === language_core_1.FileKind.TypeScriptHostFile && (ext === '.d.ts' || ext.match(/^\.(js|ts)x?$/))) {
|
|
288
|
-
result = file;
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
return [result, source];
|
|
293
|
-
}
|
|
294
|
-
else {
|
|
295
|
-
return virtualFiles.getVirtualFile(fileName);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
exports.decorateLanguageService = decorateLanguageService;
|
|
300
|
-
function notEmpty(value) {
|
|
301
|
-
return value !== null && value !== undefined;
|
|
302
|
-
}
|
|
303
|
-
//# sourceMappingURL=languageService.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { LanguageContext } from '@volar/language-core';
|
|
2
|
-
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
|
-
export declare function createLanguageServiceHost(ctx: LanguageContext, ts: typeof import('typescript/lib/tsserverlibrary'), sys: ts.System & {
|
|
4
|
-
version?: number;
|
|
5
|
-
}): ts.LanguageServiceHost;
|
|
6
|
-
//# sourceMappingURL=languageServiceHost.d.ts.map
|