@volar/language-server 1.0.8 → 1.0.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/features/customFeatures.js +59 -8
- package/out/features/languageFeatures.d.ts +2 -2
- package/out/features/languageFeatures.js +4 -3
- package/out/protocol.d.ts +3 -0
- package/out/protocol.js +5 -1
- package/out/registerFeatures.d.ts +3 -2
- package/out/registerFeatures.js +77 -42
- package/out/server.js +28 -5
- package/out/types.d.ts +7 -2
- package/out/utils/cancellationPipe.d.ts +3 -3
- package/out/utils/cancellationPipe.js +6 -6
- package/out/utils/config.js +11 -6
- package/out/utils/configurationHost.js +14 -2
- package/out/utils/nodeFileSystemHost.js +2 -2
- package/out/utils/project.d.ts +52 -12
- package/out/utils/project.js +13 -2
- package/out/utils/snapshots.d.ts +1 -1
- package/out/utils/snapshots.js +8 -7
- package/out/utils/uriMap.d.ts +22 -0
- package/out/utils/uriMap.js +77 -0
- package/out/utils/webFileSystemHost.js +2 -2
- package/out/utils/workspaceProjects.d.ts +53 -12
- package/out/utils/workspaceProjects.js +8 -2
- package/out/utils/workspaces.d.ts +152 -32
- package/out/utils/workspaces.js +12 -3
- package/package.json +7 -7
package/out/utils/project.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as shared from '@volar/shared';
|
|
1
2
|
import * as embeddedLS from '@volar/language-service';
|
|
2
3
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
4
|
import * as vscode from 'vscode-languageserver';
|
|
@@ -6,10 +7,54 @@ import { FileSystemHost, LanguageServerInitializationOptions, LanguageServerPlug
|
|
|
6
7
|
import { createSnapshots } from './snapshots';
|
|
7
8
|
import { ConfigurationHost } from '@volar/language-service';
|
|
8
9
|
import * as path from 'typesafe-path';
|
|
9
|
-
import {
|
|
10
|
+
import { CancellationTokenHost } from './cancellationPipe';
|
|
10
11
|
export interface Project extends ReturnType<typeof createProject> {
|
|
11
12
|
}
|
|
12
|
-
export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, ts: typeof import('typescript/lib/tsserverlibrary'), rootUri: URI, tsConfig: path.PosixPath | ts.CompilerOptions, tsLocalized: ts.MapLike<string> | undefined, documents: ReturnType<typeof createSnapshots>, configHost: ConfigurationHost | undefined, documentRegistry: ts.DocumentRegistry | undefined, cancelTokenHost:
|
|
13
|
+
export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, ts: typeof import('typescript/lib/tsserverlibrary'), rootUri: URI, tsConfig: path.PosixPath | ts.CompilerOptions, tsLocalized: ts.MapLike<string> | undefined, documents: ReturnType<typeof createSnapshots>, configHost: ConfigurationHost | undefined, documentRegistry: ts.DocumentRegistry | undefined, cancelTokenHost: CancellationTokenHost, serverOptions: LanguageServerInitializationOptions): Promise<{
|
|
14
|
+
tsConfig: ts.CompilerOptions | path.PosixPath;
|
|
15
|
+
scripts: {
|
|
16
|
+
clear: () => void;
|
|
17
|
+
values: () => IterableIterator<{
|
|
18
|
+
version: number;
|
|
19
|
+
fileName: string;
|
|
20
|
+
snapshot: ts.IScriptSnapshot | undefined;
|
|
21
|
+
snapshotVersion: number | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
uriDelete: (_uri: string) => boolean;
|
|
24
|
+
uriGet: (_uri: string) => {
|
|
25
|
+
version: number;
|
|
26
|
+
fileName: string;
|
|
27
|
+
snapshot: ts.IScriptSnapshot | undefined;
|
|
28
|
+
snapshotVersion: number | undefined;
|
|
29
|
+
} | undefined;
|
|
30
|
+
uriHas: (_uri: string) => boolean;
|
|
31
|
+
uriSet: (_uri: string, item: {
|
|
32
|
+
version: number;
|
|
33
|
+
fileName: string;
|
|
34
|
+
snapshot: ts.IScriptSnapshot | undefined;
|
|
35
|
+
snapshotVersion: number | undefined;
|
|
36
|
+
}) => void;
|
|
37
|
+
pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
|
|
38
|
+
pathGet: (rootUri: shared._2.URI, path: string) => {
|
|
39
|
+
version: number;
|
|
40
|
+
fileName: string;
|
|
41
|
+
snapshot: ts.IScriptSnapshot | undefined;
|
|
42
|
+
snapshotVersion: number | undefined;
|
|
43
|
+
} | undefined;
|
|
44
|
+
pathHas: (rootUri: shared._2.URI, path: string) => {
|
|
45
|
+
version: number;
|
|
46
|
+
fileName: string;
|
|
47
|
+
snapshot: ts.IScriptSnapshot | undefined;
|
|
48
|
+
snapshotVersion: number | undefined;
|
|
49
|
+
} | undefined;
|
|
50
|
+
pathSet: (rootUri: shared._2.URI, path: string, item: {
|
|
51
|
+
version: number;
|
|
52
|
+
fileName: string;
|
|
53
|
+
snapshot: ts.IScriptSnapshot | undefined;
|
|
54
|
+
snapshotVersion: number | undefined;
|
|
55
|
+
}) => void;
|
|
56
|
+
};
|
|
57
|
+
languageServiceHost: embeddedLS.LanguageServiceHost;
|
|
13
58
|
getLanguageService: () => {
|
|
14
59
|
doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
15
60
|
findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
|
|
@@ -20,12 +65,9 @@ export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: R
|
|
|
20
65
|
prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
21
66
|
doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
22
67
|
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
23
|
-
getSemanticTokens: (uri: string, range: vscode.Range | undefined,
|
|
68
|
+
getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: embeddedLS.SemanticToken[]) => void) | undefined) => Promise<embeddedLS.SemanticToken[] | undefined> | undefined;
|
|
24
69
|
doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
25
|
-
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<
|
|
26
|
-
isIncomplete: boolean;
|
|
27
|
-
items: vscode.CompletionItem[];
|
|
28
|
-
}>;
|
|
70
|
+
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<vscode.CompletionList>;
|
|
29
71
|
doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
|
|
30
72
|
doCodeActionResolve: (item: vscode.CodeAction) => Promise<vscode.CodeAction>;
|
|
31
73
|
doCompletionResolve: (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
|
|
@@ -63,12 +105,9 @@ export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: R
|
|
|
63
105
|
prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
64
106
|
doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
65
107
|
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
66
|
-
getSemanticTokens: (uri: string, range: vscode.Range | undefined,
|
|
108
|
+
getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: embeddedLS.SemanticToken[]) => void) | undefined) => Promise<embeddedLS.SemanticToken[] | undefined> | undefined;
|
|
67
109
|
doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
68
|
-
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<
|
|
69
|
-
isIncomplete: boolean;
|
|
70
|
-
items: vscode.CompletionItem[];
|
|
71
|
-
}>;
|
|
110
|
+
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<vscode.CompletionList>;
|
|
72
111
|
doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
|
|
73
112
|
doCodeActionResolve: (item: vscode.CodeAction) => Promise<vscode.CodeAction>;
|
|
74
113
|
doCompletionResolve: (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
|
|
@@ -97,5 +136,6 @@ export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: R
|
|
|
97
136
|
context: embeddedLS.LanguageServiceRuntimeContext;
|
|
98
137
|
} | undefined;
|
|
99
138
|
getParsedCommandLine: () => ts.ParsedCommandLine;
|
|
139
|
+
tryAddFile: (fileName: string) => void;
|
|
100
140
|
dispose: () => void;
|
|
101
141
|
}>;
|
package/out/utils/project.js
CHANGED
|
@@ -16,6 +16,7 @@ const vscode = require("vscode-languageserver");
|
|
|
16
16
|
const vscode_uri_1 = require("vscode-uri");
|
|
17
17
|
const config_1 = require("./config");
|
|
18
18
|
const path = require("typesafe-path");
|
|
19
|
+
const uriMap_1 = require("./uriMap");
|
|
19
20
|
function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLocalized, documents, configHost, documentRegistry, cancelTokenHost, serverOptions) {
|
|
20
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
22
|
const sys = fsHost.getWorkspaceFileSystem(rootUri);
|
|
@@ -24,7 +25,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
24
25
|
let projectVersionUpdateTime = cancelTokenHost.getMtime();
|
|
25
26
|
let vueLs;
|
|
26
27
|
let parsedCommandLine = createParsedCommandLine(ts, sys, shared.getPathOfUri(rootUri.toString()), tsConfig, plugins);
|
|
27
|
-
const scripts =
|
|
28
|
+
const scripts = (0, uriMap_1.createUriMap)();
|
|
28
29
|
const languageServiceHost = createLanguageServiceHost();
|
|
29
30
|
const disposeWatchEvent = fsHost.onDidChangeWatchedFiles(params => {
|
|
30
31
|
onWorkspaceFilesChanged(params.changes);
|
|
@@ -34,9 +35,18 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
34
35
|
projectVersionUpdateTime = cancelTokenHost.getMtime();
|
|
35
36
|
});
|
|
36
37
|
return {
|
|
38
|
+
tsConfig,
|
|
39
|
+
scripts,
|
|
40
|
+
languageServiceHost,
|
|
37
41
|
getLanguageService,
|
|
38
42
|
getLanguageServiceDontCreate: () => vueLs,
|
|
39
43
|
getParsedCommandLine: () => parsedCommandLine,
|
|
44
|
+
tryAddFile: (fileName) => {
|
|
45
|
+
if (!parsedCommandLine.fileNames.includes(fileName)) {
|
|
46
|
+
parsedCommandLine.fileNames.push(fileName);
|
|
47
|
+
projectVersion++;
|
|
48
|
+
}
|
|
49
|
+
},
|
|
40
50
|
dispose,
|
|
41
51
|
};
|
|
42
52
|
function getLanguageService() {
|
|
@@ -95,6 +105,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
|
|
|
95
105
|
const deletes = changes.filter(change => change.type === vscode.FileChangeType.Deleted);
|
|
96
106
|
if (creates.length || deletes.length) {
|
|
97
107
|
parsedCommandLine = createParsedCommandLine(ts, sys, shared.getPathOfUri(rootUri.toString()), tsConfig, plugins);
|
|
108
|
+
projectVersion++;
|
|
98
109
|
typeRootVersion++;
|
|
99
110
|
}
|
|
100
111
|
});
|
|
@@ -207,7 +218,7 @@ function createParsedCommandLine(ts, sys, rootPath, tsConfig, plugins) {
|
|
|
207
218
|
content = ts.parseJsonSourceFileConfigFileContent(config, sys, path.dirname(tsConfig), {}, tsConfig, undefined, extraFileExtensions);
|
|
208
219
|
}
|
|
209
220
|
else {
|
|
210
|
-
content = ts.parseJsonConfigFileContent({}, sys, rootPath, tsConfig, path.join(rootPath, 'jsconfig.json'), undefined, extraFileExtensions);
|
|
221
|
+
content = ts.parseJsonConfigFileContent({ files: [] }, sys, rootPath, tsConfig, path.join(rootPath, 'jsconfig.json'), undefined, extraFileExtensions);
|
|
211
222
|
}
|
|
212
223
|
// fix https://github.com/johnsoncodehk/volar/issues/1786
|
|
213
224
|
// https://github.com/microsoft/TypeScript/issues/30457
|
package/out/utils/snapshots.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as vscode from 'vscode-languageserver';
|
|
|
3
3
|
import * as shared from '@volar/shared';
|
|
4
4
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
5
5
|
interface IncrementalScriptSnapshotChange {
|
|
6
|
-
|
|
6
|
+
applied: boolean;
|
|
7
7
|
changeRange: ts.TextChangeRange | undefined;
|
|
8
8
|
version: number;
|
|
9
9
|
contentChange: {
|
package/out/utils/snapshots.js
CHANGED
|
@@ -3,13 +3,14 @@ exports.createSnapshots = exports.combineContinuousChangeRanges = void 0;
|
|
|
3
3
|
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
|
4
4
|
const vscode = require("vscode-languageserver");
|
|
5
5
|
const shared = require("@volar/shared");
|
|
6
|
+
const uriMap_1 = require("./uriMap");
|
|
6
7
|
class IncrementalScriptSnapshot {
|
|
7
8
|
constructor(uri, languageId, version, text) {
|
|
8
9
|
this.uri = uri;
|
|
9
10
|
this.document = vscode_languageserver_textdocument_1.TextDocument.create(uri, languageId, version, text);
|
|
10
11
|
this.changes = [
|
|
11
12
|
{
|
|
12
|
-
|
|
13
|
+
applied: true,
|
|
13
14
|
changeRange: undefined,
|
|
14
15
|
version,
|
|
15
16
|
contentChange: undefined,
|
|
@@ -24,7 +25,7 @@ class IncrementalScriptSnapshot {
|
|
|
24
25
|
vscode_languageserver_textdocument_1.TextDocument.update(this.document, params.contentChanges, params.textDocument.version);
|
|
25
26
|
this.changes = [
|
|
26
27
|
{
|
|
27
|
-
|
|
28
|
+
applied: true,
|
|
28
29
|
changeRange: undefined,
|
|
29
30
|
version: params.textDocument.version,
|
|
30
31
|
contentChange: undefined,
|
|
@@ -65,7 +66,7 @@ class IncrementalScriptSnapshot {
|
|
|
65
66
|
getDocument() {
|
|
66
67
|
this.clearUnReferenceVersions();
|
|
67
68
|
const lastChange = this.changes[this.changes.length - 1];
|
|
68
|
-
if (!lastChange.
|
|
69
|
+
if (!lastChange.applied) {
|
|
69
70
|
this.applyVersionToRootDocument(lastChange.version, false);
|
|
70
71
|
}
|
|
71
72
|
return this.document;
|
|
@@ -94,7 +95,7 @@ class IncrementalScriptSnapshot {
|
|
|
94
95
|
if (change.version > version) {
|
|
95
96
|
break;
|
|
96
97
|
}
|
|
97
|
-
if (!change.
|
|
98
|
+
if (!change.applied) {
|
|
98
99
|
if (change.contentChange) {
|
|
99
100
|
change.changeRange = {
|
|
100
101
|
span: {
|
|
@@ -105,7 +106,7 @@ class IncrementalScriptSnapshot {
|
|
|
105
106
|
};
|
|
106
107
|
vscode_languageserver_textdocument_1.TextDocument.update(this.document, [change.contentChange], change.version);
|
|
107
108
|
}
|
|
108
|
-
change.
|
|
109
|
+
change.applied = true;
|
|
109
110
|
}
|
|
110
111
|
removeEnd = i + 1;
|
|
111
112
|
}
|
|
@@ -143,7 +144,7 @@ function _combineContinuousChangeRanges(a, b) {
|
|
|
143
144
|
return { span: { start, length }, newLength };
|
|
144
145
|
}
|
|
145
146
|
function createSnapshots(connection) {
|
|
146
|
-
const snapshots =
|
|
147
|
+
const snapshots = (0, uriMap_1.createUriMap)();
|
|
147
148
|
const onDidChangeContents = new Set();
|
|
148
149
|
const onDidCloses = new Set();
|
|
149
150
|
connection.onDidOpenTextDocument(params => {
|
|
@@ -158,7 +159,7 @@ function createSnapshots(connection) {
|
|
|
158
159
|
if (params.contentChanges.every(vscode.TextDocumentContentChangeEvent.isIncremental)) {
|
|
159
160
|
for (const contentChange of params.contentChanges) {
|
|
160
161
|
incrementalSnapshot.changes.push({
|
|
161
|
-
|
|
162
|
+
applied: false,
|
|
162
163
|
changeRange: undefined,
|
|
163
164
|
contentChange,
|
|
164
165
|
version: params.textDocument.version,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { URI } from 'vscode-uri';
|
|
2
|
+
export * as _ from 'vscode-uri';
|
|
3
|
+
interface Options<T> {
|
|
4
|
+
delete(key: string): boolean;
|
|
5
|
+
get(key: string): T | undefined;
|
|
6
|
+
has(key: string): boolean;
|
|
7
|
+
set(key: string, value: T): void;
|
|
8
|
+
clear(): void;
|
|
9
|
+
values(): IterableIterator<T>;
|
|
10
|
+
}
|
|
11
|
+
export declare function createUriMap<T>(map?: Options<T>): {
|
|
12
|
+
clear: () => void;
|
|
13
|
+
values: () => IterableIterator<T>;
|
|
14
|
+
uriDelete: (_uri: string) => boolean;
|
|
15
|
+
uriGet: (_uri: string) => T | undefined;
|
|
16
|
+
uriHas: (_uri: string) => boolean;
|
|
17
|
+
uriSet: (_uri: string, item: T) => void;
|
|
18
|
+
pathDelete: (rootUri: URI, path: string) => boolean;
|
|
19
|
+
pathGet: (rootUri: URI, path: string) => T | undefined;
|
|
20
|
+
pathHas: (rootUri: URI, path: string) => T | undefined;
|
|
21
|
+
pathSet: (rootUri: URI, path: string, item: T) => void;
|
|
22
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
exports.createUriMap = exports._ = void 0;
|
|
3
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
4
|
+
const shared = require("@volar/shared");
|
|
5
|
+
exports._ = require("vscode-uri");
|
|
6
|
+
function createUriMap(map = new Map()) {
|
|
7
|
+
const uriToUriKeys = new Map();
|
|
8
|
+
const pathToUriKeys = new WeakMap();
|
|
9
|
+
return {
|
|
10
|
+
clear,
|
|
11
|
+
values,
|
|
12
|
+
uriDelete,
|
|
13
|
+
uriGet,
|
|
14
|
+
uriHas,
|
|
15
|
+
uriSet,
|
|
16
|
+
pathDelete,
|
|
17
|
+
pathGet,
|
|
18
|
+
pathHas,
|
|
19
|
+
pathSet,
|
|
20
|
+
};
|
|
21
|
+
function getUriByUri(uri) {
|
|
22
|
+
if (!uriToUriKeys.has(uri))
|
|
23
|
+
uriToUriKeys.set(uri, normalizeUri(uri).toLowerCase());
|
|
24
|
+
return uriToUriKeys.get(uri);
|
|
25
|
+
}
|
|
26
|
+
function getUriByPath(rootUri, path) {
|
|
27
|
+
let map = pathToUriKeys.get(rootUri);
|
|
28
|
+
if (!map) {
|
|
29
|
+
map = new Map();
|
|
30
|
+
pathToUriKeys.set(rootUri, map);
|
|
31
|
+
}
|
|
32
|
+
if (!map.has(path)) {
|
|
33
|
+
map.set(path, shared.getUriByPath(rootUri, path).toLowerCase());
|
|
34
|
+
}
|
|
35
|
+
return map.get(path);
|
|
36
|
+
}
|
|
37
|
+
function clear() {
|
|
38
|
+
return map.clear();
|
|
39
|
+
}
|
|
40
|
+
function values() {
|
|
41
|
+
return map.values();
|
|
42
|
+
}
|
|
43
|
+
function uriDelete(_uri) {
|
|
44
|
+
return map.delete(getUriByUri(_uri));
|
|
45
|
+
}
|
|
46
|
+
function uriGet(_uri) {
|
|
47
|
+
return map.get(getUriByUri(_uri));
|
|
48
|
+
}
|
|
49
|
+
function uriHas(_uri) {
|
|
50
|
+
return map.has(getUriByUri(_uri));
|
|
51
|
+
}
|
|
52
|
+
function uriSet(_uri, item) {
|
|
53
|
+
return map.set(getUriByUri(_uri), item);
|
|
54
|
+
}
|
|
55
|
+
function pathDelete(rootUri, path) {
|
|
56
|
+
return uriDelete(getUriByPath(rootUri, path));
|
|
57
|
+
}
|
|
58
|
+
function pathGet(rootUri, path) {
|
|
59
|
+
return uriGet(getUriByPath(rootUri, path));
|
|
60
|
+
}
|
|
61
|
+
function pathHas(rootUri, path) {
|
|
62
|
+
return uriGet(getUriByPath(rootUri, path));
|
|
63
|
+
}
|
|
64
|
+
function pathSet(rootUri, path, item) {
|
|
65
|
+
return uriSet(getUriByPath(rootUri, path), item);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.createUriMap = createUriMap;
|
|
69
|
+
function normalizeUri(uri) {
|
|
70
|
+
try {
|
|
71
|
+
return vscode_uri_1.URI.parse(uri).toString();
|
|
72
|
+
}
|
|
73
|
+
catch (_a) {
|
|
74
|
+
return '';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=uriMap.js.map
|
|
@@ -9,16 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.createWebFileSystemHost = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
12
|
const path = require("typesafe-path");
|
|
14
13
|
const vscode_html_languageservice_1 = require("vscode-html-languageservice");
|
|
15
14
|
const vscode = require("vscode-languageserver");
|
|
16
15
|
const vscode_uri_1 = require("vscode-uri");
|
|
17
16
|
const protocol_1 = require("../protocol");
|
|
18
17
|
const utilities_1 = require("./ts/utilities");
|
|
18
|
+
const uriMap_1 = require("./uriMap");
|
|
19
19
|
let currentCwd = '/';
|
|
20
20
|
function createWebFileSystemHost() {
|
|
21
|
-
const instances =
|
|
21
|
+
const instances = (0, uriMap_1.createUriMap)();
|
|
22
22
|
const onDidChangeWatchedFilesCb = new Set();
|
|
23
23
|
const root = {
|
|
24
24
|
dirs: new Map(),
|
|
@@ -7,9 +7,9 @@ import { LanguageServerPlugin, RuntimeEnvironment, FileSystemHost, LanguageServe
|
|
|
7
7
|
import { createSnapshots } from './snapshots';
|
|
8
8
|
import { URI } from 'vscode-uri';
|
|
9
9
|
import { ConfigurationHost } from '@volar/language-service';
|
|
10
|
-
import {
|
|
10
|
+
import { CancellationTokenHost } from './cancellationPipe';
|
|
11
11
|
export declare const rootTsConfigNames: string[];
|
|
12
|
-
export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, rootUri: URI, ts: typeof import('typescript/lib/tsserverlibrary'), tsLocalized: ts.MapLike<string> | undefined, documents: ReturnType<typeof createSnapshots>, configHost: ConfigurationHost | undefined, cancelTokenHost:
|
|
12
|
+
export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, rootUri: URI, ts: typeof import('typescript/lib/tsserverlibrary'), tsLocalized: ts.MapLike<string> | undefined, documents: ReturnType<typeof createSnapshots>, configHost: ConfigurationHost | undefined, cancelTokenHost: CancellationTokenHost, serverOptions: LanguageServerInitializationOptions): Promise<{
|
|
13
13
|
projects: {
|
|
14
14
|
clear: () => void;
|
|
15
15
|
values: () => IterableIterator<Project>;
|
|
@@ -22,9 +22,54 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
|
|
|
22
22
|
pathHas: (rootUri: shared._2.URI, path: string) => Project | undefined;
|
|
23
23
|
pathSet: (rootUri: shared._2.URI, path: string, item: Project) => void;
|
|
24
24
|
};
|
|
25
|
+
documentRegistry: ts.DocumentRegistry;
|
|
25
26
|
getProjectAndTsConfig: (uri: string) => Promise<{
|
|
26
27
|
tsconfig: string;
|
|
27
28
|
project: {
|
|
29
|
+
tsConfig: ts.CompilerOptions | path.PosixPath;
|
|
30
|
+
scripts: {
|
|
31
|
+
clear: () => void;
|
|
32
|
+
values: () => IterableIterator<{
|
|
33
|
+
version: number;
|
|
34
|
+
fileName: string;
|
|
35
|
+
snapshot: ts.IScriptSnapshot | undefined;
|
|
36
|
+
snapshotVersion: number | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
uriDelete: (_uri: string) => boolean;
|
|
39
|
+
uriGet: (_uri: string) => {
|
|
40
|
+
version: number;
|
|
41
|
+
fileName: string;
|
|
42
|
+
snapshot: ts.IScriptSnapshot | undefined;
|
|
43
|
+
snapshotVersion: number | undefined;
|
|
44
|
+
} | undefined;
|
|
45
|
+
uriHas: (_uri: string) => boolean;
|
|
46
|
+
uriSet: (_uri: string, item: {
|
|
47
|
+
version: number;
|
|
48
|
+
fileName: string;
|
|
49
|
+
snapshot: ts.IScriptSnapshot | undefined;
|
|
50
|
+
snapshotVersion: number | undefined;
|
|
51
|
+
}) => void;
|
|
52
|
+
pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
|
|
53
|
+
pathGet: (rootUri: shared._2.URI, path: string) => {
|
|
54
|
+
version: number;
|
|
55
|
+
fileName: string;
|
|
56
|
+
snapshot: ts.IScriptSnapshot | undefined;
|
|
57
|
+
snapshotVersion: number | undefined;
|
|
58
|
+
} | undefined;
|
|
59
|
+
pathHas: (rootUri: shared._2.URI, path: string) => {
|
|
60
|
+
version: number;
|
|
61
|
+
fileName: string;
|
|
62
|
+
snapshot: ts.IScriptSnapshot | undefined;
|
|
63
|
+
snapshotVersion: number | undefined;
|
|
64
|
+
} | undefined;
|
|
65
|
+
pathSet: (rootUri: shared._2.URI, path: string, item: {
|
|
66
|
+
version: number;
|
|
67
|
+
fileName: string;
|
|
68
|
+
snapshot: ts.IScriptSnapshot | undefined;
|
|
69
|
+
snapshotVersion: number | undefined;
|
|
70
|
+
}) => void;
|
|
71
|
+
};
|
|
72
|
+
languageServiceHost: import("@volar/language-service").LanguageServiceHost;
|
|
28
73
|
getLanguageService: () => {
|
|
29
74
|
doValidation: (uri: string, token?: vscode.CancellationToken | undefined, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
30
75
|
findReferences: (uri: string, position: vscode.Position) => Promise<vscode.Location[] | undefined>;
|
|
@@ -35,12 +80,9 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
|
|
|
35
80
|
prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
36
81
|
doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
37
82
|
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
38
|
-
getSemanticTokens: (uri: string, range: vscode.Range | undefined,
|
|
83
|
+
getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
|
|
39
84
|
doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
40
|
-
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<
|
|
41
|
-
isIncomplete: boolean;
|
|
42
|
-
items: vscode.CompletionItem[];
|
|
43
|
-
}>;
|
|
85
|
+
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<vscode.CompletionList>;
|
|
44
86
|
doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
|
|
45
87
|
doCodeActionResolve: (item: vscode.CodeAction) => Promise<vscode.CodeAction>;
|
|
46
88
|
doCompletionResolve: (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
|
|
@@ -78,12 +120,9 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
|
|
|
78
120
|
prepareRename: (uri: string, position: vscode.Position) => Promise<NonNullable<vscode.Range | vscode.ResponseError<void> | null | undefined> | undefined>;
|
|
79
121
|
doRename: (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
80
122
|
getEditsForFileRename: (oldUri: string, newUri: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
81
|
-
getSemanticTokens: (uri: string, range: vscode.Range | undefined,
|
|
123
|
+
getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: import("@volar/language-service").SemanticToken[]) => void) | undefined) => Promise<import("@volar/language-service").SemanticToken[] | undefined> | undefined;
|
|
82
124
|
doHover: (uri: string, position: vscode.Position) => Promise<vscode.Hover | undefined>;
|
|
83
|
-
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<
|
|
84
|
-
isIncomplete: boolean;
|
|
85
|
-
items: vscode.CompletionItem[];
|
|
86
|
-
}>;
|
|
125
|
+
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext | undefined) => Promise<vscode.CompletionList>;
|
|
87
126
|
doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext) => Promise<vscode.CodeAction[] | undefined>;
|
|
88
127
|
doCodeActionResolve: (item: vscode.CodeAction) => Promise<vscode.CodeAction>;
|
|
89
128
|
doCompletionResolve: (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
|
|
@@ -112,10 +151,12 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
|
|
|
112
151
|
context: import("@volar/language-service").LanguageServiceRuntimeContext;
|
|
113
152
|
} | undefined;
|
|
114
153
|
getParsedCommandLine: () => ts.ParsedCommandLine;
|
|
154
|
+
tryAddFile: (fileName: string) => void;
|
|
115
155
|
dispose: () => void;
|
|
116
156
|
};
|
|
117
157
|
} | undefined>;
|
|
118
158
|
getInferredProject: () => Project;
|
|
159
|
+
getInferredProjectDontCreate: () => Project | undefined;
|
|
119
160
|
reload: () => void;
|
|
120
161
|
dispose(): void;
|
|
121
162
|
}>;
|
|
@@ -15,13 +15,14 @@ const vscode = require("vscode-languageserver");
|
|
|
15
15
|
const project_1 = require("./project");
|
|
16
16
|
const inferredCompilerOptions_1 = require("./inferredCompilerOptions");
|
|
17
17
|
const vscode_uri_1 = require("vscode-uri");
|
|
18
|
+
const uriMap_1 = require("./uriMap");
|
|
18
19
|
exports.rootTsConfigNames = ['tsconfig.json', 'jsconfig.json'];
|
|
19
20
|
function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLocalized, documents, configHost, cancelTokenHost, serverOptions) {
|
|
20
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
22
|
let inferredProject;
|
|
22
23
|
const sys = fsHost.getWorkspaceFileSystem(rootUri);
|
|
23
24
|
const documentRegistry = ts.createDocumentRegistry(sys.useCaseSensitiveFileNames, shared.normalizeFileName(rootUri.fsPath));
|
|
24
|
-
const projects =
|
|
25
|
+
const projects = (0, uriMap_1.createUriMap)();
|
|
25
26
|
const rootTsConfigs = new Set(sys.readDirectory(rootUri.fsPath, exports.rootTsConfigNames, undefined, ['**/*']));
|
|
26
27
|
const disposeWatch = fsHost.onDidChangeWatchedFiles((params, reason) => __awaiter(this, void 0, void 0, function* () {
|
|
27
28
|
const disposes = [];
|
|
@@ -52,8 +53,10 @@ function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLoc
|
|
|
52
53
|
}));
|
|
53
54
|
return {
|
|
54
55
|
projects,
|
|
56
|
+
documentRegistry,
|
|
55
57
|
getProjectAndTsConfig,
|
|
56
58
|
getInferredProject,
|
|
59
|
+
getInferredProjectDontCreate: () => inferredProject,
|
|
57
60
|
reload: clearProjects,
|
|
58
61
|
dispose() {
|
|
59
62
|
clearProjects();
|
|
@@ -135,7 +138,10 @@ function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLoc
|
|
|
135
138
|
for (const rootTsConfig of [...rootTsConfigs].sort((a, b) => sortTsConfigs(uri.fsPath, a, b))) {
|
|
136
139
|
const project = yield projects.pathGet(rootUri, rootTsConfig);
|
|
137
140
|
if (project) {
|
|
138
|
-
|
|
141
|
+
let chains = yield getReferencesChains(project.getParsedCommandLine(), rootTsConfig, []);
|
|
142
|
+
if (serverOptions.reverseConfigFilePriority) {
|
|
143
|
+
chains = chains.reverse();
|
|
144
|
+
}
|
|
139
145
|
for (const chain of chains) {
|
|
140
146
|
for (let i = chain.length - 1; i >= 0; i--) {
|
|
141
147
|
const tsconfig = chain[i];
|