From 9596d543bf6d5b8afa7f75ca0fe17dc2b9c81f34 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Tue, 3 Dec 2024 11:50:03 +0100 Subject: [PATCH] Use alternativeFile whenever the version is 0.0.0-dev --- .../enso/interpreter/runtime/ModuleSources.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/ModuleSources.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/ModuleSources.java index 6b7d964f43a8..072aaf731a16 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/ModuleSources.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/ModuleSources.java @@ -7,6 +7,7 @@ import org.enso.common.LanguageInfo; import org.enso.pkg.QualifiedName; import org.enso.text.buffer.Rope; +import org.enso.version.BuildVersion; /** * Keeps information about various kinds of sources associated with a {@link Module}. All the record @@ -70,7 +71,7 @@ ModuleSources ensureSource(QualifiedName name) throws IOException { return new ModuleSources(file, rope, src); } else if (file != null) { var b = Source.newBuilder(LanguageInfo.ID, file); - assert alternativeFile(b, file) : "Cannot find alternative for " + file; + alternativeFile(b, file); var src = b.build(); org.enso.text.buffer.Rope lit = Rope.apply(src.getCharacters().toString()); return new ModuleSources(file, lit, src); @@ -92,18 +93,23 @@ String getPath() { * {@code -ea} is enabled, then we try to locate library files under the {@code * distribution}/{@code lib} directories. */ - private static boolean alternativeFile(Source.SourceBuilder b, TruffleFile file) { + private static void alternativeFile(Source.SourceBuilder b, TruffleFile file) { + if (!BuildVersion.defaultDevEnsoVersion().equals(BuildVersion.ensoVersion())) { + // no changes when not running development version + return; + } var root = file; var stack = new LinkedList(); while (root != null) { - if ("0.0.0-dev".equals(root.getName())) { + if (BuildVersion.defaultDevEnsoVersion().equals(root.getName())) { break; } stack.addFirst(root.getName()); root = root.getParent(); } if (root == null) { - return true; + // give up when we cannot find a root + return; } var libName = root.getParent(); var libNamespace = libName.getParent(); @@ -124,10 +130,8 @@ private static boolean alternativeFile(Source.SourceBuilder b, TruffleFile file) } if (newFile.exists()) { b.uri(newFile.toUri()); - return true; } } } - return false; } }