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

@volar/typescript

Package Overview
Dependencies
Maintainers
1
Versions
222
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@volar/typescript - npm Package Compare versions

Comparing version 2.3.0-alpha.9 to 2.3.0-alpha.10

244

lib/node/decorateLanguageService.js

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

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (serviceScript || sourceScript?.associatedOnly) {
const tree = getNavigationTree(sourceScript.id);
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (serviceScript || targetScript?.associatedOnly) {
const tree = getNavigationTree(targetScript.id);
tree.childItems = undefined;

@@ -27,4 +27,4 @@ return tree;

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (serviceScript || sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (serviceScript || targetScript?.associatedOnly) {
return [];

@@ -40,14 +40,14 @@ }

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return [];
}
if (serviceScript) {
const map = language.maps.get(serviceScript.code, sourceScript);
const map = language.maps.get(serviceScript.code, targetScript);
if (!map.mappings.some(mapping => (0, language_core_1.isFormattingEnabled)(mapping.data))) {
return [];
}
const edits = getFormattingEditsForDocument(sourceScript.id, options);
const edits = getFormattingEditsForDocument(targetScript.id, options);
return edits
.map(edit => (0, transform_1.transformTextChange)(sourceScript, language, serviceScript, edit, language_core_1.isFormattingEnabled)?.[1])
.map(edit => (0, transform_1.transformTextChange)(targetScript, language, serviceScript, edit, language_core_1.isFormattingEnabled)?.[1])
.filter(utils_1.notEmpty);

@@ -61,13 +61,13 @@ }

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return [];
}
if (serviceScript) {
const generateStart = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, start, language_core_1.isFormattingEnabled);
const generateEnd = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, end, language_core_1.isFormattingEnabled);
const generateStart = (0, transform_1.toGeneratedOffset)(language, serviceScript, targetScript, start, language_core_1.isFormattingEnabled);
const generateEnd = (0, transform_1.toGeneratedOffset)(language, serviceScript, targetScript, end, language_core_1.isFormattingEnabled);
if (generateStart !== undefined && generateEnd !== undefined) {
const edits = getFormattingEditsForRange(sourceScript.id, generateStart, generateEnd, options);
const edits = getFormattingEditsForRange(targetScript.id, generateStart, generateEnd, options);
return edits
.map(edit => (0, transform_1.transformTextChange)(sourceScript, language, serviceScript, edit, language_core_1.isFormattingEnabled)?.[1])
.map(edit => (0, transform_1.transformTextChange)(targetScript, language, serviceScript, edit, language_core_1.isFormattingEnabled)?.[1])
.filter(utils_1.notEmpty);

@@ -83,12 +83,12 @@ }

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return [];
}
if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, position, language_core_1.isFormattingEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, targetScript, position, language_core_1.isFormattingEnabled);
if (generatePosition !== undefined) {
const edits = getFormattingEditsAfterKeystroke(sourceScript.id, generatePosition, key, options);
const edits = getFormattingEditsAfterKeystroke(targetScript.id, generatePosition, key, options);
return edits
.map(edit => (0, transform_1.transformTextChange)(sourceScript, language, serviceScript, edit, language_core_1.isFormattingEnabled)?.[1])
.map(edit => (0, transform_1.transformTextChange)(targetScript, language, serviceScript, edit, language_core_1.isFormattingEnabled)?.[1])
.filter(utils_1.notEmpty);

@@ -104,18 +104,18 @@ }

const edits = getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences);
return (0, transform_1.transformFileTextChanges)(undefined, language, edits, language_core_1.isRenameEnabled);
return (0, transform_1.transformFileTextChanges)(language, edits, language_core_1.isRenameEnabled);
};
languageService.getLinkedEditingRangeAtPosition = (filePath, position) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return undefined;
}
if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, position, language_core_1.isLinkedEditingEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, targetScript, position, language_core_1.isLinkedEditingEnabled);
if (generatePosition !== undefined) {
const info = getLinkedEditingRangeAtPosition(sourceScript.id, generatePosition);
const info = getLinkedEditingRangeAtPosition(targetScript.id, generatePosition);
if (info) {
return {
ranges: info.ranges
.map(span => (0, transform_1.transformTextSpan)(sourceScript, language, serviceScript, span, language_core_1.isLinkedEditingEnabled)?.[1])
.map(span => (0, transform_1.transformTextSpan)(targetScript, language, serviceScript, span, language_core_1.isLinkedEditingEnabled)?.[1])
.filter(utils_1.notEmpty),

@@ -133,15 +133,15 @@ wordPattern: info.wordPattern,

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return undefined;
}
if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, position, language_core_1.isCallHierarchyEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, targetScript, position, language_core_1.isCallHierarchyEnabled);
if (generatePosition !== undefined) {
const item = prepareCallHierarchy(sourceScript.id, generatePosition);
const item = prepareCallHierarchy(targetScript.id, generatePosition);
if (Array.isArray(item)) {
return item.map(item => (0, transform_1.transformCallHierarchyItem)(undefined, language, item, language_core_1.isCallHierarchyEnabled));
return item.map(item => (0, transform_1.transformCallHierarchyItem)(language, item, language_core_1.isCallHierarchyEnabled));
}
else if (item) {
return (0, transform_1.transformCallHierarchyItem)(undefined, language, item, language_core_1.isCallHierarchyEnabled);
return (0, transform_1.transformCallHierarchyItem)(language, item, language_core_1.isCallHierarchyEnabled);
}

@@ -157,10 +157,10 @@ }

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return [];
}
if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, position, language_core_1.isCallHierarchyEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, targetScript, position, language_core_1.isCallHierarchyEnabled);
if (generatePosition !== undefined) {
calls = provideCallHierarchyIncomingCalls(sourceScript.id, generatePosition);
calls = provideCallHierarchyIncomingCalls(targetScript.id, generatePosition);
}

