From 536a49f35db30663f1eab9d5840142d5c0436942 Mon Sep 17 00:00:00 2001 From: Pavel Marek Date: Thu, 31 Oct 2024 16:25:45 +0100 Subject: [PATCH] Fix Meta.get_qualified_type_name when run as single file (#11401) `Meta.get_qualified_type_name` correctly returns fully qualified type name when running a single file from a project with `enso --run Proj/src/Main.enso`. --- .../caches/HelloWorldCacheTest.java | 11 +- .../test/meta/QualifiedNameTest.java | 37 + .../test/context/SuggestionBuilderTest.scala | 955 +++++++++--------- .../test/refactoring/IRUtilsTest.scala | 38 +- .../test/semantic/ImportExportTest.scala | 59 +- .../test/semantic/TypeSignaturesTest.scala | 105 +- .../interpreter/node/ProgramRootNode.java | 13 +- .../org/enso/interpreter/runtime/Module.java | 25 + .../runtime/scope/TopLevelScope.java | 11 +- .../scala/org/enso/pkg/QualifiedName.scala | 6 + .../src/Semantic/Meta_Location_Spec.enso | 2 +- 11 files changed, 700 insertions(+), 562 deletions(-) create mode 100644 engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/meta/QualifiedNameTest.java diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/caches/HelloWorldCacheTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/caches/HelloWorldCacheTest.java index 57d0e3a5e389..77ce9831168b 100644 --- a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/caches/HelloWorldCacheTest.java +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/caches/HelloWorldCacheTest.java @@ -1,5 +1,8 @@ package org.enso.interpreter.caches; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.containsString; import static org.junit.Assert.assertTrue; import java.io.ByteArrayOutputStream; @@ -29,9 +32,13 @@ public void loadingHelloWorldTwiceUsesCaching() throws Exception { // the second run must read Hello_World from its .ir file! var secondMsgs = executeOnce(helloWorld); assertTrue("Contains hello world:\n" + secondMsgs, secondMsgs.contains("Hello World")); - assertTrue( + assertThat( "Properly deserialized:\n" + secondMsgs, - secondMsgs.contains("Deserializing module Hello_World from IR file: true")); + secondMsgs, + allOf( + containsString("Deserializing module"), + containsString("Hello_World"), + containsString("from IR file: true"))); } private static String executeOnce(File src) throws Exception { diff --git a/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/meta/QualifiedNameTest.java b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/meta/QualifiedNameTest.java new file mode 100644 index 000000000000..8111fe210ccd --- /dev/null +++ b/engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/meta/QualifiedNameTest.java @@ -0,0 +1,37 @@ +package org.enso.interpreter.test.meta; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +import java.io.IOException; +import org.enso.test.utils.ProjectUtils; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +public class QualifiedNameTest { + @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); + + private static final String mainModSrc = + """ + from Standard.Base import all + + type My_Type + Value x + + main = + obj = My_Type.Value 42 + Meta.get_qualified_type_name obj + """; + + @Test + public void qualifiedTypeNameWorks_WhenRunningSingleFile() throws IOException { + var projDir = temporaryFolder.newFolder().toPath(); + ProjectUtils.createProject("Proj", mainModSrc, projDir); + ProjectUtils.testProjectRun( + projDir, + (res) -> { + assertThat(res.asString(), is("local.Proj.Main.My_Type")); + }); + } +} diff --git a/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/context/SuggestionBuilderTest.scala b/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/context/SuggestionBuilderTest.scala index 378ca5e162e3..4375c599e395 100644 --- a/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/context/SuggestionBuilderTest.scala +++ b/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/context/SuggestionBuilderTest.scala @@ -1,5 +1,6 @@ package org.enso.compiler.test.context +import com.oracle.truffle.api.TruffleFile import org.enso.compiler.suggestions.SuggestionBuilder import org.enso.compiler.core.ir.Module import org.enso.interpreter.runtime @@ -7,8 +8,10 @@ import org.enso.interpreter.runtime.EnsoContext import org.enso.interpreter.test.InterpreterContext import org.enso.pkg.QualifiedName import org.enso.common.{LanguageInfo, MethodNames} +import org.enso.editions.LibraryName import org.enso.polyglot.Suggestion import org.enso.polyglot.data.Tree +import org.enso.pkg.Package import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpecLike @@ -24,22 +27,28 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { implicit private class PreprocessModule(code: String) { - def preprocessModule(name: QualifiedName): Module = { + def preprocessModule(moduleName: QualifiedName = Module): Module = { + var pkg: Package[TruffleFile] = null + if (!moduleName.isSimple()) { + val libName = LibraryName.fromModuleName(moduleName.toString) + libName shouldBe defined + val pkgOpt = + langCtx.getPackageRepository.getPackageForLibrary(libName.get) + pkgOpt shouldBe defined + pkg = pkgOpt.get + } val module = new runtime.Module( - name, - null, + moduleName, + pkg, code.stripMargin.linesIterator.mkString("\n") ) langCtx.getCompiler.run(module.asCompilerModule()) module.getIr } - def preprocessModule: Module = - preprocessModule(Module) - } - private val Module = QualifiedName(List("Unnamed"), "Test") + private val Module = QualifiedName.simpleName("Test") private val ModuleNode = Tree.Node( Suggestion.Module( module = Module.toString, @@ -61,7 +70,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { "build method without explicit arguments" in { val code = """foo = 42""" - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -69,10 +78,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -91,7 +100,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | |## The foo |foo = 42""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -99,10 +108,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = Some(" The foo"), @@ -120,7 +129,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { """@a foo |@b bar |foo a b = a + b""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -128,7 +137,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion @@ -136,7 +145,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Suggestion .Argument("b", SuggestionBuilder.Any, false, false, None) ), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -156,7 +165,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |## The foo |foo : Number |foo = 42""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -164,10 +173,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = "Number", isStatic = true, documentation = Some(" The foo"), @@ -185,7 +194,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { """ |foo : Foo.Bar |foo = 42""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -193,10 +202,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = "Foo.Bar", isStatic = true, documentation = None, @@ -216,7 +225,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | |foo : Text -> Number |foo a = 42""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -224,7 +233,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion.Argument( @@ -235,7 +244,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { None ) ), - selfType = "Unnamed.Test", + selfType = "Test", returnType = "Standard.Base.Data.Numbers.Number", isStatic = true, documentation = None, @@ -253,7 +262,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { """import Standard.Base.Data.Text.Text | |foo (a : Text) = 42""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -261,7 +270,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion.Argument( @@ -272,7 +281,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { None ) ), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -290,7 +299,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { """import Standard.Base.Data.Text.Text | |foo (a : Text = "42") = a""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -298,7 +307,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion.Argument( @@ -309,7 +318,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Some("\"42\"") ) ), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -327,7 +336,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { """ |foo : Either (Vector Number) Text -> Number |foo a = 42""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -335,7 +344,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion.Argument( @@ -346,7 +355,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { None ) ), - selfType = "Unnamed.Test", + selfType = "Test", returnType = "Number", isStatic = true, documentation = None, @@ -365,7 +374,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { """ |foo : Foo.Bar Baz |foo = 42""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -373,10 +382,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = "Foo.Bar Baz", isStatic = true, documentation = None, @@ -396,7 +405,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | x = a + 1 | y = b - 2 | x * y""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -404,7 +413,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion @@ -412,7 +421,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Suggestion .Argument("b", SuggestionBuilder.Any, false, false, None) ), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -422,7 +431,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Local( externalId = None, - "Unnamed.Test", + "Test", "x", "Number", Suggestion @@ -437,7 +446,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Local( externalId = None, - "Unnamed.Test", + "Test", "y", SuggestionBuilder.Any, Suggestion @@ -458,7 +467,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { "build method with default arguments" in { val code = """foo (a = 0) (b = "bar") (c = x.y) = a + b + c""" - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -466,7 +475,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion @@ -488,7 +497,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Some("x.y") ) ), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -507,7 +516,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | |MyType.bar self a b = a + b |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -515,10 +524,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "MyType", params = Seq(), - returnType = "Unnamed.Test.MyType", + returnType = "Test.MyType", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -527,17 +536,17 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "bar", arguments = Seq( Suggestion - .Argument("self", "Unnamed.Test.MyType", false, false, None), + .Argument("self", "Test.MyType", false, false, None), Suggestion .Argument("a", SuggestionBuilder.Any, false, false, None), Suggestion .Argument("b", SuggestionBuilder.Any, false, false, None) ), - selfType = "Unnamed.Test.MyType", + selfType = "Test.MyType", returnType = SuggestionBuilder.Any, isStatic = false, documentation = None, @@ -553,7 +562,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { val code = """MyAtom.bar a b = a + b""" - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root(Vector(ModuleNode)) } @@ -567,7 +576,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |MyAtom.bar : Number -> Number -> Number |MyAtom.bar self a b = a + b |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -575,13 +584,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "MyAtom", params = Seq( Suggestion .Argument("a", SuggestionBuilder.Any, false, false, None) ), - returnType = "Unnamed.Test.MyAtom", + returnType = "Test.MyAtom", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -590,15 +599,15 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "bar", arguments = Seq( Suggestion - .Argument("self", "Unnamed.Test.MyAtom", false, false, None), + .Argument("self", "Test.MyAtom", false, false, None), Suggestion.Argument("a", "Number", false, false, None), Suggestion.Argument("b", "Number", false, false, None) ), - selfType = "Unnamed.Test.MyAtom", + selfType = "Test.MyAtom", returnType = "Number", isStatic = false, documentation = Some(" My bar"), @@ -618,7 +627,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |MyAtom.apply : (Number -> Number) -> Number |MyAtom.apply self f = f self |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -626,10 +635,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "MyAtom", params = Seq(), - returnType = "Unnamed.Test.MyAtom", + returnType = "Test.MyAtom", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -638,14 +647,14 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "apply", arguments = Seq( Suggestion - .Argument("self", "Unnamed.Test.MyAtom", false, false, None), + .Argument("self", "Test.MyAtom", false, false, None), Suggestion.Argument("f", "Number -> Number", false, false, None) ), - selfType = "Unnamed.Test.MyAtom", + selfType = "Test.MyAtom", returnType = "Number", isStatic = false, documentation = None, @@ -669,7 +678,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |Other_Atom.apply : (Number | Other_Atom | My_Atom) -> Number |Other_Atom.apply self f = f self |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -677,10 +686,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "My_Atom", params = Seq(), - returnType = "Unnamed.Test.My_Atom", + returnType = "Test.My_Atom", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -689,10 +698,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Variant_1", arguments = Seq(), - returnType = "Unnamed.Test.My_Atom", + returnType = "Test.My_Atom", documentation = None, annotations = Seq() ), @@ -701,10 +710,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Variant_2", arguments = Seq(), - returnType = "Unnamed.Test.My_Atom", + returnType = "Test.My_Atom", documentation = None, annotations = Seq() ), @@ -713,10 +722,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Other_Atom", params = Seq(), - returnType = "Unnamed.Test.Other_Atom", + returnType = "Test.Other_Atom", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -725,34 +734,34 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "apply", arguments = Seq( Suggestion .Argument( "self", - "Unnamed.Test.Other_Atom", + "Test.Other_Atom", false, false, None ), Suggestion.Argument( "f", - "Number | Unnamed.Test.Other_Atom | Unnamed.Test.My_Atom", + "Number | Test.Other_Atom | Test.My_Atom", false, false, None, Some( Seq( "Number", - "Unnamed.Test.Other_Atom", - "Unnamed.Test.My_Atom.Variant_1", - "Unnamed.Test.My_Atom.Variant_2" + "Test.Other_Atom", + "Test.My_Atom.Variant_1", + "Test.My_Atom.Variant_2" ) ) ) ), - selfType = "Unnamed.Test.Other_Atom", + selfType = "Test.Other_Atom", returnType = "Number", isStatic = false, documentation = None, @@ -779,7 +788,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |foo : Text | Boolean | Value | Auto -> Value |foo a = a |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -787,10 +796,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Value", params = Seq(), - returnType = "Unnamed.Test.Value", + returnType = "Test.Value", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -799,10 +808,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "A", arguments = Seq(), - returnType = "Unnamed.Test.Value", + returnType = "Test.Value", documentation = None, annotations = Seq() ), @@ -811,10 +820,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "B", arguments = Seq(), - returnType = "Unnamed.Test.Value", + returnType = "Test.Value", documentation = None, annotations = Seq() ), @@ -823,10 +832,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Auto", params = Seq(), - returnType = "Unnamed.Test.Auto", + returnType = "Test.Auto", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -835,12 +844,12 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion.Argument( "a", - "Standard.Base.Data.Text.Text | Standard.Base.Data.Boolean.Boolean | Unnamed.Test.Value | Unnamed.Test.Auto", + "Standard.Base.Data.Text.Text | Standard.Base.Data.Boolean.Boolean | Test.Value | Test.Auto", false, false, None, @@ -848,15 +857,15 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Seq( "Standard.Base.Data.Boolean.Boolean.True", "Standard.Base.Data.Boolean.Boolean.False", - "Unnamed.Test.Value.A", - "Unnamed.Test.Value.B", - "Unnamed.Test.Auto" + "Test.Value.A", + "Test.Value.B", + "Test.Auto" ) ) ) ), - selfType = "Unnamed.Test", - returnType = "Unnamed.Test.Value", + selfType = "Test", + returnType = "Test.Value", isStatic = true, documentation = None, annotations = Seq() @@ -878,7 +887,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | |foo (a : Value | Auto) = a |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -886,10 +895,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Value", params = Seq(), - returnType = "Unnamed.Test.Value", + returnType = "Test.Value", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -898,10 +907,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "A", arguments = Seq(), - returnType = "Unnamed.Test.Value", + returnType = "Test.Value", documentation = None, annotations = Seq() ), @@ -910,10 +919,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "B", arguments = Seq(), - returnType = "Unnamed.Test.Value", + returnType = "Test.Value", documentation = None, annotations = Seq() ), @@ -922,10 +931,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Auto", params = Seq(), - returnType = "Unnamed.Test.Auto", + returnType = "Test.Auto", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -934,19 +943,19 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion.Argument( "a", - "Unnamed.Test.Value | Unnamed.Test.Auto", + "Test.Value | Test.Auto", false, false, None, - Some(Seq("..A", "..B", "Unnamed.Test.Auto")) + Some(Seq("..A", "..B", "Test.Auto")) ) ), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -969,7 +978,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | |foo (a : Value | Boolean) = a |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -977,10 +986,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Value", params = Seq(), - returnType = "Unnamed.Test.Value", + returnType = "Test.Value", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -989,10 +998,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "A", arguments = Seq(), - returnType = "Unnamed.Test.Value", + returnType = "Test.Value", documentation = None, annotations = Seq() ), @@ -1001,10 +1010,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "B", arguments = Seq(), - returnType = "Unnamed.Test.Value", + returnType = "Test.Value", documentation = None, annotations = Seq() ), @@ -1013,19 +1022,19 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion.Argument( "a", - "Unnamed.Test.Value | Standard.Base.Data.Boolean.Boolean", + "Test.Value | Standard.Base.Data.Boolean.Boolean", false, false, None, Some(Seq("..A", "..B", "True", "False")) ) ), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -1049,7 +1058,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |foo : Value | Auto -> Value | Auto |foo (a : Value | Auto) = a |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -1057,10 +1066,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Value", params = Seq(), - returnType = "Unnamed.Test.Value", + returnType = "Test.Value", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -1069,10 +1078,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "A", arguments = Seq(), - returnType = "Unnamed.Test.Value", + returnType = "Test.Value", documentation = None, annotations = Seq() ), @@ -1081,10 +1090,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "B", arguments = Seq(), - returnType = "Unnamed.Test.Value", + returnType = "Test.Value", documentation = None, annotations = Seq() ), @@ -1093,10 +1102,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Auto", params = Seq(), - returnType = "Unnamed.Test.Auto", + returnType = "Test.Auto", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -1105,20 +1114,20 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion.Argument( "a", - "Unnamed.Test.Value | Unnamed.Test.Auto", + "Test.Value | Test.Auto", false, false, None, - Some(Seq("..A", "..B", "Unnamed.Test.Auto")) + Some(Seq("..A", "..B", "Test.Auto")) ) ), - selfType = "Unnamed.Test", - returnType = "Unnamed.Test.Value | Unnamed.Test.Auto", + selfType = "Test", + returnType = "Test.Value | Test.Auto", isStatic = true, documentation = None, annotations = Seq() @@ -1142,7 +1151,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | |foo (a : T | K) = a |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -1150,10 +1159,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "T", params = Seq(), - returnType = "Unnamed.Test.T", + returnType = "Test.T", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -1162,10 +1171,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "A", arguments = Seq(), - returnType = "Unnamed.Test.T", + returnType = "Test.T", documentation = None, annotations = Seq() ), @@ -1174,10 +1183,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "B", arguments = Seq(), - returnType = "Unnamed.Test.T", + returnType = "Test.T", documentation = None, annotations = Seq() ), @@ -1186,10 +1195,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "K", params = Seq(), - returnType = "Unnamed.Test.K", + returnType = "Test.K", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -1198,10 +1207,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "B", arguments = Seq(), - returnType = "Unnamed.Test.K", + returnType = "Test.K", documentation = None, annotations = Seq() ), @@ -1210,10 +1219,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "C", arguments = Seq(), - returnType = "Unnamed.Test.K", + returnType = "Test.K", documentation = None, annotations = Seq() ), @@ -1222,26 +1231,26 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion.Argument( "a", - "Unnamed.Test.T | Unnamed.Test.K", + "Test.T | Test.K", false, false, None, Some( Seq( - "Unnamed.Test.T.A", - "Unnamed.Test.T.B", - "Unnamed.Test.K.B", - "Unnamed.Test.K.C" + "Test.T.A", + "Test.T.B", + "Test.K.B", + "Test.K.C" ) ) ) ), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -1257,7 +1266,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { val code = """foo ~a = a + 1""" - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -1265,13 +1274,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion .Argument("a", SuggestionBuilder.Any, true, false, None) ), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -1290,7 +1299,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | |foo : A -> A |foo a = a + 1""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -1298,10 +1307,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "A", params = Seq(), - returnType = "Unnamed.Test.A", + returnType = "Test.A", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -1310,20 +1319,20 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion.Argument( "a", - "Unnamed.Test.A", + "Test.A", false, false, None, - Some(Seq("Unnamed.Test.A")) + Some(Seq("Test.A")) ) ), - selfType = "Unnamed.Test", - returnType = "Unnamed.Test.A", + selfType = "Test", + returnType = "Test.A", isStatic = true, documentation = None, annotations = Seq() @@ -1344,7 +1353,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |## My conversion |Foo.from (that:Numbers.Number) = Foo.Value a |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -1352,10 +1361,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Foo", params = Seq(), - returnType = "Unnamed.Test.Foo", + returnType = "Test.Foo", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -1364,13 +1373,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Value", arguments = Seq( Suggestion .Argument("foo", SuggestionBuilder.Any, false, false, None) ), - returnType = "Unnamed.Test.Foo", + returnType = "Test.Foo", documentation = None, annotations = Seq() ), @@ -1379,13 +1388,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = List( Suggestion - .Argument("self", "Unnamed.Test.Foo", false, false, None) + .Argument("self", "Test.Foo", false, false, None) ), - selfType = "Unnamed.Test.Foo", + selfType = "Test.Foo", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -1395,7 +1404,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Conversion( externalId = None, - module = "Unnamed.Test", + module = "Test", arguments = Seq( Suggestion.Argument( "that", @@ -1406,7 +1415,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { ) ), selfType = "Standard.Base.Data.Numbers.Number", - returnType = "Unnamed.Test.Foo", + returnType = "Test.Foo", documentation = Some(" My conversion") ), Vector() @@ -1424,7 +1433,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | |Foo.from (that:Numbers.Number) other=1 = Foo.Value that other |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -1432,10 +1441,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Foo", params = Seq(), - returnType = "Unnamed.Test.Foo", + returnType = "Test.Foo", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -1444,7 +1453,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Value", arguments = Seq( Suggestion @@ -1452,7 +1461,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Suggestion .Argument("bar", SuggestionBuilder.Any, false, false, None) ), - returnType = "Unnamed.Test.Foo", + returnType = "Test.Foo", documentation = None, annotations = Seq() ), @@ -1461,13 +1470,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = List( Suggestion - .Argument("self", "Unnamed.Test.Foo", false, false, None) + .Argument("self", "Test.Foo", false, false, None) ), - selfType = "Unnamed.Test.Foo", + selfType = "Test.Foo", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -1477,13 +1486,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "bar", arguments = List( Suggestion - .Argument("self", "Unnamed.Test.Foo", false, false, None) + .Argument("self", "Test.Foo", false, false, None) ), - selfType = "Unnamed.Test.Foo", + selfType = "Test.Foo", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -1493,7 +1502,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Conversion( externalId = None, - module = "Unnamed.Test", + module = "Test", arguments = Seq( Suggestion.Argument( "that", @@ -1512,7 +1521,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { ) ), selfType = "Standard.Base.Data.Numbers.Number", - returnType = "Unnamed.Test.Foo", + returnType = "Test.Foo", documentation = None ), Vector() @@ -1531,7 +1540,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | |Foo.from (that:Numbers.Number) (other:Boolean=Boolean.True) = Foo.Value that other |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -1539,10 +1548,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Foo", params = Seq(), - returnType = "Unnamed.Test.Foo", + returnType = "Test.Foo", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -1551,7 +1560,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Value", arguments = Seq( Suggestion @@ -1559,7 +1568,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Suggestion .Argument("bar", SuggestionBuilder.Any, false, false, None) ), - returnType = "Unnamed.Test.Foo", + returnType = "Test.Foo", documentation = None, annotations = Seq() ), @@ -1568,13 +1577,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = List( Suggestion - .Argument("self", "Unnamed.Test.Foo", false, false, None) + .Argument("self", "Test.Foo", false, false, None) ), - selfType = "Unnamed.Test.Foo", + selfType = "Test.Foo", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -1584,13 +1593,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "bar", arguments = List( Suggestion - .Argument("self", "Unnamed.Test.Foo", false, false, None) + .Argument("self", "Test.Foo", false, false, None) ), - selfType = "Unnamed.Test.Foo", + selfType = "Test.Foo", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -1600,7 +1609,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Conversion( externalId = None, - module = "Unnamed.Test", + module = "Test", arguments = Seq( Suggestion.Argument( "that", @@ -1625,7 +1634,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { ) ), selfType = "Standard.Base.Data.Numbers.Number", - returnType = "Unnamed.Test.Foo", + returnType = "Test.Foo", documentation = None ), Vector() @@ -1641,7 +1650,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | foo a = a + 1 | foo 42 |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -1649,10 +1658,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -1662,7 +1671,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Function( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion @@ -1692,7 +1701,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | b | foo 42 |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -1700,10 +1709,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -1713,7 +1722,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Function( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion @@ -1730,7 +1739,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Local( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "b", returnType = SuggestionBuilder.Any, scope = Suggestion.Scope( @@ -1757,7 +1766,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | foo a = a + 1 | foo 42 |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -1765,10 +1774,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -1778,7 +1787,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Function( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion.Argument("a", "Number", false, false, None) @@ -1808,7 +1817,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | foo a = a + 1 | foo 42 |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -1816,10 +1825,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "A", params = Seq(), - returnType = "Unnamed.Test.A", + returnType = "Test.A", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -1828,10 +1837,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -1841,20 +1850,20 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Function( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion .Argument( "a", - "Unnamed.Test.A", + "Test.A", false, false, None, - Some(Seq("Unnamed.Test.A")) + Some(Seq("Test.A")) ) ), - returnType = "Unnamed.Test.A", + returnType = "Test.A", scope = Suggestion.Scope( Suggestion.Position(2, 6), Suggestion.Position(5, 10) @@ -1877,7 +1886,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | foo a = a + 1 | foo 42 |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -1885,10 +1894,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -1898,7 +1907,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Function( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion @@ -1932,7 +1941,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | foo = 42 | foo |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -1940,10 +1949,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -1953,7 +1962,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Local( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", returnType = SuggestionBuilder.Any, scope = Suggestion.Scope( @@ -1979,7 +1988,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | b | foo |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -1987,10 +1996,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -2000,7 +2009,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Local( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", returnType = SuggestionBuilder.Any, scope = Suggestion.Scope( @@ -2013,7 +2022,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Local( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "b", returnType = SuggestionBuilder.Any, scope = Suggestion.Scope( @@ -2040,7 +2049,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | foo = 42 | foo |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -2048,10 +2057,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -2061,7 +2070,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Local( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", returnType = "Number", scope = Suggestion.Scope( @@ -2088,7 +2097,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | foo = A | foo |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -2096,10 +2105,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "A", params = Seq(), - returnType = "Unnamed.Test.A", + returnType = "Test.A", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -2108,10 +2117,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -2121,9 +2130,9 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Local( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", - returnType = "Unnamed.Test.A", + returnType = "Test.A", scope = Suggestion.Scope( Suggestion.Position(2, 6), Suggestion.Position(5, 7) @@ -2146,7 +2155,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | foo = 42 | foo |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -2154,10 +2163,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -2167,7 +2176,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Local( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", returnType = SuggestionBuilder.Any, scope = Suggestion.Scope( @@ -2189,7 +2198,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { val code = """type MyType | MkMyType a b""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -2197,10 +2206,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "MyType", params = Seq(), - returnType = "Unnamed.Test.MyType", + returnType = "Test.MyType", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -2209,7 +2218,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "MkMyType", arguments = Seq( Suggestion @@ -2217,7 +2226,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Suggestion .Argument("b", SuggestionBuilder.Any, false, false, None) ), - returnType = "Unnamed.Test.MyType", + returnType = "Test.MyType", documentation = None, annotations = Seq() ), @@ -2226,13 +2235,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "a", arguments = List( Suggestion - .Argument("self", "Unnamed.Test.MyType", false, false, None) + .Argument("self", "Test.MyType", false, false, None) ), - selfType = "Unnamed.Test.MyType", + selfType = "Test.MyType", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -2242,13 +2251,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "b", arguments = List( Suggestion - .Argument("self", "Unnamed.Test.MyType", false, false, None) + .Argument("self", "Test.MyType", false, false, None) ), - selfType = "Unnamed.Test.MyType", + selfType = "Test.MyType", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -2268,7 +2277,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |type Mtp | ## My sweet type | MyType a b""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -2276,10 +2285,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Mtp", params = Seq(), - returnType = "Unnamed.Test.Mtp", + returnType = "Test.Mtp", parentType = Some(SuggestionBuilder.Any), documentation = Some(" My sweet type") ), @@ -2288,7 +2297,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "MyType", arguments = Seq( Suggestion @@ -2296,7 +2305,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Suggestion .Argument("b", SuggestionBuilder.Any, false, false, None) ), - returnType = "Unnamed.Test.Mtp", + returnType = "Test.Mtp", documentation = Some(" My sweet type"), annotations = Seq() ), @@ -2305,13 +2314,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "a", arguments = List( Suggestion - .Argument("self", "Unnamed.Test.Mtp", false, false, None) + .Argument("self", "Test.Mtp", false, false, None) ), - selfType = "Unnamed.Test.Mtp", + selfType = "Test.Mtp", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -2321,13 +2330,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "b", arguments = List( Suggestion - .Argument("self", "Unnamed.Test.Mtp", false, false, None) + .Argument("self", "Test.Mtp", false, false, None) ), - selfType = "Unnamed.Test.Mtp", + selfType = "Test.Mtp", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -2344,7 +2353,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { """type Maybe | Nothing | Just a""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -2352,10 +2361,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Maybe", params = Seq(), - returnType = "Unnamed.Test.Maybe", + returnType = "Test.Maybe", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -2364,10 +2373,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Nothing", arguments = Seq(), - returnType = "Unnamed.Test.Maybe", + returnType = "Test.Maybe", documentation = None, annotations = Seq() ), @@ -2376,13 +2385,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Just", arguments = Seq( Suggestion .Argument("a", SuggestionBuilder.Any, false, false, None) ), - returnType = "Unnamed.Test.Maybe", + returnType = "Test.Maybe", documentation = None, annotations = Seq() ), @@ -2391,13 +2400,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "a", arguments = List( Suggestion - .Argument("self", "Unnamed.Test.Maybe", false, false, None) + .Argument("self", "Test.Maybe", false, false, None) ), - selfType = "Unnamed.Test.Maybe", + selfType = "Test.Maybe", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -2419,7 +2428,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | Nothing | ## Something there | Just a""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -2427,10 +2436,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Maybe", params = Seq(), - returnType = "Unnamed.Test.Maybe", + returnType = "Test.Maybe", parentType = Some(SuggestionBuilder.Any), documentation = Some(" When in doubt") ), @@ -2439,10 +2448,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Nothing", arguments = Seq(), - returnType = "Unnamed.Test.Maybe", + returnType = "Test.Maybe", documentation = Some(" Nothing here"), annotations = Seq() ), @@ -2451,13 +2460,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Just", arguments = Seq( Suggestion .Argument("a", SuggestionBuilder.Any, false, false, None) ), - returnType = "Unnamed.Test.Maybe", + returnType = "Test.Maybe", documentation = Some(" Something there"), annotations = Seq() ), @@ -2466,13 +2475,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "a", arguments = List( Suggestion - .Argument("self", "Unnamed.Test.Maybe", false, false, None) + .Argument("self", "Test.Maybe", false, false, None) ), - selfType = "Unnamed.Test.Maybe", + selfType = "Test.Maybe", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -2495,7 +2504,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | empty : List | empty = Nil |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -2503,10 +2512,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "List", params = Seq(), - returnType = "Unnamed.Test.List", + returnType = "Test.List", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -2515,10 +2524,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Cons", arguments = Seq(), - returnType = "Unnamed.Test.List", + returnType = "Test.List", documentation = Some(" And more"), annotations = Seq() ), @@ -2527,10 +2536,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Nil", arguments = Seq(), - returnType = "Unnamed.Test.List", + returnType = "Test.List", documentation = Some(" End"), annotations = Seq() ), @@ -2539,11 +2548,11 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "empty", arguments = Seq(), - selfType = "Unnamed.Test.List", - returnType = "Unnamed.Test.List", + selfType = "Test.List", + returnType = "Test.List", isStatic = true, documentation = Some(" a method"), annotations = Seq() @@ -2563,7 +2572,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | map self f = case self of | Just a -> Just (f a) | Nothing -> Nothing""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -2571,10 +2580,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Maybe", params = Seq(), - returnType = "Unnamed.Test.Maybe", + returnType = "Test.Maybe", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -2583,10 +2592,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Nothing", arguments = Seq(), - returnType = "Unnamed.Test.Maybe", + returnType = "Test.Maybe", documentation = None, annotations = Seq() ), @@ -2595,13 +2604,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Just", arguments = Seq( Suggestion .Argument("a", SuggestionBuilder.Any, false, false, None) ), - returnType = "Unnamed.Test.Maybe", + returnType = "Test.Maybe", documentation = None, annotations = Seq() ), @@ -2610,13 +2619,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "a", arguments = List( Suggestion - .Argument("self", "Unnamed.Test.Maybe", false, false, None) + .Argument("self", "Test.Maybe", false, false, None) ), - selfType = "Unnamed.Test.Maybe", + selfType = "Test.Maybe", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -2626,15 +2635,15 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "map", arguments = Seq( Suggestion - .Argument("self", "Unnamed.Test.Maybe", false, false, None), + .Argument("self", "Test.Maybe", false, false, None), Suggestion .Argument("f", SuggestionBuilder.Any, false, false, None) ), - selfType = "Unnamed.Test.Maybe", + selfType = "Test.Maybe", returnType = SuggestionBuilder.Any, isStatic = false, documentation = None, @@ -2656,7 +2665,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |type T | A (x : S) |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -2664,10 +2673,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "S", params = Seq(), - returnType = "Unnamed.Test.S", + returnType = "Test.S", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -2676,10 +2685,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "X", arguments = Seq(), - returnType = "Unnamed.Test.S", + returnType = "Test.S", documentation = None, annotations = Seq() ), @@ -2688,10 +2697,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Y", arguments = Seq(), - returnType = "Unnamed.Test.S", + returnType = "Test.S", documentation = None, annotations = Seq() ), @@ -2700,10 +2709,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "T", params = Seq(), - returnType = "Unnamed.Test.T", + returnType = "Test.T", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -2712,19 +2721,19 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "A", arguments = Seq( Suggestion.Argument( "x", - "Unnamed.Test.S", + "Test.S", false, false, None, Some(Seq("..X", "..Y")) ) ), - returnType = "Unnamed.Test.T", + returnType = "Test.T", documentation = None, annotations = Seq() ), @@ -2733,14 +2742,14 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "x", arguments = Seq( Suggestion - .Argument("self", "Unnamed.Test.T", false, false, None) + .Argument("self", "Test.T", false, false, None) ), - selfType = "Unnamed.Test.T", - returnType = "Unnamed.Test.S", + selfType = "Test.T", + returnType = "Test.S", documentation = None, annotations = Seq() ), @@ -2759,7 +2768,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | X a b | Y c |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -2767,10 +2776,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "S", params = Seq(), - returnType = "Unnamed.Test.S", + returnType = "Test.S", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -2779,7 +2788,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "X", arguments = Seq( Suggestion @@ -2787,7 +2796,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Suggestion .Argument("b", SuggestionBuilder.Any, false, false, None) ), - returnType = "Unnamed.Test.S", + returnType = "Test.S", documentation = None, annotations = Seq("a", "b") ), @@ -2796,13 +2805,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Y", arguments = Seq( Suggestion .Argument("c", SuggestionBuilder.Any, false, false, None) ), - returnType = "Unnamed.Test.S", + returnType = "Test.S", documentation = None, annotations = Seq() ), @@ -2811,13 +2820,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "a", arguments = Seq( Suggestion - .Argument("self", "Unnamed.Test.S", false, false, None) + .Argument("self", "Test.S", false, false, None) ), - selfType = "Unnamed.Test.S", + selfType = "Test.S", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -2827,13 +2836,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "b", arguments = Seq( Suggestion - .Argument("self", "Unnamed.Test.S", false, false, None) + .Argument("self", "Test.S", false, false, None) ), - selfType = "Unnamed.Test.S", + selfType = "Test.S", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -2843,13 +2852,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "c", arguments = Seq( Suggestion - .Argument("self", "Unnamed.Test.S", false, false, None) + .Argument("self", "Test.S", false, false, None) ), - selfType = "Unnamed.Test.S", + selfType = "Test.S", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -2868,7 +2877,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |type T | A (x : Numbers.Number) |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -2876,10 +2885,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "T", params = Seq(), - returnType = "Unnamed.Test.T", + returnType = "Test.T", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -2888,7 +2897,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "A", arguments = Seq( Suggestion @@ -2900,7 +2909,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { None ) ), - returnType = "Unnamed.Test.T", + returnType = "Test.T", documentation = None, annotations = Seq() ), @@ -2909,13 +2918,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "x", arguments = Seq( Suggestion - .Argument("self", "Unnamed.Test.T", false, false, None) + .Argument("self", "Test.T", false, false, None) ), - selfType = "Unnamed.Test.T", + selfType = "Test.T", returnType = "Standard.Base.Data.Numbers.Number", documentation = None, annotations = Seq() @@ -2934,7 +2943,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | L (x : a) | R (y : b) |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -2942,7 +2951,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "E", params = Seq( Suggestion @@ -2950,7 +2959,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Suggestion .Argument("b", SuggestionBuilder.Any, false, false, None) ), - returnType = "Unnamed.Test.E", + returnType = "Test.E", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -2959,12 +2968,12 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "L", arguments = Seq( Suggestion.Argument("x", "a", false, false, None) ), - returnType = "Unnamed.Test.E", + returnType = "Test.E", documentation = None, annotations = Seq() ), @@ -2973,12 +2982,12 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "R", arguments = Seq( Suggestion.Argument("y", "b", false, false, None) ), - returnType = "Unnamed.Test.E", + returnType = "Test.E", documentation = None, annotations = Seq() ), @@ -2987,13 +2996,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "x", arguments = Seq( Suggestion - .Argument("self", "Unnamed.Test.E", false, false, None) + .Argument("self", "Test.E", false, false, None) ), - selfType = "Unnamed.Test.E", + selfType = "Test.E", returnType = "a", documentation = None, annotations = Seq() @@ -3003,13 +3012,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "y", arguments = Seq( Suggestion - .Argument("self", "Unnamed.Test.E", false, false, None) + .Argument("self", "Test.E", false, false, None) ), - selfType = "Unnamed.Test.E", + selfType = "Test.E", returnType = "b", documentation = None, annotations = Seq() @@ -3028,7 +3037,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |type T | A a_internal internal_a x |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -3036,10 +3045,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "T", params = Seq(), - returnType = "Unnamed.Test.T", + returnType = "Test.T", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -3048,7 +3057,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "A", arguments = Seq( Suggestion.Argument( @@ -3073,7 +3082,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { None ) ), - returnType = "Unnamed.Test.T", + returnType = "Test.T", documentation = None, annotations = Seq() ), @@ -3082,13 +3091,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "x", arguments = Seq( Suggestion - .Argument("self", "Unnamed.Test.T", false, false, None) + .Argument("self", "Test.T", false, false, None) ), - selfType = "Unnamed.Test.T", + selfType = "Test.T", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -3106,7 +3115,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | | foo self = x + y |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -3114,10 +3123,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "T", params = Seq(), - returnType = "Unnamed.Test.T", + returnType = "Test.T", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -3126,13 +3135,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq( Suggestion - .Argument("self", "Unnamed.Test.T", false, false, None) + .Argument("self", "Test.T", false, false, None) ), - selfType = "Unnamed.Test.T", + selfType = "Test.T", returnType = SuggestionBuilder.Any, isStatic = false, documentation = None, @@ -3150,7 +3159,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | private priv_meth self = 42 | pub_meth self = 42 |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -3158,10 +3167,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "T", params = Seq(), - returnType = "Unnamed.Test.T", + returnType = "Test.T", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -3170,13 +3179,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "pub_meth", arguments = Seq( Suggestion - .Argument("self", "Unnamed.Test.T", false, false, None) + .Argument("self", "Test.T", false, false, None) ), - selfType = "Unnamed.Test.T", + selfType = "Test.T", returnType = SuggestionBuilder.Any, isStatic = false, documentation = None, @@ -3196,7 +3205,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |pub_stat_method x = 42 |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -3204,13 +3213,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "pub_stat_method", arguments = Seq( Suggestion .Argument("x", "Standard.Base.Any.Any", false, false, None) ), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -3292,7 +3301,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | MkMyType a b | |main = IO.println "Hello!"""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -3300,10 +3309,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "MyType", params = Seq(), - returnType = "Unnamed.Test.MyType", + returnType = "Test.MyType", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -3312,7 +3321,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "MkMyType", arguments = Seq( Suggestion @@ -3320,7 +3329,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Suggestion .Argument("b", SuggestionBuilder.Any, false, false, None) ), - returnType = "Unnamed.Test.MyType", + returnType = "Test.MyType", documentation = None, annotations = Seq() ), @@ -3329,13 +3338,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "a", arguments = List( Suggestion - .Argument("self", "Unnamed.Test.MyType", false, false, None) + .Argument("self", "Test.MyType", false, false, None) ), - selfType = "Unnamed.Test.MyType", + selfType = "Test.MyType", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -3345,13 +3354,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "b", arguments = List( Suggestion - .Argument("self", "Unnamed.Test.MyType", false, false, None) + .Argument("self", "Test.MyType", false, false, None) ), - selfType = "Unnamed.Test.MyType", + selfType = "Test.MyType", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -3361,10 +3370,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -3384,7 +3393,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | |main = "Hello World!" |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root(Vector()) } @@ -3395,7 +3404,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | Mk_Test a | |main = IO.println "Hello!"""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -3403,10 +3412,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Test", params = Seq(), - returnType = "Unnamed.Test.Test", + returnType = "Test.Test", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -3415,13 +3424,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Mk_Test", arguments = Seq( Suggestion .Argument("a", SuggestionBuilder.Any, false, false, None) ), - returnType = "Unnamed.Test.Test", + returnType = "Test.Test", documentation = None, annotations = Seq() ), @@ -3430,13 +3439,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "a", arguments = List( Suggestion - .Argument("self", "Unnamed.Test.Test", false, false, None) + .Argument("self", "Test.Test", false, false, None) ), - selfType = "Unnamed.Test.Test", + selfType = "Test.Test", returnType = SuggestionBuilder.Any, documentation = None, annotations = Seq() @@ -3446,10 +3455,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -3476,7 +3485,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |main = | quux A | A.quux A""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -3484,10 +3493,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "A", params = List(), - returnType = "Unnamed.Test.A", + returnType = "Test.A", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -3496,10 +3505,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Mk_A", arguments = List(), - returnType = "Unnamed.Test.A", + returnType = "Test.A", documentation = None, annotations = Seq() ), @@ -3508,7 +3517,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Mk_A_Plus", arguments = List( Suggestion.Argument( @@ -3520,7 +3529,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { None ) ), - returnType = "Unnamed.Test.A", + returnType = "Test.A", documentation = None, annotations = Seq() ), @@ -3529,13 +3538,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Getter( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "a", arguments = Vector( Suggestion - .Argument("self", "Unnamed.Test.A", false, false, None, None) + .Argument("self", "Test.A", false, false, None, None) ), - selfType = "Unnamed.Test.A", + selfType = "Test.A", returnType = "Standard.Base.Any.Any", documentation = None, annotations = Seq() @@ -3545,22 +3554,22 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( None, - "Unnamed.Test", + "Test", "quux", Vector( Suggestion - .Argument("self", "Unnamed.Test.A", false, false, None), + .Argument("self", "Test.A", false, false, None), Suggestion.Argument( "x", - "Unnamed.Test.A", + "Test.A", false, false, None, - Some(List("Unnamed.Test.A.Mk_A", "Unnamed.Test.A.Mk_A_Plus")) + Some(List("Test.A.Mk_A", "Test.A.Mk_A_Plus")) ) ), - selfType = "Unnamed.Test.A", - returnType = "Unnamed.Test.A", + selfType = "Test.A", + returnType = "Test.A", isStatic = false, documentation = None, annotations = Seq() @@ -3570,20 +3579,20 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "quux", arguments = Vector( Suggestion.Argument( "x", - "Unnamed.Test.A", + "Test.A", false, false, None, - Some(List("Unnamed.Test.A.Mk_A", "Unnamed.Test.A.Mk_A_Plus")) + Some(List("Test.A.Mk_A", "Test.A.Mk_A_Plus")) ) ), - selfType = "Unnamed.Test", - returnType = "Unnamed.Test.A", + selfType = "Test", + returnType = "Test.A", isStatic = true, documentation = None, annotations = Seq() @@ -3593,10 +3602,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = List(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -3622,7 +3631,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |main = | quux A | A.quux A""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -3630,10 +3639,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Type( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "A", params = List(), - returnType = "Unnamed.Test.A", + returnType = "Test.A", parentType = Some(SuggestionBuilder.Any), documentation = None ), @@ -3642,10 +3651,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.Constructor( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "Mk_A", arguments = List(), - returnType = "Unnamed.Test.A", + returnType = "Test.A", documentation = None, annotations = Seq() ), @@ -3654,22 +3663,22 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "quux", arguments = Vector( Suggestion - .Argument("self", "Unnamed.Test.A", false, false, None), + .Argument("self", "Test.A", false, false, None), Suggestion.Argument( "x", - "Unnamed.Test.A", + "Test.A", false, false, None, None ) ), - selfType = "Unnamed.Test.A", - returnType = "Unnamed.Test.A", + selfType = "Test.A", + returnType = "Test.A", isStatic = false, documentation = None, annotations = Seq() @@ -3679,20 +3688,20 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "quux", arguments = Vector( Suggestion.Argument( "x", - "Unnamed.Test.A", + "Test.A", false, false, None, None ) ), - selfType = "Unnamed.Test", - returnType = "Unnamed.Test.A", + selfType = "Test", + returnType = "Test.A", isStatic = true, documentation = None, annotations = Seq() @@ -3702,10 +3711,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = List(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -3726,7 +3735,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |[[{"index": {"value": 7}, "size": {"value": 19}}, "4083ce56-a5e5-4ecd-bf45-37ddf0b58456"]] |[] |""".stripMargin.linesIterator.mkString("\n") - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -3735,10 +3744,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Suggestion.DefinedMethod( externalId = Some(UUID.fromString("4083ce56-a5e5-4ecd-bf45-37ddf0b58456")), - module = "Unnamed.Test", + module = "Test", name = "main", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -3761,7 +3770,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |[[{"index": {"value": 18}, "size": {"value": 1}}, "f533d910-63f8-44cd-9204-a1e2d46bb7c3"]] |[] |""".stripMargin.linesIterator.mkString("\n") - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -3769,10 +3778,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -3784,7 +3793,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { externalId = Some( UUID.fromString("f533d910-63f8-44cd-9204-a1e2d46bb7c3") ), - module = "Unnamed.Test", + module = "Test", name = "id", arguments = Seq( Suggestion @@ -3816,7 +3825,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |[[{"index": {"value": 17}, "size": {"value": 2}}, "0270bcdf-26b8-4b99-8745-85b3600c7359"]] |[] |""".stripMargin.linesIterator.mkString("\n") - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( @@ -3824,10 +3833,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "main", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = None, @@ -3839,7 +3848,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { externalId = Some( UUID.fromString("0270bcdf-26b8-4b99-8745-85b3600c7359") ), - module = "Unnamed.Test", + module = "Test", name = "foo", returnType = SuggestionBuilder.Any, scope = Suggestion.Scope( @@ -3863,13 +3872,13 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | |## The foo |foo = 42""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() build(code, module) shouldEqual Tree.Root( Vector( Tree.Node( Suggestion.Module( - module = "Unnamed.Test", + module = "Test", documentation = Some(" Module doc") ), Vector() @@ -3877,10 +3886,10 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { Tree.Node( Suggestion.DefinedMethod( externalId = None, - module = "Unnamed.Test", + module = "Test", name = "foo", arguments = Seq(), - selfType = "Unnamed.Test", + selfType = "Test", returnType = SuggestionBuilder.Any, isStatic = true, documentation = Some(" The foo"), @@ -3900,15 +3909,15 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { | |foo : My_Tp -> My_Tp |foo arg = arg.do_sth""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() val suggestions = build(code, module) val fooSuggestion = suggestions.collectFirst { case s: Suggestion.DefinedMethod if s.name == "foo" => s } val fooArg = fooSuggestion.get.arguments(0) - fooArg.reprType shouldEqual "Unnamed.Test.My_Tp" + fooArg.reprType shouldEqual "Test.My_Tp" fooArg.tagValues shouldEqual Some( - List("Unnamed.Test.My_Tp.Variant_A", "Unnamed.Test.My_Tp.Variant_B") + List("Test.My_Tp.Variant_A", "Test.My_Tp.Variant_B") ) } @@ -3919,7 +3928,7 @@ class SuggestionBuilderTest extends AnyWordSpecLike with Matchers { |Text.trim : (Location.Start | Location.End | Location.Both) -> (Text | (Text -> Boolean)) -> Text |Text.trim self where=Location.Both what=_.is_whitespace = self |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() val suggestions = build(code, module) val method = suggestions.collectFirst { case s: Suggestion.DefinedMethod if s.name == "trim" => s diff --git a/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/refactoring/IRUtilsTest.scala b/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/refactoring/IRUtilsTest.scala index 36e35bf442c2..4bdbf9c01c91 100644 --- a/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/refactoring/IRUtilsTest.scala +++ b/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/refactoring/IRUtilsTest.scala @@ -22,23 +22,19 @@ class IRUtilsTest extends AnyWordSpecLike with Matchers with OptionValues { .invokeMember(MethodNames.TopScope.LEAK_CONTEXT) .asHostObject[EnsoContext]() - implicit private class PreprocessModule(code: String) { + private val moduleName = QualifiedName.simpleName("Test") - private val Module = QualifiedName(List("Unnamed"), "Test") + implicit private class PreprocessModule(code: String) { - def preprocessModule(name: QualifiedName): Module = { + def preprocessModule(): Module = { val module = new runtime.Module( - name, + moduleName, null, code.stripMargin.linesIterator.mkString("\n") ) langCtx.getCompiler.run(module.asCompilerModule()) module.getIr } - - def preprocessModule: Module = - preprocessModule(Module) - } private def findUsagesOfLiteral( @@ -86,7 +82,7 @@ class IRUtilsTest extends AnyWordSpecLike with Matchers with OptionValues { |[] |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() val operator1 = IRUtils.findByExternalId(module, uuid1).get val usages = findUsagesOfLiteral(module, operator1) @@ -111,7 +107,7 @@ class IRUtilsTest extends AnyWordSpecLike with Matchers with OptionValues { |[] |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() val operator1 = IRUtils.findByExternalId(module, uuid1).get val usages = findUsagesOfLiteral(module, operator1) @@ -136,7 +132,7 @@ class IRUtilsTest extends AnyWordSpecLike with Matchers with OptionValues { |[] |""".stripMargin - val module = code.preprocessModule + val module = code.preprocessModule() val operator1 = IRUtils.findByExternalId(module, uuid1).get val usages = findUsagesOfLiteral(module, operator1) @@ -148,8 +144,7 @@ class IRUtilsTest extends AnyWordSpecLike with Matchers with OptionValues { } "find usages of a static method call in main body" in { - val uuid1 = new UUID(0, 1) - val moduleName = QualifiedName(List("Unnamed"), "Test") + val uuid1 = new UUID(0, 1) val code = s"""function1 x = x + 1 | @@ -164,7 +159,7 @@ class IRUtilsTest extends AnyWordSpecLike with Matchers with OptionValues { |[] |""".stripMargin - val module = code.preprocessModule(moduleName) + val module = code.preprocessModule() val function1 = IRUtils.findByExternalId(module, uuid1).get val usages = findUsagesOfModuleMethod(moduleName, module, function1) @@ -176,8 +171,7 @@ class IRUtilsTest extends AnyWordSpecLike with Matchers with OptionValues { } "find usages of a static call in lambda" in { - val uuid1 = new UUID(0, 1) - val moduleName = QualifiedName(List("Unnamed"), "Test") + val uuid1 = new UUID(0, 1) val code = s"""function1 x = x | @@ -192,7 +186,7 @@ class IRUtilsTest extends AnyWordSpecLike with Matchers with OptionValues { |[] |""".stripMargin - val module = code.preprocessModule(moduleName) + val module = code.preprocessModule() val function1 = IRUtils.findByExternalId(module, uuid1).get val usages = findUsagesOfModuleMethod(moduleName, module, function1) @@ -204,8 +198,7 @@ class IRUtilsTest extends AnyWordSpecLike with Matchers with OptionValues { } "find usages of a static method call in presence of an instance method" in { - val uuid1 = new UUID(0, 1) - val moduleName = QualifiedName(List("Unnamed"), "Test") + val uuid1 = new UUID(0, 1) val code = s"""function1 x = x | @@ -220,7 +213,7 @@ class IRUtilsTest extends AnyWordSpecLike with Matchers with OptionValues { |[] |""".stripMargin - val module = code.preprocessModule(moduleName) + val module = code.preprocessModule() val function1 = IRUtils.findByExternalId(module, uuid1).get val usages = findUsagesOfModuleMethod(moduleName, module, function1) @@ -232,8 +225,7 @@ class IRUtilsTest extends AnyWordSpecLike with Matchers with OptionValues { } "find usages of a static method call in presence of a type method" in { - val uuid1 = new UUID(0, 1) - val moduleName = QualifiedName(List("Unnamed"), "Test") + val uuid1 = new UUID(0, 1) val code = s"""function1 x = x | @@ -251,7 +243,7 @@ class IRUtilsTest extends AnyWordSpecLike with Matchers with OptionValues { |[] |""".stripMargin - val module = code.preprocessModule(moduleName) + val module = code.preprocessModule() val operator1 = IRUtils.findByExternalId(module, uuid1).get val usages = findUsagesOfModuleMethod(moduleName, module, operator1) diff --git a/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/semantic/ImportExportTest.scala b/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/semantic/ImportExportTest.scala index 76ddcce6b97f..b28553b3b5ad 100644 --- a/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/semantic/ImportExportTest.scala +++ b/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/semantic/ImportExportTest.scala @@ -1,5 +1,6 @@ package org.enso.compiler.test.semantic +import com.oracle.truffle.api.TruffleFile import org.enso.compiler.core.Implicits.AsMetadata import org.enso.compiler.core.ir.{Module, ProcessingPass, Warning} import org.enso.compiler.core.ir.expression.errors @@ -11,17 +12,18 @@ import org.enso.interpreter.runtime import org.enso.interpreter.runtime.EnsoContext import org.enso.persist.Persistance import org.enso.pkg.QualifiedName +import org.enso.pkg.Package import org.enso.common.LanguageInfo -import org.enso.common.MethodNames import org.enso.compiler.phase.exports.Node import org.enso.common.RuntimeOptions +import org.enso.test.utils.{ContextUtils, ProjectUtils} import org.graalvm.polyglot.{Context, Engine} -import org.scalatest.BeforeAndAfter +import org.scalatest.{BeforeAndAfter} import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpecLike import java.io.ByteArrayOutputStream -import java.nio.file.Paths +import java.nio.file.{Files, Path, Paths} import java.util.logging.Level import java.io.IOException @@ -35,12 +37,17 @@ class ImportExportTest with BeforeAndAfter { private val out = new ByteArrayOutputStream() + private val namespace = "local" + private val packageName = "My_Package" + private val packageQualifiedName = + QualifiedName.fromString(namespace + "." + packageName) + private val engine = Engine .newBuilder("enso") .allowExperimentalOptions(true) .build() - private val ctx = Context + private val ctxBldr = Context .newBuilder(LanguageInfo.ID) .engine(engine) .allowExperimentalOptions(true) @@ -51,7 +58,7 @@ class ImportExportTest .option(RuntimeOptions.LOG_LEVEL, Level.WARNING.getName()) .option(RuntimeOptions.DISABLE_IR_CACHES, "true") .option(RuntimeOptions.STRICT_ERRORS, "false") - .logHandler(System.err) + .logHandler(out) .option( RuntimeOptions.LANGUAGE_HOME_OVERRIDE, Paths @@ -60,23 +67,34 @@ class ImportExportTest .getAbsolutePath ) .option(RuntimeOptions.EDITION_OVERRIDE, "0.0.0-dev") - .build() - private val langCtx: EnsoContext = ctx - .getBindings(LanguageInfo.ID) - .invokeMember(MethodNames.TopScope.LEAK_CONTEXT) - .asHostObject[EnsoContext]() + private var ctx: Context = _ + private var langCtx: EnsoContext = _ + private var tmpDir: Path = _ + private var pkg: Package[TruffleFile] = _ - private val namespace = "my_pkg" - private val packageName = "My_Package" - private val packageQualifiedName = - QualifiedName.fromString(namespace + "." + packageName) + before { + // Create temp dir with skeleton project structure. In the tests, we will create + // synthetic modules that will be part of this project. + tmpDir = Files.createTempDirectory("enso-test") + ProjectUtils.createProject(packageName, "main = 42", tmpDir) + ctxBldr.option(RuntimeOptions.PROJECT_ROOT, tmpDir.toAbsolutePath.toString) + ctx = ctxBldr.build() + langCtx = ContextUtils.leakContext(ctx) + langCtx.getPackageRepository.getMainProjectPackage shouldBe defined + pkg = langCtx.getPackageRepository.getMainProjectPackage.get + ctx.enter() + } - langCtx.getPackageRepository.registerSyntheticPackage(namespace, packageName) + after { + ctx.leave() + out.reset() + ProjectUtils.deleteRecursively(tmpDir) + } implicit private class CreateModule(moduleCode: String) { def createModule(moduleName: QualifiedName): runtime.Module = { - val module = new runtime.Module(moduleName, null, moduleCode) + val module = new runtime.Module(moduleName, pkg, moduleCode) langCtx.getPackageRepository.registerModuleCreatedInRuntime( module.asCompilerModule() ) @@ -114,15 +132,6 @@ class ImportExportTest ) } - before { - ctx.enter() - } - - after { - ctx.leave() - out.reset() - } - "Import resolution with just two modules" should { "resolve one import symbol from a module" in { val moduleCode = diff --git a/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/semantic/TypeSignaturesTest.scala b/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/semantic/TypeSignaturesTest.scala index bfec8924f73f..3bab4f826e92 100644 --- a/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/semantic/TypeSignaturesTest.scala +++ b/engine/runtime-integration-tests/src/test/scala/org/enso/compiler/test/semantic/TypeSignaturesTest.scala @@ -6,15 +6,21 @@ import org.enso.compiler.core.ir import org.enso.compiler.core.ir.module.scope.definition import org.enso.compiler.core.ir.`type` import org.enso.compiler.pass.resolve.{TypeNames, TypeSignatures} -import org.enso.interpreter.runtime import org.enso.interpreter.runtime.EnsoContext import org.enso.interpreter.test.InterpreterContext import org.enso.pkg.QualifiedName -import org.enso.common.{LanguageInfo, MethodNames} +import org.enso.common.{LanguageInfo, MethodNames, RuntimeOptions} +import org.enso.editions.LibraryName +import org.enso.test.utils.{ProjectUtils, SourceModule} +import org.enso.testkit.WithTemporaryDirectory +import org.scalatest.BeforeAndAfterAll import org.scalatest.matchers.{MatchResult, Matcher} import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpecLike +import java.io.ByteArrayOutputStream +import scala.jdk.CollectionConverters.SetHasAsJava + trait TypeMatchers { sealed trait Sig { def ->:(that: Sig): Sig = this match { @@ -127,36 +133,67 @@ trait TypeMatchers { class TypeSignaturesTest extends AnyWordSpecLike with Matchers - with TypeMatchers { + with TypeMatchers + with WithTemporaryDirectory + with BeforeAndAfterAll { - private val ctx = new InterpreterContext() - private val langCtx = ctx - .ctx() - .getBindings(LanguageInfo.ID) - .invokeMember(MethodNames.TopScope.LEAK_CONTEXT) - .asHostObject[EnsoContext]() + private var ctx: InterpreterContext = _ + private var langCtx: EnsoContext = _ + private var devNull: ByteArrayOutputStream = new ByteArrayOutputStream() - private val Module = QualifiedName.fromString("Unnamed.Test") + override def afterAll(): Unit = { + ctx.close() + devNull.close() + devNull = null + ctx = null + langCtx = null + } - langCtx.getPackageRepository.registerSyntheticPackage("my_pkg", "My_Lib") - langCtx.getTopScope.createModule( - QualifiedName.fromString("my_pkg.My_Lib.Util"), - null, - s""" - |type Util_1 - |type Util_2 - | - |type Util_Sum - | Util_Sum_1 - | Util_Sum_2 - |""".stripMargin - ) + private val libName: LibraryName = LibraryName("local", "My_Lib") implicit private class PreprocessModule(code: String) { def preprocessModule: Module = { - val module = new runtime.Module(Module, null, code) - langCtx.getCompiler.run(module.asCompilerModule()) - module.getIr + val utilMod = new SourceModule( + QualifiedName.simpleName("Util"), + """ + |type Util_1 + |type Util_2 + | + |type Util_Sum + | Util_Sum_1 + | Util_Sum_2 + |""".stripMargin + ) + val testMod = new SourceModule(QualifiedName.simpleName("Test"), code) + ProjectUtils.createProject( + libName.name, + Set(utilMod, testMod).asJava, + getTestDirectory + ) + ctx = new InterpreterContext(bldr => + bldr + .option( + RuntimeOptions.PROJECT_ROOT, + getTestDirectory.toFile.getAbsolutePath + ) + .logHandler(devNull) + ) + langCtx = ctx + .ctx() + .getBindings(LanguageInfo.ID) + .invokeMember(MethodNames.TopScope.LEAK_CONTEXT) + .asHostObject[EnsoContext]() + val pkgWasLoaded = + langCtx.getPackageRepository.ensurePackageIsLoaded(libName) + pkgWasLoaded.isRight shouldBe true + + val testModName = QualifiedName.fromString(libName.toString + ".Test") + val module = + langCtx.getPackageRepository.getLoadedModule(testModName.toString) + module shouldBe defined + val compilerRes = langCtx.getCompiler.run(module.get) + compilerRes.compiledModules.isEmpty shouldBe false + module.get.getIr } } @@ -202,41 +239,41 @@ class TypeSignaturesTest |foo a = 42""".stripMargin val module = code.preprocessModule getSignature(module, "foo") should typeAs( - "Unnamed.Test.A" ->: "Unnamed.Test.B" ->: "Unnamed.Test.C" ->: "Unnamed.Test.C" ->: "Unnamed.Test.A" + "local.My_Lib.Test.A" ->: "local.My_Lib.Test.B" ->: "local.My_Lib.Test.C" ->: "local.My_Lib.Test.C" ->: "local.My_Lib.Test.A" ) } - "resolve imported names" in { + "XX resolve imported names" in { val code = """ - |from my_pkg.My_Lib.Util import all + |from project.Util import all | |foo : Util_1 -> Util_2 |foo a = 23 |""".stripMargin val module = code.preprocessModule getSignature(module, "foo") should typeAs( - "my_pkg.My_Lib.Util.Util_1" ->: "my_pkg.My_Lib.Util.Util_2" + "local.My_Lib.Util.Util_1" ->: "local.My_Lib.Util.Util_2" ) } "resolve imported union type names" in { val code = """ - |from my_pkg.My_Lib.Util import all + |from project.Util import all | |foo : Util_Sum -> Util_2 |foo a = 23 |""".stripMargin val module = code.preprocessModule getSignature(module, "foo") should typeAs( - "my_pkg.My_Lib.Util.Util_Sum" ->: "my_pkg.My_Lib.Util.Util_2" + "local.My_Lib.Util.Util_Sum" ->: "local.My_Lib.Util.Util_2" ) } "resolve anonymous sum types" in { val code = - """from my_pkg.My_Lib.Util import all + """from project.Util import all | |type Foo | @@ -245,7 +282,7 @@ class TypeSignaturesTest |""".stripMargin val module = code.preprocessModule getSignature(module, "baz") should typeAs( - ("Unnamed.Test.Foo" | "my_pkg.My_Lib.Util.Util_2" | "my_pkg.My_Lib.Util.Util_Sum") ->: "Unnamed.Test.Foo" + ("local.My_Lib.Test.Foo" | "local.My_Lib.Util.Util_2" | "local.My_Lib.Util.Util_Sum") ->: "local.My_Lib.Test.Foo" ) } diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/ProgramRootNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/ProgramRootNode.java index 60c57e468a68..04810484104e 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/ProgramRootNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/ProgramRootNode.java @@ -52,14 +52,21 @@ public static ProgramRootNode build(EnsoLanguage language, Source sourceCode) { public Object execute(VirtualFrame frame) { if (module == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); - QualifiedName name = QualifiedName.simpleName(canonicalizeName(sourceCode.getName())); + QualifiedName simpleName = QualifiedName.simpleName(canonicalizeName(sourceCode.getName())); EnsoContext ctx = EnsoContext.get(this); if (sourceCode.getPath() != null) { TruffleFile src = ctx.getTruffleFile(new File(sourceCode.getPath())); Package pkg = ctx.getPackageOf(src).orElse(null); - module = new Module(name, pkg, src); + QualifiedName qualifiedName; + if (pkg != null) { + qualifiedName = + QualifiedName.fromString(pkg.libraryName().toString() + "." + simpleName.item()); + } else { + qualifiedName = simpleName; + } + module = new Module(qualifiedName, pkg, src); } else { - module = new Module(name, null, sourceCode.getCharacters().toString()); + module = new Module(simpleName, null, sourceCode.getCharacters().toString()); } ctx.getPackageRepository().registerModuleCreatedInRuntime(module.asCompilerModule()); if (ctx.isStrictErrors()) { diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/Module.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/Module.java index 9d59f77ab0ab..e7b0cbded6df 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/Module.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/Module.java @@ -87,6 +87,7 @@ public final class Module implements EnsoObject { * @param sourceFile the module's source file. */ public Module(QualifiedName name, Package pkg, TruffleFile sourceFile) { + ensureConsistentName(name, pkg); this.sources = ModuleSources.NONE.newWith(sourceFile); this.name = name; this.scopeBuilder = new ModuleScope.Builder(this); @@ -105,6 +106,7 @@ public Module(QualifiedName name, Package pkg, TruffleFile sourceFi * @param literalSource the module's source. */ public Module(QualifiedName name, Package pkg, String literalSource) { + ensureConsistentName(name, pkg); this.sources = ModuleSources.NONE.newWith(Rope.apply(literalSource)); this.name = name; this.scopeBuilder = new ModuleScope.Builder(this); @@ -124,6 +126,7 @@ public Module(QualifiedName name, Package pkg, String literalSource * @param literalSource the module's source. */ public Module(QualifiedName name, Package pkg, Rope literalSource) { + ensureConsistentName(name, pkg); this.sources = ModuleSources.NONE.newWith(literalSource); this.name = name; this.scopeBuilder = new ModuleScope.Builder(this); @@ -143,6 +146,7 @@ public Module(QualifiedName name, Package pkg, Rope literalSource) */ private Module( QualifiedName name, Package pkg, boolean synthetic, Rope literalSource) { + ensureConsistentName(name, pkg); this.sources = literalSource == null ? ModuleSources.NONE : ModuleSources.NONE.newWith(literalSource); this.name = name; @@ -159,6 +163,27 @@ private Module( } } + private void ensureConsistentName(QualifiedName name, Package pkg) { + if (name.toString().equals(Builtins.MODULE_NAME)) { + return; + } + if (pkg != null && name.isSimple()) { + throw new IllegalArgumentException( + "Simple module name must not be in a package, i.e., trying to initialize a module in a" + + " package '" + + pkg.libraryName().toString() + + "' with a simple name '" + + name + + "'"); + } else if (pkg == null && !name.isSimple()) { + throw new IllegalArgumentException( + "Qualified module name must be in a package, i.e., trying to initialize " + + "a module with a qualified name '" + + name + + "' without a package"); + } + } + /** * Unwraps runtime module from compiler module. * diff --git a/engine/runtime/src/main/java/org/enso/interpreter/runtime/scope/TopLevelScope.java b/engine/runtime/src/main/java/org/enso/interpreter/runtime/scope/TopLevelScope.java index 37d03116996e..c71f2c6315a6 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/runtime/scope/TopLevelScope.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/runtime/scope/TopLevelScope.java @@ -16,6 +16,7 @@ import java.util.concurrent.ExecutionException; import org.enso.common.MethodNames; import org.enso.compiler.PackageRepository; +import org.enso.editions.LibraryName; import org.enso.interpreter.EnsoLanguage; import org.enso.interpreter.runtime.EnsoContext; import org.enso.interpreter.runtime.Module; @@ -151,7 +152,15 @@ private static Module registerModule( Types.extractArguments(arguments, String.class, String.class); QualifiedName qualName = QualifiedName.fromString(args.getFirst()); File location = new File(args.getSecond()); - Module module = new Module(qualName, null, context.getTruffleFile(location)); + var libName = LibraryName.fromModuleName(qualName.toString()); + Package pkg = null; + if (libName.isDefined()) { + var pkgOpt = context.getPackageRepository().getPackageForLibraryJava(libName.get()); + if (pkgOpt.isPresent()) { + pkg = pkgOpt.get(); + } + } + Module module = new Module(qualName, pkg, context.getTruffleFile(location)); scope.packageRepository.registerModuleCreatedInRuntime(module.asCompilerModule()); return module; } diff --git a/lib/scala/pkg/src/main/scala/org/enso/pkg/QualifiedName.scala b/lib/scala/pkg/src/main/scala/org/enso/pkg/QualifiedName.scala index c3581dbcecfc..c89ff6bc94d5 100644 --- a/lib/scala/pkg/src/main/scala/org/enso/pkg/QualifiedName.scala +++ b/lib/scala/pkg/src/main/scala/org/enso/pkg/QualifiedName.scala @@ -49,6 +49,12 @@ case class QualifiedName(path: List[String], item: String) { path.asJava } + /** Returns true if this a simple name, not a fully qualified name. + */ + def isSimple(): Boolean = { + path.isEmpty + } + def fullPath(): List[String] = path :+ item } diff --git a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso index 2535ed375d37..ca12d0f76312 100644 --- a/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso +++ b/test/Base_Tests/src/Semantic/Meta_Location_Spec.enso @@ -27,7 +27,7 @@ add_specs suite_builder = suite_builder.group "Meta-Value Inspection" group_buil y = My_Type.Value 1 2 3 Meta.get_qualified_type_name x . should_equal "Standard.Base.Data.Numbers.Integer" Meta.get_simple_type_name x . should_equal "Integer" - Meta.get_qualified_type_name y . should_end_with "Meta_Location_Spec.My_Type" + Meta.get_qualified_type_name y . should_equal "enso_dev.Base_Tests.Semantic.Meta_Location_Spec.My_Type" Meta.get_simple_type_name y . should_equal "My_Type" group_builder.specify "should allow access to package names" <|