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.0.0-alpha.3 to 2.0.0-alpha.4

lib/node/decorateProgram.d.ts

3

index.d.ts
export * from './lib/documentRegistry';
export * from './lib/node/decorateLanguageService';
export * from './lib/node/decorateLanguageServiceHost';
export * from './lib/node/decorateProgram';
export * from './lib/node/proxyCreateProgram';
export * from './lib/protocol/createProject';
export * from './lib/protocol/createSys';
export * from './lib/protocol/getProgram';

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

__exportStar(require("./lib/node/decorateLanguageServiceHost"), exports);
__exportStar(require("./lib/node/decorateProgram"), exports);
__exportStar(require("./lib/node/proxyCreateProgram"), exports);
__exportStar(require("./lib/protocol/createProject"), exports);
__exportStar(require("./lib/protocol/createSys"), exports);
__exportStar(require("./lib/protocol/getProgram"), exports);
//# sourceMappingURL=index.js.map
import { FileProvider } from '@volar/language-core';
import type * as ts from 'typescript/lib/tsserverlibrary';
export declare function decorateLanguageService(virtualFiles: FileProvider, languageService: ts.LanguageService, isTsPlugin: boolean): void;
export declare function decorateLanguageService(files: FileProvider, languageService: ts.LanguageService): void;

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

