@volar/language-server 1.0.22 → 1.0.24
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 +8 -8
- package/out/browser/index.js +1 -1
- package/out/common/features/customFeatures.js +11 -12
- package/out/common/features/languageFeatures.js +12 -8
- package/out/common/project.js +11 -8
- package/out/common/utils/isFileInDir.d.ts +2 -0
- package/out/common/utils/isFileInDir.js +9 -0
- package/out/common/utils/uriMap.js +1 -1
- package/out/common/workspace.js +14 -13
- package/out/common/workspaces.js +4 -3
- package/out/node/fileSystem.js +1 -1
- package/out/node/index.js +2 -2
- package/package.json +5 -5
|
@@ -37,7 +37,7 @@ function createWebFileSystemHost() {
|
|
|
37
37
|
connection = _connection;
|
|
38
38
|
connection.onDidChangeWatchedFiles(params => {
|
|
39
39
|
for (const change of params.changes) {
|
|
40
|
-
const fsPath = shared.
|
|
40
|
+
const fsPath = shared.uriToFileName(change.uri);
|
|
41
41
|
const dir = getDir(path.dirname(fsPath));
|
|
42
42
|
const name = path.basename(fsPath);
|
|
43
43
|
if (change.type === vscode.FileChangeType.Created) {
|
|
@@ -78,11 +78,11 @@ function createWebFileSystemHost() {
|
|
|
78
78
|
},
|
|
79
79
|
};
|
|
80
80
|
function createWorkspaceFileSystem(rootUri) {
|
|
81
|
-
const rootPath = shared.
|
|
81
|
+
const rootPath = shared.uriToFileName(rootUri.toString());
|
|
82
82
|
return {
|
|
83
83
|
newLine: '\n',
|
|
84
84
|
useCaseSensitiveFileNames: false,
|
|
85
|
-
getCurrentDirectory: () => shared.
|
|
85
|
+
getCurrentDirectory: () => shared.uriToFileName(rootUri.toString()),
|
|
86
86
|
fileExists,
|
|
87
87
|
readFile,
|
|
88
88
|
readDirectory,
|
|
@@ -169,7 +169,7 @@ function createWebFileSystemHost() {
|
|
|
169
169
|
}
|
|
170
170
|
function statAsync(connection, fsPath, dir) {
|
|
171
171
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
-
const uri = shared.
|
|
172
|
+
const uri = shared.fileNameToUri(fsPath);
|
|
173
173
|
if (uri.startsWith('https://cdn.jsdelivr.net/npm/')) { // stat request always response file type for jsdelivr
|
|
174
174
|
const text = yield readJsdelivrFile(connection, uri);
|
|
175
175
|
if (text !== undefined) {
|
|
@@ -197,7 +197,7 @@ function createWebFileSystemHost() {
|
|
|
197
197
|
}
|
|
198
198
|
function readFileAsync(connection, fsPath, dir) {
|
|
199
199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
-
const uri = shared.
|
|
200
|
+
const uri = shared.fileNameToUri(fsPath);
|
|
201
201
|
if (uri.startsWith('https://cdn.jsdelivr.net/npm/')) {
|
|
202
202
|
const text = yield readJsdelivrFile(connection, uri);
|
|
203
203
|
if (text !== undefined) {
|
|
@@ -238,12 +238,12 @@ function createWebFileSystemHost() {
|
|
|
238
238
|
}
|
|
239
239
|
function readDirectoryAsync(connection, fsPath, dir) {
|
|
240
240
|
return __awaiter(this, void 0, void 0, function* () {
|
|
241
|
-
const uri = shared.
|
|
241
|
+
const uri = shared.fileNameToUri(fsPath);
|
|
242
242
|
const result = yield connection.sendRequest(protocol_1.FsReadDirectoryRequest.type, uri);
|
|
243
243
|
for (const [name, fileType] of result) {
|
|
244
244
|
if (dir.fileTypes.get(name) !== fileType && (fileType === vscode_html_languageservice_1.FileType.File || fileType === vscode_html_languageservice_1.FileType.SymbolicLink)) {
|
|
245
245
|
changes.push({
|
|
246
|
-
uri: shared.
|
|
246
|
+
uri: shared.fileNameToUri(path.join(fsPath, name)),
|
|
247
247
|
type: vscode.FileChangeType.Created,
|
|
248
248
|
});
|
|
249
249
|
}
|
|
@@ -262,7 +262,7 @@ function createWebFileSystemHost() {
|
|
|
262
262
|
let i = 0;
|
|
263
263
|
while (pendings.length) {
|
|
264
264
|
const current = pendings.shift();
|
|
265
|
-
progress === null || progress === void 0 ? void 0 : progress.report(i / pendings.length, vscode_uri_1.URI.parse(shared.
|
|
265
|
+
progress === null || progress === void 0 ? void 0 : progress.report(i / pendings.length, vscode_uri_1.URI.parse(shared.fileNameToUri(current[1])).fsPath);
|
|
266
266
|
yield current;
|
|
267
267
|
i++;
|
|
268
268
|
}
|
package/out/browser/index.js
CHANGED
|
@@ -49,7 +49,7 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
49
49
|
loadTypescriptLocalized(tsdk, locale) {
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
51
|
try {
|
|
52
|
-
const uri = shared.
|
|
52
|
+
const uri = shared.fileNameToUri(`${tsdk}/${locale}/diagnosticMessages.generated.json`);
|
|
53
53
|
const json = yield (0, http_1.default)(uri);
|
|
54
54
|
return JSON.parse(json);
|
|
55
55
|
}
|
|
@@ -67,7 +67,7 @@ function register(connection, projects) {
|
|
|
67
67
|
connection.onRequest(protocol_1.GetMatchTsConfigRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
68
68
|
const project = (yield projects.getProject(params.uri));
|
|
69
69
|
if (project === null || project === void 0 ? void 0 : project.tsconfig) {
|
|
70
|
-
return { uri: shared.
|
|
70
|
+
return { uri: shared.fileNameToUri(project.tsconfig) };
|
|
71
71
|
}
|
|
72
72
|
}));
|
|
73
73
|
connection.onRequest(protocol_1.GetVirtualFileNamesRequest.type, (document) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -75,9 +75,9 @@ function register(connection, projects) {
|
|
|
75
75
|
const project = yield projects.getProject(document.uri);
|
|
76
76
|
const fileNames = [];
|
|
77
77
|
if (project) {
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
(0, language_core_1.forEachEmbeddedFile)(
|
|
78
|
+
const rootVirtualFile = (_q = (_p = project.project) === null || _p === void 0 ? void 0 : _p.getLanguageService().context.core.virtualFiles.getSource(shared.uriToFileName(document.uri))) === null || _q === void 0 ? void 0 : _q.root;
|
|
79
|
+
if (rootVirtualFile) {
|
|
80
|
+
(0, language_core_1.forEachEmbeddedFile)(rootVirtualFile, e => {
|
|
81
81
|
if (e.snapshot.getLength() && e.kind === 1) {
|
|
82
82
|
fileNames.push(e.fileName);
|
|
83
83
|
}
|
|
@@ -87,16 +87,15 @@ function register(connection, projects) {
|
|
|
87
87
|
return fileNames;
|
|
88
88
|
}));
|
|
89
89
|
connection.onRequest(protocol_1.GetVirtualFileRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
var _r, _s, _t;
|
|
90
|
+
var _r, _s, _t, _u;
|
|
91
91
|
const project = yield projects.getProject(params.sourceFileUri);
|
|
92
92
|
if (project) {
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
const virtualFile = sourceAndVirtual[2];
|
|
93
|
+
const [virtualFile, source] = (_s = (_r = project.project) === null || _r === void 0 ? void 0 : _r.getLanguageService().context.core.virtualFiles.getVirtualFile(params.virtualFileName)) !== null && _s !== void 0 ? _s : [];
|
|
94
|
+
if (virtualFile && source) {
|
|
96
95
|
const mappings = {};
|
|
97
96
|
for (const mapping of virtualFile.mappings) {
|
|
98
|
-
const sourceUri = shared.
|
|
99
|
-
(
|
|
97
|
+
const sourceUri = shared.fileNameToUri((_t = mapping.source) !== null && _t !== void 0 ? _t : source.fileName);
|
|
98
|
+
(_u = mappings[sourceUri]) !== null && _u !== void 0 ? _u : (mappings[sourceUri] = []);
|
|
100
99
|
mappings[sourceUri].push(mapping);
|
|
101
100
|
}
|
|
102
101
|
return {
|
|
@@ -110,11 +109,11 @@ function register(connection, projects) {
|
|
|
110
109
|
projects.reloadProject();
|
|
111
110
|
});
|
|
112
111
|
connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
var
|
|
112
|
+
var _v;
|
|
114
113
|
const fs = yield Promise.resolve().then(() => require('fs'));
|
|
115
114
|
const project = yield projects.getProject(params.uri);
|
|
116
115
|
if (project) {
|
|
117
|
-
const ls = (
|
|
116
|
+
const ls = (_v = (yield project.project)) === null || _v === void 0 ? void 0 : _v.getLanguageServiceDontCreate();
|
|
118
117
|
if (ls) {
|
|
119
118
|
const sourceFiles = new Set(ls.context.host.getScriptFileNames());
|
|
120
119
|
for (const virtualFile of ls.context.core.typescript.languageServiceHost.getScriptFileNames()) {
|
|
@@ -267,19 +267,23 @@ function register(connection, projects, initParams, cancelHost, semanticTokensLe
|
|
|
267
267
|
}));
|
|
268
268
|
// TODO: connection.languages.inlayHint.resolve
|
|
269
269
|
connection.workspace.onWillRenameFiles((params) => __awaiter(this, void 0, void 0, function* () {
|
|
270
|
-
var _o;
|
|
271
270
|
const config = yield connection.workspace.getConfiguration('volar.updateImportsOnFileMove.enabled');
|
|
272
271
|
if (!config) {
|
|
273
272
|
return null;
|
|
274
273
|
}
|
|
275
|
-
|
|
276
|
-
|
|
274
|
+
const _edits = yield Promise.all(params.files.map((file) => __awaiter(this, void 0, void 0, function* () {
|
|
275
|
+
var _o;
|
|
276
|
+
return (_o = yield worker(file.oldUri, vueLs => {
|
|
277
|
+
var _a;
|
|
278
|
+
return (_a = vueLs.getEditsForFileRename(file.oldUri, file.newUri)) !== null && _a !== void 0 ? _a : null;
|
|
279
|
+
})) !== null && _o !== void 0 ? _o : null;
|
|
280
|
+
})));
|
|
281
|
+
const edits = _edits.filter(shared.notEmpty);
|
|
282
|
+
if (edits.length) {
|
|
283
|
+
embedded.mergeWorkspaceEdits(edits[0], ...edits.slice(1));
|
|
284
|
+
return edits[0];
|
|
277
285
|
}
|
|
278
|
-
|
|
279
|
-
return (_o = yield worker(file.oldUri, vueLs => {
|
|
280
|
-
var _a;
|
|
281
|
-
return (_a = vueLs.getEditsForFileRename(file.oldUri, file.newUri)) !== null && _a !== void 0 ? _a : null;
|
|
282
|
-
})) !== null && _o !== void 0 ? _o : null;
|
|
286
|
+
return null;
|
|
283
287
|
}));
|
|
284
288
|
connection.onRequest(protocol_1.AutoInsertRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
|
|
285
289
|
return worker(params.textDocument.uri, vueLs => {
|
package/out/common/project.js
CHANGED
|
@@ -35,7 +35,7 @@ function createProject(context) {
|
|
|
35
35
|
let projectVersion = 0;
|
|
36
36
|
let projectVersionUpdateTime = context.workspace.workspaces.cancelTokenHost.getMtime();
|
|
37
37
|
let languageService;
|
|
38
|
-
let parsedCommandLine = createParsedCommandLine(context.workspace.workspaces.ts, sys, shared.
|
|
38
|
+
let parsedCommandLine = createParsedCommandLine(context.workspace.workspaces.ts, sys, shared.uriToFileName(context.rootUri.toString()), context.tsConfig, context.workspace.workspaces.plugins);
|
|
39
39
|
const scripts = (0, uriMap_1.createUriMap)();
|
|
40
40
|
const languageServiceHost = createLanguageServiceHost();
|
|
41
41
|
const disposeWatchEvent = (_a = context.workspace.workspaces.fileSystemHost) === null || _a === void 0 ? void 0 : _a.onDidChangeWatchedFiles(params => {
|
|
@@ -121,7 +121,7 @@ function createProject(context) {
|
|
|
121
121
|
const creates = changes.filter(change => change.type === vscode.FileChangeType.Created);
|
|
122
122
|
const deletes = changes.filter(change => change.type === vscode.FileChangeType.Deleted);
|
|
123
123
|
if (creates.length || deletes.length) {
|
|
124
|
-
parsedCommandLine = createParsedCommandLine(context.workspace.workspaces.ts, sys, shared.
|
|
124
|
+
parsedCommandLine = createParsedCommandLine(context.workspace.workspaces.ts, sys, shared.uriToFileName(context.rootUri.toString()), context.tsConfig, context.workspace.workspaces.plugins);
|
|
125
125
|
projectVersion++;
|
|
126
126
|
typeRootVersion++;
|
|
127
127
|
}
|
|
@@ -148,7 +148,7 @@ function createProject(context) {
|
|
|
148
148
|
readDirectory: sys.readDirectory,
|
|
149
149
|
realpath: sys.realpath,
|
|
150
150
|
fileExists: sys.fileExists,
|
|
151
|
-
getCurrentDirectory: () => shared.
|
|
151
|
+
getCurrentDirectory: () => shared.uriToFileName(context.rootUri.toString()),
|
|
152
152
|
getProjectReferences: () => parsedCommandLine.projectReferences,
|
|
153
153
|
getCancellationToken: () => token,
|
|
154
154
|
// custom
|
|
@@ -276,10 +276,13 @@ function getHTMLDocumentContext(ts, host) {
|
|
|
276
276
|
resolveReference(ref, base) {
|
|
277
277
|
var _a, _b;
|
|
278
278
|
const isUri = base.indexOf('://') >= 0;
|
|
279
|
-
const resolveResult = ts.resolveModuleName(ref, isUri ? shared.
|
|
280
|
-
const failedLookupLocations = resolveResult.failedLookupLocations;
|
|
279
|
+
const resolveResult = ts.resolveModuleName(ref, isUri ? shared.uriToFileName(base) : base, host.getCompilationSettings(), host);
|
|
280
|
+
const failedLookupLocations = typeof resolveResult === 'object' ? resolveResult.failedLookupLocations : [];
|
|
281
281
|
const dirs = new Set();
|
|
282
|
-
|
|
282
|
+
if (!failedLookupLocations) {
|
|
283
|
+
console.warn(`[volar] failedLookupLocations not exists, ts: ${ts.version}`);
|
|
284
|
+
}
|
|
285
|
+
for (let failed of failedLookupLocations !== null && failedLookupLocations !== void 0 ? failedLookupLocations : []) {
|
|
283
286
|
const fileName = path.basename(failed);
|
|
284
287
|
if (fileName === 'index.d.ts' || fileName === '*.d.ts') {
|
|
285
288
|
dirs.add(path.dirname(failed));
|
|
@@ -291,12 +294,12 @@ function getHTMLDocumentContext(ts, host) {
|
|
|
291
294
|
continue;
|
|
292
295
|
}
|
|
293
296
|
if (host.fileExists(failed)) {
|
|
294
|
-
return isUri ? shared.
|
|
297
|
+
return isUri ? shared.fileNameToUri(failed) : failed;
|
|
295
298
|
}
|
|
296
299
|
}
|
|
297
300
|
for (const dir of dirs) {
|
|
298
301
|
if ((_b = (_a = host.directoryExists) === null || _a === void 0 ? void 0 : _a.call(host, dir)) !== null && _b !== void 0 ? _b : true) {
|
|
299
|
-
return isUri ? shared.
|
|
302
|
+
return isUri ? shared.fileNameToUri(dir) : dir;
|
|
300
303
|
}
|
|
301
304
|
}
|
|
302
305
|
return undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.isFileInDir = void 0;
|
|
3
|
+
const path = require("typesafe-path");
|
|
4
|
+
function isFileInDir(fileName, dir) {
|
|
5
|
+
const relative = path.relative(dir, fileName);
|
|
6
|
+
return !!relative && !relative.startsWith('..') && !path.isAbsolute(relative);
|
|
7
|
+
}
|
|
8
|
+
exports.isFileInDir = isFileInDir;
|
|
9
|
+
//# sourceMappingURL=isFileInDir.js.map
|
|
@@ -25,7 +25,7 @@ function createUriMap(map = new Map()) {
|
|
|
25
25
|
}
|
|
26
26
|
function getUriByPath(path) {
|
|
27
27
|
if (!pathToUri.has(path)) {
|
|
28
|
-
pathToUri.set(path, shared.
|
|
28
|
+
pathToUri.set(path, shared.fileNameToUri(path).toLowerCase());
|
|
29
29
|
}
|
|
30
30
|
return pathToUri.get(path);
|
|
31
31
|
}
|
package/out/common/workspace.js
CHANGED
|
@@ -17,27 +17,28 @@ const project_1 = require("./project");
|
|
|
17
17
|
const inferredCompilerOptions_1 = require("./utils/inferredCompilerOptions");
|
|
18
18
|
const serverConfig_1 = require("./utils/serverConfig");
|
|
19
19
|
const uriMap_1 = require("./utils/uriMap");
|
|
20
|
+
const isFileInDir_1 = require("./utils/isFileInDir");
|
|
20
21
|
exports.rootTsConfigNames = ['tsconfig.json', 'jsconfig.json'];
|
|
21
22
|
function createWorkspace(context) {
|
|
22
23
|
var _a, _b, _c;
|
|
23
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
25
|
let inferredProject;
|
|
25
|
-
const serverConfig = (0, serverConfig_1.loadServerConfig)(shared.
|
|
26
|
+
const serverConfig = (0, serverConfig_1.loadServerConfig)(shared.uriToFileName(context.rootUri.toString()), context.workspaces.initOptions.configFilePath);
|
|
26
27
|
const sys = (_a = context.workspaces.fileSystemHost) === null || _a === void 0 ? void 0 : _a.getWorkspaceFileSystem(context.rootUri);
|
|
27
|
-
const documentRegistry = sys ? (_b = context.workspaces.ts) === null || _b === void 0 ? void 0 : _b.createDocumentRegistry(sys.useCaseSensitiveFileNames, shared.
|
|
28
|
+
const documentRegistry = sys ? (_b = context.workspaces.ts) === null || _b === void 0 ? void 0 : _b.createDocumentRegistry(sys.useCaseSensitiveFileNames, shared.uriToFileName(context.rootUri.toString())) : undefined;
|
|
28
29
|
const projects = (0, uriMap_1.createUriMap)();
|
|
29
|
-
const rootTsConfigs = new Set(sys === null || sys === void 0 ? void 0 : sys.readDirectory(shared.
|
|
30
|
+
const rootTsConfigs = new Set(sys === null || sys === void 0 ? void 0 : sys.readDirectory(shared.uriToFileName(context.rootUri.toString()), exports.rootTsConfigNames, undefined, ['**/*']).map(fileName => shared.normalizeFileName(fileName)));
|
|
30
31
|
const disposeTsConfigWatch = (_c = context.workspaces.fileSystemHost) === null || _c === void 0 ? void 0 : _c.onDidChangeWatchedFiles(({ changes }) => {
|
|
31
32
|
for (const change of changes) {
|
|
32
33
|
if (exports.rootTsConfigNames.includes(change.uri.substring(change.uri.lastIndexOf('/') + 1))) {
|
|
33
34
|
if (change.type === vscode.FileChangeType.Created) {
|
|
34
|
-
if (
|
|
35
|
-
rootTsConfigs.add(shared.
|
|
35
|
+
if ((0, isFileInDir_1.isFileInDir)(shared.uriToFileName(change.uri), shared.uriToFileName(context.rootUri.toString()))) {
|
|
36
|
+
rootTsConfigs.add(shared.uriToFileName(change.uri));
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
else if ((change.type === vscode.FileChangeType.Changed || change.type === vscode.FileChangeType.Deleted) && projects.uriHas(change.uri)) {
|
|
39
40
|
if (change.type === vscode.FileChangeType.Deleted) {
|
|
40
|
-
rootTsConfigs.delete(shared.
|
|
41
|
+
rootTsConfigs.delete(shared.uriToFileName(change.uri));
|
|
41
42
|
}
|
|
42
43
|
const project = projects.uriGet(change.uri);
|
|
43
44
|
projects.uriDelete(change.uri);
|
|
@@ -106,11 +107,11 @@ function createWorkspace(context) {
|
|
|
106
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
108
|
let matches = [];
|
|
108
109
|
for (const rootTsConfig of rootTsConfigs) {
|
|
109
|
-
if (
|
|
110
|
+
if ((0, isFileInDir_1.isFileInDir)(shared.uriToFileName(uri.toString()), path.dirname(rootTsConfig))) {
|
|
110
111
|
matches.push(rootTsConfig);
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
|
-
matches = matches.sort((a, b) => sortTsConfigs(shared.
|
|
114
|
+
matches = matches.sort((a, b) => sortTsConfigs(shared.uriToFileName(uri.toString()), a, b));
|
|
114
115
|
if (matches.length) {
|
|
115
116
|
yield getParsedCommandLine(matches[0]);
|
|
116
117
|
}
|
|
@@ -132,14 +133,14 @@ function createWorkspace(context) {
|
|
|
132
133
|
var _a, _b;
|
|
133
134
|
const project = yield projects.pathGet(tsconfig);
|
|
134
135
|
const ls = project === null || project === void 0 ? void 0 : project.getLanguageServiceDontCreate();
|
|
135
|
-
const validDoc = (_b = (_a = ls === null || ls === void 0 ? void 0 : ls.context.typescript) === null || _a === void 0 ? void 0 : _a.languageService.getProgram()) === null || _b === void 0 ? void 0 : _b.getSourceFile(shared.
|
|
136
|
+
const validDoc = (_b = (_a = ls === null || ls === void 0 ? void 0 : ls.context.typescript) === null || _a === void 0 ? void 0 : _a.languageService.getProgram()) === null || _b === void 0 ? void 0 : _b.getSourceFile(shared.uriToFileName(uri.toString()));
|
|
136
137
|
return !!validDoc;
|
|
137
138
|
}));
|
|
138
139
|
}
|
|
139
140
|
function findTsconfig(match) {
|
|
140
141
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
142
|
const checked = new Set();
|
|
142
|
-
for (const rootTsConfig of [...rootTsConfigs].sort((a, b) => sortTsConfigs(shared.
|
|
143
|
+
for (const rootTsConfig of [...rootTsConfigs].sort((a, b) => sortTsConfigs(shared.uriToFileName(uri.toString()), a, b))) {
|
|
143
144
|
const project = yield projects.pathGet(rootTsConfig);
|
|
144
145
|
if (project) {
|
|
145
146
|
let chains = yield getReferencesChains(project.getParsedCommandLine(), rootTsConfig, []);
|
|
@@ -214,7 +215,7 @@ function createWorkspace(context) {
|
|
|
214
215
|
project = (0, project_1.createProject)({
|
|
215
216
|
workspace: context,
|
|
216
217
|
serverConfig,
|
|
217
|
-
rootUri: vscode_uri_1.URI.parse(shared.
|
|
218
|
+
rootUri: vscode_uri_1.URI.parse(shared.fileNameToUri(path.dirname(tsConfig))),
|
|
218
219
|
tsConfig,
|
|
219
220
|
documentRegistry,
|
|
220
221
|
});
|
|
@@ -226,8 +227,8 @@ function createWorkspace(context) {
|
|
|
226
227
|
}
|
|
227
228
|
exports.createWorkspace = createWorkspace;
|
|
228
229
|
function sortTsConfigs(file, a, b) {
|
|
229
|
-
const inA =
|
|
230
|
-
const inB =
|
|
230
|
+
const inA = (0, isFileInDir_1.isFileInDir)(file, path.dirname(a));
|
|
231
|
+
const inB = (0, isFileInDir_1.isFileInDir)(file, path.dirname(b));
|
|
231
232
|
if (inA !== inB) {
|
|
232
233
|
const aWeight = inA ? 1 : 0;
|
|
233
234
|
const bWeight = inB ? 1 : 0;
|
package/out/common/workspaces.js
CHANGED
|
@@ -13,6 +13,7 @@ const shared = require("@volar/shared");
|
|
|
13
13
|
const vscode = require("vscode-languageserver");
|
|
14
14
|
const types_1 = require("../types");
|
|
15
15
|
const workspace_1 = require("./workspace");
|
|
16
|
+
const isFileInDir_1 = require("./utils/isFileInDir");
|
|
16
17
|
function createWorkspaces(context) {
|
|
17
18
|
var _a, _b, _c;
|
|
18
19
|
const workspaces = new Map();
|
|
@@ -147,8 +148,8 @@ function createWorkspaces(context) {
|
|
|
147
148
|
var _a;
|
|
148
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
150
|
const rootUris = [...workspaces.keys()]
|
|
150
|
-
.filter(rootUri =>
|
|
151
|
-
.sort((a, b) => (0, workspace_1.sortTsConfigs)(shared.
|
|
151
|
+
.filter(rootUri => (0, isFileInDir_1.isFileInDir)(shared.uriToFileName(uri), shared.uriToFileName(rootUri)))
|
|
152
|
+
.sort((a, b) => (0, workspace_1.sortTsConfigs)(shared.uriToFileName(uri), shared.uriToFileName(a), shared.uriToFileName(b)));
|
|
152
153
|
if (context.initOptions.serverMode !== types_1.ServerMode.Syntactic) {
|
|
153
154
|
for (const rootUri of rootUris) {
|
|
154
155
|
const workspace = yield workspaces.get(rootUri);
|
|
@@ -160,7 +161,7 @@ function createWorkspaces(context) {
|
|
|
160
161
|
}
|
|
161
162
|
if (rootUris.length) {
|
|
162
163
|
const project = yield ((_a = (yield workspaces.get(rootUris[0]))) === null || _a === void 0 ? void 0 : _a.getInferredProject());
|
|
163
|
-
project === null || project === void 0 ? void 0 : project.tryAddFile(shared.
|
|
164
|
+
project === null || project === void 0 ? void 0 : project.tryAddFile(shared.uriToFileName(uri));
|
|
164
165
|
return {
|
|
165
166
|
tsconfig: undefined,
|
|
166
167
|
project,
|
package/out/node/fileSystem.js
CHANGED
|
@@ -51,7 +51,7 @@ function createNodeFileSystemHost(ts, capabilities) {
|
|
|
51
51
|
};
|
|
52
52
|
function createWorkspaceFileSystem(ts, capabilities, rootUri) {
|
|
53
53
|
var _a;
|
|
54
|
-
const rootPath = shared.
|
|
54
|
+
const rootPath = shared.uriToFileName(rootUri.toString());
|
|
55
55
|
const workspaceSys = new Proxy(ts.sys, {
|
|
56
56
|
get(target, prop) {
|
|
57
57
|
const fn = target[prop];
|
package/out/node/index.js
CHANGED
|
@@ -72,7 +72,7 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
72
72
|
fileSystemProvide: {
|
|
73
73
|
stat: (uri) => {
|
|
74
74
|
return new Promise((resolve, reject) => {
|
|
75
|
-
fs.stat(shared.
|
|
75
|
+
fs.stat(shared.uriToFileName(uri), (err, stats) => {
|
|
76
76
|
if (stats) {
|
|
77
77
|
resolve({
|
|
78
78
|
type: stats.isFile() ? html.FileType.File
|
|
@@ -92,7 +92,7 @@ function startLanguageServer(connection, ...plugins) {
|
|
|
92
92
|
},
|
|
93
93
|
readDirectory: (uri) => {
|
|
94
94
|
return new Promise((resolve, reject) => {
|
|
95
|
-
fs.readdir(shared.
|
|
95
|
+
fs.readdir(shared.uriToFileName(uri), (err, files) => {
|
|
96
96
|
if (files) {
|
|
97
97
|
resolve(files.map(file => [file, html.FileType.File]));
|
|
98
98
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"directory": "packages/language-server"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@volar/language-core": "1.0.
|
|
21
|
-
"@volar/language-service": "1.0.
|
|
22
|
-
"@volar/shared": "1.0.
|
|
20
|
+
"@volar/language-core": "1.0.24",
|
|
21
|
+
"@volar/language-service": "1.0.24",
|
|
22
|
+
"@volar/shared": "1.0.24",
|
|
23
23
|
"request-light": "^0.6.0",
|
|
24
24
|
"typesafe-path": "^0.2.2",
|
|
25
25
|
"vscode-html-languageservice": "^5.0.3",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
29
29
|
"vscode-uri": "^3.0.7"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "46da609e8914e29642f4707dec31507ad51b03fc"
|
|
32
32
|
}
|