This commit is contained in:
8
node_modules/@volar/language-service/lib/features/provideAutoInsertSnippet.d.ts
generated
vendored
Normal file
8
node_modules/@volar/language-service/lib/features/provideAutoInsertSnippet.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, selection: vscode.Position, change: {
|
||||
rangeOffset: number;
|
||||
rangeLength: number;
|
||||
text: string;
|
||||
}, token?: vscode.CancellationToken) => Promise<string | undefined>;
|
||||
31
node_modules/@volar/language-service/lib/features/provideAutoInsertSnippet.js
generated
vendored
Normal file
31
node_modules/@volar/language-service/lib/features/provideAutoInsertSnippet.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context) {
|
||||
return (uri, selection, change, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => ({ selection, change }), function* (docs) {
|
||||
for (const mappedPosition of (0, featureWorkers_1.getGeneratedPositions)(docs, selection, language_core_1.isAutoInsertEnabled)) {
|
||||
for (const mapped of docs[2].toGeneratedLocation(change.rangeOffset)) {
|
||||
yield {
|
||||
selection: mappedPosition,
|
||||
change: {
|
||||
text: change.text,
|
||||
rangeOffset: mapped[0],
|
||||
rangeLength: change.rangeLength,
|
||||
},
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, (plugin, document, args) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
return plugin[1].provideAutoInsertSnippet?.(document, args.selection, args.change, token);
|
||||
}, snippet => snippet);
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideAutoInsertSnippet.js.map
|
||||
17
node_modules/@volar/language-service/lib/features/provideCallHierarchyItems.d.ts
generated
vendored
Normal file
17
node_modules/@volar/language-service/lib/features/provideCallHierarchyItems.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export interface PluginCallHierarchyData {
|
||||
uri: string;
|
||||
original: Pick<vscode.CallHierarchyItem, 'data'>;
|
||||
pluginIndex: number;
|
||||
embeddedDocumentUri: string | undefined;
|
||||
}
|
||||
export declare function register(context: LanguageServiceContext): {
|
||||
getCallHierarchyItems(uri: URI, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
|
||||
getTypeHierarchyItems(uri: URI, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.TypeHierarchyItem[] | undefined>;
|
||||
getCallHierarchyIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
|
||||
getCallHierarchyOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
|
||||
getTypeHierarchySupertypes(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.TypeHierarchyItem[] | undefined>;
|
||||
getTypeHierarchySubtypes(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.TypeHierarchyItem[] | undefined>;
|
||||
};
|
||||
240
node_modules/@volar/language-service/lib/features/provideCallHierarchyItems.js
generated
vendored
Normal file
240
node_modules/@volar/language-service/lib/features/provideCallHierarchyItems.js
generated
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const dedupe = require("../utils/dedupe");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context) {
|
||||
return {
|
||||
getCallHierarchyItems(uri, position, token = cancellation_1.NoneCancellationToken) {
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, docs => (0, featureWorkers_1.getGeneratedPositions)(docs, position, language_core_1.isCallHierarchyEnabled), async (plugin, document, position, map) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
const items = await plugin[1].provideCallHierarchyItems?.(document, position, token);
|
||||
items?.forEach(item => {
|
||||
item.data = {
|
||||
uri: uri.toString(),
|
||||
original: {
|
||||
data: item.data,
|
||||
},
|
||||
pluginIndex: context.plugins.indexOf(plugin),
|
||||
embeddedDocumentUri: map?.[1].uri,
|
||||
};
|
||||
});
|
||||
return items;
|
||||
}, (data, map) => {
|
||||
if (!map) {
|
||||
return data;
|
||||
}
|
||||
return data
|
||||
.map(item => transformHierarchyItem(item, [])?.[0])
|
||||
.filter(item => !!item);
|
||||
}, arr => dedupe.withLocations(arr.flat()));
|
||||
},
|
||||
getTypeHierarchyItems(uri, position, token = cancellation_1.NoneCancellationToken) {
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, docs => (0, featureWorkers_1.getGeneratedPositions)(docs, position, language_core_1.isTypeHierarchyEnabled), async (plugin, document, position, map) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
const items = await plugin[1].provideTypeHierarchyItems?.(document, position, token);
|
||||
items?.forEach(item => {
|
||||
item.data = {
|
||||
uri: uri.toString(),
|
||||
original: {
|
||||
data: item.data,
|
||||
},
|
||||
pluginIndex: context.plugins.indexOf(plugin),
|
||||
embeddedDocumentUri: map?.[1].uri,
|
||||
};
|
||||
});
|
||||
return items;
|
||||
}, (data, map) => {
|
||||
if (!map) {
|
||||
return data;
|
||||
}
|
||||
return data
|
||||
.map(item => transformHierarchyItem(item, [])?.[0])
|
||||
.filter(item => !!item);
|
||||
}, arr => dedupe.withLocations(arr.flat()));
|
||||
},
|
||||
async getCallHierarchyIncomingCalls(item, token) {
|
||||
const data = item.data;
|
||||
let incomingItems = [];
|
||||
if (data) {
|
||||
const plugin = context.plugins[data.pluginIndex];
|
||||
if (!plugin[1].provideCallHierarchyIncomingCalls) {
|
||||
return incomingItems;
|
||||
}
|
||||
Object.assign(item, data.original);
|
||||
if (data.embeddedDocumentUri) {
|
||||
const isEmbeddedContent = !!context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(data.embeddedDocumentUri));
|
||||
if (isEmbeddedContent) {
|
||||
const _calls = await plugin[1].provideCallHierarchyIncomingCalls(item, token);
|
||||
for (const _call of _calls) {
|
||||
const calls = transformHierarchyItem(_call.from, _call.fromRanges);
|
||||
if (!calls) {
|
||||
continue;
|
||||
}
|
||||
incomingItems.push({
|
||||
from: calls[0],
|
||||
fromRanges: calls[1],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const _calls = await plugin[1].provideCallHierarchyIncomingCalls(item, token);
|
||||
for (const _call of _calls) {
|
||||
const calls = transformHierarchyItem(_call.from, _call.fromRanges);
|
||||
if (!calls) {
|
||||
continue;
|
||||
}
|
||||
incomingItems.push({
|
||||
from: calls[0],
|
||||
fromRanges: calls[1],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return dedupe.withCallHierarchyIncomingCalls(incomingItems);
|
||||
},
|
||||
async getCallHierarchyOutgoingCalls(item, token) {
|
||||
const data = item.data;
|
||||
let items = [];
|
||||
if (data) {
|
||||
const plugin = context.plugins[data.pluginIndex];
|
||||
if (!plugin[1].provideCallHierarchyOutgoingCalls) {
|
||||
return items;
|
||||
}
|
||||
Object.assign(item, data.original);
|
||||
if (data.embeddedDocumentUri) {
|
||||
const isEmbeddedContent = !!context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(data.embeddedDocumentUri));
|
||||
if (isEmbeddedContent) {
|
||||
const _calls = await plugin[1].provideCallHierarchyOutgoingCalls(item, token);
|
||||
for (const call of _calls) {
|
||||
const calls = transformHierarchyItem(call.to, call.fromRanges);
|
||||
if (!calls) {
|
||||
continue;
|
||||
}
|
||||
items.push({
|
||||
to: calls[0],
|
||||
fromRanges: calls[1],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const _calls = await plugin[1].provideCallHierarchyOutgoingCalls(item, token);
|
||||
for (const call of _calls) {
|
||||
const calls = transformHierarchyItem(call.to, call.fromRanges);
|
||||
if (!calls) {
|
||||
continue;
|
||||
}
|
||||
items.push({
|
||||
to: calls[0],
|
||||
fromRanges: calls[1],
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return dedupe.withCallHierarchyOutgoingCalls(items);
|
||||
},
|
||||
async getTypeHierarchySupertypes(item, token) {
|
||||
const data = item.data;
|
||||
if (data) {
|
||||
const plugin = context.plugins[data.pluginIndex];
|
||||
if (!plugin[1].provideTypeHierarchySupertypes) {
|
||||
return [];
|
||||
}
|
||||
Object.assign(item, data.original);
|
||||
if (data.embeddedDocumentUri) {
|
||||
const isEmbeddedContent = !!context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(data.embeddedDocumentUri));
|
||||
if (isEmbeddedContent) {
|
||||
const items = await plugin[1].provideTypeHierarchySupertypes(item, token);
|
||||
return items
|
||||
.map(item => transformHierarchyItem(item, [])?.[0])
|
||||
.filter(item => !!item);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const items = await plugin[1].provideTypeHierarchySupertypes(item, token);
|
||||
return items
|
||||
.map(item => transformHierarchyItem(item, [])?.[0])
|
||||
.filter(item => !!item);
|
||||
}
|
||||
}
|
||||
},
|
||||
async getTypeHierarchySubtypes(item, token) {
|
||||
const data = item.data;
|
||||
if (data) {
|
||||
const plugin = context.plugins[data.pluginIndex];
|
||||
if (!plugin[1].provideTypeHierarchySubtypes) {
|
||||
return [];
|
||||
}
|
||||
Object.assign(item, data.original);
|
||||
if (data.embeddedDocumentUri) {
|
||||
const isEmbeddedContent = !!context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(data.embeddedDocumentUri));
|
||||
if (isEmbeddedContent) {
|
||||
const items = await plugin[1].provideTypeHierarchySubtypes(item, token);
|
||||
return items
|
||||
.map(item => transformHierarchyItem(item, [])?.[0])
|
||||
.filter(item => !!item);
|
||||
}
|
||||
}
|
||||
else {
|
||||
const items = await plugin[1].provideTypeHierarchySubtypes(item, token);
|
||||
return items
|
||||
.map(item => transformHierarchyItem(item, [])?.[0])
|
||||
.filter(item => !!item);
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
function transformHierarchyItem(tsItem, tsRanges) {
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(tsItem.uri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
||||
if (!sourceScript || !virtualCode) {
|
||||
return [tsItem, tsRanges];
|
||||
}
|
||||
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot);
|
||||
for (const [sourceScript, map] of context.language.maps.forEach(virtualCode)) {
|
||||
const sourceDocument = context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot);
|
||||
const docs = [sourceDocument, embeddedDocument, map];
|
||||
let range = (0, featureWorkers_1.getSourceRange)(docs, tsItem.range);
|
||||
if (!range) {
|
||||
// TODO: <script> range
|
||||
range = {
|
||||
start: sourceDocument.positionAt(0),
|
||||
end: sourceDocument.positionAt(sourceDocument.getText().length),
|
||||
};
|
||||
}
|
||||
const selectionRange = (0, featureWorkers_1.getSourceRange)(docs, tsItem.selectionRange);
|
||||
if (!selectionRange) {
|
||||
continue;
|
||||
}
|
||||
const vueRanges = tsRanges.map(tsRange => (0, featureWorkers_1.getSourceRange)(docs, tsRange)).filter(range => !!range);
|
||||
const vueItem = {
|
||||
...tsItem,
|
||||
name: tsItem.name === embeddedDocument.uri.substring(embeddedDocument.uri.lastIndexOf('/') + 1)
|
||||
? sourceDocument.uri.substring(sourceDocument.uri.lastIndexOf('/') + 1)
|
||||
: tsItem.name,
|
||||
uri: sourceDocument.uri,
|
||||
// TS Bug: `range: range` not works
|
||||
range: {
|
||||
start: range.start,
|
||||
end: range.end,
|
||||
},
|
||||
selectionRange: {
|
||||
start: selectionRange.start,
|
||||
end: selectionRange.end,
|
||||
},
|
||||
};
|
||||
return [vueItem, vueRanges];
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=provideCallHierarchyItems.js.map
|
||||
10
node_modules/@volar/language-service/lib/features/provideCodeActions.d.ts
generated
vendored
Normal file
10
node_modules/@volar/language-service/lib/features/provideCodeActions.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export interface ServiceCodeActionData {
|
||||
uri: string;
|
||||
version: number;
|
||||
original: Pick<vscode.CodeAction, 'data' | 'edit'>;
|
||||
pluginIndex: number;
|
||||
}
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token?: vscode.CancellationToken) => Promise<vscode.CodeAction[] | undefined>;
|
||||
97
node_modules/@volar/language-service/lib/features/provideCodeActions.js
generated
vendored
Normal file
97
node_modules/@volar/language-service/lib/features/provideCodeActions.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const common_1 = require("../utils/common");
|
||||
const dedupe = require("../utils/dedupe");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
const transform_1 = require("../utils/transform");
|
||||
function register(context) {
|
||||
return async (uri, range, codeActionContext, token = cancellation_1.NoneCancellationToken) => {
|
||||
const sourceScript = context.language.scripts.get(uri);
|
||||
if (!sourceScript) {
|
||||
return;
|
||||
}
|
||||
const transformedCodeActions = new WeakSet();
|
||||
return await (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => ({ range, codeActionContext }), function* (docs) {
|
||||
const _codeActionContext = {
|
||||
diagnostics: (0, transform_1.transformLocations)(codeActionContext.diagnostics, range => (0, featureWorkers_1.getGeneratedRange)(docs, range)),
|
||||
only: codeActionContext.only,
|
||||
};
|
||||
const mapped = (0, common_1.findOverlapCodeRange)(docs[0].offsetAt(range.start), docs[0].offsetAt(range.end), docs[2], language_core_1.isCodeActionsEnabled);
|
||||
if (mapped) {
|
||||
yield {
|
||||
range: {
|
||||
start: docs[1].positionAt(mapped.start),
|
||||
end: docs[1].positionAt(mapped.end),
|
||||
},
|
||||
codeActionContext: _codeActionContext,
|
||||
};
|
||||
}
|
||||
}, async (plugin, document, { range, codeActionContext }) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
const pluginIndex = context.plugins.indexOf(plugin);
|
||||
const diagnostics = codeActionContext.diagnostics.filter(diagnostic => {
|
||||
const data = diagnostic.data;
|
||||
if (data && data.version !== document.version) {
|
||||
return false;
|
||||
}
|
||||
return data?.pluginIndex === pluginIndex;
|
||||
}).map(diagnostic => {
|
||||
const data = diagnostic.data;
|
||||
return {
|
||||
...diagnostic,
|
||||
...data.original,
|
||||
};
|
||||
});
|
||||
const codeActions = await plugin[1].provideCodeActions?.(document, range, {
|
||||
...codeActionContext,
|
||||
diagnostics,
|
||||
}, token);
|
||||
codeActions?.forEach(codeAction => {
|
||||
if (plugin[1].resolveCodeAction) {
|
||||
codeAction.data = {
|
||||
uri: uri.toString(),
|
||||
version: document.version,
|
||||
original: {
|
||||
data: codeAction.data,
|
||||
edit: codeAction.edit,
|
||||
},
|
||||
pluginIndex: context.plugins.indexOf(plugin),
|
||||
};
|
||||
}
|
||||
else {
|
||||
delete codeAction.data;
|
||||
}
|
||||
});
|
||||
if (codeActions && plugin[1].transformCodeAction) {
|
||||
for (let i = 0; i < codeActions.length; i++) {
|
||||
const transformed = plugin[1].transformCodeAction(codeActions[i]);
|
||||
if (transformed) {
|
||||
codeActions[i] = transformed;
|
||||
transformedCodeActions.add(transformed);
|
||||
}
|
||||
}
|
||||
}
|
||||
return codeActions;
|
||||
}, actions => actions
|
||||
.map(action => {
|
||||
if (transformedCodeActions.has(action)) {
|
||||
return action;
|
||||
}
|
||||
if (action.edit) {
|
||||
const edit = (0, transform_1.transformWorkspaceEdit)(action.edit, context, 'codeAction');
|
||||
if (!edit) {
|
||||
return;
|
||||
}
|
||||
action.edit = edit;
|
||||
}
|
||||
return action;
|
||||
})
|
||||
.filter(action => !!action), arr => dedupe.withCodeAction(arr.flat()));
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideCodeActions.js.map
|
||||
17
node_modules/@volar/language-service/lib/features/provideCodeLenses.d.ts
generated
vendored
Normal file
17
node_modules/@volar/language-service/lib/features/provideCodeLenses.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export interface ServiceCodeLensData {
|
||||
kind: 'normal';
|
||||
uri: string;
|
||||
original: Pick<vscode.CodeLens, 'data'>;
|
||||
pluginIndex: number;
|
||||
}
|
||||
export interface ServiceReferencesCodeLensData {
|
||||
kind: 'references';
|
||||
sourceFileUri: string;
|
||||
workerFileUri: string;
|
||||
workerFileRange: vscode.Range;
|
||||
pluginIndex: number;
|
||||
}
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
|
||||
64
node_modules/@volar/language-service/lib/features/provideCodeLenses.js
generated
vendored
Normal file
64
node_modules/@volar/language-service/lib/features/provideCodeLenses.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context) {
|
||||
return async (uri, token = cancellation_1.NoneCancellationToken) => {
|
||||
return await (0, featureWorkers_1.documentFeatureWorker)(context, uri, docs => docs[2].mappings.some(mapping => (0, language_core_1.isCodeLensEnabled)(mapping.data)), async (plugin, document) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
let codeLens = await plugin[1].provideCodeLenses?.(document, token);
|
||||
const pluginIndex = context.plugins.indexOf(plugin);
|
||||
codeLens?.forEach(codeLens => {
|
||||
if (plugin[1].resolveCodeLens) {
|
||||
codeLens.data = {
|
||||
kind: 'normal',
|
||||
uri: uri.toString(),
|
||||
original: {
|
||||
data: codeLens.data,
|
||||
},
|
||||
pluginIndex,
|
||||
};
|
||||
}
|
||||
else {
|
||||
delete codeLens.data;
|
||||
}
|
||||
});
|
||||
const ranges = await plugin[1].provideReferencesCodeLensRanges?.(document, token);
|
||||
const referencesCodeLens = ranges?.map(range => ({
|
||||
range,
|
||||
data: {
|
||||
kind: 'references',
|
||||
sourceFileUri: uri.toString(),
|
||||
workerFileUri: document.uri,
|
||||
workerFileRange: range,
|
||||
pluginIndex: pluginIndex,
|
||||
},
|
||||
}));
|
||||
codeLens = [
|
||||
...codeLens ?? [],
|
||||
...referencesCodeLens ?? [],
|
||||
];
|
||||
return codeLens;
|
||||
}, (data, docs) => {
|
||||
if (!docs) {
|
||||
return data;
|
||||
}
|
||||
return data
|
||||
.map(codeLens => {
|
||||
const range = (0, featureWorkers_1.getSourceRange)(docs, codeLens.range, language_core_1.isCodeLensEnabled);
|
||||
if (range) {
|
||||
return {
|
||||
...codeLens,
|
||||
range,
|
||||
};
|
||||
}
|
||||
})
|
||||
.filter(codeLens => !!codeLens);
|
||||
}, arr => arr.flat()) ?? [];
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideCodeLenses.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideColorPresentations.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideColorPresentations.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.ColorPresentation[] | undefined>;
|
||||
46
node_modules/@volar/language-service/lib/features/provideColorPresentations.js
generated
vendored
Normal file
46
node_modules/@volar/language-service/lib/features/provideColorPresentations.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context) {
|
||||
return (uri, color, range, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => range, function* (docs) {
|
||||
for (const mappedRange of (0, featureWorkers_1.getGeneratedRanges)(docs, range, language_core_1.isColorEnabled)) {
|
||||
yield mappedRange;
|
||||
}
|
||||
}, (plugin, document, range) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
return plugin[1].provideColorPresentations?.(document, color, range, token);
|
||||
}, (data, docs) => {
|
||||
if (!docs) {
|
||||
return data;
|
||||
}
|
||||
return data
|
||||
.map(colorPresentation => {
|
||||
if (colorPresentation.textEdit) {
|
||||
const range = (0, featureWorkers_1.getSourceRange)(docs, colorPresentation.textEdit.range);
|
||||
if (!range) {
|
||||
return undefined;
|
||||
}
|
||||
colorPresentation.textEdit.range = range;
|
||||
}
|
||||
if (colorPresentation.additionalTextEdits) {
|
||||
for (const textEdit of colorPresentation.additionalTextEdits) {
|
||||
const range = (0, featureWorkers_1.getSourceRange)(docs, textEdit.range);
|
||||
if (!range) {
|
||||
return undefined;
|
||||
}
|
||||
textEdit.range = range;
|
||||
}
|
||||
}
|
||||
return colorPresentation;
|
||||
})
|
||||
.filter(colorPresentation => !!colorPresentation);
|
||||
});
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideColorPresentations.js.map
|
||||
10
node_modules/@volar/language-service/lib/features/provideCompletionItems.d.ts
generated
vendored
Normal file
10
node_modules/@volar/language-service/lib/features/provideCompletionItems.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export interface ServiceCompletionData {
|
||||
uri: string;
|
||||
original: Pick<vscode.CompletionItem, 'additionalTextEdits' | 'textEdit' | 'data'>;
|
||||
pluginIndex: number;
|
||||
embeddedDocumentUri: string | undefined;
|
||||
}
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, completionContext?: vscode.CompletionContext, token?: vscode.CancellationToken) => Promise<vscode.CompletionList>;
|
||||
205
node_modules/@volar/language-service/lib/features/provideCompletionItems.js
generated
vendored
Normal file
205
node_modules/@volar/language-service/lib/features/provideCompletionItems.js
generated
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
const transform_1 = require("../utils/transform");
|
||||
function register(context) {
|
||||
let lastResult;
|
||||
return async (uri, position, completionContext = { triggerKind: 1, }, token = cancellation_1.NoneCancellationToken) => {
|
||||
let langaugeIdAndSnapshot;
|
||||
let sourceScript;
|
||||
const decoded = context.decodeEmbeddedDocumentUri(uri);
|
||||
if (decoded) {
|
||||
langaugeIdAndSnapshot = context.language.scripts.get(decoded[0])?.generated?.embeddedCodes.get(decoded[1]);
|
||||
}
|
||||
else {
|
||||
sourceScript = context.language.scripts.get(uri);
|
||||
langaugeIdAndSnapshot = sourceScript;
|
||||
}
|
||||
if (!langaugeIdAndSnapshot) {
|
||||
return {
|
||||
isIncomplete: false,
|
||||
items: [],
|
||||
};
|
||||
}
|
||||
if (completionContext?.triggerKind === 3
|
||||
&& lastResult?.uri.toString() === uri.toString()) {
|
||||
for (const cacheData of lastResult.results) {
|
||||
if (!cacheData.list?.isIncomplete) {
|
||||
continue;
|
||||
}
|
||||
const pluginIndex = context.plugins.findIndex(plugin => plugin[1] === cacheData.plugin);
|
||||
if (cacheData.embeddedDocumentUri) {
|
||||
const decoded = context.decodeEmbeddedDocumentUri(cacheData.embeddedDocumentUri);
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
||||
if (!sourceScript || !virtualCode) {
|
||||
continue;
|
||||
}
|
||||
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot);
|
||||
for (const [sourceScript, map] of context.language.maps.forEach(virtualCode)) {
|
||||
const sourceDocument = context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot);
|
||||
const docs = [sourceDocument, embeddedDocument, map];
|
||||
for (const mapped of (0, featureWorkers_1.getGeneratedPositions)(docs, position, data => (0, language_core_1.isCompletionEnabled)(data))) {
|
||||
if (!cacheData.plugin.provideCompletionItems) {
|
||||
continue;
|
||||
}
|
||||
cacheData.list = await cacheData.plugin.provideCompletionItems(embeddedDocument, mapped, completionContext, token);
|
||||
if (!cacheData.list) {
|
||||
continue;
|
||||
}
|
||||
for (const item of cacheData.list.items) {
|
||||
if (cacheData.plugin.resolveCompletionItem) {
|
||||
item.data = {
|
||||
uri: uri.toString(),
|
||||
original: {
|
||||
additionalTextEdits: item.additionalTextEdits,
|
||||
textEdit: item.textEdit,
|
||||
data: item.data,
|
||||
},
|
||||
pluginIndex: pluginIndex,
|
||||
embeddedDocumentUri: embeddedDocument.uri,
|
||||
};
|
||||
}
|
||||
else {
|
||||
delete item.data;
|
||||
}
|
||||
}
|
||||
cacheData.list = (0, transform_1.transformCompletionList)(cacheData.list, range => (0, featureWorkers_1.getSourceRange)(docs, range), embeddedDocument, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!cacheData.plugin.provideCompletionItems) {
|
||||
continue;
|
||||
}
|
||||
const document = context.documents.get(uri, langaugeIdAndSnapshot.languageId, langaugeIdAndSnapshot.snapshot);
|
||||
cacheData.list = await cacheData.plugin.provideCompletionItems(document, position, completionContext, token);
|
||||
if (!cacheData.list) {
|
||||
continue;
|
||||
}
|
||||
for (const item of cacheData.list.items) {
|
||||
if (cacheData.plugin.resolveCompletionItem) {
|
||||
item.data = {
|
||||
uri: uri.toString(),
|
||||
original: {
|
||||
additionalTextEdits: item.additionalTextEdits,
|
||||
textEdit: item.textEdit,
|
||||
data: item.data,
|
||||
},
|
||||
pluginIndex: pluginIndex,
|
||||
embeddedDocumentUri: undefined,
|
||||
};
|
||||
}
|
||||
else {
|
||||
delete item.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
lastResult = {
|
||||
uri,
|
||||
results: [],
|
||||
};
|
||||
// monky fix https://github.com/johnsoncodehk/volar/issues/1358
|
||||
let isFirstMapping = true;
|
||||
let mainCompletionUri;
|
||||
const sortedPlugins = [...context.plugins]
|
||||
.filter(plugin => !context.disabledServicePlugins.has(plugin[1]))
|
||||
.sort((a, b) => sortServices(a[1], b[1]));
|
||||
const worker = async (document, position, docs, codeInfo) => {
|
||||
for (const plugin of sortedPlugins) {
|
||||
if (token.isCancellationRequested) {
|
||||
break;
|
||||
}
|
||||
if (!plugin[1].provideCompletionItems) {
|
||||
continue;
|
||||
}
|
||||
if (plugin[1].isAdditionalCompletion && !isFirstMapping) {
|
||||
continue;
|
||||
}
|
||||
if (completionContext?.triggerCharacter && !plugin[0].capabilities.completionProvider?.triggerCharacters?.includes(completionContext.triggerCharacter)) {
|
||||
continue;
|
||||
}
|
||||
const isAdditional = (codeInfo && typeof codeInfo.completion === 'object' && codeInfo.completion.isAdditional) || plugin[1].isAdditionalCompletion;
|
||||
if (mainCompletionUri && (!isAdditional || mainCompletionUri !== document.uri)) {
|
||||
continue;
|
||||
}
|
||||
// avoid duplicate items with .vue and .vue.html
|
||||
if (plugin[1].isAdditionalCompletion && lastResult?.results.some(data => data.plugin === plugin[1])) {
|
||||
continue;
|
||||
}
|
||||
let completionList = await plugin[1].provideCompletionItems(document, position, completionContext, token);
|
||||
if (!completionList || !completionList.items.length) {
|
||||
continue;
|
||||
}
|
||||
if (typeof codeInfo?.completion === 'object' && codeInfo.completion.onlyImport) {
|
||||
completionList.items = completionList.items.filter(item => !!item.labelDetails);
|
||||
}
|
||||
if (!isAdditional) {
|
||||
mainCompletionUri = document.uri;
|
||||
}
|
||||
const pluginIndex = context.plugins.indexOf(plugin);
|
||||
for (const item of completionList.items) {
|
||||
if (plugin[1].resolveCompletionItem) {
|
||||
item.data = {
|
||||
uri: uri.toString(),
|
||||
original: {
|
||||
additionalTextEdits: item.additionalTextEdits,
|
||||
textEdit: item.textEdit,
|
||||
data: item.data,
|
||||
},
|
||||
pluginIndex,
|
||||
embeddedDocumentUri: docs ? document.uri : undefined,
|
||||
};
|
||||
}
|
||||
else {
|
||||
delete item.data;
|
||||
}
|
||||
}
|
||||
if (docs) {
|
||||
completionList = (0, transform_1.transformCompletionList)(completionList, range => (0, featureWorkers_1.getSourceRange)(docs, range, language_core_1.isCompletionEnabled), document, context);
|
||||
}
|
||||
lastResult?.results.push({
|
||||
embeddedDocumentUri: docs ? vscode_uri_1.URI.parse(document.uri) : undefined,
|
||||
plugin: plugin[1],
|
||||
list: completionList,
|
||||
});
|
||||
}
|
||||
isFirstMapping = false;
|
||||
};
|
||||
if (sourceScript?.generated) {
|
||||
for (const docs of (0, featureWorkers_1.forEachEmbeddedDocument)(context, sourceScript, sourceScript.generated.root)) {
|
||||
let _data;
|
||||
for (const mappedPosition of (0, featureWorkers_1.getGeneratedPositions)(docs, position, data => {
|
||||
_data = data;
|
||||
return (0, language_core_1.isCompletionEnabled)(data);
|
||||
})) {
|
||||
await worker(docs[1], mappedPosition, docs, _data);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const document = context.documents.get(uri, langaugeIdAndSnapshot.languageId, langaugeIdAndSnapshot.snapshot);
|
||||
await worker(document, position);
|
||||
}
|
||||
}
|
||||
return combineCompletionList(lastResult.results.map(cacheData => cacheData.list));
|
||||
function sortServices(a, b) {
|
||||
return (b.isAdditionalCompletion ? -1 : 1) - (a.isAdditionalCompletion ? -1 : 1);
|
||||
}
|
||||
function combineCompletionList(lists) {
|
||||
return {
|
||||
isIncomplete: lists.some(list => list?.isIncomplete),
|
||||
itemDefaults: lists.find(list => list?.itemDefaults)?.itemDefaults,
|
||||
items: lists.map(list => list?.items ?? []).flat(),
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideCompletionItems.js.map
|
||||
5
node_modules/@volar/language-service/lib/features/provideDefinition.d.ts
generated
vendored
Normal file
5
node_modules/@volar/language-service/lib/features/provideDefinition.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import type { CodeInformation } from '@volar/language-core';
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext, apiName: 'provideDeclaration' | 'provideDefinition' | 'provideTypeDefinition' | 'provideImplementation', isValidPosition: (data: CodeInformation) => boolean): (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
||||
125
node_modules/@volar/language-service/lib/features/provideDefinition.js
generated
vendored
Normal file
125
node_modules/@volar/language-service/lib/features/provideDefinition.js
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const dedupe = require("../utils/dedupe");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context, apiName, isValidPosition) {
|
||||
return (uri, position, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, docs => (0, featureWorkers_1.getGeneratedPositions)(docs, position, isValidPosition), async (plugin, document, position) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
const recursiveChecker = dedupe.createLocationSet();
|
||||
const result = [];
|
||||
await withLinkedCode(document, position, undefined);
|
||||
return result;
|
||||
async function withLinkedCode(document, position, originDefinition) {
|
||||
const api = plugin[1][apiName];
|
||||
if (!api) {
|
||||
return;
|
||||
}
|
||||
if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } })) {
|
||||
return;
|
||||
}
|
||||
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
||||
const definitions = await api?.(document, position, token) ?? [];
|
||||
for (const definition of definitions) {
|
||||
let foundMirrorPosition = false;
|
||||
recursiveChecker.add({ uri: definition.targetUri, range: { start: definition.targetRange.start, end: definition.targetRange.start } });
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(definition.targetUri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
||||
const linkedCodeMap = virtualCode && sourceScript
|
||||
? context.language.linkedCodeMaps.get(virtualCode)
|
||||
: undefined;
|
||||
if (sourceScript && virtualCode && linkedCodeMap) {
|
||||
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot);
|
||||
for (const linkedPos of (0, featureWorkers_1.getLinkedCodePositions)(embeddedDocument, linkedCodeMap, definition.targetSelectionRange.start)) {
|
||||
if (recursiveChecker.has({ uri: embeddedDocument.uri, range: { start: linkedPos, end: linkedPos } })) {
|
||||
continue;
|
||||
}
|
||||
foundMirrorPosition = true;
|
||||
await withLinkedCode(embeddedDocument, linkedPos, originDefinition ?? definition);
|
||||
}
|
||||
}
|
||||
if (!foundMirrorPosition) {
|
||||
if (originDefinition) {
|
||||
result.push({
|
||||
...definition,
|
||||
originSelectionRange: originDefinition.originSelectionRange,
|
||||
});
|
||||
}
|
||||
else {
|
||||
result.push(definition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, (data, map) => data.map(link => {
|
||||
if (link.originSelectionRange && map) {
|
||||
const originSelectionRange = toSourcePositionPreferSurroundedPosition(map, link.originSelectionRange, position);
|
||||
if (!originSelectionRange) {
|
||||
return;
|
||||
}
|
||||
link.originSelectionRange = originSelectionRange;
|
||||
}
|
||||
let foundTargetSelectionRange = false;
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(link.targetUri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const targetVirtualFile = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
||||
if (sourceScript && targetVirtualFile) {
|
||||
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, targetVirtualFile.id), targetVirtualFile.languageId, targetVirtualFile.snapshot);
|
||||
for (const [targetScript, targetSourceMap] of context.language.maps.forEach(targetVirtualFile)) {
|
||||
const sourceDocument = context.documents.get(targetScript.id, targetScript.languageId, targetScript.snapshot);
|
||||
const docs = [sourceDocument, embeddedDocument, targetSourceMap];
|
||||
const targetSelectionRange = (0, featureWorkers_1.getSourceRange)(docs, link.targetSelectionRange);
|
||||
if (!targetSelectionRange) {
|
||||
continue;
|
||||
}
|
||||
foundTargetSelectionRange = true;
|
||||
let targetRange = (0, featureWorkers_1.getSourceRange)(docs, link.targetRange);
|
||||
link.targetUri = sourceDocument.uri;
|
||||
// loose range mapping to for template slots, slot properties
|
||||
link.targetRange = targetRange ?? targetSelectionRange;
|
||||
link.targetSelectionRange = targetSelectionRange;
|
||||
}
|
||||
if (apiName === 'provideDefinition' && !foundTargetSelectionRange) {
|
||||
for (const [targetScript] of context.language.maps.forEach(targetVirtualFile)) {
|
||||
if (targetScript.id.toString() !== uri.toString()) {
|
||||
return {
|
||||
...link,
|
||||
targetUri: targetScript.id.toString(),
|
||||
targetRange: {
|
||||
start: { line: 0, character: 0 },
|
||||
end: { line: 0, character: 0 },
|
||||
},
|
||||
targetSelectionRange: {
|
||||
start: { line: 0, character: 0 },
|
||||
end: { line: 0, character: 0 },
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
return link;
|
||||
}).filter(link => !!link), arr => dedupe.withLocationLinks(arr.flat()));
|
||||
};
|
||||
}
|
||||
function toSourcePositionPreferSurroundedPosition(docs, mappedRange, position) {
|
||||
let result;
|
||||
for (const range of (0, featureWorkers_1.getSourceRanges)(docs, mappedRange)) {
|
||||
if (!result) {
|
||||
result = range;
|
||||
}
|
||||
if ((range.start.line < position.line || (range.start.line === position.line && range.start.character <= position.character))
|
||||
&& (range.end.line > position.line || (range.end.line === position.line && range.end.character >= position.character))) {
|
||||
return range;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
//# sourceMappingURL=provideDefinition.js.map
|
||||
22
node_modules/@volar/language-service/lib/features/provideDiagnostics.d.ts
generated
vendored
Normal file
22
node_modules/@volar/language-service/lib/features/provideDiagnostics.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
import { DocumentsAndMap } from '../utils/featureWorkers';
|
||||
export interface ServiceDiagnosticData {
|
||||
uri: string;
|
||||
version: number;
|
||||
original: Pick<vscode.Diagnostic, 'data'>;
|
||||
isFormat: boolean;
|
||||
pluginIndex: number;
|
||||
documentUri: string;
|
||||
}
|
||||
export declare const errorMarkups: Map<URI, {
|
||||
error: vscode.Diagnostic;
|
||||
markup: vscode.MarkupContent;
|
||||
}[]>;
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, response?: (result: vscode.Diagnostic[]) => void, token?: vscode.CancellationToken) => Promise<vscode.Diagnostic[]>;
|
||||
export declare function transformDiagnostic(context: LanguageServiceContext, error: vscode.Diagnostic, docs: DocumentsAndMap | undefined): vscode.Diagnostic | undefined;
|
||||
export declare function updateRange(range: vscode.Range, change: {
|
||||
range: vscode.Range;
|
||||
newEnd: vscode.Position;
|
||||
}): vscode.Range | undefined;
|
||||
243
node_modules/@volar/language-service/lib/features/provideDiagnostics.js
generated
vendored
Normal file
243
node_modules/@volar/language-service/lib/features/provideDiagnostics.js
generated
vendored
Normal file
@@ -0,0 +1,243 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.errorMarkups = void 0;
|
||||
exports.register = register;
|
||||
exports.transformDiagnostic = transformDiagnostic;
|
||||
exports.updateRange = updateRange;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const common_1 = require("../utils/common");
|
||||
const dedupe = require("../utils/dedupe");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
const uriMap_1 = require("../utils/uriMap");
|
||||
exports.errorMarkups = (0, uriMap_1.createUriMap)();
|
||||
function register(context) {
|
||||
const lastResponses = (0, uriMap_1.createUriMap)();
|
||||
const cacheMaps = {
|
||||
semantic: new Map(),
|
||||
syntactic: new Map(),
|
||||
};
|
||||
context.env.onDidChangeConfiguration?.(() => {
|
||||
lastResponses.clear();
|
||||
cacheMaps.semantic.clear();
|
||||
cacheMaps.syntactic.clear();
|
||||
});
|
||||
return async (uri, response, token = cancellation_1.NoneCancellationToken) => {
|
||||
let langaugeIdAndSnapshot;
|
||||
const decoded = context.decodeEmbeddedDocumentUri(uri);
|
||||
if (decoded) {
|
||||
langaugeIdAndSnapshot = context.language.scripts.get(decoded[0])?.generated?.embeddedCodes.get(decoded[1]);
|
||||
}
|
||||
else {
|
||||
langaugeIdAndSnapshot = context.language.scripts.get(uri);
|
||||
}
|
||||
if (!langaugeIdAndSnapshot) {
|
||||
return [];
|
||||
}
|
||||
const document = context.documents.get(uri, langaugeIdAndSnapshot.languageId, langaugeIdAndSnapshot.snapshot);
|
||||
const lastResponse = lastResponses.get(uri) ?? lastResponses.set(uri, {
|
||||
semantic: { errors: [] },
|
||||
syntactic: { errors: [] },
|
||||
}).get(uri);
|
||||
let updateCacheRangeFailed = false;
|
||||
let errorsUpdated = false;
|
||||
let lastCheckCancelAt = 0;
|
||||
for (const cache of Object.values(lastResponse)) {
|
||||
const oldSnapshot = cache.snapshot;
|
||||
const oldDocument = cache.document;
|
||||
const change = oldSnapshot ? langaugeIdAndSnapshot.snapshot.getChangeRange(oldSnapshot) : undefined;
|
||||
cache.snapshot = langaugeIdAndSnapshot.snapshot;
|
||||
cache.document = document;
|
||||
if (!updateCacheRangeFailed && oldDocument && change) {
|
||||
const changeRange = {
|
||||
range: {
|
||||
start: oldDocument.positionAt(change.span.start),
|
||||
end: oldDocument.positionAt(change.span.start + change.span.length),
|
||||
},
|
||||
newEnd: document.positionAt(change.span.start + change.newLength),
|
||||
};
|
||||
for (const error of cache.errors) {
|
||||
if (!updateRange(error.range, changeRange)) {
|
||||
updateCacheRangeFailed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
await worker('syntactic', cacheMaps.syntactic, lastResponse.syntactic);
|
||||
processResponse();
|
||||
await worker('semantic', cacheMaps.semantic, lastResponse.semantic);
|
||||
return collectErrors();
|
||||
function processResponse() {
|
||||
if (errorsUpdated && !updateCacheRangeFailed) {
|
||||
response?.(collectErrors());
|
||||
errorsUpdated = false;
|
||||
}
|
||||
}
|
||||
function collectErrors() {
|
||||
return Object.values(lastResponse).flatMap(({ errors }) => errors);
|
||||
}
|
||||
async function worker(kind, cacheMap, cache) {
|
||||
const result = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, docs => docs[2].mappings.some(mapping => (0, language_core_1.isDiagnosticsEnabled)(mapping.data)), async (plugin, document) => {
|
||||
const interFileDependencies = plugin[0].capabilities.diagnosticProvider?.interFileDependencies;
|
||||
if (kind === 'semantic' !== interFileDependencies) {
|
||||
return;
|
||||
}
|
||||
if (Date.now() - lastCheckCancelAt >= 10) {
|
||||
await (0, common_1.sleep)(10); // waiting LSP event polling
|
||||
lastCheckCancelAt = Date.now();
|
||||
}
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
const pluginIndex = context.plugins.indexOf(plugin);
|
||||
const pluginCache = cacheMap.get(pluginIndex) ?? cacheMap.set(pluginIndex, new Map()).get(pluginIndex);
|
||||
const cache = pluginCache.get(document.uri);
|
||||
if (!interFileDependencies && cache && cache.documentVersion === document.version) {
|
||||
return cache.errors;
|
||||
}
|
||||
const errors = await plugin[1].provideDiagnostics?.(document, token) || [];
|
||||
errors.forEach(error => {
|
||||
error.data = {
|
||||
uri: uri.toString(),
|
||||
version: document.version,
|
||||
pluginIndex: pluginIndex,
|
||||
isFormat: false,
|
||||
original: {
|
||||
data: error.data,
|
||||
},
|
||||
documentUri: document.uri,
|
||||
};
|
||||
});
|
||||
errorsUpdated = true;
|
||||
pluginCache.set(document.uri, {
|
||||
documentVersion: document.version,
|
||||
errors,
|
||||
});
|
||||
return errors;
|
||||
}, (errors, map) => {
|
||||
return errors
|
||||
.map(error => transformDiagnostic(context, error, map))
|
||||
.filter(error => !!error);
|
||||
}, arr => dedupe.withDiagnostics(arr.flat()));
|
||||
if (result) {
|
||||
cache.errors = result;
|
||||
cache.snapshot = langaugeIdAndSnapshot?.snapshot;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
function transformDiagnostic(context, error, docs) {
|
||||
// clone it to avoid modify cache
|
||||
let _error = { ...error };
|
||||
if (docs) {
|
||||
const range = (0, featureWorkers_1.getSourceRange)(docs, error.range, data => (0, language_core_1.shouldReportDiagnostics)(data, error.source, error.code));
|
||||
if (!range) {
|
||||
return;
|
||||
}
|
||||
_error.range = range;
|
||||
}
|
||||
if (_error.relatedInformation) {
|
||||
const relatedInfos = [];
|
||||
for (const info of _error.relatedInformation) {
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(info.location.uri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
||||
if (sourceScript && virtualCode) {
|
||||
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot);
|
||||
for (const [sourceScript, map] of context.language.maps.forEach(virtualCode)) {
|
||||
const sourceDocument = context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot);
|
||||
const docs = [sourceDocument, embeddedDocument, map];
|
||||
const range = (0, featureWorkers_1.getSourceRange)(docs, info.location.range, data => (0, language_core_1.shouldReportDiagnostics)(data, undefined, undefined));
|
||||
if (range) {
|
||||
relatedInfos.push({
|
||||
location: {
|
||||
uri: sourceDocument.uri,
|
||||
range,
|
||||
},
|
||||
message: info.message,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
relatedInfos.push(info);
|
||||
}
|
||||
}
|
||||
_error.relatedInformation = relatedInfos;
|
||||
}
|
||||
return _error;
|
||||
}
|
||||
function updateRange(range, change) {
|
||||
if (!updatePosition(range.start, change, false)) {
|
||||
return;
|
||||
}
|
||||
if (!updatePosition(range.end, change, true)) {
|
||||
return;
|
||||
}
|
||||
if (range.end.line === range.start.line && range.end.character <= range.start.character) {
|
||||
range.end.character++;
|
||||
}
|
||||
return range;
|
||||
}
|
||||
function updatePosition(position, change, isEnd) {
|
||||
if (change.range.end.line > position.line) {
|
||||
if (change.newEnd.line > position.line) {
|
||||
// No change
|
||||
return true;
|
||||
}
|
||||
else if (change.newEnd.line === position.line) {
|
||||
position.character = Math.min(position.character, change.newEnd.character);
|
||||
return true;
|
||||
}
|
||||
else if (change.newEnd.line < position.line) {
|
||||
position.line = change.newEnd.line;
|
||||
position.character = change.newEnd.character;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (change.range.end.line === position.line) {
|
||||
const characterDiff = change.newEnd.character - change.range.end.character;
|
||||
if (position.character >= change.range.end.character) {
|
||||
if (change.newEnd.line !== change.range.end.line) {
|
||||
position.line = change.newEnd.line;
|
||||
position.character = change.newEnd.character + position.character - change.range.end.character;
|
||||
}
|
||||
else {
|
||||
if (isEnd ? change.range.end.character < position.character : change.range.end.character <= position.character) {
|
||||
position.character += characterDiff;
|
||||
}
|
||||
else {
|
||||
const offset = change.range.end.character - position.character;
|
||||
if (-characterDiff > offset) {
|
||||
position.character += characterDiff + offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (change.newEnd.line === change.range.end.line) {
|
||||
const offset = change.range.end.character - position.character;
|
||||
if (-characterDiff > offset) {
|
||||
position.character += characterDiff + offset;
|
||||
}
|
||||
}
|
||||
else if (change.newEnd.line < change.range.end.line) {
|
||||
position.line = change.newEnd.line;
|
||||
position.character = change.newEnd.character;
|
||||
}
|
||||
else {
|
||||
// No change
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (change.range.end.line < position.line) {
|
||||
position.line += change.newEnd.line - change.range.end.line;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//# sourceMappingURL=provideDiagnostics.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideDocumentColors.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideDocumentColors.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.ColorInformation[] | undefined>;
|
||||
32
node_modules/@volar/language-service/lib/features/provideDocumentColors.js
generated
vendored
Normal file
32
node_modules/@volar/language-service/lib/features/provideDocumentColors.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context) {
|
||||
return (uri, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, docs => docs[2].mappings.some(mapping => (0, language_core_1.isColorEnabled)(mapping.data)), (plugin, document) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
return plugin[1].provideDocumentColors?.(document, token);
|
||||
}, (data, docs) => {
|
||||
if (!docs) {
|
||||
return data;
|
||||
}
|
||||
return data
|
||||
.map(color => {
|
||||
const range = (0, featureWorkers_1.getSourceRange)(docs, color.range, language_core_1.isColorEnabled);
|
||||
if (range) {
|
||||
return {
|
||||
range,
|
||||
color: color.color,
|
||||
};
|
||||
}
|
||||
})
|
||||
.filter(color => !!color);
|
||||
}, arr => arr.flat());
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideDocumentColors.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideDocumentDropEdits.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideDocumentDropEdits.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { DataTransferItem, LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, dataTransfer: Map<string, DataTransferItem>, token?: vscode.CancellationToken) => Promise<import("../types").DocumentDropEdit | undefined>;
|
||||
26
node_modules/@volar/language-service/lib/features/provideDocumentDropEdits.js
generated
vendored
Normal file
26
node_modules/@volar/language-service/lib/features/provideDocumentDropEdits.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
const transform_1 = require("../utils/transform");
|
||||
function register(context) {
|
||||
return (uri, position, dataTransfer, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, function* (docs) {
|
||||
for (const mappedPosition of (0, featureWorkers_1.getGeneratedPositions)(docs, position)) {
|
||||
yield mappedPosition;
|
||||
}
|
||||
}, (plugin, document, arg) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
return plugin[1].provideDocumentDropEdits?.(document, arg, dataTransfer, token);
|
||||
}, edit => {
|
||||
if (edit.additionalEdit) {
|
||||
edit.additionalEdit = (0, transform_1.transformWorkspaceEdit)(edit.additionalEdit, context, undefined);
|
||||
}
|
||||
return edit;
|
||||
});
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideDocumentDropEdits.js.map
|
||||
7
node_modules/@volar/language-service/lib/features/provideDocumentFormattingEdits.d.ts
generated
vendored
Normal file
7
node_modules/@volar/language-service/lib/features/provideDocumentFormattingEdits.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, options: vscode.FormattingOptions, range: vscode.Range | undefined, onTypeParams: {
|
||||
ch: string;
|
||||
position: vscode.Position;
|
||||
} | undefined, token?: vscode.CancellationToken) => Promise<vscode.TextEdit[] | undefined>;
|
||||
226
node_modules/@volar/language-service/lib/features/provideDocumentFormattingEdits.js
generated
vendored
Normal file
226
node_modules/@volar/language-service/lib/features/provideDocumentFormattingEdits.js
generated
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const common_1 = require("../utils/common");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context) {
|
||||
return async (uri, options, range, onTypeParams, token = cancellation_1.NoneCancellationToken) => {
|
||||
const sourceScript = context.language.scripts.get(uri);
|
||||
if (!sourceScript) {
|
||||
return;
|
||||
}
|
||||
let document = context.documents.get(uri, sourceScript.languageId, sourceScript.snapshot);
|
||||
range ??= {
|
||||
start: document.positionAt(0),
|
||||
end: document.positionAt(document.getText().length),
|
||||
};
|
||||
if (!sourceScript.generated) {
|
||||
return onTypeParams
|
||||
? (await tryFormat(document, document, sourceScript, undefined, 0, onTypeParams.position, onTypeParams.ch))?.edits
|
||||
: (await tryFormat(document, document, sourceScript, undefined, 0, range, undefined))?.edits;
|
||||
}
|
||||
const embeddedRanges = new Map(); // TODO: Formatting of upper-level virtual code may cause offset of lower-level selection range
|
||||
const startOffset = document.offsetAt(range.start);
|
||||
const endOffset = document.offsetAt(range.end);
|
||||
for (const code of (0, language_core_1.forEachEmbeddedCode)(sourceScript.generated.root)) {
|
||||
const map = context.language.maps.get(code, sourceScript);
|
||||
if (map) {
|
||||
const embeddedRange = (0, common_1.findOverlapCodeRange)(startOffset, endOffset, map, language_core_1.isFormattingEnabled);
|
||||
if (embeddedRange) {
|
||||
if (embeddedRange.start === map.mappings[0].generatedOffsets[0]) {
|
||||
embeddedRange.start = 0;
|
||||
}
|
||||
const lastMapping = map.mappings[map.mappings.length - 1];
|
||||
if (embeddedRange.end === lastMapping.generatedOffsets[lastMapping.generatedOffsets.length - 1] + (lastMapping.generatedLengths ?? lastMapping.lengths)[lastMapping.lengths.length - 1]) {
|
||||
embeddedRange.end = code.snapshot.getLength();
|
||||
}
|
||||
embeddedRanges.set(code.id, embeddedRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
const originalDocument = document;
|
||||
let tempSourceSnapshot = sourceScript.snapshot;
|
||||
let tempVirtualFile = context.language.scripts.set(vscode_uri_1.URI.parse(sourceScript.id.toString() + '.tmp'), sourceScript.snapshot, sourceScript.languageId, [sourceScript.generated.languagePlugin])?.generated?.root;
|
||||
if (!tempVirtualFile) {
|
||||
return;
|
||||
}
|
||||
let currentCodes = [];
|
||||
for (let depth = 0; (currentCodes = getNestedEmbeddedFiles(context, sourceScript.id, tempVirtualFile, depth)).length > 0; depth++) {
|
||||
let edits = [];
|
||||
for (const code of currentCodes) {
|
||||
if (!code.mappings.some(mapping => (0, language_core_1.isFormattingEnabled)(mapping.data))) {
|
||||
continue;
|
||||
}
|
||||
const currentRange = embeddedRanges.get(code.id);
|
||||
if (!currentRange) {
|
||||
continue;
|
||||
}
|
||||
const isChildRange = [...(0, language_core_1.forEachEmbeddedCode)(code)].some(child => {
|
||||
if (child === code) {
|
||||
return false;
|
||||
}
|
||||
const childRange = embeddedRanges.get(child.id);
|
||||
return childRange && childRange.end - childRange.start >= currentRange.end - currentRange.start;
|
||||
});
|
||||
if (isChildRange) {
|
||||
continue;
|
||||
}
|
||||
const docs = [
|
||||
context.documents.get(uri, sourceScript.languageId, tempSourceSnapshot),
|
||||
context.documents.get(context.encodeEmbeddedDocumentUri(uri, code.id), code.languageId, code.snapshot),
|
||||
context.language.mapperFactory(code.mappings),
|
||||
];
|
||||
let embeddedResult;
|
||||
if (onTypeParams) {
|
||||
for (const embeddedPosition of (0, featureWorkers_1.getGeneratedPositions)(docs, onTypeParams.position)) {
|
||||
embeddedResult = await tryFormat(docs[0], docs[1], sourceScript, code, depth, embeddedPosition, onTypeParams.ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (currentRange) {
|
||||
embeddedResult = await tryFormat(docs[0], docs[1], sourceScript, code, depth, {
|
||||
start: docs[1].positionAt(currentRange.start),
|
||||
end: docs[1].positionAt(currentRange.end),
|
||||
});
|
||||
}
|
||||
if (!embeddedResult) {
|
||||
continue;
|
||||
}
|
||||
for (const textEdit of embeddedResult.edits) {
|
||||
const range = (0, featureWorkers_1.getSourceRange)(docs, textEdit.range);
|
||||
if (range) {
|
||||
edits.push({
|
||||
newText: textEdit.newText,
|
||||
range,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (edits.length > 0) {
|
||||
const newText = vscode_languageserver_textdocument_1.TextDocument.applyEdits(document, edits);
|
||||
document = vscode_languageserver_textdocument_1.TextDocument.create(document.uri, document.languageId, document.version + 1, newText);
|
||||
tempSourceSnapshot = (0, common_1.stringToSnapshot)(newText);
|
||||
tempVirtualFile = context.language.scripts.set(vscode_uri_1.URI.parse(sourceScript.id.toString() + '.tmp'), tempSourceSnapshot, sourceScript.languageId, [sourceScript.generated.languagePlugin])?.generated?.root;
|
||||
if (!tempVirtualFile) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (document.getText() === originalDocument.getText()) {
|
||||
return;
|
||||
}
|
||||
const editRange = {
|
||||
start: originalDocument.positionAt(0),
|
||||
end: originalDocument.positionAt(originalDocument.getText().length),
|
||||
};
|
||||
const textEdit = {
|
||||
range: editRange,
|
||||
newText: document.getText(),
|
||||
};
|
||||
return [textEdit];
|
||||
}
|
||||
finally {
|
||||
context.language.scripts.delete(vscode_uri_1.URI.parse(sourceScript.id.toString() + '.tmp'));
|
||||
}
|
||||
async function tryFormat(sourceDocument, document, sourceScript, virtualCode, embeddedLevel, rangeOrPosition, ch) {
|
||||
if (context.disabledEmbeddedDocumentUris.get(vscode_uri_1.URI.parse(document.uri))) {
|
||||
return;
|
||||
}
|
||||
let codeOptions;
|
||||
rangeOrPosition ??= {
|
||||
start: document.positionAt(0),
|
||||
end: document.positionAt(document.getText().length),
|
||||
};
|
||||
if (virtualCode) {
|
||||
codeOptions = {
|
||||
level: embeddedLevel,
|
||||
initialIndentLevel: 0,
|
||||
};
|
||||
if (virtualCode.mappings.length) {
|
||||
const firstMapping = virtualCode.mappings[0];
|
||||
const startOffset = firstMapping.sourceOffsets[0];
|
||||
const startPosition = sourceDocument.positionAt(startOffset);
|
||||
codeOptions.initialIndentLevel = computeInitialIndent(sourceDocument.getText(), sourceDocument.offsetAt({ line: startPosition.line, character: 0 }), options);
|
||||
}
|
||||
for (const plugin of context.plugins) {
|
||||
if (context.disabledServicePlugins.has(plugin[1])) {
|
||||
continue;
|
||||
}
|
||||
codeOptions = await plugin[1].resolveEmbeddedCodeFormattingOptions?.(sourceScript, virtualCode, codeOptions, token) ?? codeOptions;
|
||||
}
|
||||
}
|
||||
for (const plugin of context.plugins) {
|
||||
if (context.disabledServicePlugins.has(plugin[1])) {
|
||||
continue;
|
||||
}
|
||||
if (token.isCancellationRequested) {
|
||||
break;
|
||||
}
|
||||
let edits;
|
||||
try {
|
||||
if (ch !== undefined && rangeOrPosition && 'line' in rangeOrPosition && 'character' in rangeOrPosition) {
|
||||
if (plugin[0].capabilities.documentOnTypeFormattingProvider?.triggerCharacters?.includes(ch)) {
|
||||
edits = await plugin[1].provideOnTypeFormattingEdits?.(document, rangeOrPosition, ch, options, codeOptions, token);
|
||||
}
|
||||
}
|
||||
else if (ch === undefined && rangeOrPosition && 'start' in rangeOrPosition && 'end' in rangeOrPosition) {
|
||||
edits = await plugin[1].provideDocumentFormattingEdits?.(document, rangeOrPosition, options, codeOptions, token);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.warn(err);
|
||||
}
|
||||
if (!edits) {
|
||||
continue;
|
||||
}
|
||||
return {
|
||||
plugin,
|
||||
edits,
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
function getNestedEmbeddedFiles(context, uri, rootCode, depth) {
|
||||
const nestedCodesByLevel = [[rootCode]];
|
||||
while (true) {
|
||||
if (nestedCodesByLevel.length > depth) {
|
||||
return nestedCodesByLevel[depth];
|
||||
}
|
||||
const nestedCodes = [];
|
||||
for (const code of nestedCodesByLevel[nestedCodesByLevel.length - 1]) {
|
||||
if (code.embeddedCodes) {
|
||||
for (const embedded of code.embeddedCodes) {
|
||||
if (!context.disabledEmbeddedDocumentUris.get(context.encodeEmbeddedDocumentUri(uri, embedded.id))) {
|
||||
nestedCodes.push(embedded);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
nestedCodesByLevel.push(nestedCodes);
|
||||
}
|
||||
}
|
||||
function computeInitialIndent(content, i, options) {
|
||||
let nChars = 0;
|
||||
const tabSize = options.tabSize || 4;
|
||||
while (i < content.length) {
|
||||
const ch = content.charAt(i);
|
||||
if (ch === ' ') {
|
||||
nChars++;
|
||||
}
|
||||
else if (ch === '\t') {
|
||||
nChars += tabSize;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return Math.floor(nChars / tabSize);
|
||||
}
|
||||
//# sourceMappingURL=provideDocumentFormattingEdits.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideDocumentHighlights.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideDocumentHighlights.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
|
||||
68
node_modules/@volar/language-service/lib/features/provideDocumentHighlights.js
generated
vendored
Normal file
68
node_modules/@volar/language-service/lib/features/provideDocumentHighlights.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const dedupe = require("../utils/dedupe");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context) {
|
||||
return (uri, position, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, docs => (0, featureWorkers_1.getGeneratedPositions)(docs, position, language_core_1.isHighlightEnabled), async (plugin, document, position) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
const recursiveChecker = dedupe.createLocationSet();
|
||||
const result = [];
|
||||
await withLinkedCode(document, position);
|
||||
return result;
|
||||
async function withLinkedCode(document, position) {
|
||||
if (!plugin[1].provideDocumentHighlights) {
|
||||
return;
|
||||
}
|
||||
if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } })) {
|
||||
return;
|
||||
}
|
||||
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
||||
const references = await plugin[1].provideDocumentHighlights(document, position, token) ?? [];
|
||||
for (const reference of references) {
|
||||
let foundMirrorPosition = false;
|
||||
recursiveChecker.add({ uri: document.uri, range: { start: reference.range.start, end: reference.range.start } });
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(document.uri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
||||
const linkedCodeMap = virtualCode && sourceScript
|
||||
? context.language.linkedCodeMaps.get(virtualCode)
|
||||
: undefined;
|
||||
if (sourceScript && virtualCode && linkedCodeMap) {
|
||||
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot);
|
||||
for (const linkedPos of (0, featureWorkers_1.getLinkedCodePositions)(embeddedDocument, linkedCodeMap, reference.range.start)) {
|
||||
if (recursiveChecker.has({ uri: embeddedDocument.uri, range: { start: linkedPos, end: linkedPos } })) {
|
||||
continue;
|
||||
}
|
||||
foundMirrorPosition = true;
|
||||
await withLinkedCode(embeddedDocument, linkedPos);
|
||||
}
|
||||
}
|
||||
if (!foundMirrorPosition) {
|
||||
result.push(reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, (data, docs) => data
|
||||
.map(highlight => {
|
||||
if (!docs) {
|
||||
return highlight;
|
||||
}
|
||||
const range = (0, featureWorkers_1.getSourceRange)(docs, highlight.range, language_core_1.isHighlightEnabled);
|
||||
if (range) {
|
||||
return {
|
||||
...highlight,
|
||||
range,
|
||||
};
|
||||
}
|
||||
})
|
||||
.filter(highlight => !!highlight), arr => arr.flat());
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideDocumentHighlights.js.map
|
||||
9
node_modules/@volar/language-service/lib/features/provideDocumentLinks.d.ts
generated
vendored
Normal file
9
node_modules/@volar/language-service/lib/features/provideDocumentLinks.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export interface DocumentLinkData {
|
||||
uri: string;
|
||||
original: Pick<vscode.DocumentLink, 'data'>;
|
||||
pluginIndex: number;
|
||||
}
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
|
||||
53
node_modules/@volar/language-service/lib/features/provideDocumentLinks.js
generated
vendored
Normal file
53
node_modules/@volar/language-service/lib/features/provideDocumentLinks.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
const transform_1 = require("../utils/transform");
|
||||
function register(context) {
|
||||
return async (uri, token = cancellation_1.NoneCancellationToken) => {
|
||||
return await (0, featureWorkers_1.documentFeatureWorker)(context, uri, docs => docs[2].mappings.some(mapping => (0, language_core_1.isDocumentLinkEnabled)(mapping.data)), async (plugin, document) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
const links = await plugin[1].provideDocumentLinks?.(document, token);
|
||||
for (const link of links ?? []) {
|
||||
if (plugin[1].resolveDocumentLink) {
|
||||
link.data = {
|
||||
uri: uri.toString(),
|
||||
original: {
|
||||
data: link.data,
|
||||
},
|
||||
pluginIndex: context.plugins.indexOf(plugin),
|
||||
};
|
||||
}
|
||||
else {
|
||||
delete link.data;
|
||||
}
|
||||
}
|
||||
return links;
|
||||
}, (links, docs) => {
|
||||
if (!docs) {
|
||||
return links;
|
||||
}
|
||||
return links
|
||||
.map(link => {
|
||||
const range = (0, featureWorkers_1.getSourceRange)(docs, link.range, language_core_1.isDocumentLinkEnabled);
|
||||
if (!range) {
|
||||
return;
|
||||
}
|
||||
link = {
|
||||
...link,
|
||||
range,
|
||||
};
|
||||
if (link.target) {
|
||||
link.target = (0, transform_1.transformDocumentLinkTarget)(link.target, context).toString();
|
||||
}
|
||||
return link;
|
||||
})
|
||||
.filter(link => !!link);
|
||||
}, arr => arr.flat()) ?? [];
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideDocumentLinks.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideDocumentSemanticTokens.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideDocumentSemanticTokens.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, _reportProgress?: (tokens: vscode.SemanticTokens) => void, token?: vscode.CancellationToken) => Promise<vscode.SemanticTokens | undefined>;
|
||||
67
node_modules/@volar/language-service/lib/features/provideDocumentSemanticTokens.js
generated
vendored
Normal file
67
node_modules/@volar/language-service/lib/features/provideDocumentSemanticTokens.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const SemanticTokensBuilder_1 = require("../utils/SemanticTokensBuilder");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const common_1 = require("../utils/common");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context) {
|
||||
return async (uri, range, legend, _reportProgress, // TODO
|
||||
token = cancellation_1.NoneCancellationToken) => {
|
||||
const sourceScript = context.language.scripts.get(uri);
|
||||
if (!sourceScript) {
|
||||
return;
|
||||
}
|
||||
const document = context.documents.get(uri, sourceScript.languageId, sourceScript.snapshot);
|
||||
if (!range) {
|
||||
range = {
|
||||
start: { line: 0, character: 0 },
|
||||
end: { line: document.lineCount - 1, character: document.getText().length },
|
||||
};
|
||||
}
|
||||
const tokens = await (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => range, function* (docs) {
|
||||
const mapped = (0, common_1.findOverlapCodeRange)(docs[0].offsetAt(range.start), docs[0].offsetAt(range.end), docs[2], language_core_1.isSemanticTokensEnabled);
|
||||
if (mapped) {
|
||||
yield {
|
||||
start: docs[1].positionAt(mapped.start),
|
||||
end: docs[1].positionAt(mapped.end),
|
||||
};
|
||||
}
|
||||
}, (plugin, document, range) => {
|
||||
if (token?.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
return plugin[1].provideDocumentSemanticTokens?.(document, range, legend, token);
|
||||
}, (tokens, docs) => {
|
||||
if (!docs) {
|
||||
return tokens;
|
||||
}
|
||||
return tokens
|
||||
.map(_token => {
|
||||
const range = (0, featureWorkers_1.getSourceRange)(docs, {
|
||||
start: { line: _token[0], character: _token[1] },
|
||||
end: { line: _token[0], character: _token[1] + _token[2] },
|
||||
}, language_core_1.isSemanticTokensEnabled);
|
||||
if (range) {
|
||||
return [range.start.line, range.start.character, range.end.character - range.start.character, _token[3], _token[4]];
|
||||
}
|
||||
})
|
||||
.filter(token => !!token);
|
||||
}, tokens => tokens.flat()
|
||||
// tokens => reportProgress?.(buildTokens(tokens)), // TODO: this has no effect with LSP
|
||||
);
|
||||
if (tokens) {
|
||||
return buildTokens(tokens);
|
||||
}
|
||||
};
|
||||
}
|
||||
function buildTokens(tokens) {
|
||||
const builder = new SemanticTokensBuilder_1.SemanticTokensBuilder();
|
||||
const sortedTokens = tokens.sort((a, b) => a[0] - b[0] === 0 ? a[1] - b[1] : a[0] - b[0]);
|
||||
for (const token of sortedTokens) {
|
||||
builder.push(...token);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
//# sourceMappingURL=provideDocumentSemanticTokens.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideDocumentSymbols.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideDocumentSymbols.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.DocumentSymbol[] | undefined>;
|
||||
53
node_modules/@volar/language-service/lib/features/provideDocumentSymbols.js
generated
vendored
Normal file
53
node_modules/@volar/language-service/lib/features/provideDocumentSymbols.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const common_1 = require("../utils/common");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
const transform_1 = require("../utils/transform");
|
||||
function register(context) {
|
||||
return (uri, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, docs => docs[2].mappings.some(mapping => (0, language_core_1.isSymbolsEnabled)(mapping.data)), (plugin, document) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
return plugin[1].provideDocumentSymbols?.(document, token);
|
||||
}, (data, docs) => {
|
||||
if (!docs) {
|
||||
return data;
|
||||
}
|
||||
return data
|
||||
.map(symbol => (0, transform_1.transformDocumentSymbol)(symbol, range => (0, featureWorkers_1.getSourceRange)(docs, range, language_core_1.isSymbolsEnabled)))
|
||||
.filter(symbol => !!symbol);
|
||||
}, results => {
|
||||
for (let i = 0; i < results.length; i++) {
|
||||
for (let j = 0; j < results.length; j++) {
|
||||
if (i === j) {
|
||||
continue;
|
||||
}
|
||||
results[i] = results[i].filter(child => {
|
||||
for (const parent of forEachSymbol(results[j])) {
|
||||
if ((0, common_1.isInsideRange)(parent.range, child.range)) {
|
||||
parent.children ??= [];
|
||||
parent.children.push(child);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
return results.flat();
|
||||
});
|
||||
};
|
||||
}
|
||||
function* forEachSymbol(symbols) {
|
||||
for (const symbol of symbols) {
|
||||
if (symbol.children) {
|
||||
yield* forEachSymbol(symbol.children);
|
||||
}
|
||||
yield symbol;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=provideDocumentSymbols.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideFileReferences.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideFileReferences.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext, NullableProviderResult } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => NullableProviderResult<vscode.Location[]>;
|
||||
39
node_modules/@volar/language-service/lib/features/provideFileReferences.js
generated
vendored
Normal file
39
node_modules/@volar/language-service/lib/features/provideFileReferences.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const dedupe = require("../utils/dedupe");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context) {
|
||||
return (uri, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, () => true, async (plugin, document) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
return await plugin[1].provideFileReferences?.(document, token) ?? [];
|
||||
}, data => data
|
||||
.map(reference => {
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(reference.uri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
||||
if (!sourceScript || !virtualCode) {
|
||||
return reference;
|
||||
}
|
||||
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot);
|
||||
for (const [sourceScript, map] of context.language.maps.forEach(virtualCode)) {
|
||||
const sourceDocument = context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot);
|
||||
const docs = [sourceDocument, embeddedDocument, map];
|
||||
const range = (0, featureWorkers_1.getSourceRange)(docs, reference.range, language_core_1.isReferencesEnabled);
|
||||
if (range) {
|
||||
reference.uri = sourceDocument.uri;
|
||||
reference.range = range;
|
||||
return reference;
|
||||
}
|
||||
}
|
||||
})
|
||||
.filter(reference => !!reference), arr => dedupe.withLocations(arr.flat()));
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideFileReferences.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideFileRenameEdits.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideFileRenameEdits.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
import type * as _ from 'vscode-languageserver-protocol';
|
||||
export declare function register(context: LanguageServiceContext): (oldUri: URI, newUri: URI, token?: _.CancellationToken) => Promise<_.WorkspaceEdit | undefined>;
|
||||
30
node_modules/@volar/language-service/lib/features/provideFileRenameEdits.js
generated
vendored
Normal file
30
node_modules/@volar/language-service/lib/features/provideFileRenameEdits.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const dedupe = require("../utils/dedupe");
|
||||
const transform_1 = require("../utils/transform");
|
||||
function register(context) {
|
||||
return async (oldUri, newUri, token = cancellation_1.NoneCancellationToken) => {
|
||||
for (const plugin of context.plugins) {
|
||||
if (context.disabledServicePlugins.has(plugin[1])) {
|
||||
continue;
|
||||
}
|
||||
if (token.isCancellationRequested) {
|
||||
break;
|
||||
}
|
||||
if (!plugin[1].provideFileRenameEdits) {
|
||||
continue;
|
||||
}
|
||||
const workspaceEdit = await plugin[1].provideFileRenameEdits(oldUri, newUri, token);
|
||||
if (workspaceEdit) {
|
||||
const result = (0, transform_1.transformWorkspaceEdit)(workspaceEdit, context, 'fileName');
|
||||
if (result?.documentChanges) {
|
||||
result.documentChanges = dedupe.withDocumentChanges(result.documentChanges);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideFileRenameEdits.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideFoldingRanges.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideFoldingRanges.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
import type * as _ from 'vscode-languageserver-protocol';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, token?: _.CancellationToken) => Promise<_.FoldingRange[] | undefined>;
|
||||
23
node_modules/@volar/language-service/lib/features/provideFoldingRanges.js
generated
vendored
Normal file
23
node_modules/@volar/language-service/lib/features/provideFoldingRanges.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
const transform_1 = require("../utils/transform");
|
||||
function register(context) {
|
||||
return (uri, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, docs => docs[2].mappings.some(mapping => (0, language_core_1.isFoldingRangesEnabled)(mapping.data)), (plugin, document) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
return plugin[1].provideFoldingRanges?.(document, token);
|
||||
}, (data, docs) => {
|
||||
if (!docs) {
|
||||
return data;
|
||||
}
|
||||
return (0, transform_1.transformFoldingRanges)(data, range => (0, featureWorkers_1.getSourceRange)(docs, range, language_core_1.isFoldingRangesEnabled));
|
||||
}, arr => arr.flat());
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideFoldingRanges.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideHover.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideHover.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Hover | undefined>;
|
||||
89
node_modules/@volar/language-service/lib/features/provideHover.js
generated
vendored
Normal file
89
node_modules/@volar/language-service/lib/features/provideHover.js
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const common_1 = require("../utils/common");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
const transform_1 = require("../utils/transform");
|
||||
const provideDiagnostics_1 = require("./provideDiagnostics");
|
||||
function register(context) {
|
||||
return async (uri, position, token = cancellation_1.NoneCancellationToken) => {
|
||||
let hover = await (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, docs => (0, featureWorkers_1.getGeneratedPositions)(docs, position, language_core_1.isHoverEnabled), (plugin, document, position) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
return plugin[1].provideHover?.(document, position, token);
|
||||
}, (item, docs) => {
|
||||
if (!docs || !item.range) {
|
||||
return item;
|
||||
}
|
||||
item.range = (0, featureWorkers_1.getSourceRange)(docs, item.range, language_core_1.isHoverEnabled);
|
||||
return item;
|
||||
}, (hovers) => ({
|
||||
contents: {
|
||||
kind: 'markdown',
|
||||
value: hovers.map(getHoverTexts).flat().join('\n\n---\n\n'),
|
||||
},
|
||||
range: hovers.find(hover => hover.range && (0, common_1.isInsideRange)(hover.range, { start: position, end: position }))?.range ?? hovers[0].range,
|
||||
}));
|
||||
const markups = provideDiagnostics_1.errorMarkups.get(uri);
|
||||
if (markups) {
|
||||
for (const errorAndMarkup of markups) {
|
||||
if ((0, common_1.isInsideRange)(errorAndMarkup.error.range, { start: position, end: position })) {
|
||||
hover ??= {
|
||||
contents: {
|
||||
kind: 'markdown',
|
||||
value: '',
|
||||
},
|
||||
};
|
||||
hover.range = errorAndMarkup.error.range;
|
||||
if (typeof hover.contents !== 'object' || typeof hover.contents !== 'string') {
|
||||
hover.contents = {
|
||||
kind: 'markdown',
|
||||
value: hover.contents,
|
||||
};
|
||||
}
|
||||
if (hover.contents.value) {
|
||||
hover.contents.value += '\n\n---\n\n';
|
||||
}
|
||||
hover.contents.value += errorAndMarkup.markup.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return hover;
|
||||
};
|
||||
function getHoverTexts(hover) {
|
||||
if (typeof hover.contents === 'string') {
|
||||
return [(0, transform_1.transformMarkdown)(hover.contents, context)];
|
||||
}
|
||||
if (Array.isArray(hover.contents)) {
|
||||
return hover.contents.map(content => {
|
||||
if (typeof content === 'string') {
|
||||
return (0, transform_1.transformMarkdown)(content, context);
|
||||
}
|
||||
if (content.language === 'md') {
|
||||
return `\`\`\`${content.language}\n${(0, transform_1.transformMarkdown)(content.value, context)}\n\`\`\``;
|
||||
}
|
||||
else {
|
||||
return `\`\`\`${content.language}\n${content.value}\n\`\`\``;
|
||||
}
|
||||
});
|
||||
}
|
||||
if ('kind' in hover.contents) {
|
||||
if (hover.contents.kind === 'markdown') {
|
||||
return [(0, transform_1.transformMarkdown)(hover.contents.value, context)];
|
||||
}
|
||||
else {
|
||||
return [hover.contents.value];
|
||||
}
|
||||
}
|
||||
if (hover.contents.language === 'md') {
|
||||
return [`\`\`\`${hover.contents.language}\n${(0, transform_1.transformMarkdown)(hover.contents.value, context)}\n\`\`\``];
|
||||
}
|
||||
else {
|
||||
return [`\`\`\`${hover.contents.language}\n${hover.contents.value}\n\`\`\``];
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=provideHover.js.map
|
||||
9
node_modules/@volar/language-service/lib/features/provideInlayHints.d.ts
generated
vendored
Normal file
9
node_modules/@volar/language-service/lib/features/provideInlayHints.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export interface InlayHintData {
|
||||
uri: string;
|
||||
original: Pick<vscode.CodeAction, 'data' | 'edit'>;
|
||||
pluginIndex: number;
|
||||
}
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
|
||||
64
node_modules/@volar/language-service/lib/features/provideInlayHints.js
generated
vendored
Normal file
64
node_modules/@volar/language-service/lib/features/provideInlayHints.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const common_1 = require("../utils/common");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
const transform_1 = require("../utils/transform");
|
||||
function register(context) {
|
||||
return async (uri, range, token = cancellation_1.NoneCancellationToken) => {
|
||||
const sourceScript = context.language.scripts.get(uri);
|
||||
if (!sourceScript) {
|
||||
return;
|
||||
}
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => range, function* (docs) {
|
||||
const mapped = (0, common_1.findOverlapCodeRange)(docs[0].offsetAt(range.start), docs[0].offsetAt(range.end), docs[2], language_core_1.isInlayHintsEnabled);
|
||||
if (mapped) {
|
||||
yield {
|
||||
start: docs[1].positionAt(mapped.start),
|
||||
end: docs[1].positionAt(mapped.end),
|
||||
};
|
||||
}
|
||||
}, async (plugin, document, arg) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
const hints = await plugin[1].provideInlayHints?.(document, arg, token);
|
||||
hints?.forEach(link => {
|
||||
if (plugin[1].resolveInlayHint) {
|
||||
link.data = {
|
||||
uri: uri.toString(),
|
||||
original: {
|
||||
data: link.data,
|
||||
},
|
||||
pluginIndex: context.plugins.indexOf(plugin),
|
||||
};
|
||||
}
|
||||
else {
|
||||
delete link.data;
|
||||
}
|
||||
});
|
||||
return hints;
|
||||
}, (inlayHints, docs) => {
|
||||
if (!docs) {
|
||||
return inlayHints;
|
||||
}
|
||||
return inlayHints
|
||||
.map((_inlayHint) => {
|
||||
const edits = _inlayHint.textEdits
|
||||
?.map(textEdit => (0, transform_1.transformTextEdit)(textEdit, range => (0, featureWorkers_1.getSourceRange)(docs, range), docs[1]))
|
||||
.filter(textEdit => !!textEdit);
|
||||
for (const position of (0, featureWorkers_1.getSourcePositions)(docs, _inlayHint.position, language_core_1.isInlayHintsEnabled)) {
|
||||
return {
|
||||
..._inlayHint,
|
||||
position,
|
||||
textEdits: edits,
|
||||
};
|
||||
}
|
||||
})
|
||||
.filter(hint => !!hint);
|
||||
}, arr => arr.flat());
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideInlayHints.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideInlineValue.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideInlineValue.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, range: vscode.Range, ivContext: vscode.InlineValueContext, token?: vscode.CancellationToken) => Promise<vscode.InlineValue[] | undefined>;
|
||||
30
node_modules/@volar/language-service/lib/features/provideInlineValue.js
generated
vendored
Normal file
30
node_modules/@volar/language-service/lib/features/provideInlineValue.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context) {
|
||||
return (uri, range, ivContext, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => range, docs => (0, featureWorkers_1.getGeneratedRanges)(docs, range, language_core_1.isInlineValueEnabled), (plugin, document, range) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
return plugin[1].provideInlineValues?.(document, range, ivContext, token);
|
||||
}, (items, docs) => {
|
||||
if (!docs) {
|
||||
return items;
|
||||
}
|
||||
return items
|
||||
.map(item => {
|
||||
const mappedRange = (0, featureWorkers_1.getSourceRange)(docs, item.range, language_core_1.isInlineValueEnabled);
|
||||
if (mappedRange) {
|
||||
item.range = mappedRange;
|
||||
return item;
|
||||
}
|
||||
})
|
||||
.filter(item => !!item);
|
||||
}, results => results.flat());
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideInlineValue.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideLinkedEditingRanges.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideLinkedEditingRanges.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LinkedEditingRanges | undefined>;
|
||||
31
node_modules/@volar/language-service/lib/features/provideLinkedEditingRanges.js
generated
vendored
Normal file
31
node_modules/@volar/language-service/lib/features/provideLinkedEditingRanges.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context) {
|
||||
return (uri, position, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, function* (docs) {
|
||||
for (const pos of (0, featureWorkers_1.getGeneratedPositions)(docs, position, language_core_1.isLinkedEditingEnabled)) {
|
||||
yield pos;
|
||||
}
|
||||
}, (plugin, document, position) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
return plugin[1].provideLinkedEditingRanges?.(document, position, token);
|
||||
}, (ranges, docs) => {
|
||||
if (!docs) {
|
||||
return ranges;
|
||||
}
|
||||
return {
|
||||
wordPattern: ranges.wordPattern,
|
||||
ranges: ranges.ranges
|
||||
.map(range => (0, featureWorkers_1.getSourceRange)(docs, range, language_core_1.isLinkedEditingEnabled))
|
||||
.filter(range => !!range),
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideLinkedEditingRanges.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideMoniker.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideMoniker.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Moniker[] | undefined>;
|
||||
17
node_modules/@volar/language-service/lib/features/provideMoniker.js
generated
vendored
Normal file
17
node_modules/@volar/language-service/lib/features/provideMoniker.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context) {
|
||||
return (uri, position, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, docs => (0, featureWorkers_1.getGeneratedPositions)(docs, position, language_core_1.isMonikerEnabled), (plugin, document, position) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
return plugin[1].provideMoniker?.(document, position, token);
|
||||
}, result => result, results => results.flat());
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideMoniker.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideReferences.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideReferences.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, referenceContext: vscode.ReferenceContext, token?: vscode.CancellationToken) => Promise<vscode.Location[] | undefined>;
|
||||
80
node_modules/@volar/language-service/lib/features/provideReferences.js
generated
vendored
Normal file
80
node_modules/@volar/language-service/lib/features/provideReferences.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const dedupe = require("../utils/dedupe");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context) {
|
||||
return (uri, position, referenceContext, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, docs => (0, featureWorkers_1.getGeneratedPositions)(docs, position, language_core_1.isReferencesEnabled), async (plugin, document, position) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
const recursiveChecker = dedupe.createLocationSet();
|
||||
const result = [];
|
||||
await withLinkedCode(document, position);
|
||||
return result;
|
||||
async function withLinkedCode(document, position) {
|
||||
if (!plugin[1].provideReferences) {
|
||||
return;
|
||||
}
|
||||
if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } })) {
|
||||
return;
|
||||
}
|
||||
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
||||
const references = await plugin[1].provideReferences(document, position, referenceContext, token) ?? [];
|
||||
for (const reference of references) {
|
||||
let foundMirrorPosition = false;
|
||||
recursiveChecker.add({ uri: reference.uri, range: { start: reference.range.start, end: reference.range.start } });
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(reference.uri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
||||
const linkedCodeMap = virtualCode && sourceScript
|
||||
? context.language.linkedCodeMaps.get(virtualCode)
|
||||
: undefined;
|
||||
if (sourceScript && virtualCode && linkedCodeMap) {
|
||||
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot);
|
||||
for (const linkedPos of (0, featureWorkers_1.getLinkedCodePositions)(embeddedDocument, linkedCodeMap, reference.range.start)) {
|
||||
if (recursiveChecker.has({ uri: embeddedDocument.uri, range: { start: linkedPos, end: linkedPos } })) {
|
||||
continue;
|
||||
}
|
||||
foundMirrorPosition = true;
|
||||
await withLinkedCode(embeddedDocument, linkedPos);
|
||||
}
|
||||
}
|
||||
if (!foundMirrorPosition) {
|
||||
result.push(reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, data => {
|
||||
const results = [];
|
||||
for (const reference of data) {
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(reference.uri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
||||
if (sourceScript && virtualCode) {
|
||||
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot);
|
||||
for (const [sourceScript, map] of context.language.maps.forEach(virtualCode)) {
|
||||
const sourceDocument = context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot);
|
||||
const docs = [sourceDocument, embeddedDocument, map];
|
||||
const range = (0, featureWorkers_1.getSourceRange)(docs, reference.range, language_core_1.isReferencesEnabled);
|
||||
if (range) {
|
||||
results.push({
|
||||
uri: sourceDocument.uri,
|
||||
range,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
results.push(reference);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}, arr => dedupe.withLocations(arr.flat()));
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideReferences.js.map
|
||||
5
node_modules/@volar/language-service/lib/features/provideRenameEdits.d.ts
generated
vendored
Normal file
5
node_modules/@volar/language-service/lib/features/provideRenameEdits.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, newName: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceEdit | undefined>;
|
||||
export declare function mergeWorkspaceEdits(original: vscode.WorkspaceEdit, ...others: vscode.WorkspaceEdit[]): void;
|
||||
140
node_modules/@volar/language-service/lib/features/provideRenameEdits.js
generated
vendored
Normal file
140
node_modules/@volar/language-service/lib/features/provideRenameEdits.js
generated
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
exports.mergeWorkspaceEdits = mergeWorkspaceEdits;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const dedupe = require("../utils/dedupe");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
const transform_1 = require("../utils/transform");
|
||||
function register(context) {
|
||||
return (uri, position, newName, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => ({ position, newName }), function* (docs) {
|
||||
let _data;
|
||||
for (const mappedPosition of (0, featureWorkers_1.getGeneratedPositions)(docs, position, data => {
|
||||
_data = data;
|
||||
return (0, language_core_1.isRenameEnabled)(data);
|
||||
})) {
|
||||
yield {
|
||||
position: mappedPosition,
|
||||
newName: (0, language_core_1.resolveRenameNewName)(newName, _data),
|
||||
};
|
||||
}
|
||||
;
|
||||
}, async (plugin, document, params) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
const recursiveChecker = dedupe.createLocationSet();
|
||||
let result;
|
||||
await withLinkedCode(document, params.position, params.newName);
|
||||
return result;
|
||||
async function withLinkedCode(document, position, newName) {
|
||||
if (!plugin[1].provideRenameEdits) {
|
||||
return;
|
||||
}
|
||||
if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } })) {
|
||||
return;
|
||||
}
|
||||
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
||||
const workspaceEdit = await plugin[1].provideRenameEdits(document, position, newName, token);
|
||||
if (!workspaceEdit) {
|
||||
return;
|
||||
}
|
||||
if (!result) {
|
||||
result = {};
|
||||
}
|
||||
if (workspaceEdit.changes) {
|
||||
for (const editUri in workspaceEdit.changes) {
|
||||
const textEdits = workspaceEdit.changes[editUri];
|
||||
for (const textEdit of textEdits) {
|
||||
let foundMirrorPosition = false;
|
||||
recursiveChecker.add({ uri: editUri, range: { start: textEdit.range.start, end: textEdit.range.start } });
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(editUri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
||||
const linkedCodeMap = virtualCode && sourceScript
|
||||
? context.language.linkedCodeMaps.get(virtualCode)
|
||||
: undefined;
|
||||
if (sourceScript && virtualCode && linkedCodeMap) {
|
||||
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot);
|
||||
for (const linkedPos of (0, featureWorkers_1.getLinkedCodePositions)(embeddedDocument, linkedCodeMap, textEdit.range.start)) {
|
||||
if (recursiveChecker.has({ uri: embeddedDocument.uri, range: { start: linkedPos, end: linkedPos } })) {
|
||||
continue;
|
||||
}
|
||||
foundMirrorPosition = true;
|
||||
await withLinkedCode(embeddedDocument, linkedPos, newName);
|
||||
}
|
||||
}
|
||||
if (!foundMirrorPosition) {
|
||||
if (!result.changes) {
|
||||
result.changes = {};
|
||||
}
|
||||
if (!result.changes[editUri]) {
|
||||
result.changes[editUri] = [];
|
||||
}
|
||||
result.changes[editUri].push(textEdit);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (workspaceEdit.changeAnnotations) {
|
||||
for (const uri in workspaceEdit.changeAnnotations) {
|
||||
if (!result.changeAnnotations) {
|
||||
result.changeAnnotations = {};
|
||||
}
|
||||
result.changeAnnotations[uri] = workspaceEdit.changeAnnotations[uri];
|
||||
}
|
||||
}
|
||||
if (workspaceEdit.documentChanges) {
|
||||
if (!result.documentChanges) {
|
||||
result.documentChanges = [];
|
||||
}
|
||||
result.documentChanges = result.documentChanges.concat(workspaceEdit.documentChanges);
|
||||
}
|
||||
}
|
||||
}, data => {
|
||||
return (0, transform_1.transformWorkspaceEdit)(data, context, 'rename');
|
||||
}, workspaceEdits => {
|
||||
const mainEdit = workspaceEdits[0];
|
||||
const otherEdits = workspaceEdits.slice(1);
|
||||
mergeWorkspaceEdits(mainEdit, ...otherEdits);
|
||||
if (mainEdit.changes) {
|
||||
for (const uri in mainEdit.changes) {
|
||||
mainEdit.changes[uri] = dedupe.withTextEdits(mainEdit.changes[uri]);
|
||||
}
|
||||
}
|
||||
return workspaceEdits[0];
|
||||
});
|
||||
};
|
||||
}
|
||||
function mergeWorkspaceEdits(original, ...others) {
|
||||
for (const other of others) {
|
||||
for (const uri in other.changeAnnotations) {
|
||||
if (!original.changeAnnotations) {
|
||||
original.changeAnnotations = {};
|
||||
}
|
||||
original.changeAnnotations[uri] = other.changeAnnotations[uri];
|
||||
}
|
||||
for (const uri in other.changes) {
|
||||
if (!original.changes) {
|
||||
original.changes = {};
|
||||
}
|
||||
if (!original.changes[uri]) {
|
||||
original.changes[uri] = [];
|
||||
}
|
||||
const edits = other.changes[uri];
|
||||
original.changes[uri] = original.changes[uri].concat(edits);
|
||||
}
|
||||
if (other.documentChanges) {
|
||||
if (!original.documentChanges) {
|
||||
original.documentChanges = [];
|
||||
}
|
||||
for (const docChange of other.documentChanges) {
|
||||
(0, transform_1.pushEditToDocumentChanges)(original.documentChanges, docChange);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=provideRenameEdits.js.map
|
||||
9
node_modules/@volar/language-service/lib/features/provideRenameRange.d.ts
generated
vendored
Normal file
9
node_modules/@volar/language-service/lib/features/provideRenameRange.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Range | {
|
||||
range: vscode.Range;
|
||||
placeholder: string;
|
||||
} | {
|
||||
message: string;
|
||||
} | undefined>;
|
||||
32
node_modules/@volar/language-service/lib/features/provideRenameRange.js
generated
vendored
Normal file
32
node_modules/@volar/language-service/lib/features/provideRenameRange.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context) {
|
||||
return (uri, position, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, docs => (0, featureWorkers_1.getGeneratedPositions)(docs, position, language_core_1.isRenameEnabled), (plugin, document, position) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
return plugin[1].provideRenameRange?.(document, position, token);
|
||||
}, (item, docs) => {
|
||||
if (!docs) {
|
||||
return item;
|
||||
}
|
||||
if ('start' in item && 'end' in item) {
|
||||
return (0, featureWorkers_1.getSourceRange)(docs, item);
|
||||
}
|
||||
return item;
|
||||
}, prepares => {
|
||||
for (const prepare of prepares) {
|
||||
if ('start' in prepare && 'end' in prepare) {
|
||||
return prepare; // if has any valid range, ignore other errors
|
||||
}
|
||||
}
|
||||
return prepares[0];
|
||||
});
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideRenameRange.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideSelectionRanges.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideSelectionRanges.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, positions: vscode.Position[], token?: vscode.CancellationToken) => Promise<vscode.SelectionRange[] | undefined>;
|
||||
69
node_modules/@volar/language-service/lib/features/provideSelectionRanges.js
generated
vendored
Normal file
69
node_modules/@volar/language-service/lib/features/provideSelectionRanges.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const common_1 = require("../utils/common");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
const transform_1 = require("../utils/transform");
|
||||
function register(context) {
|
||||
return (uri, positions, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => positions, function* (docs) {
|
||||
const result = positions
|
||||
.map(position => {
|
||||
for (const mappedPosition of (0, featureWorkers_1.getGeneratedPositions)(docs, position, language_core_1.isSelectionRangesEnabled)) {
|
||||
return mappedPosition;
|
||||
}
|
||||
})
|
||||
.filter(position => !!position);
|
||||
if (result.length) {
|
||||
yield result;
|
||||
}
|
||||
}, async (plugin, document, positions) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
const selectionRanges = await plugin[1].provideSelectionRanges?.(document, positions, token);
|
||||
if (selectionRanges && selectionRanges.length !== positions.length) {
|
||||
console.error('Selection ranges count should be equal to positions count:', plugin[0].name, selectionRanges.length, positions.length);
|
||||
return;
|
||||
}
|
||||
return selectionRanges;
|
||||
}, (data, docs) => {
|
||||
if (!docs) {
|
||||
return data;
|
||||
}
|
||||
return (0, transform_1.transformSelectionRanges)(data, range => (0, featureWorkers_1.getSourceRange)(docs, range, language_core_1.isSelectionRangesEnabled));
|
||||
}, results => {
|
||||
const result = [];
|
||||
for (let i = 0; i < positions.length; i++) {
|
||||
let pluginResults = [];
|
||||
for (const ranges of results) {
|
||||
pluginResults.push(ranges[i]);
|
||||
}
|
||||
pluginResults = pluginResults.sort((a, b) => {
|
||||
if ((0, common_1.isInsideRange)(a.range, b.range)) {
|
||||
return 1;
|
||||
}
|
||||
if ((0, common_1.isInsideRange)(b.range, a.range)) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
for (let j = 1; j < pluginResults.length; j++) {
|
||||
let top = pluginResults[j - 1];
|
||||
const parent = pluginResults[j];
|
||||
while (top.parent && (0, common_1.isInsideRange)(parent.range, top.parent.range) && !(0, common_1.isEqualRange)(parent.range, top.parent.range)) {
|
||||
top = top.parent;
|
||||
}
|
||||
if (top) {
|
||||
top.parent = parent;
|
||||
}
|
||||
}
|
||||
result.push(pluginResults[0]);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideSelectionRanges.js.map
|
||||
4
node_modules/@volar/language-service/lib/features/provideSignatureHelp.d.ts
generated
vendored
Normal file
4
node_modules/@volar/language-service/lib/features/provideSignatureHelp.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import { URI } from 'vscode-uri';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, signatureHelpContext?: vscode.SignatureHelpContext, token?: vscode.CancellationToken) => Promise<vscode.SignatureHelp | undefined>;
|
||||
27
node_modules/@volar/language-service/lib/features/provideSignatureHelp.js
generated
vendored
Normal file
27
node_modules/@volar/language-service/lib/features/provideSignatureHelp.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const language_core_1 = require("@volar/language-core");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
function register(context) {
|
||||
return (uri, position, signatureHelpContext = {
|
||||
triggerKind: 1,
|
||||
isRetrigger: false,
|
||||
}, token = cancellation_1.NoneCancellationToken) => {
|
||||
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, docs => (0, featureWorkers_1.getGeneratedPositions)(docs, position, language_core_1.isSignatureHelpEnabled), (plugin, document, position) => {
|
||||
if (token.isCancellationRequested) {
|
||||
return;
|
||||
}
|
||||
if (signatureHelpContext?.triggerKind === 2
|
||||
&& signatureHelpContext.triggerCharacter
|
||||
&& !(signatureHelpContext.isRetrigger
|
||||
? plugin[0].capabilities.signatureHelpProvider?.retriggerCharacters
|
||||
: plugin[0].capabilities.signatureHelpProvider?.triggerCharacters)?.includes(signatureHelpContext.triggerCharacter)) {
|
||||
return;
|
||||
}
|
||||
return plugin[1].provideSignatureHelp?.(document, position, signatureHelpContext, token);
|
||||
}, data => data);
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideSignatureHelp.js.map
|
||||
3
node_modules/@volar/language-service/lib/features/provideWorkspaceDiagnostics.d.ts
generated
vendored
Normal file
3
node_modules/@volar/language-service/lib/features/provideWorkspaceDiagnostics.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (token?: vscode.CancellationToken) => Promise<vscode.WorkspaceDocumentDiagnosticReport[]>;
|
||||
68
node_modules/@volar/language-service/lib/features/provideWorkspaceDiagnostics.js
generated
vendored
Normal file
68
node_modules/@volar/language-service/lib/features/provideWorkspaceDiagnostics.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const provideDiagnostics_1 = require("./provideDiagnostics");
|
||||
function register(context) {
|
||||
return async (token = cancellation_1.NoneCancellationToken) => {
|
||||
const allItems = [];
|
||||
for (const plugin of context.plugins) {
|
||||
if (context.disabledServicePlugins.has(plugin[1])) {
|
||||
continue;
|
||||
}
|
||||
if (token.isCancellationRequested) {
|
||||
break;
|
||||
}
|
||||
if (!plugin[1].provideWorkspaceDiagnostics) {
|
||||
continue;
|
||||
}
|
||||
const report = await plugin[1].provideWorkspaceDiagnostics(token);
|
||||
if (!report) {
|
||||
continue;
|
||||
}
|
||||
const items = report
|
||||
.map(item => {
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(item.uri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
||||
if (virtualCode && sourceScript) {
|
||||
if (item.kind === 'unchanged') {
|
||||
return {
|
||||
...item,
|
||||
uri: sourceScript.id.toString(),
|
||||
};
|
||||
}
|
||||
else {
|
||||
const map = context.language.maps.get(virtualCode, sourceScript);
|
||||
const docs = [
|
||||
context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot),
|
||||
context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot),
|
||||
map,
|
||||
];
|
||||
return {
|
||||
...item,
|
||||
items: item.items
|
||||
.map(error => (0, provideDiagnostics_1.transformDiagnostic)(context, error, docs))
|
||||
.filter(error => !!error)
|
||||
};
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (item.kind === 'unchanged') {
|
||||
return item;
|
||||
}
|
||||
return {
|
||||
...item,
|
||||
items: item.items
|
||||
.map(error => (0, provideDiagnostics_1.transformDiagnostic)(context, error, undefined))
|
||||
.filter(error => !!error)
|
||||
};
|
||||
}
|
||||
});
|
||||
allItems.push(...items);
|
||||
}
|
||||
return allItems;
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideWorkspaceDiagnostics.js.map
|
||||
7
node_modules/@volar/language-service/lib/features/provideWorkspaceSymbols.d.ts
generated
vendored
Normal file
7
node_modules/@volar/language-service/lib/features/provideWorkspaceSymbols.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export interface WorkspaceSymbolData {
|
||||
original: Pick<vscode.WorkspaceSymbol, 'data'>;
|
||||
pluginIndex: number;
|
||||
}
|
||||
export declare function register(context: LanguageServiceContext): (query: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;
|
||||
64
node_modules/@volar/language-service/lib/features/provideWorkspaceSymbols.js
generated
vendored
Normal file
64
node_modules/@volar/language-service/lib/features/provideWorkspaceSymbols.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
const transform_1 = require("../utils/transform");
|
||||
function register(context) {
|
||||
return async (query, token = cancellation_1.NoneCancellationToken) => {
|
||||
const symbolsList = [];
|
||||
for (const plugin of context.plugins) {
|
||||
if (context.disabledServicePlugins.has(plugin[1])) {
|
||||
continue;
|
||||
}
|
||||
if (token.isCancellationRequested) {
|
||||
break;
|
||||
}
|
||||
if (!plugin[1].provideWorkspaceSymbols) {
|
||||
continue;
|
||||
}
|
||||
const embeddedSymbols = await plugin[1].provideWorkspaceSymbols(query, token);
|
||||
if (!embeddedSymbols) {
|
||||
continue;
|
||||
}
|
||||
const symbols = embeddedSymbols
|
||||
.map(symbol => (0, transform_1.transformWorkspaceSymbol)(symbol, loc => {
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(loc.uri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
||||
if (sourceScript && virtualCode) {
|
||||
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot);
|
||||
for (const [sourceScript, map] of context.language.maps.forEach(virtualCode)) {
|
||||
const sourceDocument = context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot);
|
||||
const docs = [sourceDocument, embeddedDocument, map];
|
||||
const range = (0, featureWorkers_1.getSourceRange)(docs, loc.range);
|
||||
if (range) {
|
||||
return { uri: sourceDocument.uri, range };
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return loc;
|
||||
}
|
||||
}))
|
||||
.filter(symbol => !!symbol);
|
||||
symbols?.forEach(symbol => {
|
||||
if (plugin[1].resolveWorkspaceSymbol) {
|
||||
symbol.data = {
|
||||
original: {
|
||||
data: symbol.data,
|
||||
},
|
||||
pluginIndex: context.plugins.indexOf(plugin),
|
||||
};
|
||||
}
|
||||
else {
|
||||
delete symbol.data;
|
||||
}
|
||||
});
|
||||
symbolsList.push(symbols);
|
||||
}
|
||||
return symbolsList.flat();
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=provideWorkspaceSymbols.js.map
|
||||
3
node_modules/@volar/language-service/lib/features/resolveCodeAction.d.ts
generated
vendored
Normal file
3
node_modules/@volar/language-service/lib/features/resolveCodeAction.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (item: vscode.CodeAction, token?: vscode.CancellationToken) => Promise<vscode.CodeAction>;
|
||||
29
node_modules/@volar/language-service/lib/features/resolveCodeAction.js
generated
vendored
Normal file
29
node_modules/@volar/language-service/lib/features/resolveCodeAction.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const transform_1 = require("../utils/transform");
|
||||
function register(context) {
|
||||
return async (item, token = cancellation_1.NoneCancellationToken) => {
|
||||
const data = item.data;
|
||||
if (data) {
|
||||
const plugin = context.plugins[data.pluginIndex];
|
||||
if (!plugin[1].resolveCodeAction) {
|
||||
delete item.data;
|
||||
return item;
|
||||
}
|
||||
Object.assign(item, data.original);
|
||||
item = await plugin[1].resolveCodeAction(item, token);
|
||||
item = plugin[1].transformCodeAction?.(item)
|
||||
?? (item.edit
|
||||
? {
|
||||
...item,
|
||||
edit: (0, transform_1.transformWorkspaceEdit)(item.edit, context, 'codeAction', { [data.uri]: data.version }),
|
||||
}
|
||||
: item);
|
||||
}
|
||||
delete item.data;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=resolveCodeAction.js.map
|
||||
3
node_modules/@volar/language-service/lib/features/resolveCodeLens.d.ts
generated
vendored
Normal file
3
node_modules/@volar/language-service/lib/features/resolveCodeLens.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
||||
29
node_modules/@volar/language-service/lib/features/resolveCodeLens.js
generated
vendored
Normal file
29
node_modules/@volar/language-service/lib/features/resolveCodeLens.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const references = require("./provideReferences");
|
||||
function register(context) {
|
||||
const findReferences = references.register(context);
|
||||
return async (item, token = cancellation_1.NoneCancellationToken) => {
|
||||
const data = item.data;
|
||||
if (data?.kind === 'normal') {
|
||||
const plugin = context.plugins[data.pluginIndex];
|
||||
if (!plugin[1].resolveCodeLens) {
|
||||
delete item.data;
|
||||
return item;
|
||||
}
|
||||
Object.assign(item, data.original);
|
||||
item = await plugin[1].resolveCodeLens(item, token);
|
||||
// item.range already transformed in codeLens request
|
||||
}
|
||||
else if (data?.kind === 'references') {
|
||||
const references = await findReferences(vscode_uri_1.URI.parse(data.sourceFileUri), item.range.start, { includeDeclaration: false }, token) ?? [];
|
||||
item.command = context.commands.showReferences.create(data.sourceFileUri, item.range.start, references);
|
||||
}
|
||||
delete item.data;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=resolveCodeLens.js.map
|
||||
3
node_modules/@volar/language-service/lib/features/resolveCompletionItem.d.ts
generated
vendored
Normal file
3
node_modules/@volar/language-service/lib/features/resolveCompletionItem.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (item: vscode.CompletionItem, token?: vscode.CancellationToken) => Promise<vscode.CompletionItem>;
|
||||
44
node_modules/@volar/language-service/lib/features/resolveCompletionItem.js
generated
vendored
Normal file
44
node_modules/@volar/language-service/lib/features/resolveCompletionItem.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const vscode_uri_1 = require("vscode-uri");
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const featureWorkers_1 = require("../utils/featureWorkers");
|
||||
const transform_1 = require("../utils/transform");
|
||||
function register(context) {
|
||||
return async (item, token = cancellation_1.NoneCancellationToken) => {
|
||||
const data = item.data;
|
||||
if (data) {
|
||||
const plugin = context.plugins[data.pluginIndex];
|
||||
if (!plugin[1].resolveCompletionItem) {
|
||||
delete item.data;
|
||||
return item;
|
||||
}
|
||||
item = Object.assign(item, data.original);
|
||||
if (data.embeddedDocumentUri) {
|
||||
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(data.embeddedDocumentUri));
|
||||
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
||||
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
||||
if (sourceScript && virtualCode) {
|
||||
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot);
|
||||
for (const [sourceScript, map] of context.language.maps.forEach(virtualCode)) {
|
||||
const sourceDocument = context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot);
|
||||
const docs = [sourceDocument, embeddedDocument, map];
|
||||
item = await plugin[1].resolveCompletionItem(item, token);
|
||||
item = plugin[1].transformCompletionItem?.(item) ?? (0, transform_1.transformCompletionItem)(item, embeddedRange => (0, featureWorkers_1.getSourceRange)(docs, embeddedRange), embeddedDocument, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
item = await plugin[1].resolveCompletionItem(item, token);
|
||||
}
|
||||
}
|
||||
// TODO: monkey fix import ts file icon
|
||||
if (item.detail !== item.detail + '.ts') {
|
||||
item.detail = item.detail;
|
||||
}
|
||||
delete item.data;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=resolveCompletionItem.js.map
|
||||
3
node_modules/@volar/language-service/lib/features/resolveDocumentLink.d.ts
generated
vendored
Normal file
3
node_modules/@volar/language-service/lib/features/resolveDocumentLink.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (item: vscode.DocumentLink, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink>;
|
||||
25
node_modules/@volar/language-service/lib/features/resolveDocumentLink.js
generated
vendored
Normal file
25
node_modules/@volar/language-service/lib/features/resolveDocumentLink.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
const transform_1 = require("../utils/transform");
|
||||
function register(context) {
|
||||
return async (item, token = cancellation_1.NoneCancellationToken) => {
|
||||
const data = item.data;
|
||||
if (data) {
|
||||
const plugin = context.plugins[data.pluginIndex];
|
||||
if (!plugin[1].resolveDocumentLink) {
|
||||
delete item.data;
|
||||
return item;
|
||||
}
|
||||
Object.assign(item, data.original);
|
||||
item = await plugin[1].resolveDocumentLink(item, token);
|
||||
if (item.target) {
|
||||
item.target = (0, transform_1.transformDocumentLinkTarget)(item.target, context).toString();
|
||||
}
|
||||
}
|
||||
delete item.data;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=resolveDocumentLink.js.map
|
||||
3
node_modules/@volar/language-service/lib/features/resolveInlayHint.d.ts
generated
vendored
Normal file
3
node_modules/@volar/language-service/lib/features/resolveInlayHint.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (item: vscode.InlayHint, token?: vscode.CancellationToken) => Promise<vscode.InlayHint>;
|
||||
21
node_modules/@volar/language-service/lib/features/resolveInlayHint.js
generated
vendored
Normal file
21
node_modules/@volar/language-service/lib/features/resolveInlayHint.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
function register(context) {
|
||||
return async (item, token = cancellation_1.NoneCancellationToken) => {
|
||||
const data = item.data;
|
||||
if (data) {
|
||||
const plugin = context.plugins[data.pluginIndex];
|
||||
if (!plugin[1].resolveInlayHint) {
|
||||
delete item.data;
|
||||
return item;
|
||||
}
|
||||
Object.assign(item, data.original);
|
||||
item = await plugin[1].resolveInlayHint(item, token);
|
||||
}
|
||||
delete item.data;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=resolveInlayHint.js.map
|
||||
3
node_modules/@volar/language-service/lib/features/resolveWorkspaceSymbol.d.ts
generated
vendored
Normal file
3
node_modules/@volar/language-service/lib/features/resolveWorkspaceSymbol.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type * as vscode from 'vscode-languageserver-protocol';
|
||||
import type { LanguageServiceContext } from '../types';
|
||||
export declare function register(context: LanguageServiceContext): (item: vscode.WorkspaceSymbol, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol>;
|
||||
21
node_modules/@volar/language-service/lib/features/resolveWorkspaceSymbol.js
generated
vendored
Normal file
21
node_modules/@volar/language-service/lib/features/resolveWorkspaceSymbol.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.register = register;
|
||||
const cancellation_1 = require("../utils/cancellation");
|
||||
function register(context) {
|
||||
return async (item, token = cancellation_1.NoneCancellationToken) => {
|
||||
const data = item.data;
|
||||
if (data) {
|
||||
const plugin = context.plugins[data.pluginIndex];
|
||||
if (!plugin[1].resolveWorkspaceSymbol) {
|
||||
delete item.data;
|
||||
return item;
|
||||
}
|
||||
Object.assign(item, data.original);
|
||||
item = await plugin[1].resolveWorkspaceSymbol(item, token);
|
||||
}
|
||||
delete item.data;
|
||||
return item;
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=resolveWorkspaceSymbol.js.map
|
||||
Reference in New Issue
Block a user