const dedupe_1 = require("./dedupe");
function decorateLanguageService(virtualFiles, languageService, isTsPlugin) {
const transformedDiagnostics = new WeakMap();
const utils_1 = require("./utils");
const transform_1 = require("./transform");
function decorateLanguageService(files, languageService) {
// ignored methods
const { getNavigationTree, getOutliningSpans, } = languageService;
languageService.getNavigationTree = (fileName) => {
const [virtualFile] = getVirtualFileAndMap(fileName);
const [virtualFile] = (0, utils_1.getVirtualFileAndMap)(files, fileName);
if (virtualFile) {

@@ -23,3 +24,3 @@ const tree = getNavigationTree(fileName);

languageService.getOutliningSpans = (fileName) => {
const [virtualFile] = getVirtualFileAndMap(fileName);
const [virtualFile] = (0, utils_1.getVirtualFileAndMap)(files, fileName);
if (virtualFile) {

@@ -35,12 +36,12 @@ return [];

languageService.prepareCallHierarchy = (fileName, position) => {
const [virtualFile, sourceFile, map] = getVirtualFileAndMap(fileName);
const [virtualFile, sourceFile, map] = (0, utils_1.getVirtualFileAndMap)(files, fileName);
if (virtualFile) {
for (const [generateOffset, mapping] of map.getGeneratedOffsets(position)) {
if ((0, language_core_1.isCallHierarchyEnabled)(mapping.data)) {
const item = prepareCallHierarchy(fileName, generateOffset + (isTsPlugin ? sourceFile.snapshot.getLength() : 0));
const item = prepareCallHierarchy(fileName, generateOffset + sourceFile.snapshot.getLength());
if (Array.isArray(item)) {
return item.map(item => transformCallHierarchyItem(item, language_core_1.isCallHierarchyEnabled));
return item.map(item => (0, transform_1.transformCallHierarchyItem)(files, item, language_core_1.isCallHierarchyEnabled));
}
else if (item) {
return transformCallHierarchyItem(item, language_core_1.isCallHierarchyEnabled);
return (0, transform_1.transformCallHierarchyItem)(files, item, language_core_1.isCallHierarchyEnabled);
}

@@ -56,7 +57,7 @@ }

let calls = [];
const [virtualFile, sourceFile, map] = getVirtualFileAndMap(fileName);
const [virtualFile, sourceFile, map] = (0, utils_1.getVirtualFileAndMap)(files, fileName);
if (virtualFile) {
for (const [generateOffset, mapping] of map.getGeneratedOffsets(position)) {
if ((0, language_core_1.isCallHierarchyEnabled)(mapping.data)) {
calls = provideCallHierarchyIncomingCalls(fileName, generateOffset + (isTsPlugin ? sourceFile.snapshot.getLength() : 0));
calls = provideCallHierarchyIncomingCalls(fileName, generateOffset + sourceFile.snapshot.getLength());
}

@@ -70,6 +71,6 @@ }

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

@@ -83,7 +84,7 @@ from,

let calls = [];
const [virtualFile, sourceFile, map] = getVirtualFileAndMap(fileName);
const [virtualFile, sourceFile, map] = (0, utils_1.getVirtualFileAndMap)(files, fileName);
if (virtualFile) {
for (const [generateOffset, mapping] of map.getGeneratedOffsets(position)) {
if ((0, language_core_1.isCallHierarchyEnabled)(mapping.data)) {
calls = provideCallHierarchyOutgoingCalls(fileName, generateOffset + (isTsPlugin ? sourceFile.snapshot.getLength() : 0));
calls = provideCallHierarchyOutgoingCalls(fileName, generateOffset + sourceFile.snapshot.getLength());
}

@@ -97,6 +98,6 @@ }

.map(call => {
const to = transformCallHierarchyItem(call.to, language_core_1.isCallHierarchyEnabled);
const to = (0, transform_1.transformCallHierarchyItem)(files, call.to, language_core_1.isCallHierarchyEnabled);
const fromSpans = call.fromSpans
.map(span => transformSpan(fileName, span, language_core_1.isCallHierarchyEnabled)?.textSpan)
.filter(notEmpty);
.map(span => (0, transform_1.transformSpan)(files, fileName, span, language_core_1.isCallHierarchyEnabled)?.textSpan)
.filter(utils_1.notEmpty);
return {

@@ -111,14 +112,14 @@ to,

const resolved = unresolved
.map(changes => transformFileTextChanges(changes, language_core_1.isCodeActionsEnabled))
.filter(notEmpty);
.map(changes => (0, transform_1.transformFileTextChanges)(files, changes, language_core_1.isCodeActionsEnabled))
.filter(utils_1.notEmpty);
return resolved;
};
languageService.getQuickInfoAtPosition = (fileName, position) => {
const [virtualFile, sourceFile, map] = getVirtualFileAndMap(fileName);
const [virtualFile, sourceFile, map] = (0, utils_1.getVirtualFileAndMap)(files, fileName);
if (virtualFile) {
for (const [generateOffset, mapping] of map.getGeneratedOffsets(position)) {
if ((0, language_core_1.isHoverEnabled)(mapping.data)) {
const result = getQuickInfoAtPosition(fileName, generateOffset + (isTsPlugin ? sourceFile.snapshot.getLength() : 0));
const result = getQuickInfoAtPosition(fileName, generateOffset + sourceFile.snapshot.getLength());
if (result) {
const textSpan = transformSpan(fileName, result.textSpan, language_core_1.isHoverEnabled)?.textSpan;
const textSpan = (0, transform_1.transformSpan)(files, fileName, result.textSpan, language_core_1.isHoverEnabled)?.textSpan;
if (textSpan) {

@@ -153,7 +154,7 @@ return {

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

@@ -163,3 +164,3 @@ };

})
.filter(notEmpty),
.filter(utils_1.notEmpty),
};

@@ -170,3 +171,3 @@ });

languageService.getApplicableRefactors = (fileName, positionOrRange, preferences, triggerReason, kind, includeInteractiveActions) => {
const [virtualFile, sourceFile, map] = getVirtualFileAndMap(fileName);
const [virtualFile, sourceFile, map] = (0, utils_1.getVirtualFileAndMap)(files, fileName);
if (virtualFile) {

@@ -176,6 +177,6 @@ for (const [generateOffset, mapping] of map.getGeneratedOffsets(typeof positionOrRange === 'number' ? positionOrRange : positionOrRange.pos)) {

const por = typeof positionOrRange === 'number'
? generateOffset + (isTsPlugin ? sourceFile.snapshot.getLength() : 0)
? generateOffset + sourceFile.snapshot.getLength()
: {
pos: generateOffset + (isTsPlugin ? sourceFile.snapshot.getLength() : 0),
end: generateOffset + positionOrRange.end - positionOrRange.pos + (isTsPlugin ? sourceFile.snapshot.getLength() : 0),
pos: generateOffset + sourceFile.snapshot.getLength(),
end: generateOffset + positionOrRange.end - positionOrRange.pos + sourceFile.snapshot.getLength(),
};

@@ -193,3 +194,3 @@ return getApplicableRefactors(fileName, por, preferences, triggerReason, kind, includeInteractiveActions);

let edits;
const [virtualFile, sourceFile, map] = getVirtualFileAndMap(fileName);
const [virtualFile, sourceFile, map] = (0, utils_1.getVirtualFileAndMap)(files, fileName);
if (virtualFile) {

@@ -199,6 +200,6 @@ for (const [generateOffset, mapping] of map.getGeneratedOffsets(typeof positionOrRange === 'number' ? positionOrRange : positionOrRange.pos)) {

const por = typeof positionOrRange === 'number'
? generateOffset + (isTsPlugin ? sourceFile.snapshot.getLength() : 0)
? generateOffset + sourceFile.snapshot.getLength()
: {
pos: generateOffset + (isTsPlugin ? sourceFile.snapshot.getLength() : 0),
end: generateOffset + positionOrRange.end - positionOrRange.pos + (isTsPlugin ? sourceFile.snapshot.getLength() : 0),
pos: generateOffset + sourceFile.snapshot.getLength(),
end: generateOffset + positionOrRange.end - positionOrRange.pos + sourceFile.snapshot.getLength(),
};

@@ -214,4 +215,4 @@ edits = getEditsForRefactor(fileName, formatOptions, por, refactorName, actionName, preferences);

edits.edits = edits.edits
.map(edit => transformFileTextChanges(edit, language_core_1.isCodeActionsEnabled))
.filter(notEmpty);
.map(edit => (0, transform_1.transformFileTextChanges)(files, edit, language_core_1.isCodeActionsEnabled))
.filter(utils_1.notEmpty);
return edits;

@@ -221,9 +222,9 @@ }

languageService.getRenameInfo = (fileName, position, options) => {
const [virtualFile, sourceFile, map] = getVirtualFileAndMap(fileName);
const [virtualFile, sourceFile, map] = (0, utils_1.getVirtualFileAndMap)(files, fileName);
if (virtualFile) {
for (const [generateOffset, mapping] of map.getGeneratedOffsets(position)) {
if ((0, language_core_1.isRenameEnabled)(mapping.data)) {
const info = getRenameInfo(fileName, generateOffset + (isTsPlugin ? sourceFile.snapshot.getLength() : 0), options);
const info = getRenameInfo(fileName, generateOffset + sourceFile.snapshot.getLength(), options);
if (info.canRename) {
const span = transformSpan(fileName, info.triggerSpan, language_core_1.isRenameEnabled);
const span = (0, transform_1.transformSpan)(files, fileName, info.triggerSpan, language_core_1.isRenameEnabled);
if (span) {

@@ -250,3 +251,3 @@ info.triggerSpan = span.textSpan;

let fixes = [];
const [virtualFile, sourceFile, map] = getVirtualFileAndMap(fileName);
const [virtualFile, sourceFile, map] = (0, utils_1.getVirtualFileAndMap)(files, fileName);
if (virtualFile) {

@@ -257,3 +258,3 @@ for (const [generateStart, mapping] of map.getGeneratedOffsets(start)) {

if ((0, language_core_1.isCodeActionsEnabled)(mapping.data)) {
fixes = getCodeFixesAtPosition(fileName, generateStart + (isTsPlugin ? sourceFile.snapshot.getLength() : 0), generateEnd + (isTsPlugin ? sourceFile.snapshot.getLength() : 0), errorCodes, formatOptions, preferences);
fixes = getCodeFixesAtPosition(fileName, generateStart + sourceFile.snapshot.getLength(), generateEnd + sourceFile.snapshot.getLength(), errorCodes, formatOptions, preferences);
break;

@@ -270,3 +271,3 @@ }

fixes = fixes.map(fix => {
fix.changes = fix.changes.map(edit => transformFileTextChanges(edit, language_core_1.isCodeActionsEnabled)).filter(notEmpty);
fix.changes = fix.changes.map(edit => (0, transform_1.transformFileTextChanges)(files, edit, language_core_1.isCodeActionsEnabled)).filter(utils_1.notEmpty);
return fix;

@@ -277,3 +278,3 @@ });

languageService.getEncodedSemanticClassifications = (fileName, span, format) => {
const [virtualFile, sourceFile, map] = getVirtualFileAndMap(fileName);
const [virtualFile, sourceFile, map] = (0, utils_1.getVirtualFileAndMap)(files, fileName);
if (virtualFile) {

@@ -294,12 +295,10 @@ let start;

}
if (isTsPlugin) {
start += sourceFile.snapshot.getLength();
end += sourceFile.snapshot.getLength();
}
start += sourceFile.snapshot.getLength();
end += sourceFile.snapshot.getLength();
const result = getEncodedSemanticClassifications(fileName, { start, length: end - start }, format);
const spans = [];
for (let i = 0; i < result.spans.length; i += 3) {
for (const [sourceStart, mapping] of map.getSourceOffsets(result.spans[i] - (isTsPlugin ? sourceFile.snapshot.getLength() : 0))) {
for (const [sourceStart, mapping] of map.getSourceOffsets(result.spans[i] - sourceFile.snapshot.getLength())) {
if ((0, language_core_1.isSemanticTokensEnabled)(mapping.data)) {
for (const [sourceEnd, mapping] of map.getSourceOffsets(result.spans[i] + result.spans[i + 1] - (isTsPlugin ? sourceFile.snapshot.getLength() : 0))) {
for (const [sourceEnd, mapping] of map.getSourceOffsets(result.spans[i] + result.spans[i + 1] - sourceFile.snapshot.getLength())) {
if ((0, language_core_1.isSemanticTokensEnabled)(mapping.data)) {

@@ -323,14 +322,14 @@ spans.push(sourceStart, sourceEnd - sourceStart, result.spans[i + 2]);

return getSyntacticDiagnostics(fileName)
.map(diagnostic => transformDiagnostic(diagnostic))
.filter(notEmpty);
.map(d => (0, transform_1.transformDiagnostic)(files, d))
.filter(utils_1.notEmpty);
};
languageService.getSemanticDiagnostics = (fileName) => {
return getSemanticDiagnostics(fileName)
.map(diagnostic => transformDiagnostic(diagnostic))
.filter(notEmpty);
.map(d => (0, transform_1.transformDiagnostic)(files, d))
.filter(utils_1.notEmpty);
};
languageService.getSuggestionDiagnostics = (fileName) => {
return getSuggestionDiagnostics(fileName)
.map(diagnostic => transformDiagnostic(diagnostic))
.filter(notEmpty);
.map(d => (0, transform_1.transformDiagnostic)(files, d))
.filter(utils_1.notEmpty);
};

@@ -344,4 +343,4 @@ languageService.getDefinitionAndBoundSpan = (fileName, position) => {

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

@@ -351,5 +350,5 @@ return;

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

@@ -372,3 +371,3 @@ return {

.map(symbol => {
const definition = transformDocumentSpan(symbol.definition, language_core_1.isDefinitionEnabled);
const definition = (0, transform_1.transformDocumentSpan)(files, symbol.definition, language_core_1.isDefinitionEnabled);
if (definition) {

@@ -378,8 +377,8 @@ return {

references: symbol.references
.map(r => transformDocumentSpan(r, language_core_1.isReferencesEnabled))
.filter(notEmpty),
.map(r => (0, transform_1.transformDocumentSpan)(files, r, language_core_1.isReferencesEnabled))
.filter(utils_1.notEmpty),
};
}
})
.filter(notEmpty);
.filter(utils_1.notEmpty);
return (0, dedupe_1.dedupeReferencedSymbols)(resolved);

@@ -395,4 +394,4 @@ };

.flat()
.map(s => transformDocumentSpan(s, language_core_1.isDefinitionEnabled, s.fileName !== fileName))
.filter(notEmpty);
.map(s => (0, transform_1.transformDocumentSpan)(files, s, language_core_1.isDefinitionEnabled, s.fileName !== fileName))
.filter(utils_1.notEmpty);
return (0, dedupe_1.dedupeDocumentSpans)(resolved);

@@ -408,4 +407,4 @@ };

.flat()
.map(s => transformDocumentSpan(s, language_core_1.isTypeDefinitionEnabled))
.filter(notEmpty);
.map(s => (0, transform_1.transformDocumentSpan)(files, s, language_core_1.isTypeDefinitionEnabled))
.filter(utils_1.notEmpty);
return (0, dedupe_1.dedupeDocumentSpans)(resolved);

@@ -421,4 +420,4 @@ };

.flat()
.map(s => transformDocumentSpan(s, language_core_1.isImplementationEnabled))
.filter(notEmpty);
.map(s => (0, transform_1.transformDocumentSpan)(files, s, language_core_1.isImplementationEnabled))
.filter(utils_1.notEmpty);
return (0, dedupe_1.dedupeDocumentSpans)(resolved);

@@ -434,4 +433,4 @@ };

.flat()
.map(s => transformDocumentSpan(s, language_core_1.isRenameEnabled))
.filter(notEmpty);
.map(s => (0, transform_1.transformDocumentSpan)(files, s, language_core_1.isRenameEnabled))
.filter(utils_1.notEmpty);
return (0, dedupe_1.dedupeDocumentSpans)(resolved);

@@ -447,17 +446,17 @@ };

.flat()
.map(s => transformDocumentSpan(s, language_core_1.isReferencesEnabled))
.filter(notEmpty);
.map(s => (0, transform_1.transformDocumentSpan)(files, s, language_core_1.isReferencesEnabled))
.filter(utils_1.notEmpty);
return (0, dedupe_1.dedupeDocumentSpans)(resolved);
};
languageService.getCompletionsAtPosition = (fileName, position, options, formattingSettings) => {
const [virtualFile, sourceFile, map] = getVirtualFileAndMap(fileName);
const [virtualFile, sourceFile, map] = (0, utils_1.getVirtualFileAndMap)(files, fileName);
if (virtualFile) {
for (const [generateOffset, mapping] of map.getGeneratedOffsets(position)) {
if ((0, language_core_1.isCompletionEnabled)(mapping.data)) {
const result = getCompletionsAtPosition(fileName, generateOffset + (isTsPlugin ? sourceFile.snapshot.getLength() : 0), options, formattingSettings);
const result = getCompletionsAtPosition(fileName, generateOffset + sourceFile.snapshot.getLength(), options, formattingSettings);
if (result) {
for (const entry of result.entries) {
entry.replacementSpan = transformSpan(fileName, entry.replacementSpan, language_core_1.isCompletionEnabled)?.textSpan;
entry.replacementSpan = (0, transform_1.transformSpan)(files, fileName, entry.replacementSpan, language_core_1.isCompletionEnabled)?.textSpan;
}
result.optionalReplacementSpan = transformSpan(fileName, result.optionalReplacementSpan, language_core_1.isCompletionEnabled)?.textSpan;
result.optionalReplacementSpan = (0, transform_1.transformSpan)(files, fileName, result.optionalReplacementSpan, language_core_1.isCompletionEnabled)?.textSpan;
}

@@ -476,3 +475,3 @@ return result;

for (const codeAction of details.codeActions) {
codeAction.changes = codeAction.changes.map(edit => transformFileTextChanges(edit, language_core_1.isCodeLensEnabled)).filter(notEmpty);
codeAction.changes = codeAction.changes.map(edit => (0, transform_1.transformFileTextChanges)(files, edit, language_core_1.isCodeLensEnabled)).filter(utils_1.notEmpty);
}

@@ -483,3 +482,3 @@ }

languageService.provideInlayHints = (fileName, span, preferences) => {
const [virtualFile, sourceFile, map] = getVirtualFileAndMap(fileName);
const [virtualFile, sourceFile, map] = (0, utils_1.getVirtualFileAndMap)(files, fileName);
if (virtualFile) {

@@ -500,10 +499,8 @@ let start;

}
if (isTsPlugin) {
start += sourceFile.snapshot.getLength();
end += sourceFile.snapshot.getLength();
}
start += sourceFile.snapshot.getLength();
end += sourceFile.snapshot.getLength();
const result = provideInlayHints(fileName, { start, length: end - start }, preferences);
const hints = [];
for (const hint of result) {
for (const [sourcePosition, mapping] of map.getSourceOffsets(hint.position - (isTsPlugin ? sourceFile.snapshot.getLength() : 0))) {
for (const [sourcePosition, mapping] of map.getSourceOffsets(hint.position - sourceFile.snapshot.getLength())) {
if ((0, language_core_1.isInlayHintsEnabled)(mapping.data)) {

@@ -527,4 +524,4 @@ hints.push({

const resolved = unresolved
.map(s => transformDocumentSpan(s, language_core_1.isReferencesEnabled))
.filter(notEmpty);
.map(s => (0, transform_1.transformDocumentSpan)(files, s, language_core_1.isReferencesEnabled))
.filter(utils_1.notEmpty);
return (0, dedupe_1.dedupeDocumentSpans)(resolved);

@@ -535,7 +532,7 @@ };

const processedFilePositions = new Set();
const [virtualFile, sourceFile, map] = getVirtualFileAndMap(fileName);
const [virtualFile, sourceFile, map] = (0, utils_1.getVirtualFileAndMap)(files, fileName);
if (virtualFile) {
for (const [generateOffset, mapping] of map.getGeneratedOffsets(position)) {
if (filter(mapping.data)) {
process(fileName, generateOffset + (isTsPlugin ? sourceFile.snapshot.getLength() : 0));
process(fileName, generateOffset + sourceFile.snapshot.getLength());
}

@@ -558,10 +555,10 @@ }

processedFilePositions.add(ref[0] + ':' + ref[1]);
const [virtualFile, sourceFile] = getVirtualFileAndMap(ref[0]);
const [virtualFile, sourceFile] = (0, utils_1.getVirtualFileAndMap)(files, ref[0]);
if (!virtualFile)
continue;
const linkedCodeMap = virtualFiles.getLinkedCodeMap(virtualFile);
const linkedCodeMap = files.getLinkedCodeMap(virtualFile);
if (!linkedCodeMap)
continue;
for (const linkedCodeOffset of linkedCodeMap.getLinkedOffsets(ref[1] - (isTsPlugin ? sourceFile.snapshot.getLength() : 0))) {
process(ref[0], linkedCodeOffset + (isTsPlugin ? sourceFile.snapshot.getLength() : 0));
for (const linkedCodeOffset of linkedCodeMap.getLinkedOffsets(ref[1] - sourceFile.snapshot.getLength())) {
process(ref[0], linkedCodeOffset + sourceFile.snapshot.getLength());
}

@@ -571,153 +568,4 @@ }

}
// transforms
function transformCallHierarchyItem(item, filter) {
const span = transformSpan(item.file, item.span, filter);
const selectionSpan = transformSpan(item.file, item.selectionSpan, filter);
return {
...item,
span: span?.textSpan ?? { start: 0, length: 0 },
selectionSpan: selectionSpan?.textSpan ?? { start: 0, length: 0 },
};
}
function transformDiagnostic(diagnostic) {
if (!transformedDiagnostics.has(diagnostic)) {
if (diagnostic.start !== undefined && diagnostic.file) {
transformedDiagnostics.set(diagnostic, undefined);
const [virtualFile, sourceFile, map] = getVirtualFileAndMap(diagnostic.file?.fileName);
if (virtualFile) {
for (const [sourceOffset, mapping] of map.getSourceOffsets(diagnostic.start - (isTsPlugin ? sourceFile.snapshot.getLength() : 0))) {
if ((0, language_core_1.shouldReportDiagnostics)(mapping.data)) {
transformedDiagnostics.set(diagnostic, {
...diagnostic,
start: sourceOffset,
});
break;
}
}
}
else {
transformedDiagnostics.set(diagnostic, diagnostic);
}
}
else {
transformedDiagnostics.set(diagnostic, diagnostic);
}
if (diagnostic.relatedInformation) {
diagnostic.relatedInformation = diagnostic.relatedInformation
.map(transformDiagnostic)
.filter(notEmpty);
}
}
return transformedDiagnostics.get(diagnostic);
}
function transformFileTextChanges(changes, filter) {
const [_, source] = getVirtualFileAndMap(changes.fileName);
if (source) {
return {
...changes,
fileName: source.fileName,
textChanges: changes.textChanges.map(c => {
const span = transformSpan(changes.fileName, c.span, filter);
if (span) {
return {
...c,
span: span.textSpan,
};
}
}).filter(notEmpty),
};
}
else {
return changes;
}
}
function transformDocumentSpan(documentSpan, filter, shouldFallback) {
let textSpan = transformSpan(documentSpan.fileName, documentSpan.textSpan, filter);
if (!textSpan && shouldFallback) {
const [virtualFile, source] = getVirtualFileAndMap(documentSpan.fileName);
if (virtualFile) {
textSpan = {
fileName: source.fileName,
textSpan: { start: 0, length: 0 },
};
}
}
if (!textSpan)
return;
const contextSpan = transformSpan(documentSpan.fileName, documentSpan.contextSpan, filter);
const originalTextSpan = transformSpan(documentSpan.originalFileName, documentSpan.originalTextSpan, filter);
const originalContextSpan = transformSpan(documentSpan.originalFileName, documentSpan.originalContextSpan, filter);
return {
...documentSpan,
fileName: textSpan.fileName,
textSpan: textSpan.textSpan,
contextSpan: contextSpan?.textSpan,
originalFileName: originalTextSpan?.fileName,
originalTextSpan: originalTextSpan?.textSpan,
originalContextSpan: originalContextSpan?.textSpan,
};
}
function transformSpan(fileName, textSpan, filter) {
if (!fileName)
return;
if (!textSpan)
return;
const [virtualFile, sourceFile, map] = getVirtualFileAndMap(fileName);
if (virtualFile) {
for (const sourceStart of map.getSourceOffsets(textSpan.start - (isTsPlugin ? sourceFile.snapshot.getLength() : 0))) {
if (filter(sourceStart[1].data)) {
for (const sourceEnd of map.getSourceOffsets(textSpan.start + textSpan.length - (isTsPlugin ? sourceFile.snapshot.getLength() : 0))) {
if (filter(sourceEnd[1].data)) {
return {
fileName: sourceFile.fileName,
textSpan: {
start: sourceStart[0],
length: sourceEnd[0] - sourceStart[0],
},
};
}
}
}
}
}
else {
return {
fileName,
textSpan,
};
}
}
function getVirtualFileAndMap(fileName) {
if (isTsPlugin) {
const sourceFile = virtualFiles.getSourceFile(fileName);
if (sourceFile?.virtualFile) {
for (const virtualFile of (0, language_core_1.forEachEmbeddedFile)(sourceFile.virtualFile[0])) {
const ext = virtualFile.fileName.substring(fileName.length);
if (virtualFile.typescript && (ext === '.d.ts' || ext.match(/^\.(js|ts)x?$/))) {
for (const map of virtualFiles.getMaps(virtualFile)) {
if (map[1][0] === sourceFile.snapshot) {
return [virtualFile, sourceFile, map[1][1]];
}
}
}
}
}
}
else {
const [virtualFile, sourceFile] = virtualFiles.getVirtualFile(fileName);
if (virtualFile) {
for (const map of virtualFiles.getMaps(virtualFile)) {
if (map[1][0] === sourceFile.snapshot) {
return [virtualFile, sourceFile, map[1][1]];
}
}
}
}
return [undefined, undefined, undefined];
}
}
exports.decorateLanguageService = decorateLanguageService;
function notEmpty(value) {
return value !== null && value !== undefined;
}
//# sourceMappingURL=decorateLanguageService.js.map
{
"name": "@volar/typescript",
"version": "2.0.0-alpha.3",
"version": "2.0.0-alpha.4",
"license": "MIT",

@@ -15,10 +15,11 @@ "files": [

"dependencies": {
"@volar/language-core": "2.0.0-alpha.3",
"@volar/language-core": "2.0.0-alpha.4",
"path-browserify": "^1.0.1"
},
"devDependencies": {
"@types/node": "latest",
"@types/path-browserify": "latest",
"@volar/language-service": "2.0.0-alpha.3"
"@volar/language-service": "2.0.0-alpha.4"
},
"gitHead": "0bb685a72cff180bb9b3420aaf3136c8e899c908"
"gitHead": "4d07249613d0cc5de4197e90c741a64adf92b84b"
}
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