Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@volar/language-service

Package Overview
Dependencies
Maintainers
1
Versions
233
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volar/language-service - npm Package Compare versions

Comparing version 2.2.5 to 2.3.0-alpha.0

lib/features/provideAutoInsertSnippet.d.ts

3

index.d.ts

@@ -7,3 +7,2 @@ export * from '@volar/language-core';

export * from './lib/utils/transform';
import type * as vscode from 'vscode-languageserver-protocol';
export declare const standardSemanticTokensLegend: vscode.SemanticTokensLegend;
export * from './lib/utils/uriMap';

@@ -17,3 +17,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.standardSemanticTokensLegend = exports.mergeWorkspaceEdits = void 0;
exports.mergeWorkspaceEdits = void 0;
__exportStar(require("@volar/language-core"), exports);

@@ -26,42 +26,3 @@ __exportStar(require("./lib/languageService"), exports);

__exportStar(require("./lib/utils/transform"), exports);
// https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#standard-token-types-and-modifiers
exports.standardSemanticTokensLegend = {
tokenTypes: [
'namespace',
'class',
'enum',
'interface',
'struct',
'typeParameter',
'type',
'parameter',
'variable',
'property',
'enumMember',
'decorator',
'event',
'function',
'method',
'macro',
'label',
'comment',
'string',
'keyword',
'number',
'regexp',
'operator',
],
tokenModifiers: [
'declaration',
'definition',
'readonly',
'static',
'deprecated',
'abstract',
'async',
'modification',
'documentation',
'defaultLibrary',
],
};
__exportStar(require("./lib/utils/uriMap"), exports);
//# sourceMappingURL=index.js.map

@@ -1,21 +0,22 @@

