@volar/language-server 1.6.9 → 1.7.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/out/browser/index.js +57 -62
- package/out/common/cancellationPipe.js +2 -6
- package/out/common/configurationHost.js +7 -2
- package/out/common/documents.d.ts +2 -2
- package/out/common/documents.js +10 -2
- package/out/common/features/customFeatures.js +30 -60
- package/out/common/features/languageFeatures.js +5 -5
- package/out/common/project.d.ts +115 -115
- package/out/common/project.js +150 -248
- package/out/common/server.d.ts +5 -1
- package/out/common/server.js +83 -12
- package/out/common/workspace.d.ts +325 -318
- package/out/common/workspace.js +17 -23
- package/out/common/workspaces.d.ts +400 -393
- package/out/common/workspaces.js +3 -6
- package/out/node/index.js +82 -83
- package/out/protocol.d.ts +5 -5
- package/out/protocol.js +16 -16
- package/out/types.d.ts +13 -44
- package/out/types.js +2 -2
- package/package.json +6 -6
package/out/common/workspace.js
CHANGED
|
@@ -8,17 +8,16 @@ const project_1 = require("./project");
|
|
|
8
8
|
const inferredCompilerOptions_1 = require("./utils/inferredCompilerOptions");
|
|
9
9
|
const uriMap_1 = require("./utils/uriMap");
|
|
10
10
|
const isFileInDir_1 = require("./utils/isFileInDir");
|
|
11
|
+
const language_service_1 = require("@volar/language-service");
|
|
11
12
|
exports.rootTsConfigNames = ['tsconfig.json', 'jsconfig.json'];
|
|
12
13
|
async function createWorkspace(context) {
|
|
13
|
-
const fileNameToUri = context.server.runtimeEnv.fileNameToUri;
|
|
14
|
-
const uriToFileName = context.server.runtimeEnv.uriToFileName;
|
|
15
14
|
let inferredProject;
|
|
16
|
-
|
|
17
|
-
const
|
|
15
|
+
let disposeTsConfigWatch;
|
|
16
|
+
const { fileNameToUri, uriToFileName, fs } = context.server.runtimeEnv;
|
|
18
17
|
const projects = (0, uriMap_1.createUriMap)(fileNameToUri);
|
|
19
18
|
const rootTsConfigs = new Set();
|
|
20
19
|
const searchedDirs = new Set();
|
|
21
|
-
|
|
20
|
+
context.server.onDidChangeWatchedFiles(({ changes }) => {
|
|
22
21
|
for (const change of changes) {
|
|
23
22
|
if (exports.rootTsConfigNames.includes(change.uri.substring(change.uri.lastIndexOf('/') + 1))) {
|
|
24
23
|
if (change.type === vscode.FileChangeType.Created) {
|
|
@@ -39,14 +38,13 @@ async function createWorkspace(context) {
|
|
|
39
38
|
});
|
|
40
39
|
return {
|
|
41
40
|
projects,
|
|
42
|
-
documentRegistry,
|
|
43
41
|
getProjectAndTsConfig,
|
|
44
42
|
getInferredProject,
|
|
45
43
|
getInferredProjectDontCreate: () => inferredProject,
|
|
46
44
|
reload: clearProjects,
|
|
47
45
|
dispose() {
|
|
48
46
|
clearProjects();
|
|
49
|
-
disposeTsConfigWatch?.();
|
|
47
|
+
disposeTsConfigWatch?.dispose();
|
|
50
48
|
},
|
|
51
49
|
};
|
|
52
50
|
function clearProjects() {
|
|
@@ -73,13 +71,12 @@ async function createWorkspace(context) {
|
|
|
73
71
|
function getInferredProject() {
|
|
74
72
|
if (!inferredProject) {
|
|
75
73
|
inferredProject = (async () => {
|
|
76
|
-
const inferOptions = await (0, inferredCompilerOptions_1.getInferredCompilerOptions)(context.
|
|
74
|
+
const inferOptions = await (0, inferredCompilerOptions_1.getInferredCompilerOptions)(context.server.configurationHost);
|
|
77
75
|
return (0, project_1.createProject)({
|
|
78
76
|
...context,
|
|
79
77
|
project: {
|
|
80
78
|
rootUri: context.workspace.rootUri,
|
|
81
79
|
tsConfig: inferOptions,
|
|
82
|
-
documentRegistry,
|
|
83
80
|
},
|
|
84
81
|
});
|
|
85
82
|
})();
|
|
@@ -96,7 +93,7 @@ async function createWorkspace(context) {
|
|
|
96
93
|
searchedDirs.add(dir);
|
|
97
94
|
for (const tsConfigName of exports.rootTsConfigNames) {
|
|
98
95
|
const tsconfigPath = path.join(dir, tsConfigName);
|
|
99
|
-
if (
|
|
96
|
+
if ((await fs.stat?.(fileNameToUri(tsconfigPath)))?.type === language_service_1.FileType.File) {
|
|
100
97
|
rootTsConfigs.add(tsconfigPath);
|
|
101
98
|
}
|
|
102
99
|
}
|
|
@@ -116,6 +113,12 @@ async function createWorkspace(context) {
|
|
|
116
113
|
await getParsedCommandLine(matches[0]);
|
|
117
114
|
}
|
|
118
115
|
}
|
|
116
|
+
function findIndirectReferenceTsconfig() {
|
|
117
|
+
return findTsconfig(async (tsconfig) => {
|
|
118
|
+
const project = await projects.pathGet(tsconfig);
|
|
119
|
+
return project?.askedFiles.uriHas(uri.toString()) ?? false;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
119
122
|
function findDirectIncludeTsconfig() {
|
|
120
123
|
return findTsconfig(async (tsconfig) => {
|
|
121
124
|
const map = (0, uriMap_1.createUriMap)(fileNameToUri);
|
|
@@ -126,14 +129,6 @@ async function createWorkspace(context) {
|
|
|
126
129
|
return map.uriHas(uri.toString());
|
|
127
130
|
});
|
|
128
131
|
}
|
|
129
|
-
function findIndirectReferenceTsconfig() {
|
|
130
|
-
return findTsconfig(async (tsconfig) => {
|
|
131
|
-
const project = await projects.pathGet(tsconfig);
|
|
132
|
-
const ls = project?.getLanguageServiceDontCreate();
|
|
133
|
-
const validDoc = ls?.context.typescript?.languageService.getProgram()?.getSourceFile(uriToFileName(uri.toString()));
|
|
134
|
-
return !!validDoc;
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
132
|
async function findTsconfig(match) {
|
|
138
133
|
const checked = new Set();
|
|
139
134
|
for (const rootTsConfig of [...rootTsConfigs].sort((a, b) => sortTsConfigs(uriToFileName(uri.toString()), a, b))) {
|
|
@@ -163,13 +158,13 @@ async function createWorkspace(context) {
|
|
|
163
158
|
for (const projectReference of parsedCommandLine.projectReferences) {
|
|
164
159
|
let tsConfigPath = projectReference.path.replace(/\\/g, '/');
|
|
165
160
|
// fix https://github.com/johnsoncodehk/volar/issues/712
|
|
166
|
-
if (
|
|
161
|
+
if ((await fs.stat?.(fileNameToUri(tsConfigPath)))?.type === language_service_1.FileType.File) {
|
|
167
162
|
const newTsConfigPath = path.join(tsConfigPath, 'tsconfig.json');
|
|
168
163
|
const newJsConfigPath = path.join(tsConfigPath, 'jsconfig.json');
|
|
169
|
-
if (
|
|
164
|
+
if ((await fs.stat?.(fileNameToUri(newTsConfigPath)))?.type === language_service_1.FileType.File) {
|
|
170
165
|
tsConfigPath = newTsConfigPath;
|
|
171
166
|
}
|
|
172
|
-
else if (
|
|
167
|
+
else if ((await fs.stat?.(fileNameToUri(newJsConfigPath)))?.type === language_service_1.FileType.File) {
|
|
173
168
|
tsConfigPath = newJsConfigPath;
|
|
174
169
|
}
|
|
175
170
|
}
|
|
@@ -200,13 +195,12 @@ async function createWorkspace(context) {
|
|
|
200
195
|
function getProjectByCreate(_tsConfig) {
|
|
201
196
|
const tsConfig = _tsConfig.replace(/\\/g, '/');
|
|
202
197
|
let project = projects.pathGet(tsConfig);
|
|
203
|
-
if (!project
|
|
198
|
+
if (!project) {
|
|
204
199
|
project = (0, project_1.createProject)({
|
|
205
200
|
...context,
|
|
206
201
|
project: {
|
|
207
202
|
rootUri: vscode_uri_1.URI.parse(fileNameToUri(path.dirname(tsConfig))),
|
|
208
203
|
tsConfig,
|
|
209
|
-
documentRegistry,
|
|
210
204
|
},
|
|
211
205
|
});
|
|
212
206
|
projects.pathSet(tsConfig, project);
|