diff --git a/engine/runtime-integration-tests/src/test/scala/org/enso/interpreter/test/instrument/RuntimeSuggestionUpdatesTest.scala b/engine/runtime-integration-tests/src/test/scala/org/enso/interpreter/test/instrument/RuntimeSuggestionUpdatesTest.scala index cba002ab1eb7..9e9ca0f85970 100644 --- a/engine/runtime-integration-tests/src/test/scala/org/enso/interpreter/test/instrument/RuntimeSuggestionUpdatesTest.scala +++ b/engine/runtime-integration-tests/src/test/scala/org/enso/interpreter/test/instrument/RuntimeSuggestionUpdatesTest.scala @@ -9,6 +9,7 @@ import org.enso.polyglot.ModuleExports import org.enso.polyglot.Suggestion import org.enso.polyglot.data.Tree import org.enso.polyglot.runtime.Runtime.Api +import org.enso.polyglot.runtime.Runtime.Api.SuggestionAction import org.enso.text.editing.model import org.enso.text.editing.model.TextEdit import org.graalvm.polyglot.Context @@ -20,7 +21,6 @@ import java.io.{ByteArrayOutputStream, File} import java.nio.file.{Files, Paths} import java.util.UUID import java.util.logging.Level - import scala.collection.immutable.ListSet @scala.annotation.nowarn("msg=multiarg infix syntax") @@ -1015,9 +1015,12 @@ class RuntimeSuggestionUpdatesTest """from Standard.Base import all | |import Enso_Test.Test.A - |from Enso_Test.Test.A export all |import Enso_Test.Test.A.MyType - |from Enso_Test.Test.A.MyType export all + | + |export Enso_Test.Test.A.MyType # Line 5 + |export Enso_Test.Test.A.fortytwo + |export Enso_Test.Test.A.hello # This line will be removed + |export Enso_Test.Test.A.MyType.MkA | |main = IO.println "Hello World!" |""".stripMargin.linesIterator.mkString("\n") @@ -1073,6 +1076,55 @@ class RuntimeSuggestionUpdatesTest 5 ) should contain theSameElementsAs Seq( Api.Response(requestId, Api.PushContextResponse(contextId)), + Api.Response( + Api.SuggestionsDatabaseModuleUpdateNotification( + module = "Enso_Test.Test.Main", + actions = + Vector(Api.SuggestionsDatabaseAction.Clean("Enso_Test.Test.Main")), + exports = Vector( + Api.ExportsUpdate( + ModuleExports( + "Enso_Test.Test.Main", + ListSet( + ExportedSymbol.Type("Enso_Test.Test.A", "MyType"), + ExportedSymbol.Constructor("Enso_Test.Test.A", "MkA"), + ExportedSymbol.Method("Enso_Test.Test.Main", "main"), + ExportedSymbol.Method("Enso_Test.Test.A", "hello") + ) + ), + Api.ExportsAction.Add() + ) + ), + updates = Tree.Root( + Vector( + Tree.Node( + Api.SuggestionUpdate( + Suggestion.Module("Enso_Test.Test.Main", None), + Api.SuggestionAction.Add() + ), + Vector() + ), + Tree.Node( + Api.SuggestionUpdate( + Suggestion.DefinedMethod( + None, + "Enso_Test.Test.Main", + "main", + List(), + "Enso_Test.Test.Main", + ConstantsGen.ANY, + true, + None, + Seq() + ), + Api.SuggestionAction.Add() + ), + Vector() + ) + ) + ) + ) + ), Api.Response( Api.SuggestionsDatabaseModuleUpdateNotification( module = "Enso_Test.Test.A", @@ -1094,7 +1146,10 @@ class RuntimeSuggestionUpdatesTest Vector( Tree.Node( Api.SuggestionUpdate( - Suggestion.Module("Enso_Test.Test.A", None), + Suggestion.Module( + "Enso_Test.Test.A", + None + ), Api.SuggestionAction.Add() ), Vector() @@ -1105,7 +1160,7 @@ class RuntimeSuggestionUpdatesTest None, "Enso_Test.Test.A", "MyType", - List(), + Seq(), "Enso_Test.Test.A.MyType", Some(ConstantsGen.ANY), None @@ -1121,14 +1176,19 @@ class RuntimeSuggestionUpdatesTest "Enso_Test.Test.A", "MkA", List( - Suggestion - .Argument("a", ConstantsGen.ANY, false, false, None) + Suggestion.Argument( + "a", + ConstantsGen.ANY, + false, + false, + None + ) ), "Enso_Test.Test.A.MyType", None, Seq() ), - Api.SuggestionAction.Add() + SuggestionAction.Add() ), Vector() ), @@ -1138,22 +1198,21 @@ class RuntimeSuggestionUpdatesTest None, "Enso_Test.Test.A", "a", - List( - Suggestion - .Argument( - "self", - "Enso_Test.Test.A.MyType", - false, - false, - None - ) + Seq( + Suggestion.Argument( + "self", + "Enso_Test.Test.A.MyType", + false, + false, + None + ) ), "Enso_Test.Test.A.MyType", ConstantsGen.ANY, None, Seq() ), - Api.SuggestionAction.Add() + SuggestionAction.Add() ), Vector() ), @@ -1203,71 +1262,21 @@ class RuntimeSuggestionUpdatesTest ) ) ), - Api.Response( - Api.SuggestionsDatabaseModuleUpdateNotification( - module = moduleName, - actions = Vector(Api.SuggestionsDatabaseAction.Clean(moduleName)), - exports = Vector( - Api.ExportsUpdate( - ModuleExports( - "Enso_Test.Test.Main", - ListSet( - ExportedSymbol.Type("Enso_Test.Test.A", "MyType"), - ExportedSymbol.Constructor("Enso_Test.Test.A", "MkA"), - ExportedSymbol.Method(moduleName, "main"), - ExportedSymbol.Method("Enso_Test.Test.A", "hello") - ) - ), - Api.ExportsAction.Add() - ) - ), - updates = Tree.Root( - Vector( - Tree.Node( - Api.SuggestionUpdate( - Suggestion.Module( - moduleName, - None - ), - Api.SuggestionAction.Add() - ), - Vector() - ), - Tree.Node( - Api.SuggestionUpdate( - Suggestion.DefinedMethod( - None, - moduleName, - "main", - List(), - "Enso_Test.Test.Main", - ConstantsGen.ANY, - true, - None, - Seq() - ), - Api.SuggestionAction.Add() - ), - Vector() - ) - ) - ) - ) - ), Api.Response(Api.AnalyzeModuleInScopeJobFinished()), context.executionComplete(contextId) ) context.consumeOut shouldEqual List("Hello World!") - // Modify the file + // Modify the file - remove the export of `hello` method + // Remove the line `export Enso_Test.Test.A.hello` context.send( Api.Request( Api.EditFileNotification( mainFile, Seq( TextEdit( - model.Range(model.Position(3, 32), model.Position(3, 32)), - " hiding hello" + model.Range(model.Position(7, 0), model.Position(8, 0)), + "" ) ), execute = true, @@ -1298,14 +1307,14 @@ class RuntimeSuggestionUpdatesTest ) context.consumeOut shouldEqual List("Hello World!") - // Modify the file + // Modify the file - remove all exports context.send( Api.Request( Api.EditFileNotification( mainFile, Seq( TextEdit( - model.Range(model.Position(2, 0), model.Position(7, 0)), + model.Range(model.Position(5, 0), model.Position(8, 0)), "" ) ),