import { CodeRangeKey, LinkedCodeMap, Mapping, SourceMap } from '@volar/language-core';
import { CodeInformation, CodeRangeKey, LinkedCodeMap, Mapping, SourceMap, VirtualCode } from '@volar/language-core';
import type * as vscode from 'vscode-languageserver-protocol';
import type { TextDocument } from 'vscode-languageserver-textdocument';
export declare class SourceMapWithDocuments<Data = any> {
export declare class SourceMapWithDocuments {
sourceDocument: TextDocument;
embeddedDocument: TextDocument;
map: SourceMap<Data>;
constructor(sourceDocument: TextDocument, embeddedDocument: TextDocument, map: SourceMap<Data>);
getSourceRange(range: vscode.Range, filter?: (data: Data) => boolean): vscode.Range | undefined;
getGeneratedRange(range: vscode.Range, filter?: (data: Data) => boolean): vscode.Range | undefined;
getSourceRanges(range: vscode.Range, filter?: (data: Data) => boolean): Generator<vscode.Range, void, unknown>;
getGeneratedRanges(range: vscode.Range, filter?: (data: Data) => boolean): Generator<vscode.Range, void, unknown>;
protected findRanges(range: vscode.Range, filter: (data: Data) => boolean, api: 'getSourcePositionsBase' | 'getGeneratedPositionsBase', api2: 'matchSourcePosition' | 'matchGeneratedPosition'): Generator<vscode.Range, void, unknown>;
getSourcePosition(position: vscode.Position, filter?: (data: Data) => boolean): import("vscode-languageserver-textdocument").Position | undefined;
getGeneratedPosition(position: vscode.Position, filter?: (data: Data) => boolean): import("vscode-languageserver-textdocument").Position | undefined;
getSourcePositions(position: vscode.Position, filter?: (data: Data) => boolean): Generator<import("vscode-languageserver-textdocument").Position, void, unknown>;
getGeneratedPositions(position: vscode.Position, filter?: (data: Data) => boolean): Generator<import("vscode-languageserver-textdocument").Position, void, unknown>;
getSourcePositionsBase(position: vscode.Position, filter?: (data: Data) => boolean): Generator<readonly [import("vscode-languageserver-textdocument").Position, Mapping<Data>], void, unknown>;
getGeneratedPositionsBase(position: vscode.Position, filter?: (data: Data) => boolean): Generator<readonly [import("vscode-languageserver-textdocument").Position, Mapping<Data>], void, unknown>;
protected findPositions(position: vscode.Position, filter: (data: Data) => boolean, fromDoc: TextDocument, toDoc: TextDocument, from: CodeRangeKey, to: CodeRangeKey): Generator<readonly [import("vscode-languageserver-textdocument").Position, Mapping<Data>], void, unknown>;
map: SourceMap<CodeInformation>;
virtuaoCode?: VirtualCode | undefined;
constructor(sourceDocument: TextDocument, embeddedDocument: TextDocument, map: SourceMap<CodeInformation>, virtuaoCode?: VirtualCode | undefined);
getSourceRange(range: vscode.Range, filter?: (data: CodeInformation) => boolean): vscode.Range | undefined;
getGeneratedRange(range: vscode.Range, filter?: (data: CodeInformation) => boolean): vscode.Range | undefined;
getSourceRanges(range: vscode.Range, filter?: (data: CodeInformation) => boolean): Generator<vscode.Range, void, unknown>;
getGeneratedRanges(range: vscode.Range, filter?: (data: CodeInformation) => boolean): Generator<vscode.Range, void, unknown>;
protected findRanges(range: vscode.Range, filter: (data: CodeInformation) => boolean, api: 'getSourcePositionsBase' | 'getGeneratedPositionsBase', api2: 'matchSourcePosition' | 'matchGeneratedPosition'): Generator<vscode.Range, void, unknown>;
getSourcePosition(position: vscode.Position, filter?: (data: CodeInformation) => boolean): import("vscode-languageserver-textdocument").Position | undefined;
getGeneratedPosition(position: vscode.Position, filter?: (data: CodeInformation) => boolean): import("vscode-languageserver-textdocument").Position | undefined;
getSourcePositions(position: vscode.Position, filter?: (data: CodeInformation) => boolean): Generator<import("vscode-languageserver-textdocument").Position, void, unknown>;
getGeneratedPositions(position: vscode.Position, filter?: (data: CodeInformation) => boolean): Generator<import("vscode-languageserver-textdocument").Position, void, unknown>;
getSourcePositionsBase(position: vscode.Position, filter?: (data: CodeInformation) => boolean): Generator<readonly [import("vscode-languageserver-textdocument").Position, Mapping<CodeInformation>], void, unknown>;
getGeneratedPositionsBase(position: vscode.Position, filter?: (data: CodeInformation) => boolean): Generator<readonly [import("vscode-languageserver-textdocument").Position, Mapping<CodeInformation>], void, unknown>;
protected findPositions(position: vscode.Position, filter: (data: CodeInformation) => boolean, fromDoc: TextDocument, toDoc: TextDocument, from: CodeRangeKey, to: CodeRangeKey): Generator<readonly [import("vscode-languageserver-textdocument").Position, Mapping<CodeInformation>], void, unknown>;
protected matchSourcePosition(position: vscode.Position, mapping: Mapping): import("vscode-languageserver-textdocument").Position | undefined;

@@ -26,5 +27,6 @@ protected matchGeneratedPosition(position: vscode.Position, mapping: Mapping): import("vscode-languageserver-textdocument").Position | undefined;

document: TextDocument;
private linkedMap;
constructor(document: TextDocument, linkedMap: LinkedCodeMap);
linkedMap: LinkedCodeMap;
virtualCode: VirtualCode;
constructor(document: TextDocument, linkedMap: LinkedCodeMap, virtualCode: VirtualCode);
getLinkedCodePositions(posotion: vscode.Position): Generator<import("vscode-languageserver-textdocument").Position, void, unknown>;
}

@@ -6,6 +6,7 @@ "use strict";

class SourceMapWithDocuments {
constructor(sourceDocument, embeddedDocument, map) {
constructor(sourceDocument, embeddedDocument, map, virtuaoCode) {
this.sourceDocument = sourceDocument;
this.embeddedDocument = embeddedDocument;
this.map = map;
this.virtuaoCode = virtuaoCode;
}

@@ -104,6 +105,7 @@ // Range APIs

class LinkedCodeMapWithDocument extends SourceMapWithDocuments {
constructor(document, linkedMap) {
super(document, document, linkedMap);
constructor(document, linkedMap, virtualCode) {
super(document, document, linkedMap, virtualCode);
this.document = document;
this.linkedMap = linkedMap;
this.virtualCode = virtualCode;
}

@@ -110,0 +112,0 @@ *getLinkedCodePositions(posotion) {

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
import type { LanguageServiceContext } from '../types';
import { URI } from 'vscode-uri';
export interface PluginCallHierarchyData {
uri: string;
original: Pick<vscode.CallHierarchyItem, 'data'>;
serviceIndex: number;
pluginIndex: number;
embeddedDocumentUri: string | undefined;
}
export declare function register(context: ServiceContext): {
doPrepare(uri: string, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
export declare function register(context: LanguageServiceContext): {
doPrepare(uri: URI, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
getIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
getOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
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 cancellation_1 = require("../utils/cancellation");
const language_core_1 = require("@volar/language-core");
const vscode_uri_1 = require("vscode-uri");
function register(context) {
return {
doPrepare(uri, position, token = cancellation_1.NoneCancellationToken) {
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, data => (0, language_core_1.isCallHierarchyEnabled)(data)), async (service, document, position, map) => {
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, data => (0, language_core_1.isCallHierarchyEnabled)(data)), async (plugin, document, position, map) => {
if (token.isCancellationRequested) {
return;
}
const items = await service[1].provideCallHierarchyItems?.(document, position, token);
const items = await plugin[1].provideCallHierarchyItems?.(document, position, token);
items?.forEach(item => {
item.data = {
uri,
uri: uri.toString(),
original: {
data: item.data,
},
serviceIndex: context.services.indexOf(service),
pluginIndex: context.plugins.indexOf(plugin),
embeddedDocumentUri: map?.embeddedDocument.uri,

@@ -41,4 +42,4 @@ };

if (data) {
const service = context.services[data.serviceIndex];
if (!service[1].provideCallHierarchyIncomingCalls) {
const plugin = context.plugins[data.pluginIndex];
if (!plugin[1].provideCallHierarchyIncomingCalls) {
return incomingItems;

@@ -48,5 +49,5 @@ }

if (data.embeddedDocumentUri) {
const isEmbeddedContent = !!context.decodeEmbeddedDocumentUri(data.embeddedDocumentUri);
const isEmbeddedContent = !!context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(data.embeddedDocumentUri));
if (isEmbeddedContent) {
const _calls = await service[1].provideCallHierarchyIncomingCalls(item, token);
const _calls = await plugin[1].provideCallHierarchyIncomingCalls(item, token);
for (const _call of _calls) {

@@ -65,3 +66,3 @@ const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);

else {
const _calls = await service[1].provideCallHierarchyIncomingCalls(item, token);
const _calls = await plugin[1].provideCallHierarchyIncomingCalls(item, token);
for (const _call of _calls) {

@@ -85,4 +86,4 @@ const calls = transformCallHierarchyItem(_call.from, _call.fromRanges);

if (data) {
const service = context.services[data.serviceIndex];
if (!service[1].provideCallHierarchyOutgoingCalls) {
const plugin = context.plugins[data.pluginIndex];
if (!plugin[1].provideCallHierarchyOutgoingCalls) {
return items;

@@ -92,5 +93,5 @@ }

if (data.embeddedDocumentUri) {
const isEmbeddedContent = !!context.decodeEmbeddedDocumentUri(data.embeddedDocumentUri);
const isEmbeddedContent = !!context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(data.embeddedDocumentUri));
if (isEmbeddedContent) {
const _calls = await service[1].provideCallHierarchyOutgoingCalls(item, token);
const _calls = await plugin[1].provideCallHierarchyOutgoingCalls(item, token);
for (const call of _calls) {

@@ -109,3 +110,3 @@ const calls = transformCallHierarchyItem(call.to, call.fromRanges);

else {
const _calls = await service[1].provideCallHierarchyOutgoingCalls(item, token);
const _calls = await plugin[1].provideCallHierarchyOutgoingCalls(item, token);
for (const call of _calls) {

@@ -127,3 +128,3 @@ const calls = transformCallHierarchyItem(call.to, call.fromRanges);

function transformCallHierarchyItem(tsItem, tsRanges) {
const decoded = context.decodeEmbeddedDocumentUri(tsItem.uri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(tsItem.uri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -130,0 +131,0 @@ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
import type { URI } from 'vscode-uri';
import type { LanguageServiceContext } from '../types';
export interface ServiceCodeActionData {

@@ -7,4 +8,4 @@ uri: string;

original: Pick<vscode.CodeAction, 'data' | 'edit'>;
serviceIndex: number;
pluginIndex: number;
}
export declare function register(context: ServiceContext): (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token?: vscode.CancellationToken) => Promise<vscode.CodeAction[] | undefined>;
export declare function register(context: LanguageServiceContext): (uri: URI, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token?: vscode.CancellationToken) => Promise<vscode.CodeAction[] | undefined>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const language_core_1 = require("@volar/language-core");
const cancellation_1 = require("../utils/cancellation");

@@ -9,3 +10,2 @@ const common_1 = require("../utils/common");

const transform_1 = require("../utils/transform");
const language_core_1 = require("@volar/language-core");
function register(context) {

@@ -33,7 +33,7 @@ return async (uri, range, codeActionContext, token = cancellation_1.NoneCancellationToken) => {

}
}, async (service, document, { range, codeActionContext }) => {
}, async (plugin, document, { range, codeActionContext }) => {
if (token.isCancellationRequested) {
return;
}
const serviceIndex = context.services.indexOf(service);
const pluginIndex = context.plugins.indexOf(plugin);
const diagnostics = codeActionContext.diagnostics.filter(diagnostic => {

@@ -44,3 +44,3 @@ const data = diagnostic.data;

}
return data?.serviceIndex === serviceIndex;
return data?.serviceIndex === pluginIndex;
}).map(diagnostic => {

@@ -53,3 +53,3 @@ const data = diagnostic.data;

});
const codeActions = await service[1].provideCodeActions?.(document, range, {
const codeActions = await plugin[1].provideCodeActions?.(document, range, {
...codeActionContext,

@@ -60,3 +60,3 @@ diagnostics,

codeAction.data = {
uri,
uri: uri.toString(),
version: document.version,

@@ -67,8 +67,8 @@ original: {

},
serviceIndex: context.services.indexOf(service),
pluginIndex: context.plugins.indexOf(plugin),
};
});
if (codeActions && service[1].transformCodeAction) {
if (codeActions && plugin[1].transformCodeAction) {
for (let i = 0; i < codeActions.length; i++) {
const transformed = service[1].transformCodeAction(codeActions[i]);
const transformed = plugin[1].transformCodeAction(codeActions[i]);
if (transformed) {

@@ -75,0 +75,0 @@ codeActions[i] = transformed;

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
import type { URI } from 'vscode-uri';
import type { LanguageServiceContext } from '../types';
export interface ServiceCodeLensData {

@@ -7,3 +8,3 @@ kind: 'normal';

original: Pick<vscode.CodeLens, 'data'>;
serviceIndex: number;
pluginIndex: number;
}

@@ -17,2 +18,2 @@ export interface ServiceReferencesCodeLensData {

}
export declare function register(context: ServiceContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
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 language_core_1 = require("@volar/language-core");
function register(context) {
return async (uri, token = cancellation_1.NoneCancellationToken) => {
return await (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isCodeLensEnabled)(mapping.data)), async (service, document) => {
return await (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isCodeLensEnabled)(mapping.data)), async (plugin, document) => {
if (token.isCancellationRequested) {
return;
}
let codeLens = await service[1].provideCodeLenses?.(document, token);
const serviceIndex = context.services.indexOf(service);
let codeLens = await plugin[1].provideCodeLenses?.(document, token);
const pluginIndex = context.plugins.indexOf(plugin);
codeLens?.forEach(codeLens => {
codeLens.data = {
kind: 'normal',
uri,
uri: uri.toString(),
original: {
data: codeLens.data,
},
serviceIndex,
pluginIndex,
};
});
const ranges = await service[1].provideReferencesCodeLensRanges?.(document, token);
const ranges = await plugin[1].provideReferencesCodeLensRanges?.(document, token);
const referencesCodeLens = ranges?.map(range => ({

@@ -31,6 +31,6 @@ range,

kind: 'references',
sourceFileUri: uri,
sourceFileUri: uri.toString(),
workerFileUri: document.uri,
workerFileRange: range,
serviceIndex,
serviceIndex: pluginIndex,
},

@@ -37,0 +37,0 @@ }));

@@ -1,3 +0,4 @@

import type { ServiceContext } from '../types';
import type * as vscode from 'vscode-languageserver-protocol';
export declare function register(context: ServiceContext): (uri: string, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.ColorPresentation[] | undefined>;
import type { 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>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
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 common_1 = require("../utils/common");
const cancellation_1 = require("../utils/cancellation");
const language_core_1 = require("@volar/language-core");
function register(context) {

@@ -14,7 +14,7 @@ return (uri, color, range, token = cancellation_1.NoneCancellationToken) => {

}
}, (service, document, range) => {
}, (plugin, document, range) => {
if (token.isCancellationRequested) {
return;
}
return service[1].provideColorPresentations?.(document, color, range, token);
return plugin[1].provideColorPresentations?.(document, color, range, token);
}, (data, map) => {

@@ -21,0 +21,0 @@ if (!map) {

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
import { URI } from 'vscode-uri';
import type { LanguageServiceContext } from '../types';
export interface ServiceCompletionData {
uri: string;
original: Pick<vscode.CompletionItem, 'additionalTextEdits' | 'textEdit' | 'data'>;
serviceIndex: number;
pluginIndex: number;
embeddedDocumentUri: string | undefined;
}
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext, token?: vscode.CancellationToken) => Promise<vscode.CompletionList>;
export declare function register(context: LanguageServiceContext): (uri: URI, position: vscode.Position, completionContext?: vscode.CompletionContext, token?: vscode.CancellationToken) => Promise<vscode.CompletionList>;

@@ -5,5 +5,6 @@ "use strict";

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");
const featureWorkers_1 = require("../utils/featureWorkers");
function register(context) {

@@ -20,3 +21,3 @@ let lastResult;

if (completionContext?.triggerKind === 3
&& lastResult?.uri === uri) {
&& lastResult?.uri.toString() === uri.toString()) {
for (const cacheData of lastResult.results) {

@@ -26,3 +27,3 @@ if (!cacheData.list?.isIncomplete) {

}
const serviceIndex = context.services.findIndex(service => service[1] === cacheData.service);
const pluginIndex = context.plugins.findIndex(plugin => plugin[1] === cacheData.plugin);
if (cacheData.embeddedDocumentUri) {

@@ -37,6 +38,6 @@ const decoded = context.decodeEmbeddedDocumentUri(cacheData.embeddedDocumentUri);

for (const mapped of map.getGeneratedPositions(position, data => (0, language_core_1.isCompletionEnabled)(data))) {
if (!cacheData.service.provideCompletionItems) {
if (!cacheData.plugin.provideCompletionItems) {
continue;
}
cacheData.list = await cacheData.service.provideCompletionItems(map.embeddedDocument, mapped, completionContext, token);
cacheData.list = await cacheData.plugin.provideCompletionItems(map.embeddedDocument, mapped, completionContext, token);
if (!cacheData.list) {

@@ -47,3 +48,3 @@ continue;

item.data = {
uri,
uri: uri.toString(),
original: {

@@ -54,3 +55,3 @@ additionalTextEdits: item.additionalTextEdits,

},
serviceIndex,
pluginIndex: pluginIndex,
embeddedDocumentUri: map.embeddedDocument.uri,

@@ -64,7 +65,7 @@ };

else {
if (!cacheData.service.provideCompletionItems) {
if (!cacheData.plugin.provideCompletionItems) {
continue;
}
const document = context.documents.get(uri, sourceScript.languageId, sourceScript.snapshot);
cacheData.list = await cacheData.service.provideCompletionItems(document, position, completionContext, token);
cacheData.list = await cacheData.plugin.provideCompletionItems(document, position, completionContext, token);
if (!cacheData.list) {

@@ -75,3 +76,3 @@ continue;

item.data = {
uri,
uri: uri.toString(),
original: {

@@ -82,3 +83,3 @@ additionalTextEdits: item.additionalTextEdits,

},
serviceIndex,
pluginIndex: pluginIndex,
embeddedDocumentUri: undefined,

@@ -98,20 +99,20 @@ };

let mainCompletionUri;
const services = [...context.services]
.filter(service => !context.disabledServicePlugins.has(service[1]))
const sortedPlugins = [...context.plugins]
.filter(plugin => !context.disabledServicePlugins.has(plugin[1]))
.sort((a, b) => sortServices(a[1], b[1]));
const worker = async (document, position, map, codeInfo) => {
for (const service of services) {
for (const plugin of sortedPlugins) {
if (token.isCancellationRequested) {
break;
}
if (!service[1].provideCompletionItems) {
if (!plugin[1].provideCompletionItems) {
continue;
}
if (service[1].isAdditionalCompletion && !isFirstMapping) {
if (plugin[1].isAdditionalCompletion && !isFirstMapping) {
continue;
}
if (completionContext?.triggerCharacter && !service[0].triggerCharacters?.includes(completionContext.triggerCharacter)) {
if (completionContext?.triggerCharacter && !plugin[0].capabilities.completionProvider?.triggerCharacters?.includes(completionContext.triggerCharacter)) {
continue;
}
const isAdditional = (codeInfo && typeof codeInfo.completion === 'object' && codeInfo.completion.isAdditional) || service[1].isAdditionalCompletion;
const isAdditional = (codeInfo && typeof codeInfo.completion === 'object' && codeInfo.completion.isAdditional) || plugin[1].isAdditionalCompletion;
if (mainCompletionUri && (!isAdditional || mainCompletionUri !== document.uri)) {

@@ -121,6 +122,6 @@ continue;

// avoid duplicate items with .vue and .vue.html
if (service[1].isAdditionalCompletion && lastResult?.results.some(data => data.service === service[1])) {
if (plugin[1].isAdditionalCompletion && lastResult?.results.some(data => data.plugin === plugin[1])) {
continue;
}
let completionList = await service[1].provideCompletionItems(document, position, completionContext, token);
let completionList = await plugin[1].provideCompletionItems(document, position, completionContext, token);
if (!completionList || !completionList.items.length) {

@@ -135,6 +136,6 @@ continue;

}
const serviceIndex = context.services.indexOf(service);
const pluginIndex = context.plugins.indexOf(plugin);
for (const item of completionList.items) {
item.data = {
uri,
uri: uri.toString(),
original: {

@@ -145,3 +146,3 @@ additionalTextEdits: item.additionalTextEdits,

},
serviceIndex,
pluginIndex,
embeddedDocumentUri: map ? document.uri : undefined,

@@ -154,4 +155,4 @@ };

lastResult?.results.push({
embeddedDocumentUri: map ? document.uri : undefined,
service: service[1],
embeddedDocumentUri: map ? vscode_uri_1.URI.parse(document.uri) : undefined,
plugin: plugin[1],
list: completionList,

@@ -158,0 +159,0 @@ });

import type { CodeInformation } from '@volar/language-core';
import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext, apiName: 'provideDefinition' | 'provideTypeDefinition' | 'provideImplementation', isValidPosition: (data: CodeInformation) => boolean): (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
import { URI } from 'vscode-uri';
import type { LanguageServiceContext } from '../types';
export declare function register(context: LanguageServiceContext, apiName: 'provideDefinition' | 'provideTypeDefinition' | 'provideImplementation', isValidPosition: (data: CodeInformation) => boolean): (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const vscode_uri_1 = require("vscode-uri");
const cancellation_1 = require("../utils/cancellation");

@@ -10,3 +11,3 @@ const common_1 = require("../utils/common");

return (uri, position, token = cancellation_1.NoneCancellationToken) => {
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, isValidPosition), async (service, document, position) => {
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, isValidPosition), async (plugin, document, position) => {
if (token.isCancellationRequested) {

@@ -20,3 +21,3 @@ return;

async function withLinkedCode(document, position, originDefinition) {
const api = service[1][apiName];
const api = plugin[1][apiName];
if (!api) {

@@ -33,3 +34,3 @@ return;

recursiveChecker.add({ uri: definition.targetUri, range: { start: definition.targetRange.start, end: definition.targetRange.start } });
const decoded = context.decodeEmbeddedDocumentUri(definition.targetUri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(definition.targetUri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -71,3 +72,3 @@ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

let foundTargetSelectionRange = false;
const decoded = context.decodeEmbeddedDocumentUri(link.targetUri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(link.targetUri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -90,3 +91,3 @@ const targetVirtualFile = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

for (const targetMap of context.documents.getMaps(targetVirtualFile)) {
if (targetMap && targetMap.sourceDocument.uri !== uri) {
if (targetMap && targetMap.sourceDocument.uri !== uri.toString()) {
return {

@@ -93,0 +94,0 @@ ...link,

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
import { URI } from 'vscode-uri';
import type { LanguageServiceContext } from '../types';
export declare function updateRange(range: vscode.Range, change: {

@@ -15,6 +16,6 @@ range: vscode.Range;

}
export declare const errorMarkups: Record<string, {
export declare const errorMarkups: Map<URI, {
error: vscode.Diagnostic;
markup: vscode.MarkupContent;
}[]>;
export declare function register(context: ServiceContext): (uri: string, token?: vscode.CancellationToken, response?: (result: vscode.Diagnostic[]) => void) => Promise<vscode.Diagnostic[]>;
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken, response?: (result: vscode.Diagnostic[]) => void) => Promise<vscode.Diagnostic[]>;

@@ -5,2 +5,3 @@ "use strict";

const language_core_1 = require("@volar/language-core");
const vscode_uri_1 = require("vscode-uri");
const cancellation_1 = require("../utils/cancellation");

@@ -10,2 +11,3 @@ const common_1 = require("../utils/common");

const featureWorkers_1 = require("../utils/featureWorkers");
const uriMap_1 = require("../utils/uriMap");
function updateRange(range, change) {

@@ -83,5 +85,5 @@ if (!updatePosition(range.start, change, false)) {

}
exports.errorMarkups = {};
exports.errorMarkups = (0, uriMap_1.createUriMap)();
function register(context) {
const lastResponses = new Map();
const lastResponses = (0, uriMap_1.createUriMap)();
const cacheMaps = {

@@ -145,3 +147,3 @@ semantic: new Map(),

async function worker(api, cacheMap, cache) {
const result = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isDiagnosticsEnabled)(mapping.data)), async (service, document) => {
const result = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isDiagnosticsEnabled)(mapping.data)), async (plugin, document) => {
if (token) {

@@ -156,14 +158,14 @@ if (Date.now() - lastCheckCancelAt >= 5) {

}
const serviceIndex = context.services.indexOf(service);
const serviceCache = cacheMap.get(serviceIndex) ?? cacheMap.set(serviceIndex, new Map()).get(serviceIndex);
const cache = serviceCache.get(document.uri);
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 (api !== 'provideSemanticDiagnostics' && cache && cache.documentVersion === document.version) {
return cache.errors;
}
const errors = await service[1][api]?.(document, token) || [];
const errors = await plugin[1][api]?.(document, token) || [];
errors.forEach(error => {
error.data = {
uri,
uri: uri.toString(),
version: document.version,
serviceIndex,
serviceIndex: pluginIndex,
isFormat: false,

@@ -177,3 +179,3 @@ original: {

errorsUpdated = true;
serviceCache.set(document.uri, {
pluginCache.set(document.uri, {
documentVersion: document.version,

@@ -207,3 +209,3 @@ errors,

for (const info of _error.relatedInformation) {
const decoded = context.decodeEmbeddedDocumentUri(info.location.uri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(info.location.uri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -210,0 +212,0 @@ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.ColorInformation[] | undefined>;
import type { URI } from 'vscode-uri';
import type { LanguageServiceContext } from '../types';
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.ColorInformation[] | undefined>;

@@ -10,7 +10,7 @@ "use strict";

return (uri, token = cancellation_1.NoneCancellationToken) => {
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isColorEnabled)(mapping.data)), (service, document) => {
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isColorEnabled)(mapping.data)), (plugin, document) => {
if (token.isCancellationRequested) {
return;
}
return service[1].provideDocumentColors?.(document, token);
return plugin[1].provideDocumentColors?.(document, token);
}, (data, map) => {

@@ -17,0 +17,0 @@ if (!map) {

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext, DataTransferItem } from '../types';
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, dataTransfer: Map<string, DataTransferItem>, token?: vscode.CancellationToken) => Promise<import("../types").DocumentDropEdit | undefined>;
import type { 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>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const cancellation_1 = require("../utils/cancellation");
const featureWorkers_1 = require("../utils/featureWorkers");
const cancellation_1 = require("../utils/cancellation");
const transform_1 = require("../utils/transform");

@@ -13,7 +13,7 @@ function register(context) {

}
}, (service, document, arg) => {
}, (plugin, document, arg) => {
if (token.isCancellationRequested) {
return;
}
return service[1].provideDocumentDropEdits?.(document, arg, dataTransfer, token);
return plugin[1].provideDocumentDropEdits?.(document, arg, dataTransfer, token);
}, edit => {

@@ -20,0 +20,0 @@ if (edit.additionalEdit) {

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (uri: string, options: vscode.FormattingOptions, range: vscode.Range | undefined, onTypeParams: {
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>;

@@ -6,2 +6,3 @@ "use strict";

const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
const vscode_uri_1 = require("vscode-uri");
const documents_1 = require("../documents");

@@ -11,2 +12,3 @@ const cancellation_1 = require("../utils/cancellation");

const featureWorkers_1 = require("../utils/featureWorkers");
const uriMap_1 = require("../utils/uriMap");
function register(context) {

@@ -51,3 +53,3 @@ let fakeVersion = 0;

let tempSourceSnapshot = sourceScript.snapshot;
let tempVirtualFile = context.language.scripts.set(sourceScript.id + '.tmp', sourceScript.snapshot, sourceScript.languageId, [sourceScript.generated.languagePlugin])?.generated?.root;
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) {

@@ -102,3 +104,3 @@ return;

tempSourceSnapshot = (0, common_1.stringToSnapshot)(newText);
tempVirtualFile = context.language.scripts.set(sourceScript.id + '.tmp', tempSourceSnapshot, sourceScript.languageId, [sourceScript.generated.languagePlugin])?.generated?.root;
tempVirtualFile = context.language.scripts.set(vscode_uri_1.URI.parse(sourceScript.id.toString() + '.tmp'), tempSourceSnapshot, sourceScript.languageId, [sourceScript.generated.languagePlugin])?.generated?.root;
if (!tempVirtualFile) {

@@ -123,6 +125,6 @@ break;

finally {
context.language.scripts.delete(sourceScript.id + '.tmp');
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.has(document.uri)) {
if (context.disabledEmbeddedDocumentUris.get(vscode_uri_1.URI.parse(document.uri))) {
return;

@@ -146,11 +148,11 @@ }

}
for (const service of context.services) {
if (context.disabledServicePlugins.has(service[1])) {
for (const plugin of context.plugins) {
if (context.disabledServicePlugins.has(plugin[1])) {
continue;
}
codeOptions = await service[1].resolveEmbeddedCodeFormattingOptions?.(sourceScript, virtualCode, codeOptions, token) ?? codeOptions;
codeOptions = await plugin[1].resolveEmbeddedCodeFormattingOptions?.(sourceScript, virtualCode, codeOptions, token) ?? codeOptions;
}
}
for (const service of context.services) {
if (context.disabledServicePlugins.has(service[1])) {
for (const plugin of context.plugins) {
if (context.disabledServicePlugins.has(plugin[1])) {
continue;

@@ -164,8 +166,8 @@ }

if (ch !== undefined && rangeOrPosition && 'line' in rangeOrPosition && 'character' in rangeOrPosition) {
if (service[0].autoFormatTriggerCharacters?.includes(ch)) {
edits = await service[1].provideOnTypeFormattingEdits?.(document, rangeOrPosition, ch, options, codeOptions, token);
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 service[1].provideDocumentFormattingEdits?.(document, rangeOrPosition, options, codeOptions, token);
edits = await plugin[1].provideDocumentFormattingEdits?.(document, rangeOrPosition, options, codeOptions, token);
}

@@ -180,3 +182,3 @@ }

return {
service,
plugin,
edits,

@@ -188,3 +190,3 @@ };

function createDocMap(virtualCode, documentUri, sourceLanguageId, _sourceSnapshot) {
const mapOfMap = new Map();
const mapOfMap = (0, uriMap_1.createUriMap)();
(0, language_core_1.updateVirtualCodeMapOfMap)(virtualCode, mapOfMap, sourceFileUri2 => {

@@ -198,3 +200,3 @@ if (!sourceFileUri2) {

const version = fakeVersion++;
return new documents_1.SourceMapWithDocuments(vscode_languageserver_textdocument_1.TextDocument.create(documentUri, sourceLanguageId, version, _sourceSnapshot.getText(0, _sourceSnapshot.getLength())), vscode_languageserver_textdocument_1.TextDocument.create(context.encodeEmbeddedDocumentUri(documentUri, virtualCode.id), virtualCode.languageId, version, virtualCode.snapshot.getText(0, virtualCode.snapshot.getLength())), map[1]);
return new documents_1.SourceMapWithDocuments(vscode_languageserver_textdocument_1.TextDocument.create(documentUri.toString(), sourceLanguageId, version, _sourceSnapshot.getText(0, _sourceSnapshot.getLength())), vscode_languageserver_textdocument_1.TextDocument.create(context.encodeEmbeddedDocumentUri(documentUri, virtualCode.id).toString(), virtualCode.languageId, version, virtualCode.snapshot.getText(0, virtualCode.snapshot.getLength())), map[1], virtualCode);
}

@@ -201,0 +203,0 @@ }

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
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>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
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 dedupe = require("../utils/dedupe");
const common_1 = require("../utils/common");
const cancellation_1 = require("../utils/cancellation");
const language_core_1 = require("@volar/language-core");
function register(context) {
return (uri, position, token = cancellation_1.NoneCancellationToken) => {
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, language_core_1.isHighlightEnabled), async (service, document, position) => {
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, language_core_1.isHighlightEnabled), async (plugin, document, position) => {
if (token.isCancellationRequested) {

@@ -20,3 +21,3 @@ return;

async function withLinkedCode(document, position) {
if (!service[1].provideDocumentHighlights) {
if (!plugin[1].provideDocumentHighlights) {
return;

@@ -28,7 +29,7 @@ }

recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
const references = await service[1].provideDocumentHighlights(document, position, token) ?? [];
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(document.uri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(document.uri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -35,0 +36,0 @@ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
import type { URI } from 'vscode-uri';
import type { LanguageServiceContext } from '../types';
export interface DocumentLinkData {
uri: string;
original: Pick<vscode.DocumentLink, 'data'>;
serviceIndex: number;
pluginIndex: number;
}
export declare function register(context: ServiceContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const language_core_1 = require("@volar/language-core");
const cancellation_1 = require("../utils/cancellation");

@@ -8,17 +9,16 @@ const common_1 = require("../utils/common");

const transform_1 = require("../utils/transform");
const language_core_1 = require("@volar/language-core");
function register(context) {
return async (uri, token = cancellation_1.NoneCancellationToken) => {
return await (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isDocumentLinkEnabled)(mapping.data)), async (service, document) => {
return await (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isDocumentLinkEnabled)(mapping.data)), async (plugin, document) => {
if (token.isCancellationRequested) {
return;
}
const links = await service[1].provideDocumentLinks?.(document, token);
const links = await plugin[1].provideDocumentLinks?.(document, token);
for (const link of links ?? []) {
link.data = {
uri,
uri: uri.toString(),
original: {
data: link.data,
},
serviceIndex: context.services.indexOf(service),
pluginIndex: context.plugins.indexOf(plugin),
};

@@ -42,3 +42,3 @@ }

if (link.target) {
link.target = (0, transform_1.transformDocumentLinkTarget)(link.target, context);
link.target = (0, transform_1.transformDocumentLinkTarget)(link.target, context).toString();
}

@@ -45,0 +45,0 @@ return link;

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, token?: vscode.CancellationToken, _reportProgress?: (tokens: vscode.SemanticTokens) => void) => Promise<vscode.SemanticTokens | undefined>;
import type { URI } from 'vscode-uri';
import type { LanguageServiceContext } from '../types';
export declare function register(context: LanguageServiceContext): (uri: URI, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, token?: vscode.CancellationToken, _reportProgress?: (tokens: vscode.SemanticTokens) => void) => Promise<vscode.SemanticTokens | undefined>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const language_core_1 = require("@volar/language-core");
const SemanticTokensBuilder_1 = require("../utils/SemanticTokensBuilder");

@@ -8,3 +9,2 @@ const cancellation_1 = require("../utils/cancellation");

const featureWorkers_1 = require("../utils/featureWorkers");
const language_core_1 = require("@volar/language-core");
function register(context) {

@@ -31,7 +31,7 @@ return async (uri, range, legend, token = cancellation_1.NoneCancellationToken, _reportProgress) => {

}
}, (service, document, range) => {
}, (plugin, document, range) => {
if (token?.isCancellationRequested) {
return;
}
return service[1].provideDocumentSemanticTokens?.(document, range, legend, token);
return plugin[1].provideDocumentSemanticTokens?.(document, range, legend, token);
}, (tokens, map) => {

@@ -38,0 +38,0 @@ if (!map) {

@@ -1,3 +0,4 @@

import type { ServiceContext } from '../types';
import type * as vscode from 'vscode-languageserver-protocol';
export declare function register(context: ServiceContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentSymbol[] | undefined>;
import type { URI } from 'vscode-uri';
import type { LanguageServiceContext } from '../types';
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.DocumentSymbol[] | undefined>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
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 common_1 = require("../utils/common");
const cancellation_1 = require("../utils/cancellation");
const transform_1 = require("../utils/transform");
const language_core_1 = require("@volar/language-core");
function register(context) {
return (uri, token = cancellation_1.NoneCancellationToken) => {
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isSymbolsEnabled)(mapping.data)), async (service, document) => {
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isSymbolsEnabled)(mapping.data)), async (plugin, document) => {
if (token.isCancellationRequested) {
return;
}
return service[1].provideDocumentSymbols?.(document, token);
return plugin[1].provideDocumentSymbols?.(document, token);
}, (data, map) => {

@@ -17,0 +17,0 @@ if (!map) {

@@ -1,3 +0,4 @@

import type { NullableProviderResult, ServiceContext } from '../types';
import type * as vscode from 'vscode-languageserver-protocol';
export declare function register(context: ServiceContext): (uri: string, token?: vscode.CancellationToken) => NullableProviderResult<vscode.Location[]>;
import { URI } from 'vscode-uri';
import type { NullableProviderResult, LanguageServiceContext } from '../types';
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken) => NullableProviderResult<vscode.Location[]>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
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 dedupe = require("../utils/dedupe");
const common_1 = require("../utils/common");
const cancellation_1 = require("../utils/cancellation");
const language_core_1 = require("@volar/language-core");
function register(context) {
return (uri, token = cancellation_1.NoneCancellationToken) => {
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, () => true, async (service, document) => {
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, () => true, async (plugin, document) => {
if (token.isCancellationRequested) {
return;
}
return await service[1].provideFileReferences?.(document, token) ?? [];
return await plugin[1].provideFileReferences?.(document, token) ?? [];
}, data => data
.map(reference => {
const decoded = context.decodeEmbeddedDocumentUri(reference.uri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(reference.uri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -20,0 +21,0 @@ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

@@ -1,3 +0,4 @@

import type { ServiceContext } from '../types';
import type { URI } from 'vscode-uri';
import type { LanguageServiceContext } from '../types';
import type * as _ from 'vscode-languageserver-protocol';
export declare function register(context: ServiceContext): (oldUri: string, newUri: string, token?: _.CancellationToken) => Promise<_.WorkspaceEdit | undefined>;
export declare function register(context: LanguageServiceContext): (oldUri: URI, newUri: URI, token?: _.CancellationToken) => Promise<_.WorkspaceEdit | undefined>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const cancellation_1 = require("../utils/cancellation");
const dedupe = require("../utils/dedupe");
const transform_1 = require("../utils/transform");
const dedupe = require("../utils/dedupe");
const cancellation_1 = require("../utils/cancellation");
function register(context) {
return async (oldUri, newUri, token = cancellation_1.NoneCancellationToken) => {
for (const service of context.services) {
if (context.disabledServicePlugins.has(service[1])) {
for (const plugin of context.plugins) {
if (context.disabledServicePlugins.has(plugin[1])) {
continue;

@@ -16,6 +16,6 @@ }

}
if (!service[1].provideFileRenameEdits) {
if (!plugin[1].provideFileRenameEdits) {
continue;
}
const workspaceEdit = await service[1].provideFileRenameEdits(oldUri, newUri, token);
const workspaceEdit = await plugin[1].provideFileRenameEdits(oldUri, newUri, token);
if (workspaceEdit) {

@@ -22,0 +22,0 @@ const result = (0, transform_1.transformWorkspaceEdit)(workspaceEdit, context, 'fileName');

@@ -1,3 +0,4 @@

import type { ServiceContext } from '../types';
import type { URI } from 'vscode-uri';
import type { LanguageServiceContext } from '../types';
import type * as _ from 'vscode-languageserver-protocol';
export declare function register(context: ServiceContext): (uri: string, token?: _.CancellationToken) => Promise<_.FoldingRange[] | undefined>;
export declare function register(context: LanguageServiceContext): (uri: URI, token?: _.CancellationToken) => Promise<_.FoldingRange[] | undefined>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const language_core_1 = require("@volar/language-core");
const cancellation_1 = require("../utils/cancellation");
const featureWorkers_1 = require("../utils/featureWorkers");
const cancellation_1 = require("../utils/cancellation");
const transform_1 = require("../utils/transform");
const language_core_1 = require("@volar/language-core");
function register(context) {
return (uri, token = cancellation_1.NoneCancellationToken) => {
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isFoldingRangesEnabled)(mapping.data)), (service, document) => {
return (0, featureWorkers_1.documentFeatureWorker)(context, uri, map => map.map.mappings.some(mapping => (0, language_core_1.isFoldingRangesEnabled)(mapping.data)), (plugin, document) => {
if (token.isCancellationRequested) {
return;
}
return service[1].provideFoldingRanges?.(document, token);
return plugin[1].provideFoldingRanges?.(document, token);
}, (data, map) => {

@@ -16,0 +16,0 @@ if (!map) {

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Hover | undefined>;
import type { 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>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
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 common_1 = require("../utils/common");
const transform_1 = require("../utils/transform");
const provideDiagnostics_1 = require("./provideDiagnostics");
const cancellation_1 = require("../utils/cancellation");
const transform_1 = require("../utils/transform");
const language_core_1 = require("@volar/language-core");
function register(context) {
return async (uri, position, token = cancellation_1.NoneCancellationToken) => {
let hover = await (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, language_core_1.isHoverEnabled), (service, document, position) => {
let hover = await (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, language_core_1.isHoverEnabled), (plugin, document, position) => {
if (token.isCancellationRequested) {
return;
}
return service[1].provideHover?.(document, position, token);
return plugin[1].provideHover?.(document, position, token);
}, (item, map) => {

@@ -30,3 +30,3 @@ if (!map || !item.range) {

}));
const markups = provideDiagnostics_1.errorMarkups[uri];
const markups = provideDiagnostics_1.errorMarkups.get(uri);
if (markups) {

@@ -33,0 +33,0 @@ for (const errorAndMarkup of markups) {

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
import type { URI } from 'vscode-uri';
import type { LanguageServiceContext } from '../types';
export interface InlayHintData {
uri: string;
original: Pick<vscode.CodeAction, 'data' | 'edit'>;
serviceIndex: number;
pluginIndex: number;
}
export declare function register(context: ServiceContext): (uri: string, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
export declare function register(context: LanguageServiceContext): (uri: URI, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
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 cancellation_1 = require("../utils/cancellation");
const transform_1 = require("../utils/transform");
const language_core_1 = require("@volar/language-core");
function register(context) {

@@ -23,14 +23,14 @@ return async (uri, range, token = cancellation_1.NoneCancellationToken) => {

}
}, async (service, document, arg) => {
}, async (plugin, document, arg) => {
if (token.isCancellationRequested) {
return;
}
const hints = await service[1].provideInlayHints?.(document, arg, token);
const hints = await plugin[1].provideInlayHints?.(document, arg, token);
hints?.forEach(link => {
link.data = {
uri,
uri: uri.toString(),
original: {
data: link.data,
},
serviceIndex: context.services.indexOf(service),
pluginIndex: context.plugins.indexOf(plugin),
};

@@ -37,0 +37,0 @@ });

@@ -1,3 +0,4 @@

import type { ServiceContext } from '../types';
import type * as vscode from 'vscode-languageserver-protocol';
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LinkedEditingRanges | undefined>;
import type { 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>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
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 common_1 = require("../utils/common");
const cancellation_1 = require("../utils/cancellation");
const language_core_1 = require("@volar/language-core");
function register(context) {

@@ -14,7 +14,7 @@ return (uri, position, token = cancellation_1.NoneCancellationToken) => {

}
}, (service, document, position) => {
}, (plugin, document, position) => {
if (token.isCancellationRequested) {
return;
}
return service[1].provideLinkedEditingRanges?.(document, position, token);
return plugin[1].provideLinkedEditingRanges?.(document, position, token);
}, (ranges, map) => {

@@ -21,0 +21,0 @@ if (!map) {

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, referenceContext: vscode.ReferenceContext, token?: vscode.CancellationToken) => Promise<vscode.Location[] | undefined>;
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>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
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 dedupe = require("../utils/dedupe");
const cancellation_1 = require("../utils/cancellation");
const language_core_1 = require("@volar/language-core");
function register(context) {
return (uri, position, referenceContext, token = cancellation_1.NoneCancellationToken) => {
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, language_core_1.isReferencesEnabled), async (service, document, position) => {
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, language_core_1.isReferencesEnabled), async (plugin, document, position) => {
if (token.isCancellationRequested) {

@@ -19,3 +20,3 @@ return;

async function withLinkedCode(document, position) {
if (!service[1].provideReferences) {
if (!plugin[1].provideReferences) {
return;

@@ -27,7 +28,7 @@ }

recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
const references = await service[1].provideReferences(document, position, referenceContext, token) ?? [];
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(reference.uri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(reference.uri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -55,3 +56,3 @@ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

for (const reference of data) {
const decoded = context.decodeEmbeddedDocumentUri(reference.uri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(reference.uri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -58,0 +59,0 @@ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, newName: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceEdit | undefined>;
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;

@@ -5,2 +5,3 @@ "use strict";

const language_core_1 = require("@volar/language-core");
const vscode_uri_1 = require("vscode-uri");
const cancellation_1 = require("../utils/cancellation");

@@ -24,3 +25,3 @@ const dedupe = require("../utils/dedupe");

;
}, async (service, document, params) => {
}, async (plugin, document, params) => {
if (token.isCancellationRequested) {

@@ -34,3 +35,3 @@ return;

async function withLinkedCode(document, position, newName) {
if (!service[1].provideRenameEdits) {
if (!plugin[1].provideRenameEdits) {
return;

@@ -42,3 +43,3 @@ }

recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
const workspaceEdit = await service[1].provideRenameEdits(document, position, newName, token);
const workspaceEdit = await plugin[1].provideRenameEdits(document, position, newName, token);
if (!workspaceEdit) {

@@ -56,3 +57,3 @@ return;

recursiveChecker.add({ uri: editUri, range: { start: textEdit.range.start, end: textEdit.range.start } });
const decoded = context.decodeEmbeddedDocumentUri(editUri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(editUri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -59,0 +60,0 @@ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Range | {
import type { 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;

@@ -5,0 +6,0 @@ placeholder: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const language_core_1 = require("@volar/language-core");
const cancellation_1 = require("../utils/cancellation");
const featureWorkers_1 = require("../utils/featureWorkers");
const cancellation_1 = require("../utils/cancellation");
const language_core_1 = require("@volar/language-core");
function register(context) {
return (uri, position, token = cancellation_1.NoneCancellationToken) => {
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, language_core_1.isRenameEnabled), (service, document, position) => {
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, language_core_1.isRenameEnabled), (plugin, document, position) => {
if (token.isCancellationRequested) {
return;
}
return service[1].provideRenameRange?.(document, position, token);
return plugin[1].provideRenameRange?.(document, position, token);
}, (item, map) => {

@@ -15,0 +15,0 @@ if (!map) {

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (uri: string, positions: vscode.Position[], token?: vscode.CancellationToken) => Promise<vscode.SelectionRange[] | undefined>;
import type { 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>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const language_core_1 = require("@volar/language-core");
const cancellation_1 = require("../utils/cancellation");

@@ -8,3 +9,2 @@ const common_1 = require("../utils/common");

const transform_1 = require("../utils/transform");
const language_core_1 = require("@volar/language-core");
function register(context) {

@@ -19,7 +19,7 @@ return (uri, positions, token = cancellation_1.NoneCancellationToken) => {

}
}, (service, document, positions) => {
}, (plugin, document, positions) => {
if (token.isCancellationRequested) {
return;
}
return service[1].provideSelectionRanges?.(document, positions, token);
return plugin[1].provideSelectionRanges?.(document, positions, token);
}, (data, map) => {

@@ -26,0 +26,0 @@ if (!map) {

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (uri: string, position: vscode.Position, signatureHelpContext?: vscode.SignatureHelpContext, token?: vscode.CancellationToken) => Promise<vscode.SignatureHelp | undefined>;
import type { 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>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const language_core_1 = require("@volar/language-core");
const cancellation_1 = require("../utils/cancellation");
const featureWorkers_1 = require("../utils/featureWorkers");
const cancellation_1 = require("../utils/cancellation");
const language_core_1 = require("@volar/language-core");
function register(context) {

@@ -12,3 +12,3 @@ return (uri, position, signatureHelpContext = {

}, token = cancellation_1.NoneCancellationToken) => {
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, language_core_1.isSignatureHelpEnabled), (service, document, position) => {
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, language_core_1.isSignatureHelpEnabled), (plugin, document, position) => {
if (token.isCancellationRequested) {

@@ -20,7 +20,7 @@ return;

&& !(signatureHelpContext.isRetrigger
? service[0].signatureHelpRetriggerCharacters
: service[0].signatureHelpTriggerCharacters)?.includes(signatureHelpContext.triggerCharacter)) {
? plugin[0].capabilities.signatureHelpProvider?.retriggerCharacters
: plugin[0].capabilities.signatureHelpProvider?.triggerCharacters)?.includes(signatureHelpContext.triggerCharacter)) {
return;
}
return service[1].provideSignatureHelp?.(document, position, signatureHelpContext, token);
return plugin[1].provideSignatureHelp?.(document, position, signatureHelpContext, token);
}, data => data);

@@ -27,0 +27,0 @@ };

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (query: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;
import type { LanguageServiceContext } from '../types';
export declare function register(context: LanguageServiceContext): (query: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;

@@ -7,7 +7,8 @@ "use strict";

const transform_1 = require("../utils/transform");
const vscode_uri_1 = require("vscode-uri");
function register(context) {
return async (query, token = cancellation_1.NoneCancellationToken) => {
const symbolsList = [];
for (const service of context.services) {
if (context.disabledServicePlugins.has(service[1])) {
for (const plugin of context.plugins) {
if (context.disabledServicePlugins.has(plugin[1])) {
continue;

@@ -18,6 +19,6 @@ }

}
if (!service[1].provideWorkspaceSymbols) {
if (!plugin[1].provideWorkspaceSymbols) {
continue;
}
const embeddedSymbols = await service[1].provideWorkspaceSymbols(query, token);
const embeddedSymbols = await plugin[1].provideWorkspaceSymbols(query, token);
if (!embeddedSymbols) {

@@ -27,3 +28,3 @@ continue;

const symbols = embeddedSymbols.map(symbol => (0, transform_1.transformWorkspaceSymbol)(symbol, loc => {
const decoded = context.decodeEmbeddedDocumentUri(loc.uri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(loc.uri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -30,0 +31,0 @@ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (item: vscode.CodeAction, token?: vscode.CancellationToken) => Promise<vscode.CodeAction>;
import type { LanguageServiceContext } from '../types';
export declare function register(context: LanguageServiceContext): (item: vscode.CodeAction, token?: vscode.CancellationToken) => Promise<vscode.CodeAction>;

@@ -10,9 +10,9 @@ "use strict";

if (data) {
const service = context.services[data.serviceIndex];
if (!service[1].resolveCodeAction) {
const plugin = context.plugins[data.pluginIndex];
if (!plugin[1].resolveCodeAction) {
return item;
}
Object.assign(item, data.original);
item = await service[1].resolveCodeAction(item, token);
item = service[1].transformCodeAction?.(item)
item = await plugin[1].resolveCodeAction(item, token);
item = plugin[1].transformCodeAction?.(item)
?? (item.edit

@@ -19,0 +19,0 @@ ? {

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
import type { LanguageServiceContext } from '../types';
export declare function register(context: LanguageServiceContext): (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = void 0;
const vscode_uri_1 = require("vscode-uri");
const cancellation_1 = require("../utils/cancellation");
const references = require("./provideReferences");
const cancellation_1 = require("../utils/cancellation");
function register(context) {

@@ -11,12 +12,12 @@ const findReferences = references.register(context);

if (data?.kind === 'normal') {
const service = context.services[data.serviceIndex];
if (!service[1].resolveCodeLens) {
const plugin = context.plugins[data.pluginIndex];
if (!plugin[1].resolveCodeLens) {
return item;
}
Object.assign(item, data.original);
item = await service[1].resolveCodeLens(item, token);
item = await plugin[1].resolveCodeLens(item, token);
// item.range already transformed in codeLens request
}
if (data?.kind === 'references') {
const references = await findReferences(data.sourceFileUri, item.range.start, { includeDeclaration: false }, token) ?? [];
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);

@@ -23,0 +24,0 @@ }

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (item: vscode.CompletionItem, token?: vscode.CancellationToken) => Promise<vscode.CompletionItem>;
import type { LanguageServiceContext } from '../types';
export declare function register(context: LanguageServiceContext): (item: vscode.CompletionItem, token?: vscode.CancellationToken) => Promise<vscode.CompletionItem>;

@@ -6,2 +6,3 @@ "use strict";

const transform_1 = require("../utils/transform");
const vscode_uri_1 = require("vscode-uri");
function register(context) {

@@ -11,4 +12,4 @@ return async (item, token = cancellation_1.NoneCancellationToken) => {

if (data) {
const service = context.services[data.serviceIndex];
if (!service[1].resolveCompletionItem) {
const plugin = context.plugins[data.pluginIndex];
if (!plugin[1].resolveCompletionItem) {
return item;

@@ -18,3 +19,3 @@ }

if (data.embeddedDocumentUri) {
const decoded = context.decodeEmbeddedDocumentUri(data.embeddedDocumentUri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(data.embeddedDocumentUri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -24,4 +25,4 @@ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

for (const map of context.documents.getMaps(virtualCode)) {
item = await service[1].resolveCompletionItem(item, token);
item = service[1].transformCompletionItem?.(item) ?? (0, transform_1.transformCompletionItem)(item, embeddedRange => map.getSourceRange(embeddedRange), map.embeddedDocument, context);
item = await plugin[1].resolveCompletionItem(item, token);
item = plugin[1].transformCompletionItem?.(item) ?? (0, transform_1.transformCompletionItem)(item, embeddedRange => map.getSourceRange(embeddedRange), map.embeddedDocument, context);
}

@@ -31,3 +32,3 @@ }

else {
item = await service[1].resolveCompletionItem(item, token);
item = await plugin[1].resolveCompletionItem(item, token);
}

@@ -34,0 +35,0 @@ }

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (item: vscode.DocumentLink, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink>;
import type { LanguageServiceContext } from '../types';
export declare function register(context: LanguageServiceContext): (item: vscode.DocumentLink, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink>;

@@ -10,10 +10,10 @@ "use strict";

if (data) {
const service = context.services[data.serviceIndex];
if (!service[1].resolveDocumentLink) {
const plugin = context.plugins[data.pluginIndex];
if (!plugin[1].resolveDocumentLink) {
return item;
}
Object.assign(item, data.original);
item = await service[1].resolveDocumentLink(item, token);
item = await plugin[1].resolveDocumentLink(item, token);
if (item.target) {
item.target = (0, transform_1.transformDocumentLinkTarget)(item.target, context);
item.target = (0, transform_1.transformDocumentLinkTarget)(item.target, context).toString();
}

@@ -20,0 +20,0 @@ }

import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext } from '../types';
export declare function register(context: ServiceContext): (item: vscode.InlayHint, token?: vscode.CancellationToken) => Promise<vscode.InlayHint>;
import type { LanguageServiceContext } from '../types';
export declare function register(context: LanguageServiceContext): (item: vscode.InlayHint, token?: vscode.CancellationToken) => Promise<vscode.InlayHint>;

@@ -9,8 +9,8 @@ "use strict";

if (data) {
const service = context.services[data.serviceIndex];
if (!service[1].resolveInlayHint) {
const plugin = context.plugins[data.pluginIndex];
if (!plugin[1].resolveInlayHint) {
return item;
}
Object.assign(item, data.original);
item = await service[1].resolveInlayHint(item, token);
item = await plugin[1].resolveInlayHint(item, token);
}

@@ -17,0 +17,0 @@ return item;

import { type Language } from '@volar/language-core';
import type * as vscode from 'vscode-languageserver-protocol';
import type { ServiceContext, ServiceEnvironment, LanguageServicePlugin } from './types';
import { URI } from 'vscode-uri';
import type { LanguageServicePlugin, LanguageServiceContext, LanguageServiceEnvironment } from './types';
export type LanguageService = ReturnType<typeof createLanguageService>;
export declare function createLanguageService(language: Language, servicePlugins: LanguageServicePlugin[], env: ServiceEnvironment): {
export declare function createLanguageService(language: Language<URI>, plugins: LanguageServicePlugin[], env: LanguageServiceEnvironment): {
getSemanticTokenLegend: () => {
tokenModifiers: string[];
tokenTypes: string[];
};
getTriggerCharacters: () => string[];

@@ -10,19 +15,19 @@ getAutoFormatTriggerCharacters: () => string[];

getSignatureHelpRetriggerCharacters: () => string[];
format: (uri: string, options: vscode.FormattingOptions, range: vscode.Range | undefined, onTypeParams: {
format: (uri: URI, options: vscode.FormattingOptions, range: vscode.Range | undefined, onTypeParams: {
ch: string;
position: vscode.Position;
} | undefined, token?: vscode.CancellationToken) => Promise<vscode.TextEdit[] | undefined>;
getFoldingRanges: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.FoldingRange[] | undefined>;
getSelectionRanges: (uri: string, positions: vscode.Position[], token?: vscode.CancellationToken) => Promise<vscode.SelectionRange[] | undefined>;
findLinkedEditingRanges: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LinkedEditingRanges | undefined>;
findDocumentSymbols: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentSymbol[] | undefined>;
findDocumentColors: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.ColorInformation[] | undefined>;
getColorPresentations: (uri: string, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.ColorPresentation[] | undefined>;
doValidation: (uri: string, token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
findReferences: (uri: string, position: vscode.Position, referenceContext: vscode.ReferenceContext, token?: vscode.CancellationToken) => Promise<vscode.Location[] | undefined>;
findFileReferences: (uri: string, token?: vscode.CancellationToken) => import("./types").NullableProviderResult<vscode.Location[]>;
findDefinition: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
findTypeDefinition: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
findImplementations: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
prepareRename: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Range | {
getFoldingRanges: (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.FoldingRange[] | undefined>;
getSelectionRanges: (uri: URI, positions: vscode.Position[], token?: vscode.CancellationToken) => Promise<vscode.SelectionRange[] | undefined>;
findLinkedEditingRanges: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LinkedEditingRanges | undefined>;
findDocumentSymbols: (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.DocumentSymbol[] | undefined>;
findDocumentColors: (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.ColorInformation[] | undefined>;
getColorPresentations: (uri: URI, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.ColorPresentation[] | undefined>;
doValidation: (uri: URI, token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
findReferences: (uri: URI, position: vscode.Position, referenceContext: vscode.ReferenceContext, token?: vscode.CancellationToken) => Promise<vscode.Location[] | undefined>;
findFileReferences: (uri: URI, token?: vscode.CancellationToken) => import("./types").NullableProviderResult<vscode.Location[]>;
findDefinition: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
findTypeDefinition: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
findImplementations: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
prepareRename: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Range | {
range: vscode.Range;

@@ -33,27 +38,27 @@ placeholder: string;

} | undefined>;
doRename: (uri: string, position: vscode.Position, newName: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceEdit | undefined>;
getEditsForFileRename: (oldUri: string, newUri: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceEdit | undefined>;
getSemanticTokens: (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, token?: vscode.CancellationToken, _reportProgress?: ((tokens: vscode.SemanticTokens) => void) | undefined) => Promise<vscode.SemanticTokens | undefined>;
doHover: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Hover | undefined>;
doComplete: (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext, token?: vscode.CancellationToken) => Promise<vscode.CompletionList>;
doCodeActions: (uri: string, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token?: vscode.CancellationToken) => Promise<vscode.CodeAction[] | undefined>;
doRename: (uri: URI, position: vscode.Position, newName: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceEdit | undefined>;
getEditsForFileRename: (oldUri: URI, newUri: URI, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceEdit | undefined>;
getSemanticTokens: (uri: URI, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, token?: vscode.CancellationToken, _reportProgress?: ((tokens: vscode.SemanticTokens) => void) | undefined) => Promise<vscode.SemanticTokens | undefined>;
doHover: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Hover | undefined>;
doComplete: (uri: URI, position: vscode.Position, completionContext?: vscode.CompletionContext, token?: vscode.CancellationToken) => Promise<vscode.CompletionList>;
doCodeActions: (uri: URI, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token?: vscode.CancellationToken) => Promise<vscode.CodeAction[] | undefined>;
doCodeActionResolve: (item: vscode.CodeAction, token?: vscode.CancellationToken) => Promise<vscode.CodeAction>;
doCompletionResolve: (item: vscode.CompletionItem, token?: vscode.CancellationToken) => Promise<vscode.CompletionItem>;
getSignatureHelp: (uri: string, position: vscode.Position, signatureHelpContext?: vscode.SignatureHelpContext, token?: vscode.CancellationToken) => Promise<vscode.SignatureHelp | undefined>;
doCodeLens: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
getSignatureHelp: (uri: URI, position: vscode.Position, signatureHelpContext?: vscode.SignatureHelpContext, token?: vscode.CancellationToken) => Promise<vscode.SignatureHelp | undefined>;
doCodeLens: (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
doCodeLensResolve: (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
findDocumentHighlights: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
findDocumentLinks: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
findDocumentHighlights: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
findDocumentLinks: (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
doDocumentLinkResolve: (item: vscode.DocumentLink, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink>;
findWorkspaceSymbols: (query: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;
doAutoInsert: (uri: string, selection: vscode.Position, change: {
doAutoInsert: (uri: URI, selection: vscode.Position, change: {
rangeOffset: number;
rangeLength: number;
text: string;
}, token?: vscode.CancellationToken) => Promise<string | vscode.TextEdit | undefined>;
doDocumentDrop: (uri: string, position: vscode.Position, dataTransfer: Map<string, import("./types").DataTransferItem>, token?: vscode.CancellationToken) => Promise<import("./types").DocumentDropEdit | undefined>;
getInlayHints: (uri: string, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
}, token?: vscode.CancellationToken) => Promise<string | undefined>;
doDocumentDrop: (uri: URI, position: vscode.Position, dataTransfer: Map<string, import("./types").DataTransferItem>, token?: vscode.CancellationToken) => Promise<import("./types").DocumentDropEdit | undefined>;
getInlayHints: (uri: URI, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
doInlayHintResolve: (item: vscode.InlayHint, token?: vscode.CancellationToken) => Promise<vscode.InlayHint>;
callHierarchy: {
doPrepare(uri: string, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
doPrepare(uri: URI, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
getIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;

@@ -63,3 +68,3 @@ getOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;

dispose: () => void;
context: ServiceContext;
context: LanguageServiceContext;
};

@@ -5,4 +5,6 @@ "use strict";

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 documents_1 = require("./documents");
const autoInsert = require("./features/provideAutoInsertionEdit");
const autoInsert = require("./features/provideAutoInsertSnippet");
const callHierarchy = require("./features/provideCallHierarchyItems");

@@ -39,5 +41,5 @@ const codeActions = require("./features/provideCodeActions");

const inlayHintResolve = require("./features/resolveInlayHint");
const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
function createLanguageService(language, servicePlugins, env) {
const documentVersions = new Map();
const uriMap_1 = require("./utils/uriMap");
function createLanguageService(language, plugins, env) {
const documentVersions = (0, uriMap_1.createUriMap)();
const map2DocMap = new WeakMap();

@@ -52,3 +54,3 @@ const mirrorMap2DocMirrorMap = new WeakMap();

if (!snapshot2Doc.has(snapshot)) {
snapshot2Doc.set(snapshot, new Map());
snapshot2Doc.set(snapshot, (0, uriMap_1.createUriMap)());
}

@@ -59,3 +61,3 @@ const map = snapshot2Doc.get(snapshot);

documentVersions.set(uri, version + 1);
map.set(uri, vscode_languageserver_textdocument_1.TextDocument.create(uri, languageId, version, snapshot.getText(0, snapshot.getLength())));
map.set(uri, vscode_languageserver_textdocument_1.TextDocument.create(uri.toString(), languageId, version, snapshot.getText(0, snapshot.getLength())));
}

@@ -68,3 +70,3 @@ return map.get(uri);

const embeddedUri = context.encodeEmbeddedDocumentUri(uri, virtualCode.id);
map2DocMap.set(map, new documents_1.SourceMapWithDocuments(this.get(uri, context.language.scripts.get(uri).languageId, snapshot), this.get(embeddedUri, virtualCode.languageId, virtualCode.snapshot), map));
map2DocMap.set(map, new documents_1.SourceMapWithDocuments(this.get(uri, context.language.scripts.get(uri).languageId, snapshot), this.get(embeddedUri, virtualCode.languageId, virtualCode.snapshot), map, virtualCode));
}

@@ -74,8 +76,8 @@ yield map2DocMap.get(map);

},
getLinkedCodeMap(virtualCode, sourceScriptId) {
getLinkedCodeMap(virtualCode, documentUri) {
const map = context.language.linkedCodeMaps.get(virtualCode);
if (map) {
if (!mirrorMap2DocMirrorMap.has(map)) {
const embeddedUri = context.encodeEmbeddedDocumentUri(sourceScriptId, virtualCode.id);
mirrorMap2DocMirrorMap.set(map, new documents_1.LinkedCodeMapWithDocument(this.get(embeddedUri, virtualCode.languageId, virtualCode.snapshot), map));
const embeddedUri = context.encodeEmbeddedDocumentUri(documentUri, virtualCode.id);
mirrorMap2DocMirrorMap.set(map, new documents_1.LinkedCodeMapWithDocument(this.get(embeddedUri, virtualCode.languageId, virtualCode.snapshot), map, virtualCode));
}

@@ -88,7 +90,7 @@ return mirrorMap2DocMirrorMap.get(map);

inject: (key, ...args) => {
for (const service of context.services) {
if (context.disabledServicePlugins.has(service[1])) {
for (const plugin of context.plugins) {
if (context.disabledServicePlugins.has(plugin[1])) {
continue;
}
const provide = service[1].provide?.[key];
const provide = plugin[1].provide?.[key];
if (provide) {

@@ -99,3 +101,3 @@ return provide(...args);

},
services: [],
plugins: [],
commands: {

@@ -153,12 +155,11 @@ rename: {

},
disabledEmbeddedDocumentUris: new Set(),
disabledEmbeddedDocumentUris: (0, uriMap_1.createUriMap)(),
disabledServicePlugins: new WeakSet(),
decodeEmbeddedDocumentUri(maybeEmbeddedContentUri) {
if (maybeEmbeddedContentUri.startsWith(`${embeddedContentScheme}://`)) {
const trimed = maybeEmbeddedContentUri.substring(`${embeddedContentScheme}://`.length);
const embeddedCodeId = trimed.substring(0, trimed.indexOf('/'));
const documentUri = trimed.substring(embeddedCodeId.length + 1);
if (maybeEmbeddedContentUri.scheme === embeddedContentScheme) {
const embeddedCodeId = decodeURIComponent(maybeEmbeddedContentUri.authority);
const documentUri = decodeURIComponent(maybeEmbeddedContentUri.path.substring(1));
return [
decodeURIComponent(documentUri),
decodeURIComponent(embeddedCodeId),
vscode_uri_1.URI.parse(documentUri),
embeddedCodeId,
];

@@ -168,10 +169,22 @@ }

encodeEmbeddedDocumentUri(documentUri, embeddedContentId) {
return `${embeddedContentScheme}://${encodeURIComponent(embeddedContentId)}/${encodeURIComponent(documentUri)}`;
return vscode_uri_1.URI.from({
scheme: embeddedContentScheme,
authority: encodeURIComponent(embeddedContentId),
path: '/' + encodeURIComponent(documentUri.toString()),
});
},
};
const api = {
getTriggerCharacters: () => servicePlugins.map(service => service.triggerCharacters ?? []).flat(),
getAutoFormatTriggerCharacters: () => servicePlugins.map(service => service.autoFormatTriggerCharacters ?? []).flat(),
getSignatureHelpTriggerCharacters: () => servicePlugins.map(service => service.signatureHelpTriggerCharacters ?? []).flat(),
getSignatureHelpRetriggerCharacters: () => servicePlugins.map(service => service.signatureHelpRetriggerCharacters ?? []).flat(),
getSemanticTokenLegend: () => {
const tokenModifiers = plugins.map(plugin => plugin.capabilities.semanticTokensProvider?.legend?.tokenModifiers ?? []).flat();
const tokenTypes = plugins.map(plugin => plugin.capabilities.semanticTokensProvider?.legend?.tokenTypes ?? []).flat();
return {
tokenModifiers: [...new Set(tokenModifiers)],
tokenTypes: [...new Set(tokenTypes)],
};
},
getTriggerCharacters: () => plugins.map(plugin => plugin.capabilities.completionProvider?.triggerCharacters ?? []).flat(),
getAutoFormatTriggerCharacters: () => plugins.map(plugin => plugin.capabilities.documentOnTypeFormattingProvider?.triggerCharacters ?? []).flat(),
getSignatureHelpTriggerCharacters: () => plugins.map(plugin => plugin.capabilities.signatureHelpProvider?.triggerCharacters ?? []).flat(),
getSignatureHelpRetriggerCharacters: () => plugins.map(plugin => plugin.capabilities.signatureHelpProvider?.retriggerCharacters ?? []).flat(),
format: format.register(context),

@@ -211,7 +224,7 @@ getFoldingRanges: foldingRanges.register(context),

callHierarchy: callHierarchy.register(context),
dispose: () => context.services.forEach(service => service[1].dispose?.()),
dispose: () => context.plugins.forEach(plugin => plugin[1].dispose?.()),
context,
};
for (const servicePlugin of servicePlugins) {
context.services.push([servicePlugin, servicePlugin.create(context, api)]);
for (const plugin of plugins) {
context.plugins.push([plugin, plugin.create(context, api)]);
}

@@ -218,0 +231,0 @@ return api;

@@ -7,9 +7,7 @@ import type { Language, SourceScript, VirtualCode } from '@volar/language-core';

import type { LanguageService } from './languageService';
import type { URI } from 'vscode-uri';
import type { UriMap } from './utils/uriMap';
export type * from 'vscode-languageserver-protocol';
export interface ServiceEnvironment {
workspaceFolder: string;
typescript?: {
uriToFileName(uri: string): string;
fileNameToUri(fileName: string): string;
};
export interface LanguageServiceEnvironment {
workspaceFolders: URI[];
locale?: string;

@@ -24,5 +22,5 @@ clientCapabilities?: vscode.ClientCapabilities;

export interface FileSystem {
stat(uri: string): ProviderResult<FileStat | undefined>;
readDirectory(uri: string): ProviderResult<[string, FileType][]>;
readFile(uri: string, encoding?: string): ProviderResult<string | undefined>;
stat(uri: URI): ProviderResult<FileStat | undefined>;
readDirectory(uri: URI): ProviderResult<[string, FileType][]>;
readFile(uri: URI, encoding?: string): ProviderResult<string | undefined>;
}

@@ -41,28 +39,28 @@ export interface FileStat {

}
export interface ServiceCommand<T extends any[]> {
export interface LanguageServiceCommand<T extends any[]> {
create(...args: T): vscode.Command | undefined;
is(value: vscode.Command): boolean;
}
export interface ServiceContext {
language: Language;
env: ServiceEnvironment;
export interface LanguageServiceContext {
language: Language<URI>;
env: LanguageServiceEnvironment;
inject<Provide, K extends keyof Provide = keyof Provide>(key: K, ...args: Provide[K] extends (...args: any) => any ? Parameters<Provide[K]> : never): ReturnType<Provide[K] extends (...args: any) => any ? Provide[K] : never> | undefined;
commands: {
showReferences: ServiceCommand<[uri: string, position: vscode.Position, locations: vscode.Location[]]>;
rename: ServiceCommand<[uri: string, position: vscode.Position]>;
setSelection: ServiceCommand<[position: vscode.Position]>;
showReferences: LanguageServiceCommand<[uri: string, position: vscode.Position, locations: vscode.Location[]]>;
rename: LanguageServiceCommand<[uri: string, position: vscode.Position]>;
setSelection: LanguageServiceCommand<[position: vscode.Position]>;
};
documents: {
get(uri: string, languageId: string, snapshot: ts.IScriptSnapshot): TextDocument;
get(uri: URI, languageId: string, snapshot: ts.IScriptSnapshot): TextDocument;
getMaps(virtualCode: VirtualCode): Generator<SourceMapWithDocuments>;
getLinkedCodeMap(virtualCode: VirtualCode, sourceScriptId: string): LinkedCodeMapWithDocument | undefined;
getLinkedCodeMap(virtualCode: VirtualCode, documentUri: URI): LinkedCodeMapWithDocument | undefined;
};
services: [LanguageServicePlugin, LanguageServicePluginInstance][];
disabledEmbeddedDocumentUris: Set<string>;
plugins: [LanguageServicePlugin, LanguageServicePluginInstance][];
disabledEmbeddedDocumentUris: UriMap<boolean>;
disabledServicePlugins: WeakSet<LanguageServicePluginInstance>;
decodeEmbeddedDocumentUri(maybeEmbeddedUri: string): [
documentUri: string,
decodeEmbeddedDocumentUri(maybeEmbeddedUri: URI): [
documentUri: URI,
embeddedCodeId: string
] | undefined;
encodeEmbeddedDocumentUri(uri: string, embeededCodeId: string): string;
encodeEmbeddedDocumentUri(uri: URI, embeededCodeId: string): URI;
}

@@ -80,11 +78,54 @@ export type ProviderResult<T> = T | Thenable<T>;

name?: string;
triggerCharacters?: string[];
signatureHelpTriggerCharacters?: string[];
signatureHelpRetriggerCharacters?: string[];
autoFormatTriggerCharacters?: string[];
/**
* @deprecated languageService instance must be passed
*/
create(context: ServiceContext): LanguageServicePluginInstance<P>;
create(context: ServiceContext, languageService: LanguageService): LanguageServicePluginInstance<P>;
capabilities: {
selectionRangeProvider?: boolean;
foldingRangeProvider?: boolean;
linkedEditingRangeProvider?: boolean;
colorProvider?: boolean;
documentSymbolProvider?: boolean;
documentFormattingProvider?: boolean;
referencesProvider?: boolean;
implementationProvider?: boolean;
definitionProvider?: boolean;
typeDefinitionProvider?: boolean;
callHierarchyProvider?: boolean;
hoverProvider?: boolean;
documentHighlightProvider?: boolean;
workspaceSymbolProvider?: boolean;
renameProvider?: {
prepareProvider?: boolean;
};
signatureHelpProvider?: {
triggerCharacters?: string[];
retriggerCharacters?: string[];
};
completionProvider?: {
resolveProvider?: boolean;
triggerCharacters?: string[];
};
autoInsertionProvider?: {
triggerCharacters: string[];
configurationSections?: string[];
};
documentOnTypeFormattingProvider?: {
triggerCharacters: string[];
};
documentLinkProvider?: {
resolveProvider?: boolean;
};
codeLensProvider?: {
resolveProvider?: boolean;
};
inlayHintProvider?: {
resolveProvider?: boolean;
};
semanticTokensProvider?: {
legend: vscode.SemanticTokensLegend;
};
codeActionProvider?: {
codeActionKinds?: string[];
resolveProvider?: boolean;
};
diagnosticProvider?: boolean;
};
create(context: LanguageServiceContext, languageService: LanguageService): LanguageServicePluginInstance<P>;
}

@@ -134,8 +175,8 @@ export interface EmbeddedCodeFormattingOptions {

provideReferencesCodeLensRanges?(document: TextDocument, token: vscode.CancellationToken): NullableProviderResult<vscode.Range[]>;
provideAutoInsertionEdit?(document: TextDocument, position: vscode.Position, lastChange: {
provideAutoInsertSnippet?(document: TextDocument, position: vscode.Position, lastChange: {
rangeOffset: number;
rangeLength: number;
text: string;
}, token: vscode.CancellationToken): NullableProviderResult<string | vscode.TextEdit>;
provideFileRenameEdits?(oldUri: string, newUri: string, token: vscode.CancellationToken): NullableProviderResult<vscode.WorkspaceEdit>;
}, token: vscode.CancellationToken): NullableProviderResult<string>;
provideFileRenameEdits?(oldUri: URI, newUri: URI, token: vscode.CancellationToken): NullableProviderResult<vscode.WorkspaceEdit>;
provideDocumentDropEdits?(document: TextDocument, position: vscode.Position, dataTransfer: Map<string, DataTransferItem>, token: vscode.CancellationToken): NullableProviderResult<DocumentDropEdit>;

@@ -147,3 +188,3 @@ resolveCodeLens?(codeLens: vscode.CodeLens, token: vscode.CancellationToken): ProviderResult<vscode.CodeLens>;

resolveInlayHint?(inlayHint: vscode.InlayHint, token: vscode.CancellationToken): ProviderResult<vscode.InlayHint>;
resolveEmbeddedCodeFormattingOptions?(sourceScript: SourceScript, embeddedCode: VirtualCode, options: EmbeddedCodeFormattingOptions, token: vscode.CancellationToken): NullableProviderResult<EmbeddedCodeFormattingOptions>;
resolveEmbeddedCodeFormattingOptions?(sourceScript: SourceScript<URI>, embeddedCode: VirtualCode, options: EmbeddedCodeFormattingOptions, token: vscode.CancellationToken): NullableProviderResult<EmbeddedCodeFormattingOptions>;
transformCompletionItem?(item: vscode.CompletionItem): vscode.CompletionItem | undefined;

@@ -150,0 +191,0 @@ transformCodeAction?(item: vscode.CodeAction): vscode.CodeAction | undefined;

@@ -8,3 +8,3 @@ import type * as vscode from 'vscode-languageserver-protocol';

export declare function withTextEdits<T extends vscode.TextEdit>(items: T[]): T[];
export declare function withDocumentChanges(items: NonNullable<vscode.WorkspaceEdit['documentChanges']>): (vscode.CreateFile | vscode.TextDocumentEdit | vscode.RenameFile | vscode.DeleteFile)[];
export declare function withDocumentChanges(items: NonNullable<vscode.WorkspaceEdit['documentChanges']>): (vscode.TextDocumentEdit | vscode.CreateFile | vscode.RenameFile | vscode.DeleteFile)[];
export declare function withDiagnostics<T extends vscode.Diagnostic>(items: T[]): T[];

@@ -11,0 +11,0 @@ export declare function withLocations<T extends vscode.Location>(items: T[]): T[];

@@ -1,9 +0,10 @@

import type { CodeInformation, VirtualCode } from '@volar/language-core';
import type { VirtualCode } from '@volar/language-core';
import type { TextDocument } from 'vscode-languageserver-textdocument';
import type { URI } from 'vscode-uri';
import type { SourceMapWithDocuments } from '../documents';
import type { ServiceContext, LanguageServicePluginInstance, LanguageServicePlugin } from '../types';
export declare function documentFeatureWorker<T>(context: ServiceContext, uri: string, valid: (map: SourceMapWithDocuments<CodeInformation>) => boolean, worker: (service: [LanguageServicePlugin, LanguageServicePluginInstance], document: TextDocument) => Thenable<T | null | undefined> | T | null | undefined, transformResult: (result: T, map?: SourceMapWithDocuments<CodeInformation>) => T | undefined, combineResult?: (results: T[]) => T): Promise<T | undefined>;
export declare function languageFeatureWorker<T, K>(context: ServiceContext, uri: string, getReadDocParams: () => K, eachVirtualDocParams: (map: SourceMapWithDocuments<CodeInformation>) => Generator<K>, worker: (service: [LanguageServicePlugin, LanguageServicePluginInstance], document: TextDocument, params: K, map?: SourceMapWithDocuments<CodeInformation>) => Thenable<T | null | undefined> | T | null | undefined, transformResult: (result: T, map?: SourceMapWithDocuments<CodeInformation>) => T | undefined, combineResult?: (results: T[]) => T): Promise<T | undefined>;
import type { LanguageServicePlugin, LanguageServicePluginInstance, LanguageServiceContext } from '../types';
export declare function documentFeatureWorker<T>(context: LanguageServiceContext, uri: URI, valid: (map: SourceMapWithDocuments) => boolean, worker: (plugin: [LanguageServicePlugin, LanguageServicePluginInstance], document: TextDocument) => Thenable<T | null | undefined> | T | null | undefined, transformResult: (result: T, map?: SourceMapWithDocuments) => T | undefined, combineResult?: (results: T[]) => T): Promise<T | undefined>;
export declare function languageFeatureWorker<T, K>(context: LanguageServiceContext, uri: URI, getRealDocParams: () => K, eachVirtualDocParams: (map: SourceMapWithDocuments) => Generator<K>, worker: (plugin: [LanguageServicePlugin, LanguageServicePluginInstance], document: TextDocument, params: K, map?: SourceMapWithDocuments) => Thenable<T | null | undefined> | T | null | undefined, transformResult: (result: T, map?: SourceMapWithDocuments) => T | undefined, combineResult?: (results: T[]) => T): Promise<T | undefined>;
export declare function safeCall<T>(cb: () => Thenable<T> | T, errorMsg?: string): Promise<T | undefined>;
export declare function forEachEmbeddedDocument(context: ServiceContext, sourceScriptId: string, current: VirtualCode): Generator<SourceMapWithDocuments<CodeInformation>>;
export declare function getEmbeddedFilesByLevel(context: ServiceContext, sourceFileUri: string, rootFile: VirtualCode, level: number): VirtualCode[];
export declare function forEachEmbeddedDocument(context: LanguageServiceContext, sourceScriptId: URI, current: VirtualCode): Generator<SourceMapWithDocuments>;
export declare function getEmbeddedFilesByLevel(context: LanguageServiceContext, sourceFileUri: URI, rootFile: VirtualCode, level: number): VirtualCode[];

@@ -12,3 +12,3 @@ "use strict";

exports.documentFeatureWorker = documentFeatureWorker;
async function languageFeatureWorker(context, uri, getReadDocParams, eachVirtualDocParams, worker, transformResult, combineResult) {
async function languageFeatureWorker(context, uri, getRealDocParams, eachVirtualDocParams, worker, transformResult, combineResult) {
const sourceScript = context.language.scripts.get(uri);

@@ -21,19 +21,25 @@ if (!sourceScript) {

for (const map of forEachEmbeddedDocument(context, sourceScript.id, sourceScript.generated.root)) {
if (results.length && !combineResult) {
continue;
}
for (const mappedArg of eachVirtualDocParams(map)) {
for (const [serviceId, service] of Object.entries(context.services)) {
if (context.disabledServicePlugins.has(service[1])) {
if (results.length && !combineResult) {
continue;
}
for (const [pluginIndex, plugin] of Object.entries(context.plugins)) {
if (context.disabledServicePlugins.has(plugin[1])) {
continue;
}
const embeddedResult = await safeCall(() => worker(service, map.embeddedDocument, mappedArg, map), 'service ' + serviceId + ' crashed on ' + map.embeddedDocument.uri);
if (!embeddedResult) {
if (results.length && !combineResult) {
continue;
}
const result = transformResult(embeddedResult, map);
if (!result) {
const rawResult = await safeCall(() => worker(plugin, map.embeddedDocument, mappedArg, map), `Language service plugin "${plugin[0].name}" (${pluginIndex}) failed to provide document feature for ${map.embeddedDocument.uri}.`);
if (!rawResult) {
continue;
}
results.push(result);
if (!combineResult) {
break;
const mappedResult = transformResult(rawResult, map);
if (!mappedResult) {
continue;
}
results.push(mappedResult);
}

@@ -45,8 +51,8 @@ }

const document = context.documents.get(uri, sourceScript.languageId, sourceScript.snapshot);
const params = getReadDocParams();
for (const [serviceId, service] of Object.entries(context.services)) {
if (context.disabledServicePlugins.has(service[1])) {
const params = getRealDocParams();
for (const [pluginIndex, plugin] of Object.entries(context.plugins)) {
if (context.disabledServicePlugins.has(plugin[1])) {
continue;
}
const embeddedResult = await safeCall(() => worker(service, document, params, undefined), 'service ' + serviceId + ' crashed on ' + uri);
const embeddedResult = await safeCall(() => worker(plugin, document, params, undefined), `Language service plugin "${plugin[0].name}" (${pluginIndex}) failed to provide document feature for ${document.uri}.`);
if (!embeddedResult) {

@@ -66,3 +72,4 @@ continue;

if (combineResult && results.length > 0) {
return combineResult(results);
const combined = combineResult(results);
return combined;
}

@@ -90,4 +97,4 @@ else if (results.length > 0) {

for (const map of context.documents.getMaps(current)) {
if (sourceScriptId === map.sourceDocument.uri
&& !context.disabledEmbeddedDocumentUris.has(context.encodeEmbeddedDocumentUri(sourceScriptId, current.id))) {
if (sourceScriptId.toString() === map.sourceDocument.uri
&& !context.disabledEmbeddedDocumentUris.get(context.encodeEmbeddedDocumentUri(sourceScriptId, current.id))) {
yield map;

@@ -108,3 +115,3 @@ }

for (const embedded of file.embeddedCodes) {
if (!context.disabledEmbeddedDocumentUris.has(context.encodeEmbeddedDocumentUri(sourceFileUri, embedded.id))) {
if (!context.disabledEmbeddedDocumentUris.get(context.encodeEmbeddedDocumentUri(sourceFileUri, embedded.id))) {
nextLevel.push(embedded);

@@ -111,0 +118,0 @@ }

import type * as vscode from 'vscode-languageserver-protocol';
import { URI } from 'vscode-uri';
import type { TextDocument } from 'vscode-languageserver-textdocument';
import type { ServiceContext } from '../types';
export declare function transformDocumentLinkTarget(target: string, context: ServiceContext): string;
export declare function transformMarkdown(content: string, context: ServiceContext): string;
export declare function transformCompletionItem<T extends vscode.CompletionItem>(item: T, getOtherRange: (range: vscode.Range) => vscode.Range | undefined, document: vscode.TextDocument, context: ServiceContext): T;
export declare function transformCompletionList<T extends vscode.CompletionList>(completionList: T, getOtherRange: (range: vscode.Range) => vscode.Range | undefined, document: TextDocument, context: ServiceContext): T;
import type { LanguageServiceContext } from '../types';
export declare function transformDocumentLinkTarget(_target: string, context: LanguageServiceContext): URI;
export declare function transformMarkdown(content: string, context: LanguageServiceContext): string;
export declare function transformCompletionItem<T extends vscode.CompletionItem>(item: T, getOtherRange: (range: vscode.Range) => vscode.Range | undefined, document: vscode.TextDocument, context: LanguageServiceContext): T;
export declare function transformCompletionList<T extends vscode.CompletionList>(completionList: T, getOtherRange: (range: vscode.Range) => vscode.Range | undefined, document: TextDocument, context: LanguageServiceContext): T;
export declare function transformDocumentSymbol(symbol: vscode.DocumentSymbol, getOtherRange: (range: vscode.Range) => vscode.Range | undefined): vscode.DocumentSymbol | undefined;

@@ -21,3 +22,3 @@ export declare function transformFoldingRanges(ranges: vscode.FoldingRange[], getOtherRange: (range: vscode.Range) => vscode.Range | undefined): vscode.FoldingRange[];

export declare function transformWorkspaceSymbol(symbol: vscode.WorkspaceSymbol, getOtherLocation: (location: vscode.Location) => vscode.Location | undefined): vscode.WorkspaceSymbol | undefined;
export declare function transformWorkspaceEdit(edit: vscode.WorkspaceEdit, context: ServiceContext, mode: 'fileName' | 'rename' | 'codeAction' | undefined, versions?: Record<string, number>): vscode.WorkspaceEdit | undefined;
export declare function transformWorkspaceEdit(edit: vscode.WorkspaceEdit, context: LanguageServiceContext, mode: 'fileName' | 'rename' | 'codeAction' | undefined, versions?: Record<string, number>): vscode.WorkspaceEdit | undefined;
export declare function pushEditToDocumentChanges(arr: NonNullable<vscode.WorkspaceEdit['documentChanges']>, item: NonNullable<vscode.WorkspaceEdit['documentChanges']>[number]): void;

@@ -7,6 +7,5 @@ "use strict";

const common_1 = require("./common");
function transformDocumentLinkTarget(target, context) {
const targetUri = vscode_uri_1.URI.parse(target);
const clearUri = targetUri.with({ fragment: '' }).toString(true);
const decoded = context.decodeEmbeddedDocumentUri(clearUri);
function transformDocumentLinkTarget(_target, context) {
let target = vscode_uri_1.URI.parse(_target);
const decoded = context.decodeEmbeddedDocumentUri(target);
if (!decoded) {

@@ -23,4 +22,4 @@ return target;

}
target = map.sourceDocument.uri;
const hash = targetUri.fragment;
target = vscode_uri_1.URI.parse(map.sourceDocument.uri);
const hash = target.fragment;
const range = hash.match(/^L(\d+)(,(\d+))?(-L(\d+)(,(\d+))?)?$/);

@@ -38,4 +37,6 @@ if (range) {

if (sourceRange) {
target += '#L' + (sourceRange.start.line + 1) + ',' + (sourceRange.start.character + 1);
target += '-L' + (sourceRange.end.line + 1) + ',' + (sourceRange.end.character + 1);
target = target.with({
fragment: 'L' + (sourceRange.start.line + 1) + ',' + (sourceRange.start.character + 1)
+ '-L' + (sourceRange.end.line + 1) + ',' + (sourceRange.end.character + 1),
});
break;

@@ -47,3 +48,5 @@ }

if (sourcePos) {
target += '#L' + (sourcePos.line + 1) + ',' + (sourcePos.character + 1);
target = target.with({
fragment: 'L' + (sourcePos.line + 1) + ',' + (sourcePos.character + 1),
});
break;

@@ -61,3 +64,3 @@ }

const segments = match.split('|');
segments[0] = transformDocumentLinkTarget(segments[0], context);
segments[0] = transformDocumentLinkTarget(segments[0], context).toString();
return segments.join('|');

@@ -281,3 +284,3 @@ });

const tsAnno = edit.changeAnnotations[tsUri];
const decoded = context.decodeEmbeddedDocumentUri(tsUri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(tsUri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -298,3 +301,3 @@ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

sourceResult.changes ??= {};
const decoded = context.decodeEmbeddedDocumentUri(tsUri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(tsUri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -342,3 +345,3 @@ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

if ('textDocument' in tsDocEdit) {
const decoded = context.decodeEmbeddedDocumentUri(tsDocEdit.textDocument.uri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(tsDocEdit.textDocument.uri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -395,3 +398,3 @@ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

else if (tsDocEdit.kind === 'rename') {
const decoded = context.decodeEmbeddedDocumentUri(tsDocEdit.oldUri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(tsDocEdit.oldUri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -416,3 +419,3 @@ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

else if (tsDocEdit.kind === 'delete') {
const decoded = context.decodeEmbeddedDocumentUri(tsDocEdit.uri);
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(tsDocEdit.uri));
const sourceScript = decoded && context.language.scripts.get(decoded[0]);

@@ -419,0 +422,0 @@ const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);

{
"name": "@volar/language-service",
"version": "2.2.5",
"version": "2.3.0-alpha.0",
"license": "MIT",

@@ -15,3 +15,3 @@ "files": [

"dependencies": {
"@volar/language-core": "2.2.5",
"@volar/language-core": "2.3.0-alpha.0",
"vscode-languageserver-protocol": "^3.17.5",

@@ -21,3 +21,3 @@ "vscode-languageserver-textdocument": "^1.0.11",

},
"gitHead": "ee4aaa9da58c4c942d6cb74f9028d19b7ef4465d"
"gitHead": "f17c19f712651acde33cc2171a112e64db0b460e"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc