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 1.0.8 to 1.0.9

7

out/baseLanguageService.d.ts

@@ -23,8 +23,5 @@ import { createEmbeddedLanguageServiceHost, LanguageServiceHost } from '@volar/language-core';

getEditsForFileRename: (oldUri: string, newUri: string) => Promise<_.WorkspaceEdit | undefined>;
getSemanticTokens: (uri: string, range: _.Range | undefined, cancleToken: _.CancellationToken, reportProgress?: ((tokens: import("./types").SemanticToken[]) => void) | undefined) => Promise<import("./types").SemanticToken[] | undefined> | undefined;
getSemanticTokens: (uri: string, range: _.Range | undefined, legend: _.SemanticTokensLegend, cancelToken: _.CancellationToken, reportProgress?: ((tokens: import("./types").SemanticToken[]) => void) | undefined) => Promise<import("./types").SemanticToken[] | undefined> | undefined;
doHover: (uri: string, position: _.Position) => Promise<_.Hover | undefined>;
doComplete: (uri: string, position: _.Position, completionContext?: _.CompletionContext | undefined) => Promise<{
isIncomplete: boolean;
items: _.CompletionItem[];
}>;
doComplete: (uri: string, position: _.Position, completionContext?: _.CompletionContext | undefined) => Promise<_.CompletionList>;
doCodeActions: (uri: string, range: _.Range, codeActionContext: _.CodeActionContext) => Promise<_.CodeAction[] | undefined>;

@@ -31,0 +28,0 @@ doCodeActionResolve: (item: _.CodeAction) => Promise<_.CodeAction>;

@@ -170,16 +170,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

return edits;
let newText = vscode_languageserver_textdocument_1.TextDocument.applyEdits(formatDocument, edits);
if (initialIndentBracket) {
let newText = vscode_languageserver_textdocument_1.TextDocument.applyEdits(formatDocument, edits);
newText = newText.substring(newText.indexOf(initialIndentBracket[0]) + initialIndentBracket[0].length, newText.lastIndexOf(initialIndentBracket[1]));
if (newText === document.getText()) {
edits = [];
}
else {
edits = [{
newText,
range: {
start: document.positionAt(0),
end: document.positionAt(document.getText().length),
},
}];
}
}
if (newText === document.getText()) {
return [];
}
return [{
range: {
start: document.positionAt(0),
end: document.positionAt(document.getText().length),
},
newText,
}];
return edits;
}

@@ -186,0 +189,0 @@ });

@@ -8,5 +8,27 @@ Object.defineProperty(exports, "__esModule", { value: true });

return (document, positions) => {
return (0, featureWorkers_1.documentArgFeatureWorker)(context, document, positions, sourceMap => !!sourceMap.embeddedFile.capabilities.foldingRange, (positions, sourceMap) => [positions
return (0, featureWorkers_1.documentArgFeatureWorker)(context, document, positions, sourceMap => !!sourceMap.embeddedFile.capabilities.documentFormatting, (positions, sourceMap) => {
const result = positions
.map(position => sourceMap.toGeneratedPosition(position))
.filter(shared.notEmpty)], (plugin, document, positions) => { var _a; return positions.length ? (_a = plugin.getSelectionRanges) === null || _a === void 0 ? void 0 : _a.call(plugin, document, positions) : undefined; }, (item, sourceMap) => (0, transforms_1.transformSelectionRanges)(item, range => sourceMap.toSourceRange(range)));
.filter(shared.notEmpty);
if (result.length) {
return [result];
}
return [];
}, (plugin, document, positions) => { var _a; return (_a = plugin.getSelectionRanges) === null || _a === void 0 ? void 0 : _a.call(plugin, document, positions); }, (item, sourceMap) => (0, transforms_1.transformSelectionRanges)(item, range => sourceMap.toSourceRange(range)), results => {
for (let i = 0; i < results[0].length; i++) {
const first = results[0][i];
let lastParent = first;
while (lastParent.parent) {
lastParent = lastParent.parent;
}
for (let j = 1; j < results.length; j++) {
const other = results[j][i];
lastParent.parent = other;
while (lastParent.parent) {
lastParent = lastParent.parent;
}
}
}
return results[0];
});
};

@@ -13,0 +35,0 @@ }

