typescript-svelte-plugin
Advanced tools
Comparing version 0.3.10 to 0.3.11
@@ -10,3 +10,4 @@ "use strict"; | ||
class ModuleResolutionCache { | ||
constructor() { | ||
constructor(projectService) { | ||
this.projectService = projectService; | ||
this.cache = new Map(); | ||
@@ -34,4 +35,5 @@ } | ||
delete(resolvedModuleName) { | ||
resolvedModuleName = this.projectService.toCanonicalFileName(resolvedModuleName); | ||
this.cache.forEach((val, key) => { | ||
if (val.resolvedFileName === resolvedModuleName) { | ||
if (this.projectService.toCanonicalFileName(val.resolvedFileName) === resolvedModuleName) { | ||
this.cache.delete(key); | ||
@@ -45,3 +47,5 @@ } | ||
getKey(moduleName, containingFile) { | ||
return containingFile + ':::' + (0, utils_1.ensureRealSvelteFilePath)(moduleName); | ||
return (this.projectService.toCanonicalFileName(containingFile) + | ||
':::' + | ||
this.projectService.toCanonicalFileName((0, utils_1.ensureRealSvelteFilePath)(moduleName))); | ||
} | ||
@@ -61,3 +65,3 @@ } | ||
const svelteSys = (0, svelte_sys_1.createSvelteSys)(logger); | ||
const moduleCache = new ModuleResolutionCache(); | ||
const moduleCache = new ModuleResolutionCache(project.projectService); | ||
const origResolveModuleNames = (_a = lsHost.resolveModuleNames) === null || _a === void 0 ? void 0 : _a.bind(lsHost); | ||
@@ -64,0 +68,0 @@ lsHost.resolveModuleNames = resolveModuleNames; |
@@ -6,2 +6,5 @@ "use strict"; | ||
class ProjectSvelteFilesManager { | ||
static getInstance(projectName) { | ||
return this.instances.get(projectName); | ||
} | ||
constructor(typescript, project, serverHost, snapshotManager, parsedCommandLine, configManager) { | ||
@@ -22,5 +25,2 @@ this.typescript = typescript; | ||
} | ||
static getInstance(projectName) { | ||
return this.instances.get(projectName); | ||
} | ||
updateProjectConfig(serviceHost) { | ||
@@ -27,0 +27,0 @@ var _a; |
import type ts from 'typescript/lib/tsserverlibrary'; | ||
declare type LineChar = ts.LineAndCharacter; | ||
declare type FileMapping = LineMapping[]; | ||
declare type LineMapping = CharacterMapping[]; | ||
declare type CharacterMapping = [ | ||
type LineChar = ts.LineAndCharacter; | ||
type FileMapping = LineMapping[]; | ||
type LineMapping = CharacterMapping[]; | ||
type CharacterMapping = [ | ||
number, | ||
@@ -7,0 +7,0 @@ number, |
@@ -202,7 +202,8 @@ "use strict"; | ||
get(fileName) { | ||
return this.snapshots.get(fileName); | ||
return this.snapshots.get(this.projectService.toCanonicalFileName(fileName)); | ||
} | ||
create(fileName) { | ||
if (this.snapshots.has(fileName)) { | ||
return this.snapshots.get(fileName); | ||
const canonicalFilePath = this.projectService.toCanonicalFileName(fileName); | ||
if (this.snapshots.has(canonicalFilePath)) { | ||
return this.snapshots.get(canonicalFilePath); | ||
} | ||
@@ -221,3 +222,3 @@ // This will trigger projectService.host.readFile which is patched below | ||
} | ||
const snapshot = this.snapshots.get(fileName); | ||
const snapshot = this.snapshots.get(this.projectService.toCanonicalFileName(fileName)); | ||
if (!snapshot) { | ||
@@ -228,3 +229,3 @@ this.logger.log('Svelte snapshot was not found after trying to load script snapshot for', fileName); | ||
snapshot.setAndPatchScriptInfo(scriptInfo); | ||
this.snapshots.set(fileName, snapshot); | ||
this.snapshots.set(canonicalFilePath, snapshot); | ||
return snapshot; | ||
@@ -269,3 +270,4 @@ } | ||
}); | ||
const existingSnapshot = this.snapshots.get(path); | ||
const canonicalFilePath = this.projectService.toCanonicalFileName(path); | ||
const existingSnapshot = this.snapshots.get(canonicalFilePath); | ||
if (existingSnapshot) { | ||
@@ -275,3 +277,3 @@ existingSnapshot.update(svelteCode, new source_mapper_1.SourceMapper(result.map.mappings)); | ||
else { | ||
this.snapshots.set(path, new SvelteSnapshot(this.typescript, path, svelteCode, new source_mapper_1.SourceMapper(result.map.mappings), this.logger, isTsFile)); | ||
this.snapshots.set(canonicalFilePath, new SvelteSnapshot(this.typescript, path, svelteCode, new source_mapper_1.SourceMapper(result.map.mappings), this.logger, isTsFile)); | ||
} | ||
@@ -278,0 +280,0 @@ this.logger.log('Successfully read Svelte file contents of', path); |
{ | ||
"name": "typescript-svelte-plugin", | ||
"version": "0.3.10", | ||
"version": "0.3.11", | ||
"description": "A TypeScript Plugin providing Svelte intellisense", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
72876
1591