diff --git a/codeCore/src/prog8/code/source/ImportFileSystem.kt b/codeCore/src/prog8/code/source/ImportFileSystem.kt index c0674271f..1e63b800a 100644 --- a/codeCore/src/prog8/code/source/ImportFileSystem.kt +++ b/codeCore/src/prog8/code/source/ImportFileSystem.kt @@ -35,6 +35,11 @@ object ImportFileSystem { } } + fun clearCaches() { + cache.clear() + lineSpanCache.clear() + } + fun retrieveSourceLine(position: Position): String { if(SourceCode.isLibraryResource(position.file)) { val key = SourceCode.withoutPrefix(position.file) diff --git a/compiler/src/prog8/CompilerMain.kt b/compiler/src/prog8/CompilerMain.kt index f415ee506..982ae4e5b 100644 --- a/compiler/src/prog8/CompilerMain.kt +++ b/compiler/src/prog8/CompilerMain.kt @@ -2,6 +2,7 @@ package prog8 import kotlinx.cli.* import prog8.ast.AstException +import prog8.code.source.ImportFileSystem import prog8.code.source.ImportFileSystem.expandTilde import prog8.code.target.CompilationTargets import prog8.code.target.Cx16Target @@ -188,6 +189,7 @@ private fun compileMain(args: Array): Boolean { val results = mutableListOf() while(true) { println("Continuous watch mode active. Modules: $moduleFiles") + ImportFileSystem.clearCaches() results.clear() for(filepathRaw in moduleFiles) { val filepath = pathFrom(filepathRaw).normalize() @@ -223,9 +225,6 @@ private fun compileMain(args: Array): Boolean { errors = ErrorReporter(txtcolors) ) val compilationResult = compileProgram(compilerArgs) - // Note: ImportFileSystem.clearCaches() removed - it caused race conditions with parallel tests - // where one test's cache clearing would break another test's source line lookups. - // The cache is bounded by unique source files and doesn't need manual clearing. if(checkSource==true) println("No output produced.")