@@ -11,5 +11,2 @@ import * as vscode from 'vscode-languageserver-protocol';

}
export declare function register(context: LanguageServiceRuntimeContext): (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext) => Promise<{
isIncomplete: boolean;
items: vscode.CompletionItem[];
}>;
export declare function register(context: LanguageServiceRuntimeContext): (uri: string, position: vscode.Position, completionContext?: vscode.CompletionContext) => Promise<vscode.CompletionList>;

@@ -37,12 +37,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
cacheData.list = Object.assign(Object.assign({}, embeddedCompletionList), { items: embeddedCompletionList.items.map(item => {
return Object.assign(Object.assign({}, (0, transforms_1.transformCompletionItem)(item, embeddedRange => sourceMap.toSourceRange(embeddedRange))), { data: {
uri,
originalItem: item,
pluginId: context.plugins.indexOf(cacheData.plugin),
sourceMap: {
embeddedDocumentUri: sourceMap.mappedDocument.uri,
},
} });
}) });
cacheData.list = (0, transforms_1.transformCompletionList)(embeddedCompletionList, range => sourceMap.toSourceRange(range), (newItem, oldItem) => newItem.data = {
uri,
originalItem: oldItem,
pluginId: context.plugins.indexOf(cacheData.plugin),
sourceMap: {
embeddedDocumentUri: sourceMap.mappedDocument.uri,
},
});
}

@@ -58,10 +56,8 @@ }

}
cacheData.list = Object.assign(Object.assign({}, completionList), { items: completionList.items.map(item => {
return Object.assign(Object.assign({}, item), { data: {
uri,
originalItem: item,
pluginId: context.plugins.indexOf(cacheData.plugin),
sourceMap: undefined,
} });
}) });
cacheData.list = Object.assign(Object.assign({}, completionList), { items: completionList.items.map(item => (Object.assign(Object.assign({}, item), { data: {
uri,
originalItem: item,
pluginId: context.plugins.indexOf(cacheData.plugin),
sourceMap: undefined,
} }))) });
}

@@ -104,15 +100,16 @@ }

