Skip to content

Commit

Permalink
Update RuntimeSuggestionUpdatesTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Akirathan committed Jul 11, 2024
1 parent a4aa2b6 commit 4aca14c
Showing 1 changed file with 83 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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",
Expand All @@ -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()
Expand All @@ -1105,7 +1160,7 @@ class RuntimeSuggestionUpdatesTest
None,
"Enso_Test.Test.A",
"MyType",
List(),
Seq(),
"Enso_Test.Test.A.MyType",
Some(ConstantsGen.ANY),
None
Expand All @@ -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()
),
Expand All @@ -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()
),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)),
""
)
),
Expand Down

0 comments on commit 4aca14c

Please sign in to comment.