@volar/language-server 1.4.0-alpha.0 → 1.4.0-alpha.10
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/out/browser/fileSystems.js +83 -107
- package/out/browser/index.js +11 -23
- package/out/browser/typescript/core.js +2 -1
- package/out/browser/typescript/corePublic.js +3 -2
- package/out/browser/typescript/path.js +1 -0
- package/out/browser/typescript/types.js +1 -0
- package/out/browser/typescript/utilities.js +1 -0
- package/out/common/cancellationPipe.js +2 -1
- package/out/common/configurationHost.js +13 -28
- package/out/common/documents.js +3 -3
- package/out/common/features/customFeatures.js +35 -47
- package/out/common/features/languageFeatures.js +135 -163
- package/out/common/project.d.ts +66 -62
- package/out/common/project.js +205 -228
- package/out/common/schemaRequestHandlers/file.js +1 -0
- package/out/common/schemaRequestHandlers/http.js +1 -0
- package/out/common/server.js +63 -68
- package/out/common/utils/inferredCompilerOptions.js +58 -61
- package/out/common/utils/isFileInDir.js +1 -0
- package/out/common/utils/registerFeatures.js +11 -12
- package/out/common/utils/serverConfig.js +3 -2
- package/out/common/utils/uriMap.js +2 -1
- package/out/common/workspace.d.ts +605 -568
- package/out/common/workspace.js +182 -194
- package/out/common/workspaces.d.ts +726 -682
- package/out/common/workspaces.js +82 -107
- package/out/index.js +1 -0
- package/out/node/fileSystem.js +13 -16
- package/out/node/index.js +16 -19
- package/out/protocol.d.ts +0 -6
- package/out/protocol.js +2 -5
- package/out/types.d.ts +4 -6
- package/out/types.js +1 -0
- package/package.json +4 -4
package/out/common/project.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
1
|
+
"use strict";
|
|
10
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
3
|
exports.createProject = void 0;
|
|
12
4
|
const embeddedLS = require("@volar/language-service");
|
|
@@ -16,242 +8,228 @@ const vscode_uri_1 = require("vscode-uri");
|
|
|
16
8
|
const types_1 = require("../types");
|
|
17
9
|
const serverConfig_1 = require("./utils/serverConfig");
|
|
18
10
|
const uriMap_1 = require("./utils/uriMap");
|
|
19
|
-
function createProject(context) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
11
|
+
async function createProject(context) {
|
|
12
|
+
const uriToFileName = context.workspace.workspaces.server.runtimeEnv.uriToFileName;
|
|
13
|
+
const fileNameToUri = context.workspace.workspaces.server.runtimeEnv.fileNameToUri;
|
|
14
|
+
const sys = context.workspace.workspaces.initOptions.serverMode === types_1.ServerMode.Syntactic || !context.workspace.workspaces.fileSystemHost
|
|
15
|
+
? {
|
|
16
|
+
newLine: '\n',
|
|
17
|
+
useCaseSensitiveFileNames: false,
|
|
18
|
+
fileExists: () => false,
|
|
19
|
+
readFile: () => undefined,
|
|
20
|
+
readDirectory: () => [],
|
|
21
|
+
getCurrentDirectory: () => '',
|
|
22
|
+
realpath: () => '',
|
|
23
|
+
resolvePath: () => '',
|
|
24
|
+
}
|
|
25
|
+
: context.workspace.workspaces.fileSystemHost.getWorkspaceFileSystem(context.rootUri);
|
|
26
|
+
let typeRootVersion = 0;
|
|
27
|
+
let projectVersion = 0;
|
|
28
|
+
let projectVersionUpdateTime = context.workspace.workspaces.cancelTokenHost.getMtime();
|
|
29
|
+
let languageService;
|
|
30
|
+
let parsedCommandLine = createParsedCommandLine(context.workspace.workspaces.ts, sys, uriToFileName(context.rootUri.toString()), context.tsConfig, context.workspace.workspaces.plugins);
|
|
31
|
+
const scripts = (0, uriMap_1.createUriMap)(fileNameToUri);
|
|
32
|
+
const languageServiceHost = createLanguageServiceHost();
|
|
33
|
+
const disposeWatchEvent = context.workspace.workspaces.fileSystemHost?.onDidChangeWatchedFiles(params => {
|
|
34
|
+
onWorkspaceFilesChanged(params.changes);
|
|
35
|
+
});
|
|
36
|
+
const disposeDocChange = context.workspace.workspaces.documents.onDidChangeContent(() => {
|
|
37
|
+
projectVersion++;
|
|
38
|
+
projectVersionUpdateTime = context.workspace.workspaces.cancelTokenHost.getMtime();
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
tsConfig: context.tsConfig,
|
|
42
|
+
scripts,
|
|
43
|
+
languageServiceHost,
|
|
44
|
+
getLanguageService,
|
|
45
|
+
getLanguageServiceDontCreate: () => languageService,
|
|
46
|
+
getParsedCommandLine: () => parsedCommandLine,
|
|
47
|
+
tryAddFile: (fileName) => {
|
|
48
|
+
if (!parsedCommandLine.fileNames.includes(fileName)) {
|
|
49
|
+
parsedCommandLine.fileNames.push(fileName);
|
|
50
|
+
projectVersion++;
|
|
51
|
+
projectVersionUpdateTime = context.workspace.workspaces.cancelTokenHost.getMtime();
|
|
34
52
|
}
|
|
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
|
-
projectVersionUpdateTime = context.workspace.workspaces.cancelTokenHost.getMtime();
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
dispose,
|
|
65
|
-
};
|
|
66
|
-
function getLanguageService() {
|
|
67
|
-
var _a;
|
|
68
|
-
if (!languageService) {
|
|
69
|
-
let config = (_a = (context.workspace.rootUri.scheme === 'file' ? (0, serverConfig_1.loadConfig)(context.workspace.rootUri.path, context.workspace.workspaces.initOptions.configFilePath) : {})) !== null && _a !== void 0 ? _a : {};
|
|
70
|
-
const options = {
|
|
71
|
-
uriToFileName,
|
|
72
|
-
fileNameToUri,
|
|
73
|
-
rootUri: context.rootUri,
|
|
74
|
-
host: languageServiceHost,
|
|
75
|
-
get config() {
|
|
76
|
-
return config;
|
|
77
|
-
},
|
|
78
|
-
locale: context.workspace.workspaces.initParams.locale,
|
|
79
|
-
configurationHost: context.workspace.workspaces.configurationHost,
|
|
80
|
-
fileSystemProvider: context.workspace.workspaces.server.runtimeEnv.fileSystemProvide,
|
|
81
|
-
documentContext: getDocumentContext(fileNameToUri, uriToFileName, context.workspace.workspaces.ts, languageServiceHost, context.rootUri.toString()),
|
|
82
|
-
schemaRequestService: (uri) => __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
var _b;
|
|
84
|
-
const protocol = uri.substring(0, uri.indexOf(':'));
|
|
85
|
-
const builtInHandler = context.workspace.workspaces.server.runtimeEnv.schemaRequestHandlers[protocol];
|
|
86
|
-
if (builtInHandler) {
|
|
87
|
-
return (_b = yield builtInHandler(uri)) !== null && _b !== void 0 ? _b : '';
|
|
88
|
-
}
|
|
89
|
-
return '';
|
|
90
|
-
}),
|
|
91
|
-
};
|
|
92
|
-
const lsCtx = {
|
|
93
|
-
project: context,
|
|
94
|
-
options,
|
|
95
|
-
sys,
|
|
96
|
-
host: languageServiceHost,
|
|
97
|
-
};
|
|
98
|
-
for (const plugin of context.workspace.workspaces.plugins) {
|
|
99
|
-
if (plugin.resolveConfig) {
|
|
100
|
-
config = plugin.resolveConfig(config, { typescript: lsCtx.project.workspace.workspaces.ts }, lsCtx);
|
|
53
|
+
},
|
|
54
|
+
dispose,
|
|
55
|
+
};
|
|
56
|
+
function getLanguageService() {
|
|
57
|
+
if (!languageService) {
|
|
58
|
+
let config = (context.workspace.rootUri.scheme === 'file' ? (0, serverConfig_1.loadConfig)(context.workspace.rootUri.path, context.workspace.workspaces.initOptions.configFilePath) : {}) ?? {};
|
|
59
|
+
const options = {
|
|
60
|
+
modules: { typescript: context.workspace.workspaces.ts },
|
|
61
|
+
uriToFileName,
|
|
62
|
+
fileNameToUri,
|
|
63
|
+
locale: context.workspace.workspaces.initParams.locale,
|
|
64
|
+
rootUri: context.rootUri,
|
|
65
|
+
capabilities: context.workspace.workspaces.initParams.capabilities,
|
|
66
|
+
host: languageServiceHost,
|
|
67
|
+
get config() {
|
|
68
|
+
return config;
|
|
69
|
+
},
|
|
70
|
+
configurationHost: context.workspace.workspaces.configurationHost,
|
|
71
|
+
fileSystemProvider: context.workspace.workspaces.server.runtimeEnv.fileSystemProvide,
|
|
72
|
+
fileSystemHost: context.workspace.workspaces.fileSystemHost,
|
|
73
|
+
documentContext: getDocumentContext(fileNameToUri, uriToFileName, context.workspace.workspaces.ts, languageServiceHost, context.rootUri.toString()),
|
|
74
|
+
schemaRequestService: async (uri) => {
|
|
75
|
+
const protocol = uri.substring(0, uri.indexOf(':'));
|
|
76
|
+
const builtInHandler = context.workspace.workspaces.server.runtimeEnv.schemaRequestHandlers[protocol];
|
|
77
|
+
if (builtInHandler) {
|
|
78
|
+
return await builtInHandler(uri) ?? '';
|
|
101
79
|
}
|
|
80
|
+
return '';
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
const lsCtx = {
|
|
84
|
+
project: context,
|
|
85
|
+
options,
|
|
86
|
+
sys,
|
|
87
|
+
host: languageServiceHost,
|
|
88
|
+
};
|
|
89
|
+
for (const plugin of context.workspace.workspaces.plugins) {
|
|
90
|
+
if (plugin.resolveConfig) {
|
|
91
|
+
config = plugin.resolveConfig(config, lsCtx);
|
|
102
92
|
}
|
|
103
|
-
languageService = embeddedLS.createLanguageService(options, context.documentRegistry);
|
|
104
93
|
}
|
|
105
|
-
|
|
94
|
+
languageService = embeddedLS.createLanguageService(options, context.documentRegistry);
|
|
106
95
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
else {
|
|
117
|
-
script.version--;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
else if (script && change.type === vscode.FileChangeType.Deleted) {
|
|
121
|
-
scripts.uriDelete(change.uri);
|
|
122
|
-
}
|
|
123
|
-
if (script
|
|
124
|
-
|| change.uri.endsWith('.d.ts')
|
|
125
|
-
|| change.uri.endsWith('/package.json')) {
|
|
126
|
-
projectVersion++;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
const creates = changes.filter(change => change.type === vscode.FileChangeType.Created);
|
|
130
|
-
const deletes = changes.filter(change => change.type === vscode.FileChangeType.Deleted);
|
|
131
|
-
if (creates.length || deletes.length) {
|
|
132
|
-
parsedCommandLine = createParsedCommandLine(context.workspace.workspaces.ts, sys, uriToFileName(context.rootUri.toString()), context.tsConfig, context.workspace.workspaces.plugins);
|
|
133
|
-
projectVersion++;
|
|
134
|
-
typeRootVersion++;
|
|
96
|
+
return languageService;
|
|
97
|
+
}
|
|
98
|
+
async function onWorkspaceFilesChanged(changes) {
|
|
99
|
+
const _projectVersion = projectVersion;
|
|
100
|
+
for (const change of changes) {
|
|
101
|
+
const script = scripts.uriGet(change.uri);
|
|
102
|
+
if (script && (change.type === vscode.FileChangeType.Changed || change.type === vscode.FileChangeType.Created)) {
|
|
103
|
+
if (script.version >= 0) {
|
|
104
|
+
script.version = -1;
|
|
135
105
|
}
|
|
136
|
-
|
|
137
|
-
|
|
106
|
+
else {
|
|
107
|
+
script.version--;
|
|
138
108
|
}
|
|
139
|
-
}
|
|
109
|
+
}
|
|
110
|
+
else if (script && change.type === vscode.FileChangeType.Deleted) {
|
|
111
|
+
scripts.uriDelete(change.uri);
|
|
112
|
+
}
|
|
113
|
+
if (script
|
|
114
|
+
|| change.uri.endsWith('.d.ts')
|
|
115
|
+
|| change.uri.endsWith('/package.json')) {
|
|
116
|
+
projectVersion++;
|
|
117
|
+
}
|
|
140
118
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
119
|
+
const creates = changes.filter(change => change.type === vscode.FileChangeType.Created);
|
|
120
|
+
const deletes = changes.filter(change => change.type === vscode.FileChangeType.Deleted);
|
|
121
|
+
if (creates.length || deletes.length) {
|
|
122
|
+
parsedCommandLine = createParsedCommandLine(context.workspace.workspaces.ts, sys, uriToFileName(context.rootUri.toString()), context.tsConfig, context.workspace.workspaces.plugins);
|
|
123
|
+
projectVersion++;
|
|
124
|
+
typeRootVersion++;
|
|
125
|
+
}
|
|
126
|
+
if (_projectVersion !== projectVersion) {
|
|
127
|
+
projectVersionUpdateTime = context.workspace.workspaces.cancelTokenHost.getMtime();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function createLanguageServiceHost() {
|
|
131
|
+
const token = {
|
|
132
|
+
isCancellationRequested() {
|
|
133
|
+
return context.workspace.workspaces.cancelTokenHost.getMtime() !== projectVersionUpdateTime;
|
|
134
|
+
},
|
|
135
|
+
throwIfCancellationRequested() { },
|
|
136
|
+
};
|
|
137
|
+
let host = {
|
|
138
|
+
// ts
|
|
139
|
+
getNewLine: () => sys.newLine,
|
|
140
|
+
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
|
|
141
|
+
readFile: sys.readFile,
|
|
142
|
+
writeFile: sys.writeFile,
|
|
143
|
+
directoryExists: sys.directoryExists,
|
|
144
|
+
getDirectories: sys.getDirectories,
|
|
145
|
+
readDirectory: sys.readDirectory,
|
|
146
|
+
realpath: sys.realpath,
|
|
147
|
+
fileExists: sys.fileExists,
|
|
148
|
+
getCurrentDirectory: () => uriToFileName(context.rootUri.toString()),
|
|
149
|
+
getProjectReferences: () => parsedCommandLine.projectReferences,
|
|
150
|
+
getCancellationToken: () => token,
|
|
151
|
+
// custom
|
|
152
|
+
getDefaultLibFileName: options => {
|
|
153
|
+
if (context.workspace.workspaces.initOptions.typescript && context.workspace.workspaces.ts) {
|
|
154
|
+
try {
|
|
155
|
+
return context.workspace.workspaces.ts.getDefaultLibFilePath(options);
|
|
173
156
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
157
|
+
catch {
|
|
158
|
+
// web
|
|
159
|
+
const tsdk = context.workspace.workspaces.initOptions.typescript.tsdk;
|
|
160
|
+
return tsdk + '/' + context.workspace.workspaces.ts.getDefaultLibFileName(options);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return '';
|
|
164
|
+
},
|
|
165
|
+
getProjectVersion: () => projectVersion.toString(),
|
|
166
|
+
getTypeRootsVersion: () => typeRootVersion,
|
|
167
|
+
getScriptFileNames: () => parsedCommandLine.fileNames,
|
|
168
|
+
getCompilationSettings: () => parsedCommandLine.options,
|
|
169
|
+
getScriptVersion,
|
|
170
|
+
getScriptSnapshot,
|
|
171
|
+
getScriptLanguageId: (fileName) => {
|
|
172
|
+
return context.workspace.workspaces.documents.data.pathGet(fileName)?.languageId;
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
if (context.workspace.workspaces.tsLocalized) {
|
|
176
|
+
host.getLocalizedDiagnosticMessages = () => context.workspace.workspaces.tsLocalized;
|
|
177
|
+
}
|
|
178
|
+
return host;
|
|
179
|
+
function getScriptVersion(fileName) {
|
|
180
|
+
const doc = context.workspace.workspaces.documents.data.pathGet(fileName);
|
|
181
|
+
if (doc) {
|
|
182
|
+
return doc.version.toString();
|
|
193
183
|
}
|
|
194
|
-
|
|
195
|
-
|
|
184
|
+
return scripts.pathGet(fileName)?.version.toString() ?? '';
|
|
185
|
+
}
|
|
186
|
+
function getScriptSnapshot(fileName) {
|
|
187
|
+
const doc = context.workspace.workspaces.documents.data.pathGet(fileName);
|
|
188
|
+
if (doc) {
|
|
189
|
+
return doc.getSnapshot();
|
|
196
190
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const doc = context.workspace.workspaces.documents.data.pathGet(fileName);
|
|
201
|
-
if (doc) {
|
|
202
|
-
return doc.version.toString();
|
|
203
|
-
}
|
|
204
|
-
return (_b = (_a = scripts.pathGet(fileName)) === null || _a === void 0 ? void 0 : _a.version.toString()) !== null && _b !== void 0 ? _b : '';
|
|
191
|
+
const script = scripts.pathGet(fileName);
|
|
192
|
+
if (script && script.snapshotVersion === script.version) {
|
|
193
|
+
return script.snapshot;
|
|
205
194
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (script && script.snapshotVersion === script.version) {
|
|
214
|
-
return script.snapshot;
|
|
195
|
+
if (context.workspace.workspaces.ts && sys.fileExists(fileName)) {
|
|
196
|
+
if (context.workspace.workspaces.initOptions.maxFileSize) {
|
|
197
|
+
const fileSize = sys.getFileSize?.(fileName);
|
|
198
|
+
if (fileSize !== undefined && fileSize > context.workspace.workspaces.initOptions.maxFileSize) {
|
|
199
|
+
console.warn(`IGNORING "${fileName}" because it is too large (${fileSize}bytes > ${context.workspace.workspaces.initOptions.maxFileSize}bytes)`);
|
|
200
|
+
return context.workspace.workspaces.ts.ScriptSnapshot.fromString('');
|
|
201
|
+
}
|
|
215
202
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
203
|
+
const text = sys.readFile(fileName, 'utf8');
|
|
204
|
+
if (text !== undefined) {
|
|
205
|
+
const snapshot = context.workspace.workspaces.ts.ScriptSnapshot.fromString(text);
|
|
206
|
+
if (script) {
|
|
207
|
+
script.snapshot = snapshot;
|
|
208
|
+
script.snapshotVersion = script.version;
|
|
223
209
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
else {
|
|
232
|
-
scripts.pathSet(fileName, {
|
|
233
|
-
version: -1,
|
|
234
|
-
fileName: fileName,
|
|
235
|
-
snapshot: snapshot,
|
|
236
|
-
snapshotVersion: -1,
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
return snapshot;
|
|
210
|
+
else {
|
|
211
|
+
scripts.pathSet(fileName, {
|
|
212
|
+
version: -1,
|
|
213
|
+
fileName: fileName,
|
|
214
|
+
snapshot: snapshot,
|
|
215
|
+
snapshotVersion: -1,
|
|
216
|
+
});
|
|
240
217
|
}
|
|
218
|
+
return snapshot;
|
|
241
219
|
}
|
|
242
220
|
}
|
|
243
221
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
222
|
+
}
|
|
223
|
+
function dispose() {
|
|
224
|
+
languageService?.dispose();
|
|
225
|
+
scripts.clear();
|
|
226
|
+
disposeWatchEvent?.();
|
|
227
|
+
disposeDocChange();
|
|
228
|
+
}
|
|
251
229
|
}
|
|
252
230
|
exports.createProject = createProject;
|
|
253
231
|
function createParsedCommandLine(ts, sys, rootPath, tsConfig, plugins) {
|
|
254
|
-
const extraFileExtensions = plugins.map(plugin =>
|
|
232
|
+
const extraFileExtensions = plugins.map(plugin => plugin.extraFileExtensions ?? []).flat();
|
|
255
233
|
if (ts) {
|
|
256
234
|
try {
|
|
257
235
|
let content;
|
|
@@ -269,7 +247,7 @@ function createParsedCommandLine(ts, sys, rootPath, tsConfig, plugins) {
|
|
|
269
247
|
content.fileNames = content.fileNames.map(fileName => fileName.replace(/\\/g, '/'));
|
|
270
248
|
return content;
|
|
271
249
|
}
|
|
272
|
-
catch
|
|
250
|
+
catch {
|
|
273
251
|
// will be failed if web fs host first result not ready
|
|
274
252
|
}
|
|
275
253
|
}
|
|
@@ -282,7 +260,6 @@ function createParsedCommandLine(ts, sys, rootPath, tsConfig, plugins) {
|
|
|
282
260
|
function getDocumentContext(fileNameToUri, uriToFileName, ts, host, rootUri) {
|
|
283
261
|
const documentContext = {
|
|
284
262
|
resolveReference: (ref, base) => {
|
|
285
|
-
var _a, _b;
|
|
286
263
|
if (ts && host) { // support tsconfig.json paths
|
|
287
264
|
const isUri = base.indexOf('://') >= 0;
|
|
288
265
|
const resolveResult = ts.resolveModuleName(ref, isUri ? uriToFileName(base) : base, host.getCompilationSettings(), host);
|
|
@@ -291,7 +268,7 @@ function getDocumentContext(fileNameToUri, uriToFileName, ts, host, rootUri) {
|
|
|
291
268
|
if (!failedLookupLocations) {
|
|
292
269
|
console.warn(`[volar] failedLookupLocations not exists, ts: ${ts.version}`);
|
|
293
270
|
}
|
|
294
|
-
for (let failed of failedLookupLocations
|
|
271
|
+
for (let failed of failedLookupLocations ?? []) {
|
|
295
272
|
const fileName = path.basename(failed);
|
|
296
273
|
if (fileName === 'index.d.ts' || fileName === '*.d.ts') {
|
|
297
274
|
dirs.add(path.dirname(failed));
|
|
@@ -307,7 +284,7 @@ function getDocumentContext(fileNameToUri, uriToFileName, ts, host, rootUri) {
|
|
|
307
284
|
}
|
|
308
285
|
}
|
|
309
286
|
for (const dir of dirs) {
|
|
310
|
-
if (
|
|
287
|
+
if (host.directoryExists?.(dir) ?? true) {
|
|
311
288
|
return isUri ? fileNameToUri(dir) : dir;
|
|
312
289
|
}
|
|
313
290
|
}
|