@@ -173,5 +173,5 @@ }

.map(call => {
const from = (0, transform_1.transformCallHierarchyItem)(undefined, language, call.from, language_core_1.isCallHierarchyEnabled);
const from = (0, transform_1.transformCallHierarchyItem)(language, call.from, language_core_1.isCallHierarchyEnabled);
const fromSpans = call.fromSpans
.map(span => (0, transform_1.transformSpan)(undefined, language, call.from.file, span, language_core_1.isCallHierarchyEnabled)?.textSpan)
.map(span => (0, transform_1.transformSpan)(language, call.from.file, span, language_core_1.isCallHierarchyEnabled)?.textSpan)
.filter(utils_1.notEmpty);

@@ -187,8 +187,8 @@ return {

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return [];
}
if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, position, language_core_1.isCallHierarchyEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, targetScript, position, language_core_1.isCallHierarchyEnabled);
if (generatePosition !== undefined) {

@@ -203,6 +203,6 @@ calls = provideCallHierarchyOutgoingCalls(fileName, generatePosition);

.map(call => {
const to = (0, transform_1.transformCallHierarchyItem)(undefined, language, call.to, language_core_1.isCallHierarchyEnabled);
const to = (0, transform_1.transformCallHierarchyItem)(language, call.to, language_core_1.isCallHierarchyEnabled);
const fromSpans = call.fromSpans
.map(span => serviceScript
? (0, transform_1.transformTextSpan)(sourceScript, language, serviceScript, span, language_core_1.isCallHierarchyEnabled)?.[1]
? (0, transform_1.transformTextSpan)(targetScript, language, serviceScript, span, language_core_1.isCallHierarchyEnabled)?.[1]
: span)

@@ -218,8 +218,8 @@ .filter(utils_1.notEmpty);

const unresolved = organizeImports(args, formatOptions, preferences);
return (0, transform_1.transformFileTextChanges)(undefined, language, unresolved, language_core_1.isCodeActionsEnabled);
return (0, transform_1.transformFileTextChanges)(language, unresolved, language_core_1.isCodeActionsEnabled);
};
languageService.getQuickInfoAtPosition = (filePath, position) => {
const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return undefined;

@@ -229,6 +229,6 @@ }

const infos = [];
for (const [generatePosition] of (0, transform_1.toGeneratedOffsets)(language, serviceScript, sourceScript, position, language_core_1.isHoverEnabled)) {
const info = getQuickInfoAtPosition(sourceScript.id, generatePosition);
for (const [generatePosition] of (0, transform_1.toGeneratedOffsets)(language, serviceScript, targetScript, position, language_core_1.isHoverEnabled)) {
const info = getQuickInfoAtPosition(targetScript.id, generatePosition);
if (info) {
const textSpan = (0, transform_1.transformTextSpan)(sourceScript, language, serviceScript, info.textSpan, language_core_1.isHoverEnabled)?.[1];
const textSpan = (0, transform_1.transformTextSpan)(targetScript, language, serviceScript, info.textSpan, language_core_1.isHoverEnabled)?.[1];
if (textSpan) {

@@ -287,12 +287,12 @@ infos.push({

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return undefined;
}
if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, position, language_core_1.isSignatureHelpEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, targetScript, position, language_core_1.isSignatureHelpEnabled);
if (generatePosition !== undefined) {
const result = getSignatureHelpItems(sourceScript.id, generatePosition, options);
const result = getSignatureHelpItems(targetScript.id, generatePosition, options);
if (result) {
const applicableSpan = (0, transform_1.transformTextSpan)(sourceScript, language, serviceScript, result.applicableSpan, language_core_1.isSignatureHelpEnabled)?.[1];
const applicableSpan = (0, transform_1.transformTextSpan)(targetScript, language, serviceScript, result.applicableSpan, language_core_1.isSignatureHelpEnabled)?.[1];
if (applicableSpan) {

@@ -327,7 +327,7 @@ return {

.map(span => {
const { textSpan } = (0, transform_1.transformSpan)(undefined, language, span.fileName ?? highlights.fileName, span.textSpan, language_core_1.isHighlightEnabled) ?? {};
const { textSpan } = (0, transform_1.transformSpan)(language, span.fileName ?? highlights.fileName, span.textSpan, language_core_1.isHighlightEnabled) ?? {};
if (textSpan) {
return {
...span,
contextSpan: (0, transform_1.transformSpan)(undefined, language, span.fileName ?? highlights.fileName, span.contextSpan, language_core_1.isHighlightEnabled)?.textSpan,
contextSpan: (0, transform_1.transformSpan)(language, span.fileName ?? highlights.fileName, span.contextSpan, language_core_1.isHighlightEnabled)?.textSpan,
textSpan,

@@ -344,8 +344,8 @@ };

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return [];
}
if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, typeof positionOrRange === 'number' ? positionOrRange : positionOrRange.pos, language_core_1.isCodeActionsEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, targetScript, typeof positionOrRange === 'number' ? positionOrRange : positionOrRange.pos, language_core_1.isCodeActionsEnabled);
if (generatePosition !== undefined) {

@@ -358,3 +358,3 @@ const por = typeof positionOrRange === 'number'

};
return getApplicableRefactors(sourceScript.id, por, preferences, triggerReason, kind, includeInteractiveActions);
return getApplicableRefactors(targetScript.id, por, preferences, triggerReason, kind, includeInteractiveActions);
}

@@ -370,8 +370,8 @@ return [];

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return undefined;
}
if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, typeof positionOrRange === 'number'
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, targetScript, typeof positionOrRange === 'number'
? positionOrRange

@@ -386,3 +386,3 @@ : positionOrRange.pos, language_core_1.isCodeActionsEnabled);

};
edits = getEditsForRefactor(sourceScript.id, formatOptions, por, refactorName, actionName, preferences);
edits = getEditsForRefactor(targetScript.id, formatOptions, por, refactorName, actionName, preferences);
}

@@ -394,3 +394,3 @@ }

if (edits) {
edits.edits = (0, transform_1.transformFileTextChanges)(undefined, language, edits.edits, language_core_1.isCodeActionsEnabled);
edits.edits = (0, transform_1.transformFileTextChanges)(language, edits.edits, language_core_1.isCodeActionsEnabled);
return edits;

@@ -401,4 +401,4 @@ }

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return {

@@ -411,6 +411,6 @@ canRename: false,

let failed;
for (const [generateOffset] of (0, transform_1.toGeneratedOffsets)(language, serviceScript, sourceScript, position, language_core_1.isRenameEnabled)) {
const info = getRenameInfo(sourceScript.id, generateOffset, options);
for (const [generateOffset] of (0, transform_1.toGeneratedOffsets)(language, serviceScript, targetScript, position, language_core_1.isRenameEnabled)) {
const info = getRenameInfo(targetScript.id, generateOffset, options);
if (info.canRename) {
const span = (0, transform_1.transformTextSpan)(sourceScript, language, serviceScript, info.triggerSpan, language_core_1.isRenameEnabled)?.[1];
const span = (0, transform_1.transformTextSpan)(targetScript, language, serviceScript, info.triggerSpan, language_core_1.isRenameEnabled)?.[1];
if (span) {

@@ -440,11 +440,11 @@ info.triggerSpan = span;

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return [];
}
if (serviceScript) {
const generateStart = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, start, language_core_1.isCodeActionsEnabled);
const generateEnd = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, end, language_core_1.isCodeActionsEnabled);
const generateStart = (0, transform_1.toGeneratedOffset)(language, serviceScript, targetScript, start, language_core_1.isCodeActionsEnabled);
const generateEnd = (0, transform_1.toGeneratedOffset)(language, serviceScript, targetScript, end, language_core_1.isCodeActionsEnabled);
if (generateStart !== undefined && generateEnd !== undefined) {
fixes = getCodeFixesAtPosition(sourceScript.id, generateStart, generateEnd, errorCodes, formatOptions, preferences);
fixes = getCodeFixesAtPosition(targetScript.id, generateStart, generateEnd, errorCodes, formatOptions, preferences);
}

@@ -456,3 +456,3 @@ }

fixes = fixes.map(fix => {
fix.changes = (0, transform_1.transformFileTextChanges)(undefined, language, fix.changes, language_core_1.isCodeActionsEnabled);
fix.changes = (0, transform_1.transformFileTextChanges)(language, fix.changes, language_core_1.isCodeActionsEnabled);
return fix;

@@ -464,4 +464,4 @@ });

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return {

@@ -475,3 +475,3 @@ spans: [],

let end;
const map = language.maps.get(serviceScript.code, sourceScript);
const map = language.maps.get(serviceScript.code, targetScript);
for (const mapping of map.mappings) {

@@ -487,11 +487,11 @@ // TODO reuse the logic from language service

start ??= 0;
end ??= sourceScript.snapshot.getLength();
end ??= targetScript.snapshot.getLength();
const mappingOffset = (0, transform_1.getMappingOffset)(language, serviceScript);
start += mappingOffset;
end += mappingOffset;
const result = getEncodedSemanticClassifications(sourceScript.id, { start, length: end - start }, format);
const result = getEncodedSemanticClassifications(targetScript.id, { start, length: end - start }, format);
const spans = [];
for (let i = 0; i < result.spans.length; i += 3) {
for (const sourceStart of (0, transform_1.toSourceOffsets)(sourceScript, language, serviceScript, result.spans[i], language_core_1.isSemanticTokensEnabled)) {
for (const sourceEnd of (0, transform_1.toSourceOffsets)(sourceScript, language, serviceScript, result.spans[i] + result.spans[i + 1], language_core_1.isSemanticTokensEnabled)) {
for (const sourceStart of (0, transform_1.toSourceOffsets)(targetScript, language, serviceScript, result.spans[i], language_core_1.isSemanticTokensEnabled)) {
for (const sourceEnd of (0, transform_1.toSourceOffsets)(targetScript, language, serviceScript, result.spans[i] + result.spans[i + 1], language_core_1.isSemanticTokensEnabled)) {
if (sourceStart[0] === sourceEnd[0] && sourceEnd[1] >= sourceStart[1]) {

@@ -516,8 +516,8 @@ spans.push(sourceStart[1], sourceEnd[1] - sourceStart[1], result.spans[i + 2]);

const fileName = filePath.replace(windowsPathReg, '/');
const [_serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [_serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return [];
}
return getSyntacticDiagnostics(fileName)
.map(d => (0, transform_1.transformDiagnostic)(sourceScript, language, d, languageService.getProgram(), false))
.map(d => (0, transform_1.transformDiagnostic)(targetScript, language, d, languageService.getProgram(), false))
.filter(utils_1.notEmpty);

@@ -527,8 +527,8 @@ };

const fileName = filePath.replace(windowsPathReg, '/');
const [_serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [_serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return [];
}
return getSemanticDiagnostics(fileName)
.map(d => (0, transform_1.transformDiagnostic)(sourceScript, language, d, languageService.getProgram(), false))
.map(d => (0, transform_1.transformDiagnostic)(targetScript, language, d, languageService.getProgram(), false))
.filter(utils_1.notEmpty);

@@ -538,8 +538,8 @@ };

const fileName = filePath.replace(windowsPathReg, '/');
const [_serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [_serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return [];
}
return getSuggestionDiagnostics(fileName)
.map(d => (0, transform_1.transformDiagnostic)(sourceScript, language, d, languageService.getProgram(), false))
.map(d => (0, transform_1.transformDiagnostic)(targetScript, language, d, languageService.getProgram(), false))
.filter(utils_1.notEmpty);

@@ -555,3 +555,3 @@ };

const textSpan = unresolved
.map(s => (0, transform_1.transformSpan)(undefined, language, fileName, s.textSpan, language_core_1.isDefinitionEnabled)?.textSpan)
.map(s => (0, transform_1.transformSpan)(language, fileName, s.textSpan, language_core_1.isDefinitionEnabled)?.textSpan)
.filter(utils_1.notEmpty)[0];

@@ -563,3 +563,3 @@ if (!textSpan) {

.map(s => s.definitions
?.map(s => (0, transform_1.transformDocumentSpan)(undefined, language, s, language_core_1.isDefinitionEnabled, s.fileName !== fileName))
?.map(s => (0, transform_1.transformDocumentSpan)(language, s, language_core_1.isDefinitionEnabled, s.fileName !== fileName))
.filter(utils_1.notEmpty))

@@ -585,7 +585,7 @@ .filter(utils_1.notEmpty)

.map(symbol => {
const definition = (0, transform_1.transformDocumentSpan)(undefined, language, symbol.definition, language_core_1.isDefinitionEnabled, true);
const definition = (0, transform_1.transformDocumentSpan)(language, symbol.definition, language_core_1.isDefinitionEnabled, true);
return {
definition,
references: symbol.references
.map(r => (0, transform_1.transformDocumentSpan)(undefined, language, r, language_core_1.isReferencesEnabled))
.map(r => (0, transform_1.transformDocumentSpan)(language, r, language_core_1.isReferencesEnabled))
.filter(utils_1.notEmpty),

@@ -605,3 +605,3 @@ };

.flat()
.map(s => (0, transform_1.transformDocumentSpan)(undefined, language, s, language_core_1.isDefinitionEnabled, s.fileName !== fileName))
.map(s => (0, transform_1.transformDocumentSpan)(language, s, language_core_1.isDefinitionEnabled, s.fileName !== fileName))
.filter(utils_1.notEmpty);

@@ -619,3 +619,3 @@ return (0, dedupe_1.dedupeDocumentSpans)(resolved);

.flat()
.map(s => (0, transform_1.transformDocumentSpan)(undefined, language, s, language_core_1.isTypeDefinitionEnabled))
.map(s => (0, transform_1.transformDocumentSpan)(language, s, language_core_1.isTypeDefinitionEnabled))
.filter(utils_1.notEmpty);

@@ -633,3 +633,3 @@ return (0, dedupe_1.dedupeDocumentSpans)(resolved);

.flat()
.map(s => (0, transform_1.transformDocumentSpan)(undefined, language, s, language_core_1.isImplementationEnabled))
.map(s => (0, transform_1.transformDocumentSpan)(language, s, language_core_1.isImplementationEnabled))
.filter(utils_1.notEmpty);

@@ -647,3 +647,3 @@ return (0, dedupe_1.dedupeDocumentSpans)(resolved);

.flat()
.map(s => (0, transform_1.transformDocumentSpan)(undefined, language, s, language_core_1.isRenameEnabled))
.map(s => (0, transform_1.transformDocumentSpan)(language, s, language_core_1.isRenameEnabled))
.filter(utils_1.notEmpty);

@@ -661,3 +661,3 @@ return (0, dedupe_1.dedupeDocumentSpans)(resolved);

.flat()
.map(s => (0, transform_1.transformDocumentSpan)(undefined, language, s, language_core_1.isReferencesEnabled))
.map(s => (0, transform_1.transformDocumentSpan)(language, s, language_core_1.isReferencesEnabled))
.filter(utils_1.notEmpty);

@@ -668,4 +668,4 @@ return (0, dedupe_1.dedupeDocumentSpans)(resolved);

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return undefined;

@@ -675,4 +675,4 @@ }

const results = [];
for (const [generatedOffset, mapping] of (0, transform_1.toGeneratedOffsets)(language, serviceScript, sourceScript, position, language_core_1.isCompletionEnabled)) {
const result = getCompletionsAtPosition(sourceScript.id, generatedOffset, options, formattingSettings);
for (const [generatedOffset, mapping] of (0, transform_1.toGeneratedOffsets)(language, serviceScript, targetScript, position, language_core_1.isCompletionEnabled)) {
const result = getCompletionsAtPosition(targetScript.id, generatedOffset, options, formattingSettings);
if (!result) {

@@ -685,6 +685,6 @@ continue;

for (const entry of result.entries) {
entry.replacementSpan = entry.replacementSpan && (0, transform_1.transformTextSpan)(sourceScript, language, serviceScript, entry.replacementSpan, language_core_1.isCompletionEnabled)?.[1];
entry.replacementSpan = entry.replacementSpan && (0, transform_1.transformTextSpan)(targetScript, language, serviceScript, entry.replacementSpan, language_core_1.isCompletionEnabled)?.[1];
}
result.optionalReplacementSpan = result.optionalReplacementSpan
&& (0, transform_1.transformTextSpan)(sourceScript, language, serviceScript, result.optionalReplacementSpan, language_core_1.isCompletionEnabled)?.[1];
&& (0, transform_1.transformTextSpan)(targetScript, language, serviceScript, result.optionalReplacementSpan, language_core_1.isCompletionEnabled)?.[1];
const isAdditional = typeof mapping.data.completion === 'object' && mapping.data.completion.isAdditional;

@@ -714,10 +714,10 @@ if (isAdditional) {

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return undefined;
}
if (serviceScript) {
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, sourceScript, position, language_core_1.isCompletionEnabled);
const generatePosition = (0, transform_1.toGeneratedOffset)(language, serviceScript, targetScript, position, language_core_1.isCompletionEnabled);
if (generatePosition !== undefined) {
details = getCompletionEntryDetails(sourceScript.id, generatePosition, entryName, formatOptions, source, preferences, data);
details = getCompletionEntryDetails(targetScript.id, generatePosition, entryName, formatOptions, source, preferences, data);
}

@@ -730,3 +730,3 @@ }

for (const codeAction of details.codeActions) {
codeAction.changes = (0, transform_1.transformFileTextChanges)(undefined, language, codeAction.changes, language_core_1.isCompletionEnabled);
codeAction.changes = (0, transform_1.transformFileTextChanges)(language, codeAction.changes, language_core_1.isCompletionEnabled);
}

@@ -738,4 +738,4 @@ }

const fileName = filePath.replace(windowsPathReg, '/');
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (targetScript?.associatedOnly) {
return [];

@@ -746,3 +746,3 @@ }

let end;
const map = language.maps.get(serviceScript.code, sourceScript);
const map = language.maps.get(serviceScript.code, targetScript);
for (const mapping of map.mappings) {

@@ -763,6 +763,6 @@ if ((0, language_core_1.isInlayHintsEnabled)(mapping.data) && mapping.sourceOffsets[0] >= span.start && mapping.sourceOffsets[0] <= span.start + span.length) {

end += mappingOffset;
const result = provideInlayHints(sourceScript.id, { start, length: end - start }, preferences);
const result = provideInlayHints(targetScript.id, { start, length: end - start }, preferences);
const hints = [];
for (const hint of result) {
const sourcePosition = (0, transform_1.toSourceOffset)(sourceScript, language, serviceScript, hint.position, language_core_1.isInlayHintsEnabled);
const sourcePosition = (0, transform_1.toSourceOffset)(targetScript, language, serviceScript, hint.position, language_core_1.isInlayHintsEnabled);
if (sourcePosition !== undefined) {

@@ -785,3 +785,3 @@ hints.push({

const resolved = unresolved
.map(s => (0, transform_1.transformDocumentSpan)(undefined, language, s, language_core_1.isReferencesEnabled))
.map(s => (0, transform_1.transformDocumentSpan)(language, s, language_core_1.isReferencesEnabled))
.filter(utils_1.notEmpty);

@@ -793,6 +793,6 @@ return (0, dedupe_1.dedupeDocumentSpans)(resolved);

const processedFilePositions = new Set();
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, fileName);
if (serviceScript) {
for (const [generatedOffset] of (0, transform_1.toGeneratedOffsets)(language, serviceScript, sourceScript, position, filter)) {
process(sourceScript.id, generatedOffset);
for (const [generatedOffset] of (0, transform_1.toGeneratedOffsets)(language, serviceScript, targetScript, position, filter)) {
process(targetScript.id, generatedOffset);
}

@@ -799,0 +799,0 @@ }

@@ -27,19 +27,27 @@ "use strict";

if (!sourceFile) {
return [];
return getSyntacticDiagnostics(undefined, cancellationToken)
.map(d => (0, transform_1.transformDiagnostic)(undefined, language, d, program, true))
.filter(utils_1.notEmpty);
}
const [_serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, sourceFile.fileName);
const actualSourceFile = sourceScript ? program.getSourceFile(sourceScript.id) : sourceFile;
return getSyntacticDiagnostics(actualSourceFile, cancellationToken)
.map(d => (0, transform_1.transformDiagnostic)(sourceScript, language, d, program, true))
.filter(utils_1.notEmpty);
else {
const [_serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, sourceFile.fileName);
const actualSourceFile = targetScript ? program.getSourceFile(targetScript.id) : sourceFile;
return getSyntacticDiagnostics(actualSourceFile, cancellationToken)
.map(d => (0, transform_1.transformDiagnostic)(targetScript, language, d, program, true))
.filter(utils_1.notEmpty);
}
};
program.getSemanticDiagnostics = (sourceFile, cancellationToken) => {
if (!sourceFile) {
return [];
return getSemanticDiagnostics(undefined, cancellationToken)
.map(d => (0, transform_1.transformDiagnostic)(undefined, language, d, program, true))
.filter(utils_1.notEmpty);
}
const [_serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, sourceFile.fileName);
const actualSourceFile = sourceScript ? program.getSourceFile(sourceScript.id) : sourceFile;
return getSemanticDiagnostics(actualSourceFile, cancellationToken)
.map(d => (0, transform_1.transformDiagnostic)(sourceScript, language, d, program, true))
.filter(utils_1.notEmpty);
else {
const [_serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, sourceFile.fileName);
const actualSourceFile = targetScript ? program.getSourceFile(targetScript.id) : sourceFile;
return getSemanticDiagnostics(actualSourceFile, cancellationToken)
.map(d => (0, transform_1.transformDiagnostic)(targetScript, language, d, program, true))
.filter(utils_1.notEmpty);
}
};

@@ -54,9 +62,13 @@ program.getGlobalDiagnostics = cancellationToken => {

if (!sourceFile) {
return [];
return getBindAndCheckDiagnostics(undefined, cancellationToken)
.map(d => (0, transform_1.transformDiagnostic)(undefined, language, d, program, true))
.filter(utils_1.notEmpty);
}
const [_serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, sourceFile.fileName);
const actualSourceFile = sourceScript ? program.getSourceFile(sourceScript.id) : sourceFile;
return getBindAndCheckDiagnostics(actualSourceFile, cancellationToken)
.map(d => (0, transform_1.transformDiagnostic)(sourceScript, language, d, program, true))
.filter(utils_1.notEmpty);
else {
const [_serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, sourceFile.fileName);
const actualSourceFile = targetScript ? program.getSourceFile(targetScript.id) : sourceFile;
return getBindAndCheckDiagnostics(actualSourceFile, cancellationToken)
.map(d => (0, transform_1.transformDiagnostic)(targetScript, language, d, program, true))
.filter(utils_1.notEmpty);
}
};

@@ -63,0 +75,0 @@ // fix https://github.com/vuejs/language-tools/issues/4099 with `incremental`

import type { CodeInformation, SourceScript, TypeScriptServiceScript } from '@volar/language-core';
import { Language } from '@volar/language-core';
import type * as ts from 'typescript';
export declare function transformCallHierarchyItem(targetScript: SourceScript<string> | undefined, language: Language<string>, item: ts.CallHierarchyItem, filter: (data: CodeInformation) => boolean): ts.CallHierarchyItem;
export declare function transformCallHierarchyItem(language: Language<string>, item: ts.CallHierarchyItem, filter: (data: CodeInformation) => boolean): ts.CallHierarchyItem;
export declare function transformDiagnostic<T extends ts.Diagnostic>(targetScript: SourceScript<string> | undefined, language: Language<string>, diagnostic: T, program: ts.Program | undefined, isTsc: boolean): T | undefined;
export declare function fillSourceFileText(language: Language<string>, sourceFile: ts.SourceFile): void;
export declare function transformFileTextChanges(targetScript: SourceScript<string> | undefined, language: Language<string>, changes: readonly ts.FileTextChanges[], filter: (data: CodeInformation) => boolean): ts.FileTextChanges[];
export declare function transformDocumentSpan<T extends ts.DocumentSpan>(targetScript: SourceScript<string> | undefined, language: Language<string>, documentSpan: T, filter: (data: CodeInformation) => boolean, shouldFallback?: boolean): T | undefined;
export declare function transformSpan(targetScript: SourceScript<string> | undefined, language: Language<string>, fileName: string | undefined, textSpan: ts.TextSpan | undefined, filter: (data: CodeInformation) => boolean): {
export declare function transformFileTextChanges(language: Language<string>, changes: readonly ts.FileTextChanges[], filter: (data: CodeInformation) => boolean): ts.FileTextChanges[];
export declare function transformDocumentSpan<T extends ts.DocumentSpan>(language: Language<string>, documentSpan: T, filter: (data: CodeInformation) => boolean, shouldFallback?: boolean): T | undefined;
export declare function transformSpan(language: Language<string>, fileName: string | undefined, textSpan: ts.TextSpan | undefined, filter: (data: CodeInformation) => boolean): {
fileName: string;

@@ -11,0 +11,0 @@ textSpan: ts.TextSpan;

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

const transformedSourceFile = new WeakSet();
function transformCallHierarchyItem(targetScript, language, item, filter) {
const span = transformSpan(targetScript, language, item.file, item.span, filter);
const selectionSpan = transformSpan(targetScript, language, item.file, item.selectionSpan, filter);
function transformCallHierarchyItem(language, item, filter) {
const span = transformSpan(language, item.file, item.span, filter);
const selectionSpan = transformSpan(language, item.file, item.selectionSpan, filter);
return {

@@ -26,3 +26,3 @@ ...item,

diagnostic.relatedInformation = relatedInformation
.map(d => transformDiagnostic(targetScript, language, d, program, isTsc))
.map(d => transformDiagnostic(undefined, language, d, program, isTsc))
.filter(utils_1.notEmpty);

@@ -33,5 +33,5 @@ }

&& diagnostic.length !== undefined) {
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, diagnostic.file.fileName);
const [serviceScript] = (0, utils_1.getServiceScript)(language, diagnostic.file.fileName);
if (serviceScript) {
const [sourceSpanFileName, sourceSpan] = transformTextSpan(sourceScript, language, serviceScript, {
const [sourceSpanFileName, sourceSpan] = transformTextSpan(targetScript, language, serviceScript, {
start: diagnostic.start,

@@ -74,10 +74,10 @@ length: diagnostic.length

transformedSourceFile.add(sourceFile);
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, sourceFile.fileName);
const [serviceScript, targetScript] = (0, utils_1.getServiceScript)(language, sourceFile.fileName);
if (serviceScript && !serviceScript.preventLeadingOffset) {
sourceFile.text = sourceScript.snapshot.getText(0, sourceScript.snapshot.getLength())
+ sourceFile.text.substring(sourceScript.snapshot.getLength());
sourceFile.text = targetScript.snapshot.getText(0, targetScript.snapshot.getLength())
+ sourceFile.text.substring(targetScript.snapshot.getLength());
}
}
exports.fillSourceFileText = fillSourceFileText;
function transformFileTextChanges(targetScript, language, changes, filter) {
function transformFileTextChanges(language, changes, filter) {
const changesPerFile = {};

@@ -89,3 +89,3 @@ const newFiles = new Set();

fileChanges.textChanges.forEach(c => {
const { fileName, textSpan } = transformSpan(targetScript, language, fileChanges.fileName, c.span, filter) ?? {};
const { fileName, textSpan } = transformSpan(language, fileChanges.fileName, c.span, filter) ?? {};
if (fileName && textSpan) {

@@ -117,4 +117,4 @@ (changesPerFile[fileName] ?? (changesPerFile[fileName] = [])).push({ ...c, span: textSpan });

exports.transformFileTextChanges = transformFileTextChanges;
function transformDocumentSpan(targetScript, language, documentSpan, filter, shouldFallback) {
let textSpan = transformSpan(targetScript, language, documentSpan.fileName, documentSpan.textSpan, filter);
function transformDocumentSpan(language, documentSpan, filter, shouldFallback) {
let textSpan = transformSpan(language, documentSpan.fileName, documentSpan.textSpan, filter);
if (!textSpan && shouldFallback) {

@@ -129,5 +129,5 @@ textSpan = {

}
const contextSpan = transformSpan(targetScript, language, documentSpan.fileName, documentSpan.contextSpan, filter);
const originalTextSpan = transformSpan(targetScript, language, documentSpan.originalFileName, documentSpan.originalTextSpan, filter);
const originalContextSpan = transformSpan(targetScript, language, documentSpan.originalFileName, documentSpan.originalContextSpan, filter);
const contextSpan = transformSpan(language, documentSpan.fileName, documentSpan.contextSpan, filter);
const originalTextSpan = transformSpan(language, documentSpan.originalFileName, documentSpan.originalTextSpan, filter);
const originalContextSpan = transformSpan(language, documentSpan.originalFileName, documentSpan.originalContextSpan, filter);
return {

@@ -144,12 +144,9 @@ ...documentSpan,

exports.transformDocumentSpan = transformDocumentSpan;
function transformSpan(targetScript, language, fileName, textSpan, filter) {
function transformSpan(language, fileName, textSpan, filter) {
if (!fileName || !textSpan) {
return;
}
const [serviceScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (sourceScript?.associatedOnly) {
return;
}
else if (serviceScript) {
const [sourceSpanFileName, sourceSpan] = transformTextSpan(targetScript, language, serviceScript, textSpan, filter) ?? [];
const [serviceScript] = (0, utils_1.getServiceScript)(language, fileName);
if (serviceScript) {
const [sourceSpanFileName, sourceSpan] = transformTextSpan(undefined, language, serviceScript, textSpan, filter) ?? [];
if (sourceSpan && sourceSpanFileName) {

@@ -156,0 +153,0 @@ return {

import type { Language, SourceScript, TypeScriptServiceScript } from '@volar/language-core';
export declare function notEmpty<T>(value: T | null | undefined): value is T;
export declare function getServiceScript(language: Language<string>, fileName: string): [TypeScriptServiceScript, SourceScript<string>] | [undefined, SourceScript<string>] | [undefined, undefined];
export declare function getServiceScript(language: Language<string>, fileName: string): [serviceService: TypeScriptServiceScript, targetScript: SourceScript<string>] | [undefined, SourceScript<string>] | [undefined, undefined];
{
"name": "@volar/typescript",
"version": "2.3.0-alpha.9",
"version": "2.3.0-alpha.10",
"license": "MIT",

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

"dependencies": {
"@volar/language-core": "2.3.0-alpha.9",
"@volar/language-core": "2.3.0-alpha.10",
"path-browserify": "^1.0.1",

@@ -23,5 +23,5 @@ "vscode-uri": "^3.0.8"

"@types/path-browserify": "latest",
"@volar/language-service": "2.3.0-alpha.9"
"@volar/language-service": "2.3.0-alpha.10"
},
"gitHead": "3f741930343896dfc464a893ebe5f3619bb1a1aa"
"gitHead": "44fffdc323ca3ff55818a8656a2726867df53a76"
}
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