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

@volar/language-service

Package Overview
Dependencies
Maintainers
0
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.4.0-alpha.18 to 2.4.0-alpha.19

8

lib/features/provideDiagnostics.d.ts

@@ -6,6 +6,2 @@ import { type CodeInformation } from '@volar/language-core';

import { DocumentsAndMap } from '../utils/featureWorkers';
export declare function updateRange(range: vscode.Range, change: {
range: vscode.Range;
newEnd: vscode.Position;
}): vscode.Range | undefined;
export interface ServiceDiagnosticData {

@@ -25,1 +21,5 @@ uri: string;

export declare function transformDiagnostic(context: LanguageServiceContext, error: vscode.Diagnostic, docs: DocumentsAndMap | undefined, filter: (data: CodeInformation) => boolean): vscode.Diagnostic | undefined;
export declare function updateRange(range: vscode.Range, change: {
range: vscode.Range;
newEnd: vscode.Position;
}): vscode.Range | undefined;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.errorMarkups = void 0;
exports.updateRange = updateRange;
exports.register = register;
exports.transformDiagnostic = transformDiagnostic;
exports.updateRange = updateRange;
const language_core_1 = require("@volar/language-core");

@@ -14,73 +14,2 @@ const vscode_uri_1 = require("vscode-uri");

const uriMap_1 = require("../utils/uriMap");
function updateRange(range, change) {
if (!updatePosition(range.start, change, false)) {
return;
}
if (!updatePosition(range.end, change, true)) {
return;
}
if (range.end.line === range.start.line && range.end.character <= range.start.character) {
range.end.character++;
}
return range;
}
function updatePosition(position, change, isEnd) {
if (change.range.end.line > position.line) {
if (change.newEnd.line > position.line) {
// No change
return true;
}
else if (change.newEnd.line === position.line) {
position.character = Math.min(position.character, change.newEnd.character);
return true;
}
else if (change.newEnd.line < position.line) {
position.line = change.newEnd.line;
position.character = change.newEnd.character;
return true;
}
}
else if (change.range.end.line === position.line) {
const characterDiff = change.newEnd.character - change.range.end.character;
if (position.character >= change.range.end.character) {
if (change.newEnd.line !== change.range.end.line) {
position.line = change.newEnd.line;
position.character = change.newEnd.character + position.character - change.range.end.character;
}
else {
if (isEnd ? change.range.end.character < position.character : change.range.end.character <= position.character) {
position.character += characterDiff;
}
else {
const offset = change.range.end.character - position.character;
if (-characterDiff > offset) {
position.character += characterDiff + offset;
}
}
}
return true;
}
else {
if (change.newEnd.line === change.range.end.line) {
const offset = change.range.end.character - position.character;
if (-characterDiff > offset) {
position.character += characterDiff + offset;
}
}
else if (change.newEnd.line < change.range.end.line) {
position.line = change.newEnd.line;
position.character = change.newEnd.character;
}
else {
// No change
}
return true;
}
}
else if (change.range.end.line < position.line) {
position.line += change.newEnd.line - change.range.end.line;
return true;
}
return false;
}
exports.errorMarkups = (0, uriMap_1.createUriMap)();

@@ -140,7 +69,7 @@ function register(context) {

}
await worker('provideDiagnostics', cacheMaps.syntactic, lastResponse.syntactic);
await doResponse();
await worker('provideSemanticDiagnostics', cacheMaps.semantic, lastResponse.semantic);
await worker('syntactic', cacheMaps.syntactic, lastResponse.syntactic);
processResponse();
await worker('semantic', cacheMaps.semantic, lastResponse.semantic);
return collectErrors();
function doResponse() {
function processResponse() {
if (errorsUpdated && !updateCacheRangeFailed) {

@@ -154,4 +83,8 @@ response?.(collectErrors());

}
async function worker(api, cacheMap, cache) {
async function worker(kind, cacheMap, cache) {
const result = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, docs => docs[2].mappings.some(mapping => (0, language_core_1.isDiagnosticsEnabled)(mapping.data)), async (plugin, document) => {
const interFileDependencies = plugin[0].capabilities.diagnosticProvider?.interFileDependencies;
if (kind === 'semantic' !== interFileDependencies) {
return;
}
if (Date.now() - lastCheckCancelAt >= 10) {

@@ -167,6 +100,6 @@ await (0, common_1.sleep)(10); // waiting LSP event polling

const cache = pluginCache.get(document.uri);
if (api !== 'provideSemanticDiagnostics' && cache && cache.documentVersion === document.version) {
if (!interFileDependencies && cache && cache.documentVersion === document.version) {
return cache.errors;
}
const errors = await plugin[1][api]?.(document, token) || [];
const errors = await plugin[1].provideDiagnostics?.(document, token) || [];
errors.forEach(error => {

@@ -243,2 +176,73 @@ error.data = {

}
function updateRange(range, change) {
if (!updatePosition(range.start, change, false)) {
return;
}
if (!updatePosition(range.end, change, true)) {
return;
}
if (range.end.line === range.start.line && range.end.character <= range.start.character) {
range.end.character++;
}
return range;
}
function updatePosition(position, change, isEnd) {
if (change.range.end.line > position.line) {
if (change.newEnd.line > position.line) {
// No change
return true;
}
else if (change.newEnd.line === position.line) {
position.character = Math.min(position.character, change.newEnd.character);
return true;
}
else if (change.newEnd.line < position.line) {
position.line = change.newEnd.line;
position.character = change.newEnd.character;
return true;
}
}
else if (change.range.end.line === position.line) {
const characterDiff = change.newEnd.character - change.range.end.character;
if (position.character >= change.range.end.character) {
if (change.newEnd.line !== change.range.end.line) {
position.line = change.newEnd.line;
position.character = change.newEnd.character + position.character - change.range.end.character;
}
else {
if (isEnd ? change.range.end.character < position.character : change.range.end.character <= position.character) {
position.character += characterDiff;
}
else {
const offset = change.range.end.character - position.character;
if (-characterDiff > offset) {
position.character += characterDiff + offset;
}
}
}
return true;
}
else {
if (change.newEnd.line === change.range.end.line) {
const offset = change.range.end.character - position.character;
if (-characterDiff > offset) {
position.character += characterDiff + offset;
}
}
else if (change.newEnd.line < change.range.end.line) {
position.line = change.newEnd.line;
position.character = change.newEnd.character;
}
else {
// No change
}
return true;
}
}
else if (change.range.end.line < position.line) {
position.line += change.newEnd.line - change.range.end.line;
return true;
}
return false;
}
//# sourceMappingURL=provideDiagnostics.js.map

@@ -131,6 +131,8 @@ import type { Language, SourceScript, VirtualCode } from '@volar/language-core';

diagnosticProvider?: {
workspaceDiagnostics?: boolean;
interFileDependencies: boolean;
workspaceDiagnostics: boolean;
};
fileReferencesProvider?: boolean;
fileRenameProvider?: boolean;
fileRenameEditsProvider?: boolean;
documentDropEditsProvider?: boolean;
};

@@ -180,3 +182,2 @@ create(context: LanguageServiceContext): LanguageServicePluginInstance<P>;

provideDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableProviderResult<vscode.Diagnostic[]>;
provideSemanticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableProviderResult<vscode.Diagnostic[]>;
provideWorkspaceDiagnostics?(token: vscode.CancellationToken): NullableProviderResult<vscode.WorkspaceDocumentDiagnosticReport[]>;

@@ -183,0 +184,0 @@ provideFileReferences?(document: TextDocument, token: vscode.CancellationToken): NullableProviderResult<vscode.Location[]>;

{
"name": "@volar/language-service",
"version": "2.4.0-alpha.18",
"version": "2.4.0-alpha.19",
"license": "MIT",

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

"dependencies": {
"@volar/language-core": "2.4.0-alpha.18",
"@volar/language-core": "2.4.0-alpha.19",
"vscode-languageserver-protocol": "^3.17.5",

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

},
"gitHead": "ea2e22ca17116b4274d661a014cff040c1d206cb"
"gitHead": "cbb14a44f72c365c1e8d52eff9580fb4e9765f15"
}
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