typescript-svelte-plugin
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -28,1 +28,2 @@ "use strict"; | ||
exports.ConfigManager = ConfigManager; | ||
//# sourceMappingURL=config-manager.js.map |
@@ -98,1 +98,2 @@ "use strict"; | ||
module.exports = init; | ||
//# sourceMappingURL=index.js.map |
@@ -54,1 +54,2 @@ "use strict"; | ||
exports.decorateCompletions = decorateCompletions; | ||
//# sourceMappingURL=completions.js.map |
@@ -41,1 +41,2 @@ "use strict"; | ||
exports.decorateGetDefinition = decorateGetDefinition; | ||
//# sourceMappingURL=definition.js.map |
@@ -44,1 +44,2 @@ "use strict"; | ||
} | ||
//# sourceMappingURL=diagnostics.js.map |
@@ -12,2 +12,6 @@ "use strict"; | ||
const findReferences = ls.findReferences; | ||
const getReferences = (fileName, position) => { | ||
var _a; | ||
return (_a = findReferences(fileName, position)) === null || _a === void 0 ? void 0 : _a.reduce((acc, curr) => acc.concat(curr.references), []); | ||
}; | ||
ls.findReferences = (fileName, position) => { | ||
@@ -20,3 +24,3 @@ const references = findReferences(fileName, position); | ||
...reference, | ||
references: mapReferences(reference.references, snapshotManager, logger) | ||
references: mapReferences(reference.references, snapshotManager, logger, getReferences) | ||
}; | ||
@@ -35,3 +39,3 @@ } | ||
}, | ||
references: mapReferences(reference.references, snapshotManager, logger) | ||
references: mapReferences(reference.references, snapshotManager, logger, getReferences) | ||
}; | ||
@@ -45,16 +49,36 @@ }).filter(utils_1.isNotNullOrUndefined); | ||
const references = getReferencesAtPosition(fileName, position); | ||
return references && mapReferences(references, snapshotManager, logger); | ||
return (references && | ||
mapReferences(references, snapshotManager, logger, getReferencesAtPosition)); | ||
}; | ||
} | ||
function mapReferences(references, snapshotManager, logger) { | ||
return references | ||
.map((reference) => { | ||
function mapReferences(references, snapshotManager, logger, getReferences) { | ||
const additionalStoreReferences = []; | ||
const mappedReferences = []; | ||
for (const reference of references) { | ||
const snapshot = snapshotManager.get(reference.fileName); | ||
if (!(0, utils_1.isSvelteFilePath)(reference.fileName) || !snapshot) { | ||
return reference; | ||
mappedReferences.push(reference); | ||
continue; | ||
} | ||
const textSpan = snapshot.getOriginalTextSpan(reference.textSpan); | ||
if (textSpan) { | ||
mappedReferences.push(mapReference(reference, textSpan)); | ||
} | ||
else { | ||
if ((0, utils_1.isStoreVariableIn$storeDeclaration)(snapshot.getText(), reference.textSpan.start)) { | ||
additionalStoreReferences.push(...(getReferences(reference.fileName, (0, utils_1.get$storeOffsetOf$storeDeclaration)(snapshot.getText(), reference.textSpan.start)) || [])); | ||
} | ||
} | ||
} | ||
for (const reference of additionalStoreReferences) { | ||
// We know these are Svelte files | ||
const snapshot = snapshotManager.get(reference.fileName); | ||
const textSpan = snapshot.getOriginalTextSpan(reference.textSpan); | ||
if (!textSpan) { | ||
return null; | ||
continue; | ||
} | ||
mappedReferences.push(mapReference(reference, textSpan)); | ||
} | ||
return mappedReferences; | ||
function mapReference(reference, textSpan) { | ||
logger.debug('Find references; map textSpan: changed', reference.textSpan, 'to', textSpan); | ||
@@ -69,4 +93,4 @@ return { | ||
}; | ||
}) | ||
.filter(utils_1.isNotNullOrUndefined); | ||
} | ||
} | ||
//# sourceMappingURL=find-references.js.map |
@@ -31,1 +31,2 @@ "use strict"; | ||
exports.decorateGetImplementation = decorateGetImplementation; | ||
//# sourceMappingURL=implementation.js.map |
@@ -72,1 +72,2 @@ "use strict"; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -9,6 +9,12 @@ "use strict"; | ||
const renameLocations = findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); | ||
return renameLocations === null || renameLocations === void 0 ? void 0 : renameLocations.map((renameLocation) => { | ||
if (!renameLocations) { | ||
return undefined; | ||
} | ||
const convertedRenameLocations = []; | ||
const additionalStoreRenameLocations = []; | ||
for (const renameLocation of renameLocations) { | ||
const snapshot = snapshotManager.get(renameLocation.fileName); | ||
if (!(0, utils_1.isSvelteFilePath)(renameLocation.fileName) || !snapshot) { | ||
return renameLocation; | ||
convertedRenameLocations.push(renameLocation); | ||
continue; | ||
} | ||
@@ -18,17 +24,36 @@ // TODO more needed to filter invalid locations, see RenameProvider | ||
if (!textSpan) { | ||
return null; | ||
if ((0, utils_1.isStoreVariableIn$storeDeclaration)(snapshot.getText(), renameLocation.textSpan.start)) { | ||
additionalStoreRenameLocations.push(...findRenameLocations(renameLocation.fileName, (0, utils_1.get$storeOffsetOf$storeDeclaration)(snapshot.getText(), renameLocation.textSpan.start), false, false, false)); | ||
} | ||
continue; | ||
} | ||
const converted = { | ||
...renameLocation, | ||
textSpan | ||
}; | ||
if (converted.contextSpan) { | ||
// Not important, spare the work | ||
converted.contextSpan = undefined; | ||
convertedRenameLocations.push(convert(renameLocation, textSpan)); | ||
} | ||
for (const renameLocation of additionalStoreRenameLocations) { | ||
// We know these are Svelte files | ||
const snapshot = snapshotManager.get(renameLocation.fileName); | ||
const textSpan = snapshot.getOriginalTextSpan(renameLocation.textSpan); | ||
if (!textSpan) { | ||
continue; | ||
} | ||
logger.debug('Converted rename location ', converted); | ||
return converted; | ||
}).filter(utils_1.isNotNullOrUndefined); | ||
// |$store| would be renamed, make it $|store| | ||
textSpan.start += 1; | ||
convertedRenameLocations.push(convert(renameLocation, textSpan)); | ||
} | ||
return convertedRenameLocations; | ||
}; | ||
function convert(renameLocation, textSpan) { | ||
const converted = { | ||
...renameLocation, | ||
textSpan | ||
}; | ||
if (converted.contextSpan) { | ||
// Not important, spare the work | ||
converted.contextSpan = undefined; | ||
} | ||
logger.debug('Converted rename location ', converted); | ||
return converted; | ||
} | ||
} | ||
exports.decorateRename = decorateRename; | ||
//# sourceMappingURL=rename.js.map |
@@ -22,1 +22,2 @@ "use strict"; | ||
exports.decorateUpdateImports = decorateUpdateImports; | ||
//# sourceMappingURL=update-imports.js.map |
@@ -41,1 +41,2 @@ "use strict"; | ||
exports.Logger = Logger; | ||
//# sourceMappingURL=logger.js.map |
@@ -70,3 +70,3 @@ "use strict"; | ||
}); | ||
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, compilerOptions) { | ||
function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, compilerOptions, containingSourceFile) { | ||
logger.log('Resolving modules names for ' + containingFile); | ||
@@ -77,3 +77,3 @@ // Try resolving all module names with the original method first. | ||
// all module resolving logic except for Svelte files to TypeScript. | ||
const resolved = (origResolveModuleNames === null || origResolveModuleNames === void 0 ? void 0 : origResolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, compilerOptions)) || Array.from(Array(moduleNames.length)); | ||
const resolved = (origResolveModuleNames === null || origResolveModuleNames === void 0 ? void 0 : origResolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, compilerOptions, containingSourceFile)) || Array.from(Array(moduleNames.length)); | ||
if (!configManager.getConfig().enable) { | ||
@@ -91,3 +91,3 @@ return resolved; | ||
} | ||
const resolvedModule = resolveModuleName(fileName, containingFile, compilerOptions); | ||
const resolvedModule = resolveSvelteModuleName(fileName, containingFile, compilerOptions); | ||
moduleCache.set(fileName, containingFile, resolvedModule); | ||
@@ -97,4 +97,6 @@ return resolvedModule; | ||
} | ||
function resolveModuleName(name, containingFile, compilerOptions) { | ||
const svelteResolvedModule = typescript.resolveModuleName(name, containingFile, compilerOptions, svelteSys).resolvedModule; | ||
function resolveSvelteModuleName(name, containingFile, compilerOptions) { | ||
const svelteResolvedModule = typescript.resolveModuleName(name, containingFile, compilerOptions, svelteSys | ||
// don't set mode or else .svelte imports couldn't be resolved | ||
).resolvedModule; | ||
if (!svelteResolvedModule || | ||
@@ -118,1 +120,2 @@ !(0, utils_1.isVirtualSvelteFilePath)(svelteResolvedModule.resolvedFileName)) { | ||
exports.patchModuleLoader = patchModuleLoader; | ||
//# sourceMappingURL=module-loader.js.map |
@@ -124,1 +124,2 @@ "use strict"; | ||
ProjectSvelteFilesManager.instances = new Map(); | ||
//# sourceMappingURL=project-svelte-files.js.map |
@@ -102,1 +102,2 @@ "use strict"; | ||
exports.SourceMapper = SourceMapper; | ||
//# sourceMappingURL=source-mapper.js.map |
@@ -35,3 +35,3 @@ import type ts from 'typescript/lib/tsserverlibrary'; | ||
private toggleMappingMode; | ||
private getText; | ||
getText(): string; | ||
} | ||
@@ -38,0 +38,0 @@ export declare class SvelteSnapshotManager { |
@@ -288,1 +288,2 @@ "use strict"; | ||
exports.SvelteSnapshotManager = SvelteSnapshotManager; | ||
//# sourceMappingURL=svelte-snapshots.js.map |
@@ -35,1 +35,2 @@ "use strict"; | ||
exports.createSvelteSys = createSvelteSys; | ||
//# sourceMappingURL=svelte-sys.js.map |
@@ -22,1 +22,3 @@ import type ts from 'typescript/lib/tsserverlibrary'; | ||
export declare function getConfigPathForProject(project: ts.server.Project): ts.server.NormalizedPath; | ||
export declare function isStoreVariableIn$storeDeclaration(text: string, varStart: number): boolean; | ||
export declare function get$storeOffsetOf$storeDeclaration(text: string, storePosition: number): number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getConfigPathForProject = exports.replaceDeep = exports.isNoTextSpanInGeneratedCode = exports.isInGeneratedCode = exports.isNotNullOrUndefined = exports.ensureRealSvelteFilePath = exports.toRealSvelteFilePath = exports.isVirtualSvelteFilePath = exports.isSvelteFilePath = void 0; | ||
exports.get$storeOffsetOf$storeDeclaration = exports.isStoreVariableIn$storeDeclaration = exports.getConfigPathForProject = exports.replaceDeep = exports.isNoTextSpanInGeneratedCode = exports.isInGeneratedCode = exports.isNotNullOrUndefined = exports.ensureRealSvelteFilePath = exports.toRealSvelteFilePath = exports.isVirtualSvelteFilePath = exports.isSvelteFilePath = void 0; | ||
function isSvelteFilePath(filePath) { | ||
@@ -71,1 +71,11 @@ return filePath.endsWith('.svelte'); | ||
exports.getConfigPathForProject = getConfigPathForProject; | ||
function isStoreVariableIn$storeDeclaration(text, varStart) { | ||
return (text.lastIndexOf('__sveltets_1_store_get(', varStart) === | ||
varStart - '__sveltets_1_store_get('.length); | ||
} | ||
exports.isStoreVariableIn$storeDeclaration = isStoreVariableIn$storeDeclaration; | ||
function get$storeOffsetOf$storeDeclaration(text, storePosition) { | ||
return text.lastIndexOf(' =', storePosition) - 1; | ||
} | ||
exports.get$storeOffsetOf$storeDeclaration = get$storeOffsetOf$storeDeclaration; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "typescript-svelte-plugin", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "A TypeScript Plugin providing Svelte intellisense", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68003
1510