@volar/language-server 1.2.0-alpha.9 → 1.3.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.d.ts +2 -2
- package/out/browser/fileSystems.js +151 -161
- package/out/browser/index.js +64 -32
- package/out/common/documents.d.ts +2 -1
- package/out/common/documents.js +8 -2
- package/out/common/features/customFeatures.d.ts +2 -1
- package/out/common/features/customFeatures.js +12 -12
- package/out/common/features/languageFeatures.d.ts +3 -2
- package/out/common/features/languageFeatures.js +56 -32
- package/out/common/project.d.ts +7 -5
- package/out/common/project.js +26 -17
- package/out/common/schemaRequestHandlers/http.d.ts +1 -1
- package/out/common/schemaRequestHandlers/http.js +3 -0
- package/out/common/server.d.ts +2 -2
- package/out/common/server.js +18 -15
- package/out/common/utils/uriMap.d.ts +1 -1
- package/out/common/utils/uriMap.js +2 -3
- package/out/common/workspace.d.ts +63 -45
- package/out/common/workspace.js +16 -15
- package/out/common/workspaces.d.ts +78 -56
- package/out/common/workspaces.js +4 -3
- package/out/node/fileSystem.d.ts +2 -2
- package/out/node/fileSystem.js +3 -4
- package/out/node/index.js +72 -66
- package/out/protocol.d.ts +6 -7
- package/out/protocol.js +1 -5
- package/out/types.d.ts +41 -15
- package/package.json +10 -10
package/out/common/workspace.js
CHANGED
|
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.sortTsConfigs = exports.createWorkspace = exports.rootTsConfigNames = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
12
|
const path = require("typesafe-path");
|
|
14
13
|
const vscode = require("vscode-languageserver");
|
|
15
14
|
const vscode_uri_1 = require("vscode-uri");
|
|
@@ -22,23 +21,25 @@ exports.rootTsConfigNames = ['tsconfig.json', 'jsconfig.json'];
|
|
|
22
21
|
function createWorkspace(context) {
|
|
23
22
|
var _a, _b, _c;
|
|
24
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const fileNameToUri = context.workspaces.server.runtimeEnv.fileNameToUri;
|
|
25
|
+
const uriToFileName = context.workspaces.server.runtimeEnv.uriToFileName;
|
|
25
26
|
let inferredProject;
|
|
26
|
-
const serverConfig = (0, serverConfig_1.loadConfig)(
|
|
27
|
+
const serverConfig = (0, serverConfig_1.loadConfig)(uriToFileName(context.rootUri.toString()), context.workspaces.initOptions.configFilePath);
|
|
27
28
|
const sys = (_a = context.workspaces.fileSystemHost) === null || _a === void 0 ? void 0 : _a.getWorkspaceFileSystem(context.rootUri);
|
|
28
|
-
const documentRegistry = sys ? (_b = context.workspaces.ts) === null || _b === void 0 ? void 0 : _b.createDocumentRegistry(sys.useCaseSensitiveFileNames,
|
|
29
|
-
const projects = (0, uriMap_1.createUriMap)();
|
|
30
|
-
const rootTsConfigs = new Set(sys === null || sys === void 0 ? void 0 : sys.readDirectory(
|
|
29
|
+
const documentRegistry = sys ? (_b = context.workspaces.ts) === null || _b === void 0 ? void 0 : _b.createDocumentRegistry(sys.useCaseSensitiveFileNames, uriToFileName(context.rootUri.toString())) : undefined;
|
|
30
|
+
const projects = (0, uriMap_1.createUriMap)(fileNameToUri);
|
|
31
|
+
const rootTsConfigs = new Set(sys === null || sys === void 0 ? void 0 : sys.readDirectory(uriToFileName(context.rootUri.toString()), exports.rootTsConfigNames, undefined, ['**/*']).map(fileName => fileName.replace(/\\/g, '/')));
|
|
31
32
|
const disposeTsConfigWatch = (_c = context.workspaces.fileSystemHost) === null || _c === void 0 ? void 0 : _c.onDidChangeWatchedFiles(({ changes }) => {
|
|
32
33
|
for (const change of changes) {
|
|
33
34
|
if (exports.rootTsConfigNames.includes(change.uri.substring(change.uri.lastIndexOf('/') + 1))) {
|
|
34
35
|
if (change.type === vscode.FileChangeType.Created) {
|
|
35
|
-
if ((0, isFileInDir_1.isFileInDir)(
|
|
36
|
-
rootTsConfigs.add(
|
|
36
|
+
if ((0, isFileInDir_1.isFileInDir)(uriToFileName(change.uri), uriToFileName(context.rootUri.toString()))) {
|
|
37
|
+
rootTsConfigs.add(uriToFileName(change.uri));
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
else if ((change.type === vscode.FileChangeType.Changed || change.type === vscode.FileChangeType.Deleted) && projects.uriHas(change.uri)) {
|
|
40
41
|
if (change.type === vscode.FileChangeType.Deleted) {
|
|
41
|
-
rootTsConfigs.delete(
|
|
42
|
+
rootTsConfigs.delete(uriToFileName(change.uri));
|
|
42
43
|
}
|
|
43
44
|
const project = projects.uriGet(change.uri);
|
|
44
45
|
projects.uriDelete(change.uri);
|
|
@@ -107,11 +108,11 @@ function createWorkspace(context) {
|
|
|
107
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
108
109
|
let matches = [];
|
|
109
110
|
for (const rootTsConfig of rootTsConfigs) {
|
|
110
|
-
if ((0, isFileInDir_1.isFileInDir)(
|
|
111
|
+
if ((0, isFileInDir_1.isFileInDir)(uriToFileName(uri.toString()), path.dirname(rootTsConfig))) {
|
|
111
112
|
matches.push(rootTsConfig);
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
|
-
matches = matches.sort((a, b) => sortTsConfigs(
|
|
115
|
+
matches = matches.sort((a, b) => sortTsConfigs(uriToFileName(uri.toString()), a, b));
|
|
115
116
|
if (matches.length) {
|
|
116
117
|
yield getParsedCommandLine(matches[0]);
|
|
117
118
|
}
|
|
@@ -120,7 +121,7 @@ function createWorkspace(context) {
|
|
|
120
121
|
function findDirectIncludeTsconfig() {
|
|
121
122
|
return findTsconfig((tsconfig) => __awaiter(this, void 0, void 0, function* () {
|
|
122
123
|
var _a;
|
|
123
|
-
const map = (0, uriMap_1.createUriMap)();
|
|
124
|
+
const map = (0, uriMap_1.createUriMap)(fileNameToUri);
|
|
124
125
|
const parsedCommandLine = yield getParsedCommandLine(tsconfig);
|
|
125
126
|
for (const fileName of (_a = parsedCommandLine === null || parsedCommandLine === void 0 ? void 0 : parsedCommandLine.fileNames) !== null && _a !== void 0 ? _a : []) {
|
|
126
127
|
map.pathSet(fileName, true);
|
|
@@ -133,14 +134,14 @@ function createWorkspace(context) {
|
|
|
133
134
|
var _a, _b;
|
|
134
135
|
const project = yield projects.pathGet(tsconfig);
|
|
135
136
|
const ls = project === null || project === void 0 ? void 0 : project.getLanguageServiceDontCreate();
|
|
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(
|
|
137
|
+
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(uriToFileName(uri.toString()));
|
|
137
138
|
return !!validDoc;
|
|
138
139
|
}));
|
|
139
140
|
}
|
|
140
141
|
function findTsconfig(match) {
|
|
141
142
|
return __awaiter(this, void 0, void 0, function* () {
|
|
142
143
|
const checked = new Set();
|
|
143
|
-
for (const rootTsConfig of [...rootTsConfigs].sort((a, b) => sortTsConfigs(
|
|
144
|
+
for (const rootTsConfig of [...rootTsConfigs].sort((a, b) => sortTsConfigs(uriToFileName(uri.toString()), a, b))) {
|
|
144
145
|
const project = yield projects.pathGet(rootTsConfig);
|
|
145
146
|
if (project) {
|
|
146
147
|
let chains = yield getReferencesChains(project.getParsedCommandLine(), rootTsConfig, []);
|
|
@@ -209,13 +210,13 @@ function createWorkspace(context) {
|
|
|
209
210
|
});
|
|
210
211
|
}
|
|
211
212
|
function getProjectByCreate(_tsConfig) {
|
|
212
|
-
const tsConfig =
|
|
213
|
+
const tsConfig = _tsConfig.replace(/\\/g, '/');
|
|
213
214
|
let project = projects.pathGet(tsConfig);
|
|
214
215
|
if (!project && documentRegistry) {
|
|
215
216
|
project = (0, project_1.createProject)({
|
|
216
217
|
workspace: context,
|
|
217
218
|
serverConfig,
|
|
218
|
-
rootUri: vscode_uri_1.URI.parse(
|
|
219
|
+
rootUri: vscode_uri_1.URI.parse(fileNameToUri(path.dirname(tsConfig))),
|
|
219
220
|
tsConfig,
|
|
220
221
|
documentRegistry,
|
|
221
222
|
});
|