@volar/language-service 1.4.0 → 1.5.0-alpha.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/baseLanguageService.d.ts +8 -5
- package/out/baseLanguageService.js +72 -61
- package/out/documentFeatures/colorPresentations.d.ts +2 -2
- package/out/documentFeatures/documentColors.d.ts +2 -2
- package/out/documentFeatures/documentSymbols.d.ts +2 -2
- package/out/documentFeatures/foldingRanges.d.ts +2 -2
- package/out/documentFeatures/format.d.ts +2 -2
- package/out/documentFeatures/format.js +6 -6
- package/out/documentFeatures/linkedEditingRanges.d.ts +2 -2
- package/out/documentFeatures/selectionRanges.d.ts +2 -2
- package/out/documents.d.ts +3 -3
- package/out/documents.js +10 -10
- package/out/languageFeatures/autoInsert.d.ts +2 -2
- package/out/languageFeatures/callHierarchy.d.ts +2 -2
- package/out/languageFeatures/callHierarchy.js +1 -1
- package/out/languageFeatures/codeActionResolve.d.ts +2 -2
- package/out/languageFeatures/codeActions.d.ts +2 -2
- package/out/languageFeatures/codeLens.d.ts +2 -2
- package/out/languageFeatures/codeLensResolve.d.ts +2 -2
- package/out/languageFeatures/codeLensResolve.js +1 -1
- package/out/languageFeatures/complete.d.ts +2 -2
- package/out/languageFeatures/completeResolve.d.ts +2 -2
- package/out/languageFeatures/definition.d.ts +2 -2
- package/out/languageFeatures/documentHighlights.d.ts +2 -2
- package/out/languageFeatures/documentLinkResolve.d.ts +2 -2
- package/out/languageFeatures/documentLinks.d.ts +2 -2
- package/out/languageFeatures/documentSemanticTokens.d.ts +2 -2
- package/out/languageFeatures/fileReferences.d.ts +2 -2
- package/out/languageFeatures/fileRename.d.ts +2 -2
- package/out/languageFeatures/hover.d.ts +2 -2
- package/out/languageFeatures/inlayHintResolve.d.ts +2 -2
- package/out/languageFeatures/inlayHints.d.ts +2 -2
- package/out/languageFeatures/inlayHints.js +1 -1
- package/out/languageFeatures/references.d.ts +2 -2
- package/out/languageFeatures/rename.d.ts +2 -2
- package/out/languageFeatures/renamePrepare.d.ts +2 -2
- package/out/languageFeatures/signatureHelp.d.ts +2 -2
- package/out/languageFeatures/validation.d.ts +2 -2
- package/out/languageFeatures/validation.js +2 -2
- package/out/languageFeatures/workspaceSymbols.d.ts +2 -2
- package/out/types.d.ts +76 -111
- package/out/utils/featureWorkers.d.ts +4 -4
- package/out/utils/featureWorkers.js +2 -18
- package/package.json +4 -4
- package/out/languageFeatures/codeLensResolve copy.d.ts +0 -3
- package/out/languageFeatures/codeLensResolve copy.js +0 -31
- package/out/languageFeatures/documentLinkResolve copy.d.ts +0 -3
- package/out/languageFeatures/documentLinkResolve copy.js +0 -19
- package/out/languageFeatures/documentLinks copy.d.ts +0 -8
- package/out/languageFeatures/documentLinks copy.js +0 -62
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LanguageServiceHost } from '@volar/language-core';
|
|
2
|
+
import { Config, ServiceContext, ServiceEnvironment } from './types';
|
|
2
3
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
3
4
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
4
5
|
export type LanguageService = ReturnType<typeof createLanguageServiceBase>;
|
|
5
|
-
export declare function createLanguageService(
|
|
6
|
+
export declare function createLanguageService(modules: {
|
|
7
|
+
typescript?: typeof import('typescript/lib/tsserverlibrary');
|
|
8
|
+
}, env: ServiceEnvironment, config: Config, host: LanguageServiceHost, documentRegistry?: ts.DocumentRegistry): {
|
|
6
9
|
triggerCharacters: string[];
|
|
7
10
|
autoFormatTriggerCharacters: string[];
|
|
8
11
|
signatureHelpTriggerCharacters: string[];
|
|
@@ -48,9 +51,9 @@ export declare function createLanguageService(ctx: LanguageServiceOptions, docum
|
|
|
48
51
|
getOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
|
|
49
52
|
};
|
|
50
53
|
dispose: () => void | undefined;
|
|
51
|
-
context:
|
|
54
|
+
context: ServiceContext;
|
|
52
55
|
};
|
|
53
|
-
declare function createLanguageServiceBase(context:
|
|
56
|
+
declare function createLanguageServiceBase(context: ServiceContext): {
|
|
54
57
|
triggerCharacters: string[];
|
|
55
58
|
autoFormatTriggerCharacters: string[];
|
|
56
59
|
signatureHelpTriggerCharacters: string[];
|
|
@@ -96,6 +99,6 @@ declare function createLanguageServiceBase(context: LanguageServicePluginContext
|
|
|
96
99
|
getOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
|
|
97
100
|
};
|
|
98
101
|
dispose: () => void | undefined;
|
|
99
|
-
context:
|
|
102
|
+
context: ServiceContext;
|
|
100
103
|
};
|
|
101
104
|
export {};
|
|
@@ -39,106 +39,117 @@ const selectionRanges = require("./documentFeatures/selectionRanges");
|
|
|
39
39
|
const vscode = require("vscode-languageserver-protocol");
|
|
40
40
|
// fix build
|
|
41
41
|
const common_1 = require("./utils/common");
|
|
42
|
-
function createLanguageService(
|
|
43
|
-
const languageContext = (0, language_core_1.createLanguageContext)(
|
|
44
|
-
const context = createLanguageServicePluginContext(
|
|
42
|
+
function createLanguageService(modules, env, config, host, documentRegistry) {
|
|
43
|
+
const languageContext = (0, language_core_1.createLanguageContext)(modules, host, Object.values(config.languages ?? {}).filter(common_1.notEmpty));
|
|
44
|
+
const context = createLanguageServicePluginContext(modules, env, config, host, languageContext, documentRegistry);
|
|
45
45
|
return createLanguageServiceBase(context);
|
|
46
46
|
}
|
|
47
47
|
exports.createLanguageService = createLanguageService;
|
|
48
|
-
function createLanguageServicePluginContext(
|
|
49
|
-
const ts =
|
|
48
|
+
function createLanguageServicePluginContext(modules, env, config, host, languageContext, documentRegistry) {
|
|
49
|
+
const ts = modules.typescript;
|
|
50
50
|
let tsLs;
|
|
51
51
|
if (ts) {
|
|
52
|
-
const created = tsFaster.createLanguageService(ts, languageContext.typescript.languageServiceHost, proxiedHost => ts.createLanguageService(proxiedHost, documentRegistry),
|
|
52
|
+
const created = tsFaster.createLanguageService(ts, languageContext.typescript.languageServiceHost, proxiedHost => ts.createLanguageService(proxiedHost, documentRegistry), env.rootUri.path);
|
|
53
53
|
tsLs = created.languageService;
|
|
54
|
-
if (created.setPreferences &&
|
|
55
|
-
const configHost = ctx.configurationHost;
|
|
54
|
+
if (created.setPreferences && env.getConfiguration) {
|
|
56
55
|
updatePreferences();
|
|
57
|
-
|
|
56
|
+
env.onDidChangeConfiguration?.(updatePreferences);
|
|
58
57
|
async function updatePreferences() {
|
|
59
|
-
const preferences = await
|
|
58
|
+
const preferences = await env.getConfiguration?.('typescript.preferences');
|
|
60
59
|
if (preferences) {
|
|
61
60
|
created.setPreferences?.(preferences);
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
if (created.projectUpdated) {
|
|
66
|
-
let scriptFileNames = new Set(
|
|
67
|
-
|
|
65
|
+
let scriptFileNames = new Set(host.getScriptFileNames());
|
|
66
|
+
env.onDidChangeWatchedFiles?.((params) => {
|
|
68
67
|
if (params.changes.some(change => change.type !== vscode.FileChangeType.Changed)) {
|
|
69
|
-
scriptFileNames = new Set(
|
|
68
|
+
scriptFileNames = new Set(host.getScriptFileNames());
|
|
70
69
|
}
|
|
71
70
|
for (const change of params.changes) {
|
|
72
|
-
if (scriptFileNames.has(
|
|
73
|
-
created.projectUpdated?.(
|
|
71
|
+
if (scriptFileNames.has(env.uriToFileName(change.uri))) {
|
|
72
|
+
created.projectUpdated?.(env.uriToFileName(env.rootUri.fsPath));
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
});
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
|
-
const textDocumentMapper = (0, documents_1.createDocumentsAndSourceMaps)(
|
|
78
|
+
const textDocumentMapper = (0, documents_1.createDocumentsAndSourceMaps)(env, host, languageContext.virtualFiles);
|
|
80
79
|
const documents = new WeakMap();
|
|
81
80
|
const documentVersions = new Map();
|
|
82
81
|
const context = {
|
|
83
|
-
|
|
82
|
+
env,
|
|
83
|
+
config,
|
|
84
|
+
host,
|
|
84
85
|
core: languageContext,
|
|
85
86
|
plugins: {},
|
|
86
87
|
typescript: ts && tsLs ? {
|
|
87
|
-
module: ts,
|
|
88
88
|
languageServiceHost: languageContext.typescript.languageServiceHost,
|
|
89
89
|
languageService: tsLs,
|
|
90
90
|
} : undefined,
|
|
91
91
|
documents: textDocumentMapper,
|
|
92
92
|
commands: {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
rename: {
|
|
94
|
+
create(uri, position) {
|
|
95
|
+
const source = toSourceLocation(uri, position, data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename);
|
|
96
|
+
if (!source) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
return vscode.Command.create('', 'editor.action.rename', source.uri, source.position);
|
|
100
|
+
},
|
|
101
|
+
is(command) {
|
|
102
|
+
return command.command === 'editor.action.rename';
|
|
103
|
+
},
|
|
99
104
|
},
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
105
|
+
showReferences: {
|
|
106
|
+
create(uri, position, locations) {
|
|
107
|
+
const source = toSourceLocation(uri, position);
|
|
108
|
+
if (!source) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const sourceReferences = [];
|
|
112
|
+
for (const reference of locations) {
|
|
113
|
+
if (context.documents.isVirtualFileUri(reference.uri)) {
|
|
114
|
+
for (const [_, map] of context.documents.getMapsByVirtualFileUri(reference.uri)) {
|
|
115
|
+
const range = map.toSourceRange(reference.range);
|
|
116
|
+
if (range) {
|
|
117
|
+
sourceReferences.push({ uri: map.sourceFileDocument.uri, range });
|
|
118
|
+
}
|
|
112
119
|
}
|
|
113
120
|
}
|
|
121
|
+
else {
|
|
122
|
+
sourceReferences.push(reference);
|
|
123
|
+
}
|
|
114
124
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
125
|
+
return vscode.Command.create(locations.length === 1 ? '1 reference' : `${locations.length} references`, 'editor.action.showReferences', source.uri, source.position, sourceReferences);
|
|
126
|
+
},
|
|
127
|
+
is(command) {
|
|
128
|
+
return command.command === 'editor.action.showReferences';
|
|
129
|
+
},
|
|
120
130
|
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
setSelection: {
|
|
132
|
+
create(position) {
|
|
133
|
+
return vscode.Command.create('', 'setSelection', {
|
|
134
|
+
selection: {
|
|
135
|
+
selectionStartLineNumber: position.line + 1,
|
|
136
|
+
positionLineNumber: position.line + 1,
|
|
137
|
+
selectionStartColumn: position.character + 1,
|
|
138
|
+
positionColumn: position.character + 1,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
is(command) {
|
|
143
|
+
return command.command === 'setSelection';
|
|
144
|
+
}
|
|
130
145
|
},
|
|
131
146
|
},
|
|
132
147
|
getTextDocument,
|
|
133
148
|
};
|
|
134
|
-
for (const
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
context.plugins[pluginId] = _plugin;
|
|
139
|
-
}
|
|
140
|
-
else if (plugin) {
|
|
141
|
-
context.plugins[pluginId] = plugin;
|
|
149
|
+
for (const serviceId in config.services ?? {}) {
|
|
150
|
+
const service = config.services?.[serviceId];
|
|
151
|
+
if (service) {
|
|
152
|
+
context.plugins[serviceId] = service(context, modules);
|
|
142
153
|
}
|
|
143
154
|
}
|
|
144
155
|
return context;
|
|
@@ -160,14 +171,14 @@ function createLanguageServicePluginContext(ctx, languageContext, documentRegist
|
|
|
160
171
|
}
|
|
161
172
|
}
|
|
162
173
|
function getTextDocument(uri) {
|
|
163
|
-
const fileName =
|
|
164
|
-
const scriptSnapshot =
|
|
174
|
+
const fileName = env.uriToFileName(uri);
|
|
175
|
+
const scriptSnapshot = host.getScriptSnapshot(fileName);
|
|
165
176
|
if (scriptSnapshot) {
|
|
166
177
|
let document = documents.get(scriptSnapshot);
|
|
167
178
|
if (!document) {
|
|
168
179
|
const newVersion = (documentVersions.get(uri.toLowerCase()) ?? 0) + 1;
|
|
169
180
|
documentVersions.set(uri.toLowerCase(), newVersion);
|
|
170
|
-
document = vscode_languageserver_textdocument_1.TextDocument.create(uri,
|
|
181
|
+
document = vscode_languageserver_textdocument_1.TextDocument.create(uri, host.getScriptLanguageId?.(fileName) ?? (0, common_1.resolveCommonLanguageId)(uri), newVersion, scriptSnapshot.getText(0, scriptSnapshot.getLength()));
|
|
171
182
|
documents.set(scriptSnapshot, document);
|
|
172
183
|
}
|
|
173
184
|
return document;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ServiceContext } from '../types';
|
|
2
2
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
3
|
-
export declare function register(context:
|
|
3
|
+
export declare function register(context: ServiceContext): (uri: string, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.ColorPresentation[] | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ServiceContext } from '../types';
|
|
2
2
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
3
|
-
export declare function register(context:
|
|
3
|
+
export declare function register(context: ServiceContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.ColorInformation[] | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ServiceContext } from '../types';
|
|
2
2
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
3
|
-
export declare function register(context:
|
|
3
|
+
export declare function register(context: ServiceContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentSymbol[] | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ServiceContext } from '../types';
|
|
2
2
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
3
|
-
export declare function register(context:
|
|
3
|
+
export declare function register(context: ServiceContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.FoldingRange[] | undefined>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: ServiceContext): (uri: string, options: vscode.FormattingOptions, range: vscode.Range | undefined, onTypeParams: {
|
|
4
4
|
ch: string;
|
|
5
5
|
position: vscode.Position;
|
|
6
6
|
} | undefined, token?: vscode.CancellationToken) => Promise<vscode.TextEdit[] | undefined>;
|
|
@@ -16,7 +16,7 @@ function register(context) {
|
|
|
16
16
|
? (await tryFormat(document, onTypeParams.position, onTypeParams.ch))?.edits
|
|
17
17
|
: (await tryFormat(document, range, undefined))?.edits;
|
|
18
18
|
}
|
|
19
|
-
const initialIndentLanguageId = await context.
|
|
19
|
+
const initialIndentLanguageId = await context.env.getConfiguration?.('volar.format.initialIndent') ?? { html: true };
|
|
20
20
|
const originalSnapshot = source.snapshot;
|
|
21
21
|
const rootVirtualFile = source.root;
|
|
22
22
|
const originalDocument = document;
|
|
@@ -56,7 +56,7 @@ function register(context) {
|
|
|
56
56
|
toPatchIndentUris.push({
|
|
57
57
|
uri: map.virtualFileDocument.uri,
|
|
58
58
|
isCodeBlock,
|
|
59
|
-
|
|
59
|
+
service: embeddedCodeResult.plugin,
|
|
60
60
|
});
|
|
61
61
|
for (const textEdit of embeddedCodeResult.edits) {
|
|
62
62
|
const range = map.toSourceRange(textEdit.range);
|
|
@@ -72,7 +72,7 @@ function register(context) {
|
|
|
72
72
|
if (edits.length > 0) {
|
|
73
73
|
const newText = vscode_languageserver_textdocument_1.TextDocument.applyEdits(document, edits);
|
|
74
74
|
document = vscode_languageserver_textdocument_1.TextDocument.create(document.uri, document.languageId, document.version + 1, newText);
|
|
75
|
-
context.core.virtualFiles.updateSource(context.uriToFileName(document.uri), (0, common_1.stringToSnapshot)(document.getText()), undefined);
|
|
75
|
+
context.core.virtualFiles.updateSource(context.env.uriToFileName(document.uri), (0, common_1.stringToSnapshot)(document.getText()), undefined);
|
|
76
76
|
edited = true;
|
|
77
77
|
}
|
|
78
78
|
if (level > 1) {
|
|
@@ -88,7 +88,7 @@ function register(context) {
|
|
|
88
88
|
for (const toPatchIndentUri of toPatchIndentUris) {
|
|
89
89
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(toPatchIndentUri.uri)) {
|
|
90
90
|
const indentSensitiveLines = new Set();
|
|
91
|
-
for (const plugin of toPatchIndentUri.
|
|
91
|
+
for (const plugin of toPatchIndentUri.service.provideFormattingIndentSensitiveLines ? [toPatchIndentUri.service] : Object.values(context.plugins)) {
|
|
92
92
|
if (token.isCancellationRequested)
|
|
93
93
|
break;
|
|
94
94
|
if (plugin.provideFormattingIndentSensitiveLines) {
|
|
@@ -121,7 +121,7 @@ function register(context) {
|
|
|
121
121
|
if (indentEdits.length > 0) {
|
|
122
122
|
const newText = vscode_languageserver_textdocument_1.TextDocument.applyEdits(document, indentEdits);
|
|
123
123
|
document = vscode_languageserver_textdocument_1.TextDocument.create(document.uri, document.languageId, document.version + 1, newText);
|
|
124
|
-
context.core.virtualFiles.updateSource(context.uriToFileName(document.uri), (0, common_1.stringToSnapshot)(document.getText()), undefined);
|
|
124
|
+
context.core.virtualFiles.updateSource(context.env.uriToFileName(document.uri), (0, common_1.stringToSnapshot)(document.getText()), undefined);
|
|
125
125
|
edited = true;
|
|
126
126
|
}
|
|
127
127
|
}
|
|
@@ -130,7 +130,7 @@ function register(context) {
|
|
|
130
130
|
}
|
|
131
131
|
if (edited) {
|
|
132
132
|
// recover
|
|
133
|
-
context.core.virtualFiles.updateSource(context.uriToFileName(document.uri), originalSnapshot, undefined);
|
|
133
|
+
context.core.virtualFiles.updateSource(context.env.uriToFileName(document.uri), originalSnapshot, undefined);
|
|
134
134
|
}
|
|
135
135
|
if (document.getText() === originalDocument.getText())
|
|
136
136
|
return;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ServiceContext } from '../types';
|
|
2
2
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
3
|
-
export declare function register(context:
|
|
3
|
+
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LinkedEditingRanges | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ServiceContext } from '../types';
|
|
2
2
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
3
|
-
export declare function register(context:
|
|
3
|
+
export declare function register(context: ServiceContext): (uri: string, positions: vscode.Position[], token?: vscode.CancellationToken) => Promise<vscode.SelectionRange[] | undefined>;
|
package/out/documents.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { VirtualFiles, VirtualFile, FileRangeCapabilities, MirrorBehaviorCapabilities, MirrorMap } from '@volar/language-core';
|
|
1
|
+
import { VirtualFiles, VirtualFile, FileRangeCapabilities, MirrorBehaviorCapabilities, MirrorMap, LanguageServiceHost } from '@volar/language-core';
|
|
2
2
|
import { Mapping, SourceMap } from '@volar/source-map';
|
|
3
3
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
4
4
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
5
5
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
6
|
-
import {
|
|
6
|
+
import { ServiceEnvironment } from './types';
|
|
7
7
|
export type DocumentsAndSourceMaps = ReturnType<typeof createDocumentsAndSourceMaps>;
|
|
8
8
|
export declare class SourceMapWithDocuments<Data = any> {
|
|
9
9
|
sourceFileDocument: TextDocument;
|
|
@@ -30,7 +30,7 @@ export declare class MirrorMapWithDocument extends SourceMapWithDocuments<[Mirro
|
|
|
30
30
|
constructor(document: TextDocument, map: MirrorMap);
|
|
31
31
|
findMirrorPositions(start: vscode.Position): Generator<readonly [import("vscode-languageserver-textdocument").Position, MirrorBehaviorCapabilities], void, unknown>;
|
|
32
32
|
}
|
|
33
|
-
export declare function createDocumentsAndSourceMaps(
|
|
33
|
+
export declare function createDocumentsAndSourceMaps(env: ServiceEnvironment, host: LanguageServiceHost, mapper: VirtualFiles): {
|
|
34
34
|
getSourceByUri(sourceFileUri: string): import("@volar/language-core").Source | undefined;
|
|
35
35
|
isVirtualFileUri(virtualFileUri: string): boolean;
|
|
36
36
|
getVirtualFileByUri(virtualFileUri: string): readonly [VirtualFile, import("@volar/language-core").Source] | readonly [undefined, undefined];
|
package/out/documents.js
CHANGED
|
@@ -130,23 +130,23 @@ class MirrorMapWithDocument extends SourceMapWithDocuments {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
exports.MirrorMapWithDocument = MirrorMapWithDocument;
|
|
133
|
-
function createDocumentsAndSourceMaps(
|
|
133
|
+
function createDocumentsAndSourceMaps(env, host, mapper) {
|
|
134
134
|
let version = 0;
|
|
135
135
|
const _maps = new WeakMap();
|
|
136
136
|
const _mirrorMaps = new WeakMap();
|
|
137
137
|
const _documents = new WeakMap();
|
|
138
138
|
return {
|
|
139
139
|
getSourceByUri(sourceFileUri) {
|
|
140
|
-
return mapper.getSource(
|
|
140
|
+
return mapper.getSource(env.uriToFileName(sourceFileUri));
|
|
141
141
|
},
|
|
142
142
|
isVirtualFileUri(virtualFileUri) {
|
|
143
|
-
return mapper.hasVirtualFile(
|
|
143
|
+
return mapper.hasVirtualFile(env.uriToFileName(virtualFileUri));
|
|
144
144
|
},
|
|
145
145
|
getVirtualFileByUri(virtualFileUri) {
|
|
146
|
-
return mapper.getVirtualFile(
|
|
146
|
+
return mapper.getVirtualFile(env.uriToFileName(virtualFileUri));
|
|
147
147
|
},
|
|
148
148
|
getMirrorMapByUri(virtualFileUri) {
|
|
149
|
-
const fileName =
|
|
149
|
+
const fileName = env.uriToFileName(virtualFileUri);
|
|
150
150
|
const [virtualFile] = mapper.getVirtualFile(fileName);
|
|
151
151
|
if (virtualFile) {
|
|
152
152
|
const map = mapper.getMirrorMap(virtualFile);
|
|
@@ -159,7 +159,7 @@ function createDocumentsAndSourceMaps(ctx, mapper) {
|
|
|
159
159
|
}
|
|
160
160
|
},
|
|
161
161
|
getMapsBySourceFileUri(uri) {
|
|
162
|
-
return this.getMapsBySourceFileName(
|
|
162
|
+
return this.getMapsBySourceFileName(env.uriToFileName(uri));
|
|
163
163
|
},
|
|
164
164
|
getMapsBySourceFileName(fileName) {
|
|
165
165
|
const source = mapper.getSource(fileName);
|
|
@@ -187,7 +187,7 @@ function createDocumentsAndSourceMaps(ctx, mapper) {
|
|
|
187
187
|
}
|
|
188
188
|
},
|
|
189
189
|
getMapsByVirtualFileUri(virtualFileUri) {
|
|
190
|
-
return this.getMapsByVirtualFileName(
|
|
190
|
+
return this.getMapsByVirtualFileName(env.uriToFileName(virtualFileUri));
|
|
191
191
|
},
|
|
192
192
|
*getMapsByVirtualFileName(virtualFileName) {
|
|
193
193
|
const [virtualFile] = mapper.getVirtualFile(virtualFileName);
|
|
@@ -206,7 +206,7 @@ function createDocumentsAndSourceMaps(ctx, mapper) {
|
|
|
206
206
|
}
|
|
207
207
|
},
|
|
208
208
|
getDocumentByUri(snapshot, uri) {
|
|
209
|
-
return this.getDocumentByFileName(snapshot,
|
|
209
|
+
return this.getDocumentByFileName(snapshot, env.uriToFileName(uri));
|
|
210
210
|
},
|
|
211
211
|
getDocumentByFileName,
|
|
212
212
|
};
|
|
@@ -216,8 +216,8 @@ function createDocumentsAndSourceMaps(ctx, mapper) {
|
|
|
216
216
|
}
|
|
217
217
|
const map = _documents.get(snapshot);
|
|
218
218
|
if (!map.has(fileName)) {
|
|
219
|
-
const uri =
|
|
220
|
-
map.set(fileName, vscode_languageserver_textdocument_1.TextDocument.create(uri,
|
|
219
|
+
const uri = env.fileNameToUri(fileName);
|
|
220
|
+
map.set(fileName, vscode_languageserver_textdocument_1.TextDocument.create(uri, host.getScriptLanguageId?.(fileName) ?? (0, common_1.resolveCommonLanguageId)(uri), version++, snapshot.getText(0, snapshot.getLength())));
|
|
221
221
|
}
|
|
222
222
|
return map.get(fileName);
|
|
223
223
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { ServiceContext, AutoInsertionContext } from '../types';
|
|
3
|
+
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, autoInsertContext: AutoInsertionContext, token?: vscode.CancellationToken) => Promise<NonNullable<string | vscode.TextEdit | null | undefined> | undefined>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
3
|
export interface PluginCallHierarchyData {
|
|
4
4
|
uri: string;
|
|
5
5
|
original: Pick<vscode.CallHierarchyItem, 'data'>;
|
|
6
6
|
pluginId: string;
|
|
7
7
|
virtualDocumentUri: string | undefined;
|
|
8
8
|
}
|
|
9
|
-
export declare function register(context:
|
|
9
|
+
export declare function register(context: ServiceContext): {
|
|
10
10
|
doPrepare(uri: string, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
|
|
11
11
|
getIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
|
|
12
12
|
getOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
|
|
@@ -121,7 +121,7 @@ function register(context) {
|
|
|
121
121
|
const vueRanges = tsRanges.map(tsRange => map.toSourceRange(tsRange)).filter(common_1.notEmpty);
|
|
122
122
|
const vueItem = {
|
|
123
123
|
...tsItem,
|
|
124
|
-
name: tsItem.name === path_1.posix.basename(context.uriToFileName(map.virtualFileDocument.uri)) ? path_1.posix.basename(context.uriToFileName(map.sourceFileDocument.uri)) : tsItem.name,
|
|
124
|
+
name: tsItem.name === path_1.posix.basename(context.env.uriToFileName(map.virtualFileDocument.uri)) ? path_1.posix.basename(context.env.uriToFileName(map.sourceFileDocument.uri)) : tsItem.name,
|
|
125
125
|
uri: map.sourceFileDocument.uri,
|
|
126
126
|
// TS Bug: `range: range` not works
|
|
127
127
|
range: {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: ServiceContext): (item: vscode.CodeAction, token?: vscode.CancellationToken) => Promise<vscode.CodeAction>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
3
|
export interface PluginCodeActionData {
|
|
4
4
|
uri: string;
|
|
5
5
|
version: number;
|
|
@@ -17,4 +17,4 @@ export interface RuleCodeActionData {
|
|
|
17
17
|
ruleFixIndex: number;
|
|
18
18
|
index: number;
|
|
19
19
|
}
|
|
20
|
-
export declare function register(context:
|
|
20
|
+
export declare function register(context: ServiceContext): (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token?: vscode.CancellationToken) => Promise<vscode.CodeAction[] | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ServiceContext } from '../types';
|
|
2
2
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
3
3
|
export interface PluginCodeLensData {
|
|
4
4
|
kind: 'normal';
|
|
@@ -12,4 +12,4 @@ export interface PluginReferencesCodeLensData {
|
|
|
12
12
|
range: vscode.Range;
|
|
13
13
|
pluginId: string;
|
|
14
14
|
}
|
|
15
|
-
export declare function register(context:
|
|
15
|
+
export declare function register(context: ServiceContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: ServiceContext): (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
@@ -22,7 +22,7 @@ function register(context) {
|
|
|
22
22
|
if (document && plugin.resolveReferencesCodeLensLocations) {
|
|
23
23
|
references = await plugin.resolveReferencesCodeLensLocations(document, data.range, references, token);
|
|
24
24
|
}
|
|
25
|
-
item.command = context.commands.
|
|
25
|
+
item.command = context.commands.showReferences.create(data.uri, data.range.start, references);
|
|
26
26
|
}
|
|
27
27
|
return item;
|
|
28
28
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
3
|
export interface PluginCompletionData {
|
|
4
4
|
uri: string;
|
|
5
5
|
original: Pick<vscode.CompletionItem, 'additionalTextEdits' | 'textEdit' | 'data'>;
|
|
6
6
|
pluginId: string;
|
|
7
7
|
virtualDocumentUri: string | undefined;
|
|
8
8
|
}
|
|
9
|
-
export declare function register(context:
|
|
9
|
+
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext, token?: vscode.CancellationToken) => Promise<vscode.CompletionList>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: ServiceContext): (item: vscode.CompletionItem, token?: vscode.CancellationToken) => Promise<vscode.CompletionItem>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
3
|
import { FileRangeCapabilities, MirrorBehaviorCapabilities } from '@volar/language-core';
|
|
4
|
-
export declare function register(context:
|
|
4
|
+
export declare function register(context: ServiceContext, apiName: 'provideDefinition' | 'provideTypeDefinition' | 'provideImplementation', isValidMapping: (data: FileRangeCapabilities) => boolean, isValidMirrorPosition: (mirrorData: MirrorBehaviorCapabilities) => boolean): (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: ServiceContext): (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
3
|
export interface DocumentLinkData {
|
|
4
4
|
uri: string;
|
|
5
5
|
original: Pick<vscode.DocumentLink, 'data'>;
|
|
6
6
|
pluginId: string;
|
|
7
7
|
}
|
|
8
|
-
export declare function register(context:
|
|
8
|
+
export declare function register(context: ServiceContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: ServiceContext): (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, token?: vscode.CancellationToken, reportProgress?: ((tokens: vscode.SemanticTokens) => void) | undefined) => Promise<vscode.SemanticTokens | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ServiceContext } from '../types';
|
|
2
2
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
3
3
|
import { NullableResult } from '@volar/language-service';
|
|
4
|
-
export declare function register(context:
|
|
4
|
+
export declare function register(context: ServiceContext): (uri: string, token?: vscode.CancellationToken) => NullableResult<vscode.Location[]>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ServiceContext } from '../types';
|
|
2
2
|
import type * as _ from 'vscode-languageserver-protocol';
|
|
3
|
-
export declare function register(context:
|
|
3
|
+
export declare function register(context: ServiceContext): (oldUri: string, newUri: string, token?: _.CancellationToken) => Promise<_.WorkspaceEdit | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Hover | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function register(context:
|
|
2
|
+
import type { ServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: ServiceContext): (item: vscode.InlayHint, token?: vscode.CancellationToken) => Promise<vscode.InlayHint>;
|