continue;
if (typeof (_data === null || _data === void 0 ? void 0 : _data.completion) === 'object' && _data.completion.autoImportOnly) {
embeddedCompletionList.items = embeddedCompletionList.items.filter(item => !!item.labelDetails);
}
if (!isAdditional) {
cache.mainCompletion = { documentUri: sourceMap.mappedDocument.uri };
}
const completionList = Object.assign(Object.assign({}, embeddedCompletionList), { items: embeddedCompletionList.items.map(item => {
return Object.assign(Object.assign({}, (0, transforms_1.transformCompletionItem)(item, embeddedRange => sourceMap.toSourceRange(embeddedRange))), { data: {
uri,
originalItem: item,
pluginId: context.plugins.indexOf(plugin),
sourceMap: {
embeddedDocumentUri: sourceMap.mappedDocument.uri,
}
} });
}) });
const completionList = (0, transforms_1.transformCompletionList)(embeddedCompletionList, range => sourceMap.toSourceRange(range), (newItem, oldItem) => newItem.data = {
uri,
originalItem: oldItem,
pluginId: context.plugins.indexOf(plugin),
sourceMap: {
embeddedDocumentUri: sourceMap.mappedDocument.uri,
}
});
cache.data.push({

@@ -172,4 +169,6 @@ sourceMap: {

function combineCompletionList(lists) {
var _a;
return {
isIncomplete: lists.some(list => list.isIncomplete),
itemDefaults: (_a = lists.find(list => list.itemDefaults)) === null || _a === void 0 ? void 0 : _a.itemDefaults,
items: lists.map(list => list.items).flat().filter((result) => {

@@ -176,0 +175,0 @@ var _a;

import * as vscode from 'vscode-languageserver-protocol';
import { SemanticToken } from '@volar/language-service';
import type { LanguageServiceRuntimeContext } from '../types';
export declare function register(context: LanguageServiceRuntimeContext): (uri: string, range: vscode.Range | undefined, cancleToken: vscode.CancellationToken, reportProgress?: ((tokens: SemanticToken[]) => void) | undefined) => Promise<SemanticToken[] | undefined> | undefined;
export declare function register(context: LanguageServiceRuntimeContext): (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, cancelToken: vscode.CancellationToken, reportProgress?: ((tokens: SemanticToken[]) => void) | undefined) => Promise<SemanticToken[] | undefined> | undefined;

@@ -7,3 +7,3 @@ Object.defineProperty(exports, "__esModule", { value: true });

function register(context) {
return (uri, range, cancleToken, reportProgress) => {
return (uri, range, legend, cancelToken, reportProgress) => {
const document = context.getTextDocument(uri);

@@ -20,3 +20,3 @@ if (!document)

return (0, featureWorkers_1.languageFeatureWorker)(context, uri, offsetRange, function* (offsetRange, sourceMap) {
if (cancleToken === null || cancleToken === void 0 ? void 0 : cancleToken.isCancellationRequested)
if (cancelToken === null || cancelToken === void 0 ? void 0 : cancelToken.isCancellationRequested)
return;

@@ -42,3 +42,3 @@ let range;

var _a;
return (_a = plugin.findDocumentSemanticTokens) === null || _a === void 0 ? void 0 : _a.call(plugin, document, vscode.Range.create(document.positionAt(offsetRange[0]), document.positionAt(offsetRange[1])));
return (_a = plugin.findDocumentSemanticTokens) === null || _a === void 0 ? void 0 : _a.call(plugin, document, vscode.Range.create(document.positionAt(offsetRange[0]), document.positionAt(offsetRange[1])), legend);
}, (tokens, sourceMap) => tokens.map(_token => {

@@ -45,0 +45,0 @@ if (!sourceMap)

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

newEnd: vscode.Position;
}): vscode.Range;
}): vscode.Range | undefined;
export declare function register(context: LanguageServiceRuntimeContext): (uri: string, token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;

@@ -17,4 +17,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

function updateRange(range, change) {
updatePosition(range.start, change, false);
updatePosition(range.end, change, true);
if (!updatePosition(range.start, change, false)) {
return;
}
if (!updatePosition(range.end, change, true)) {
return;
}
if (range.end.line === range.start.line && range.end.character <= range.start.character) {

@@ -30,5 +34,7 @@ range.end.character++;

// No change
return true;
}
else if (change.newEnd.line === position.line) {
position.character = Math.min(position.character, change.newEnd.character);
return true;
}

@@ -38,2 +44,3 @@ else if (change.newEnd.line < position.line) {

position.character = change.newEnd.character;
return true;
}

@@ -59,11 +66,6 @@ }

}
return true;
}
else {
if (change.newEnd.line !== change.range.end.line) {
if (change.newEnd.line < change.range.end.line) {
position.line = change.newEnd.line;
position.character = change.newEnd.character;
}
}
else {
if (change.newEnd.line === change.range.end.line) {
const offset = change.range.end.character - position.character;

@@ -74,2 +76,10 @@ if (-characterDiff > offset) {

}
else if (change.newEnd.line < change.range.end.line) {
position.line = change.newEnd.line;
position.character = change.newEnd.character;
}
else {
// No change
}
return true;
}

@@ -79,3 +89,5 @@ }

position.line += change.newEnd.line - change.range.end.line;
return true;
}
return false;
}

@@ -100,2 +112,5 @@ function register(context) {

const newDocument = newSnapshot ? vscode_languageserver_textdocument_1.TextDocument.create('file://a.txt', 'txt', 0, newSnapshot.getText(0, newSnapshot.getLength())) : undefined;
let failedToUpdateRange = false;
let errorsUpdated = false;
let lastCheckCancelAt = 0;
for (const _cache of Object.values(cache)) {

@@ -105,3 +120,3 @@ const oldSnapshot = _cache.snapshot;

_cache.snapshot = newSnapshot;
if (newDocument && oldSnapshot && newSnapshot && change) {
if (!failedToUpdateRange && newDocument && oldSnapshot && newSnapshot && change) {
const oldDocument = vscode_languageserver_textdocument_1.TextDocument.create('file://a.txt', 'txt', 0, oldSnapshot.getText(0, oldSnapshot.getLength()));

@@ -116,8 +131,9 @@ const changeRange = {

for (const error of _cache.errors) {
updateRange(error.range, changeRange);
if (!updateRange(error.range, changeRange)) {
failedToUpdateRange = true;
break;
}
}
}
}
let shouldSend = false;
let lastCheckCancelAt = 0;
yield worker('onSyntactic', scriptTsCache_syntactic, cache.tsSyntactic);

@@ -132,5 +148,5 @@ doResponse();

function doResponse() {
if (shouldSend) {
if (errorsUpdated && !failedToUpdateRange) {
response === null || response === void 0 ? void 0 : response(getErrors());
shouldSend = false;
errorsUpdated = false;
}

@@ -172,3 +188,3 @@ }

const errors = yield ((_e = (_d = plugin.validation) === null || _d === void 0 ? void 0 : _d[mode]) === null || _e === void 0 ? void 0 : _e.call(_d, document));
shouldSend = true;
errorsUpdated = true;
pluginCache.set(document.uri, {

@@ -175,0 +191,0 @@ documentVersion: document.version,

@@ -81,3 +81,3 @@ import { LanguageModule, LanguageServiceHost, EmbeddedLanguageContext, SourceFile } from '@volar/language-core';

findDocumentSymbols?(document: TextDocument): NullableResult<vscode.SymbolInformation[]>;
findDocumentSemanticTokens?(document: TextDocument, range: vscode.Range): NullableResult<SemanticToken[]>;
findDocumentSemanticTokens?(document: TextDocument, range: vscode.Range, legend: vscode.SemanticTokensLegend): NullableResult<SemanticToken[]>;
findWorkspaceSymbols?(query: string): NullableResult<vscode.SymbolInformation[]>;

@@ -84,0 +84,0 @@ doExecuteCommand?(command: string, args: any[], context: ExecuteCommandContext): NotNullableResult<void>;

@@ -6,3 +6,3 @@ import type { TextDocument } from 'vscode-languageserver-textdocument';

export declare function documentFeatureWorker<T>(context: DocumentServiceRuntimeContext, document: TextDocument, isValidSourceMap: (sourceMap: EmbeddedDocumentSourceMap) => boolean, worker: (plugin: LanguageServicePlugin, document: TextDocument) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: EmbeddedDocumentSourceMap) => T | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>): Promise<NonNullable<Awaited<T>> | undefined>;
export declare function documentArgFeatureWorker<T, K>(context: DocumentServiceRuntimeContext, document: TextDocument, arg: K, isValidSourceMap: (sourceMap: EmbeddedDocumentSourceMap) => boolean, transformArg: (arg: K, sourceMap: EmbeddedDocumentSourceMap) => Generator<K> | [K], worker: (plugin: LanguageServicePlugin, document: TextDocument, arg: K) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: EmbeddedDocumentSourceMap) => T | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>): Promise<NonNullable<Awaited<T>> | undefined>;
export declare function documentArgFeatureWorker<T, K>(context: DocumentServiceRuntimeContext, document: TextDocument, arg: K, isValidSourceMap: (sourceMap: EmbeddedDocumentSourceMap) => boolean, transformArg: (arg: K, sourceMap: EmbeddedDocumentSourceMap) => Generator<K> | K[], worker: (plugin: LanguageServicePlugin, document: TextDocument, arg: K) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: EmbeddedDocumentSourceMap) => T | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>): Promise<NonNullable<Awaited<T>> | undefined>;
export declare function languageFeatureWorker<T, K>(context: LanguageServiceRuntimeContext, uri: string, arg: K, transformArg: (arg: K, sourceMap: EmbeddedDocumentSourceMap) => Generator<K> | K[], worker: (plugin: LanguageServicePlugin, document: TextDocument, arg: K, sourceMap: EmbeddedDocumentSourceMap | undefined, vueDocument: SourceFileDocument | undefined) => T, transform: (result: NonNullable<Awaited<T>>, sourceMap: EmbeddedDocumentSourceMap | undefined) => Awaited<T> | undefined, combineResult?: (results: NonNullable<Awaited<T>>[]) => NonNullable<Awaited<T>>, reportProgress?: (result: NonNullable<Awaited<T>>) => void): Promise<NonNullable<Awaited<T>> | undefined>;
{
"name": "@volar/language-service",
"version": "1.0.8",
"version": "1.0.9",
"main": "out/index.js",

@@ -16,7 +16,7 @@ "license": "MIT",

"dependencies": {
"@volar/language-core": "1.0.8",
"@volar/shared": "1.0.8",
"@volar/source-map": "1.0.8",
"@volar/transforms": "1.0.8",
"@volar/typescript-faster": "1.0.8",
"@volar/language-core": "1.0.9",
"@volar/shared": "1.0.9",
"@volar/source-map": "1.0.9",
"@volar/transforms": "1.0.9",
"@volar/typescript-faster": "1.0.9",
"@vue/reactivity": "^3.2.40",

@@ -29,3 +29,3 @@ "vscode-html-languageservice": "^5.0.2",

},
"gitHead": "10d1a6a8b4011adee0a7c309da25caae7fb4fea9"
"gitHead": "be2081f56ce4608324795b8a0ae83c288a3a784d"
}
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