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