From 8d8e95e14ad29ff5a5efd09aa4a378dfa041657f Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 13 Feb 2020 17:33:39 +0300 Subject: [PATCH] Update to scala 2.13.1 (#481) --- azure-pipelines.yml | 4 +- build.sbt | 228 +++++++++--------- .../src/main/scala/org/enso/FileManager.scala | 6 +- .../main/scala/org/enso/filemanager/API.scala | 4 +- .../org/enso/filemanager/BehaviorTests.scala | 6 +- .../scala/org/enso/filemanager/Helpers.scala | 6 +- .../org/enso/filemanager/WatchTests.scala | 16 +- .../main/scala/org/enso/flexer/Parser.scala | 2 +- .../scala/org/enso/flexer/automata/NFA.scala | 8 +- .../org/enso/flexer/automata/State.scala | 23 +- .../src/main/scala/org/enso/graph/Graph.scala | 2 +- .../org/enso/graph/ComponentMacroTest.scala | 5 +- .../scala/org/enso/graph/FieldMacroTest.scala | 5 +- .../test/scala/org/enso/graph/GraphTest.scala | 6 +- .../org/enso/graph/GraphTestDefinition.scala | 1 + .../org/enso/graph/OpaqueMacroTest.scala | 5 +- .../org/enso/graph/TypeFunctionTest.scala | 9 +- .../src/main/scala/org/enso/Logger.scala | 1 - .../main/scala/org/enso/ParserService.scala | 2 - .../scala/org/enso/parserservice/Server.scala | 2 - .../src/main/scala/org/enso/pkg/Package.scala | 6 +- .../org/enso/projectmanager/Server.scala | 12 +- .../services/ProjectsService.scala | 67 ++--- .../services/TutorialsDownloader.scala | 9 +- .../src/main/scala/org/enso/data/Tree.scala | 2 +- .../main/scala/org/enso/syntax/text/AST.scala | 40 +-- .../org/enso/syntax/text/ast/Repr2.scala | 2 +- .../enso/syntax/text/ast/meta/Pattern.scala | 1 - .../enso/syntax/text/ast/text/Escape.scala | 1 - .../enso/syntax/text/spec/DocParserDef.scala | 2 +- .../org/enso/syntax/text/DocParser.scala | 2 +- .../scala/org/enso/syntax/text/Parser.scala | 24 +- .../org/enso/syntax/text/DocParserTests.scala | 6 +- .../org/enso/syntax/text/ParserTest.scala | 32 +-- .../main/scala/org/enso/gateway/Server.scala | 7 +- .../org/enso/gateway/GatewayJsonSpec.scala | 17 +- .../org/enso/gateway/GatewayMessageSpec.scala | 6 +- .../jsonrpcserver/MessageHandlerTest.scala | 10 +- .../languageserver/LanguageServerSpec.scala | 6 +- .../main/scala/org/enso/polyglot/Module.scala | 12 +- .../scala/org/enso/polyglot/TopScope.scala | 4 +- .../scala/org/enso/polyglot/ApiTest.scala | 8 +- .../enso/polyglot/ModuleManagementTest.scala | 14 +- .../org/enso/runner/ContextFactory.scala | 1 - .../scala/org/enso/runner/JupyterKernel.scala | 4 +- .../src/main/scala/org/enso/runner/Main.scala | 9 +- .../src/main/scala/org/enso/runner/Repl.scala | 2 +- .../interpreter/bench/RegressionTest.scala | 10 +- .../fixtures/semantic/AtomFixtures.scala | 8 +- .../interpreter/util/ScalaConversions.java | 8 +- .../scala/org/enso/compiler/Compiler.scala | 9 +- .../scala/org/enso/compiler/core/OldAST.scala | 3 +- .../generate/AstToAstExpression.scala | 3 +- .../org/enso/compiler/test/CompilerTest.scala | 5 +- .../test/core/SmartConstructorsTest.scala | 6 +- .../interpreter/test/InterpreterTest.scala | 8 +- .../enso/interpreter/test/PackageTest.scala | 5 +- .../test/instrument/ReplTest.scala | 4 +- .../test/instrument/ValueExtractorTest.scala | 4 +- .../test/semantic/CodeLocationsTest.scala | 2 +- 60 files changed, 358 insertions(+), 364 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e5920336fe4..77d9007bc49 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,7 +17,7 @@ trigger: pr: none variables: - graalVersion: 19.3.0 # Please ensure this is in sync with the graalAPIVersion in build.sbt + graalVersion: 19.3.1 # Please ensure this is in sync with the graalAPIVersion in build.sbt graalReleasesUrl: https://github.com/graalvm/graalvm-ce-builds/releases/download graalDistributionName: graalvm-ce-java8 sbtVersion: 1.3.3 # Please ensure this is in sync with project/build.properties @@ -167,4 +167,4 @@ jobs: echo "##vso[task.complete result=Failed;]DONE" condition: eq(variables['Agent.JobStatus'], 'SucceededWithIssues') displayName: Fail on Issues - \ No newline at end of file + diff --git a/build.sbt b/build.sbt index b19b553ea05..6fffbac7a41 100644 --- a/build.sbt +++ b/build.sbt @@ -12,9 +12,9 @@ import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType} //// Global Configuration //// ////////////////////////////// -val scalacVersion = "2.12.10" -val graalVersion = "19.3.0" -val circeVersion = "0.12.3" +val scalacVersion = "2.13.1" +val graalVersion = "19.3.1" +val circeVersion = "0.13.0" organization in ThisBuild := "org.enso" scalaVersion in ThisBuild := scalacVersion @@ -25,8 +25,9 @@ Global / onChangedBuildSource := ReloadOnSourceChanges ////////////////////////// javacOptions in ThisBuild ++= Seq( - "-encoding", // Provide explicit encoding (the next line) - "UTF-8" // Specify character encoding used by Java source files. + "-encoding", // Provide explicit encoding (the next line) + "UTF-8", // Specify character encoding used by Java source files. + "-deprecation" // Shows a description of each use or override of a deprecated member or class. ) scalacOptions in ThisBuild ++= Seq( @@ -42,7 +43,6 @@ scalacOptions in ThisBuild ++= Seq( "-unchecked", // Enable additional warnings where generated code depends on assumptions. "-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access. "-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver. - "-Xlint:by-name-right-associative", // By-name parameter of right associative operator. "-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error. "-Xlint:delayedinit-select", // Selecting member of DelayedInit. "-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element. @@ -56,29 +56,20 @@ scalacOptions in ThisBuild ++= Seq( "-Xlint:poly-implicit-overload", // Parameterized overloaded implicit methods are not visible as view bounds. "-Xlint:private-shadow", // A private field (or class parameter) shadows a superclass field. "-Xlint:stars-align", // Pattern sequence wildcard must align with sequence component. - "-Xlint:unsound-match", // Pattern match may not be typesafe. + "-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope. "-Xmacro-settings:-logging@org.enso", // Disable the debug logging globally. - "-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver. - "-Ypartial-unification", // Enable partial unification in type constructor inference "-Ywarn-dead-code", // Warn when dead code is identified. "-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined. - "-Ywarn-inaccessible", // Warn about inaccessible types in method signatures. - "-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`. - "-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'. - "-Ywarn-nullary-unit", // Warn when nullary methods return Unit. "-Ywarn-numeric-widen", // Warn when numerics are widened. "-Ywarn-unused:imports", // Warn if an import selector is not referenced. + "-Ywarn-unused:implicits", // Warn if an implicit parameter is unused. "-Ywarn-unused:locals", // Warn if a local definition is unused. "-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused. "-Ywarn-unused:privates", // Warn if a private member is unused. + "-Ywarn-unused:params", // Warn if a value parameter is unused. "-Ywarn-value-discard" // Warn when non-Unit expression results are unused. ) -// ENABLE THIS IN Scala 2.13.1 (where import annotation.unused is available). -// "-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope. -// "-Ywarn-unused:implicits", // Warn if an implicit parameter is unused. -// "-Ywarn-unused:params", // Warn if a value parameter is unused. - ///////////////////////////////// //// Benchmark Configuration //// ///////////////////////////////// @@ -119,20 +110,22 @@ lazy val enso = (project in file(".")) //////////////////////////// val monocle = { - val monocleVersion = "1.6.0" + val monocleVersion = "2.0.0" Seq( "com.github.julien-truffaut" %% "monocle-core" % monocleVersion, "com.github.julien-truffaut" %% "monocle-macro" % monocleVersion, "com.github.julien-truffaut" %% "monocle-law" % monocleVersion % "test" ) } + +val catsVersion = "2.1.0" val cats = { Seq( - "org.typelevel" %% "cats-core" % "2.0.0", - "org.typelevel" %% "cats-effect" % "2.0.0", - "org.typelevel" %% "cats-free" % "2.0.0", - "org.typelevel" %% "cats-macros" % "2.0.0", - "org.typelevel" %% "kittens" % "2.0.0" + "org.typelevel" %% "cats-core" % catsVersion, + "org.typelevel" %% "cats-effect" % catsVersion, + "org.typelevel" %% "cats-free" % catsVersion, + "org.typelevel" %% "cats-macros" % catsVersion, + "org.typelevel" %% "kittens" % catsVersion ) } @@ -148,8 +141,8 @@ def akkaPkg(name: String) = akkaURL %% s"akka-$name" % akkaVersion def akkaHTTPPkg(name: String) = akkaURL %% s"akka-$name" % akkaHTTPVersion val akkaURL = "com.typesafe.akka" -val akkaVersion = "2.5.23" -val akkaHTTPVersion = "10.1.8" +val akkaVersion = "2.6.3" +val akkaHTTPVersion = "10.1.11" val akkaActor = akkaPkg("actor") val akkaStream = akkaPkg("stream") val akkaTyped = akkaPkg("actor-typed") @@ -196,12 +189,11 @@ lazy val flexer = crossProject(JVMPlatform, JSPlatform) .dependsOn(logger) .settings( version := "0.1", - scalacOptions -= "-deprecation", // FIXME resolvers += Resolver.sonatypeRepo("releases"), libraryDependencies ++= scala_compiler ++ Seq( - "org.feijoas" %% "mango" % "0.14", - "org.typelevel" %%% "cats-core" % "2.0.0-RC1", - "org.typelevel" %%% "kittens" % "2.0.0" + "com.google.guava" % "guava" % "28.2-jre", + "org.typelevel" %%% "cats-core" % catsVersion, + "org.typelevel" %%% "kittens" % "2.0.0" ) ) .jsSettings(jsSettings) @@ -220,9 +212,9 @@ lazy val syntax_definition = crossProject(JVMPlatform, JSPlatform) .dependsOn(logger, flexer) .settings( libraryDependencies ++= monocle ++ scala_compiler ++ Seq( - "org.typelevel" %%% "cats-core" % "2.0.0-RC1", + "org.typelevel" %%% "cats-core" % catsVersion, "org.typelevel" %%% "kittens" % "2.0.0", - "com.lihaoyi" %%% "scalatags" % "0.7.0", + "com.lihaoyi" %%% "scalatags" % "0.8.5", "io.circe" %%% "circe-core" % circeVersion, "io.circe" %%% "circe-generic" % circeVersion, "io.circe" %%% "circe-parser" % circeVersion @@ -243,8 +235,8 @@ lazy val syntax = crossProject(JVMPlatform, JSPlatform) version := "0.1", logBuffered := false, libraryDependencies ++= Seq( - "org.scalatest" %%% "scalatest" % "3.0.5" % Test, - "com.lihaoyi" %%% "pprint" % "0.5.3", + "org.scalatest" %%% "scalatest" % "3.1.0" % Test, + "com.lihaoyi" %%% "pprint" % "0.5.9", "io.circe" %%% "circe-core" % circeVersion, "io.circe" %%% "circe-generic" % circeVersion, "io.circe" %%% "circe-parser" % circeVersion @@ -266,7 +258,7 @@ lazy val syntax = crossProject(JVMPlatform, JSPlatform) inConfig(Benchmark)(Defaults.testSettings), unmanagedSourceDirectories in Benchmark += baseDirectory.value.getParentFile / "src/bench/scala", - libraryDependencies += "com.storm-enroute" %% "scalameter" % "0.17" % "bench", + libraryDependencies += "com.storm-enroute" %% "scalameter" % "0.19" % "bench", testFrameworks := List( new TestFramework("org.scalatest.tools.Framework"), new TestFramework("org.scalameter.ScalaMeterFramework") @@ -292,16 +284,16 @@ lazy val graph = (project in file("common/graph/")) .configs(Test) .settings( version := "0.1", - scalacOptions -= "-deprecation", // FIXME resolvers ++= Seq( Resolver.sonatypeRepo("releases"), Resolver.sonatypeRepo("snapshots") ), + scalacOptions += "-Ymacro-annotations", libraryDependencies ++= scala_compiler ++ Seq( "com.chuusai" %% "shapeless" % "2.3.3", "io.estatico" %% "newtype" % "0.4.3", - "org.scalatest" %% "scalatest" % "3.2.0-SNAP10" % Test, - "org.scalacheck" %% "scalacheck" % "1.14.0" % Test, + "org.scalatest" %% "scalatest" % "3.2.0-M2" % Test, + "org.scalacheck" %% "scalacheck" % "1.14.3" % Test, "com.github.julien-truffaut" %% "monocle-core" % "2.0.0", "org.apache.commons" % "commons-lang3" % "3.9" ), @@ -314,10 +306,7 @@ lazy val graph = (project in file("common/graph/")) addCompilerPlugin( "org.typelevel" %% "kind-projector" % "0.11.0" cross CrossVersion.full ), - addCompilerPlugin ( - "org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full - ), - addCompilerPlugin("io.tryp" % "splain" % "0.5.0" cross CrossVersion.patch), + addCompilerPlugin("io.tryp" % "splain" % "0.5.1" cross CrossVersion.patch), scalacOptions ++= Seq( "-P:splain:infix:true", "-P:splain:foundreq:true", @@ -331,7 +320,7 @@ lazy val pkg = (project in file("common/pkg")) mainClass in (Compile, run) := Some("org.enso.pkg.Main"), version := "0.1", libraryDependencies ++= circe ++ Seq( - "io.circe" %% "circe-yaml" % "0.10.0", // separate from other circe deps because its independent project with its own versioning + "io.circe" %% "circe-yaml" % "0.12.0", // separate from other circe deps because its independent project with its own versioning "commons-io" % "commons-io" % "2.6" ) ) @@ -344,10 +333,11 @@ lazy val file_manager = (project in file("common/file-manager")) libraryDependencies ++= akka, libraryDependencies += akkaSLF4J, libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3", - libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.0-SNAP10" % Test, - libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.14.0" % Test, + libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.0-M2" % Test, + libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.14.3" % Test, libraryDependencies += akkaTestkitTyped, libraryDependencies += "commons-io" % "commons-io" % "2.6", + // upgrade blocked by gmethvin/directory-watcher#49 libraryDependencies += "io.methvin" % "directory-watcher" % "0.9.6" ) @@ -357,8 +347,7 @@ lazy val project_manager = (project in file("common/project-manager")) ) .settings( libraryDependencies ++= akka, - libraryDependencies ++= circe, - libraryDependencies += "io.spray" %% "spray-json" % "1.3.5" + libraryDependencies ++= circe ) .dependsOn(pkg) @@ -386,21 +375,44 @@ lazy val core_definition = (project in file("engine/core-definition")) inConfig(Benchmark)(Defaults.testSettings), parallelExecution in Test := false, logBuffered in Test := false, + scalacOptions += "-Ymacro-annotations", libraryDependencies ++= jmh ++ Seq( "com.chuusai" %% "shapeless" % "2.3.3", - "org.scalacheck" %% "scalacheck" % "1.14.0" % Test, - "org.scalactic" %% "scalactic" % "3.0.8" % Test, - "org.scalatest" %% "scalatest" % "3.2.0-SNAP10" % Test, - "org.typelevel" %% "cats-core" % "2.0.0-M4", + "org.scalacheck" %% "scalacheck" % "1.14.3" % Test, + "org.scalactic" %% "scalactic" % "3.2.0-M2" % Test, + "org.scalatest" %% "scalatest" % "3.2.0-M2" % Test, + "org.typelevel" %% "cats-core" % catsVersion, "com.github.julien-truffaut" %% "monocle-core" % "2.0.0" ), addCompilerPlugin( - "org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full + "org.typelevel" %% "kind-projector" % "0.11.0" cross CrossVersion.full + ) + ) + .dependsOn(graph) + .dependsOn(syntax.jvm) + +lazy val polyglot_api = project + .in(file("engine/polyglot-api")) + .settings( + Test / fork := true, + Test / javaOptions ++= Seq( + // Puts the language runtime on the truffle classpath, rather than the + // standard classpath. This is the recommended way of handling this and + // we should strive to use such structure everywhere. See + // https://www.graalvm.org/docs/graalvm-as-a-platform/implement-language#graalvm + s"-Dtruffle.class.path.append=${(LocalProject("runtime") / Compile / fullClasspath).value + .map(_.data) + .mkString(File.pathSeparator)}" + ), + libraryDependencies ++= Seq( + "org.graalvm.sdk" % "polyglot-tck" % graalVersion % "provided", + "org.scalatest" %% "scalatest" % "3.2.0-M2" % Test, + "org.scalacheck" %% "scalacheck" % "1.14.3" % Test ), addCompilerPlugin( "org.typelevel" %% "kind-projector" % "0.11.0" cross CrossVersion.full ), - addCompilerPlugin("io.tryp" % "splain" % "0.5.0" cross CrossVersion.patch), + addCompilerPlugin("io.tryp" % "splain" % "0.5.1" cross CrossVersion.patch), scalacOptions ++= Seq( "-P:splain:infix:true", "-P:splain:foundreq:true", @@ -408,8 +420,41 @@ lazy val core_definition = (project in file("engine/core-definition")) "-P:splain:tree:true" ) ) - .dependsOn(graph) - .dependsOn(syntax.jvm) + .dependsOn(pkg) + +lazy val json_rpc_server = (project in file("engine/json-rpc-server")) + .settings( + libraryDependencies ++= akka ++ circe ++ Seq( + "io.circe" %% "circe-generic-extras" % "0.12.2", + "io.circe" %% "circe-literal" % circeVersion, + akkaTestkit % Test, + "org.scalatest" %% "scalatest" % "3.2.0-M2" % Test, + "org.scalacheck" %% "scalacheck" % "1.14.0" % Test + ) + ) + +lazy val language_server = (project in file("engine/language-server")) + .settings( + libraryDependencies ++= akka ++ Seq( + "org.graalvm.sdk" % "polyglot-tck" % graalVersion % Provided, + akkaTestkit % Test, + "org.scalatest" %% "scalatest" % "3.2.0-M2" % Test, + "org.scalacheck" %% "scalacheck" % "1.14.3" % Test + ) + ) + .dependsOn(polyglot_api) + +lazy val gateway = (project in file("engine/gateway")) + .dependsOn(language_server) + .settings( + libraryDependencies ++= akka ++ circe ++ Seq( + "io.circe" %% "circe-generic-extras" % "0.12.2", + "io.circe" %% "circe-literal" % circeVersion, + akkaTestkit % Test, + "org.scalatest" %% "scalatest" % "3.2.0-M2" % Test, + "org.scalacheck" %% "scalacheck" % "1.14.3" % Test + ) + ) lazy val runtime = (project in file("engine/runtime")) .configs(Benchmark) @@ -420,21 +465,22 @@ lazy val runtime = (project in file("engine/runtime")) inConfig(Benchmark)(Defaults.testSettings), parallelExecution in Test := false, logBuffered in Test := false, + scalacOptions += "-Ymacro-annotations", libraryDependencies ++= jmh ++ Seq( "com.chuusai" %% "shapeless" % "2.3.3", "org.apache.commons" % "commons-lang3" % "3.9", - "org.apache.tika" % "tika-core" % "1.21", + "org.apache.tika" % "tika-core" % "1.23", "org.graalvm.sdk" % "graal-sdk" % graalVersion % "provided", "org.graalvm.sdk" % "polyglot-tck" % graalVersion % "provided", "org.graalvm.truffle" % "truffle-api" % graalVersion % "provided", "org.graalvm.truffle" % "truffle-dsl-processor" % graalVersion % "provided", "org.graalvm.truffle" % "truffle-tck" % graalVersion % "provided", "org.graalvm.truffle" % "truffle-tck-common" % graalVersion % "provided", - "org.scalacheck" %% "scalacheck" % "1.14.0" % Test, - "org.scalactic" %% "scalactic" % "3.0.8" % Test, - "org.scalatest" %% "scalatest" % "3.2.0-SNAP10" % Test, + "org.scalacheck" %% "scalacheck" % "1.14.3" % Test, + "org.scalactic" %% "scalactic" % "3.2.0-M2" % Test, + "org.scalatest" %% "scalatest" % "3.2.0-M2" % Test, "org.graalvm.truffle" % "truffle-api" % graalVersion % Benchmark, - "org.typelevel" %% "cats-core" % "2.0.0-M4" + "org.typelevel" %% "cats-core" % catsVersion ), // Note [Unmanaged Classpath] Compile / unmanagedClasspath += (core_definition / Compile / packageBin).value, @@ -448,13 +494,10 @@ lazy val runtime = (project in file("engine/runtime")) "-s", (Compile / sourceManaged).value.getAbsolutePath ), - addCompilerPlugin( - "org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full - ), addCompilerPlugin( "org.typelevel" %% "kind-projector" % "0.11.0" cross CrossVersion.full ), - addCompilerPlugin("io.tryp" % "splain" % "0.5.0" cross CrossVersion.patch), + addCompilerPlugin("io.tryp" % "splain" % "0.5.1" cross CrossVersion.patch), scalacOptions ++= Seq( "-P:splain:infix:true", "-P:splain:foundreq:true", @@ -523,7 +566,7 @@ lazy val runner = project "org.graalvm.truffle" % "truffle-api" % graalVersion % "provided", "commons-cli" % "commons-cli" % "1.4", "io.github.spencerpark" % "jupyter-jvm-basekernel" % "2.3.0", - "org.jline" % "jline" % "3.1.3" + "org.jline" % "jline" % "3.13.3" ), connectInput in run := true ) @@ -546,58 +589,3 @@ lazy val runner = project .dependsOn(language_server) .dependsOn(gateway) .dependsOn(polyglot_api) - -lazy val gateway = (project in file("engine/gateway")) - .dependsOn(language_server) - .settings( - libraryDependencies ++= akka ++ circe ++ Seq( - "io.circe" %% "circe-generic-extras" % "0.12.2", - "io.circe" %% "circe-literal" % circeVersion, - akkaTestkit % Test, - "org.scalatest" %% "scalatest" % "3.2.0-SNAP10" % Test, - "org.scalacheck" %% "scalacheck" % "1.14.0" % Test - ) - ) - -lazy val json_rpc_server = (project in file("engine/json-rpc-server")) - .settings( - libraryDependencies ++= akka ++ circe ++ Seq( - "io.circe" %% "circe-generic-extras" % "0.12.2", - "io.circe" %% "circe-literal" % circeVersion, - akkaTestkit % Test, - "org.scalatest" %% "scalatest" % "3.2.0-SNAP10" % Test, - "org.scalacheck" %% "scalacheck" % "1.14.0" % Test - ) - ) - -lazy val language_server = (project in file("engine/language-server")) - .settings( - libraryDependencies ++= akka ++ Seq( - "org.graalvm.sdk" % "polyglot-tck" % graalVersion % Provided, - akkaTestkit % Test, - "org.scalatest" %% "scalatest" % "3.2.0-SNAP10" % Test, - "org.scalacheck" %% "scalacheck" % "1.14.0" % Test - ) - ) - .dependsOn(polyglot_api) - -lazy val polyglot_api = project - .in(file("engine/polyglot-api")) - .settings( - Test / fork := true, - Test / javaOptions ++= Seq( - // Puts the language runtime on the truffle classpath, rather than the - // standard classpath. This is the recommended way of handling this and - // we should strive to use such structure everywhere. See - // https://www.graalvm.org/docs/graalvm-as-a-platform/implement-language#graalvm - s"-Dtruffle.class.path.append=${(LocalProject("runtime") / Compile / fullClasspath).value - .map(_.data) - .mkString(File.pathSeparator)}" - ), - libraryDependencies ++= Seq( - "org.graalvm.sdk" % "polyglot-tck" % graalVersion % "provided", - "org.scalatest" %% "scalatest" % "3.2.0-SNAP10" % Test, - "org.scalacheck" %% "scalacheck" % "1.14.0" % Test - ) - ) - .dependsOn(pkg) diff --git a/common/file-manager/src/main/scala/org/enso/FileManager.scala b/common/file-manager/src/main/scala/org/enso/FileManager.scala index 2d9cbad6aac..4f8d89be505 100644 --- a/common/file-manager/src/main/scala/org/enso/FileManager.scala +++ b/common/file-manager/src/main/scala/org/enso/FileManager.scala @@ -3,9 +3,9 @@ package org.enso import java.nio.file.Path import java.util.UUID -import akka.actor.Scheduler import akka.actor.typed.ActorRef import akka.actor.typed.Behavior +import akka.actor.typed.Scheduler import akka.actor.typed.scaladsl.AbstractBehavior import akka.actor.typed.scaladsl.ActorContext import akka.actor.typed.scaladsl.AskPattern.Askable @@ -28,8 +28,8 @@ import scala.util.Try * [[org.enso.filemanager.API]] for a list of supported operations and their * respective request-response packages. */ -case class FileManager(projectRoot: Path, context: ActorContext[InputMessage]) - extends AbstractBehavior[API.InputMessage] { +case class FileManager(projectRoot: Path, override val context: ActorContext[API.InputMessage]) + extends AbstractBehavior[API.InputMessage](context) { /** Active filesystem subtree watchers */ val watchers: mutable.Map[UUID, DirectoryWatcher] = mutable.Map() diff --git a/common/file-manager/src/main/scala/org/enso/filemanager/API.scala b/common/file-manager/src/main/scala/org/enso/filemanager/API.scala index 9c36c3e5634..afe606ab810 100644 --- a/common/file-manager/src/main/scala/org/enso/filemanager/API.scala +++ b/common/file-manager/src/main/scala/org/enso/filemanager/API.scala @@ -40,7 +40,7 @@ object API { projectRoot: Path, accessedPath: Path) extends Exception( - s"""Cannot access path $accessedPath because it does not belong to + s"""Cannot access path $accessedPath because it does not belong to |the project under root directory $projectRoot""".stripMargin .replaceAll("\n", " ") ) @@ -150,7 +150,7 @@ object API { override def handle(fileManager: FileManager): Response = { val str = Files.list(path) try { - Response(str.toArray.to[Vector].map(_.asInstanceOf[Path])) + Response(str.toArray.toVector.map(_.asInstanceOf[Path])) } finally str.close() } } diff --git a/common/file-manager/src/test/scala/org/enso/filemanager/BehaviorTests.scala b/common/file-manager/src/test/scala/org/enso/filemanager/BehaviorTests.scala index 5932af7c10c..daeee9ef3e4 100644 --- a/common/file-manager/src/test/scala/org/enso/filemanager/BehaviorTests.scala +++ b/common/file-manager/src/test/scala/org/enso/filemanager/BehaviorTests.scala @@ -11,15 +11,15 @@ import java.nio.file.Path import org.apache.commons.io.FileExistsException import org.enso.FileManager import org.enso.FileManager.API._ -import org.scalatest.FunSuite -import org.scalatest.Matchers import org.scalatest.Outcome +import org.scalatest.funsuite.AnyFunSuite +import org.scalatest.matchers.should.Matchers import scala.reflect.ClassTag import scala.util.Failure import scala.util.Success -class BehaviorTests extends FunSuite with Matchers with Helpers { +class BehaviorTests extends AnyFunSuite with Matchers with Helpers { var testKit: BehaviorTestKit[InputMessage] = _ var inbox: TestInbox[OutputMessage] = _ diff --git a/common/file-manager/src/test/scala/org/enso/filemanager/Helpers.scala b/common/file-manager/src/test/scala/org/enso/filemanager/Helpers.scala index 7ef45be0aa5..1902b92d58f 100644 --- a/common/file-manager/src/test/scala/org/enso/filemanager/Helpers.scala +++ b/common/file-manager/src/test/scala/org/enso/filemanager/Helpers.scala @@ -6,7 +6,7 @@ import java.nio.file.Paths import org.apache.commons.io.FileUtils -import org.scalatest.Matchers +import org.scalatest.matchers.should.Matchers trait Helpers extends Matchers { var tempDir: Path = _ @@ -71,15 +71,17 @@ trait Helpers extends Matchers { ) val listStream = Files.list(subtree.root) - try listStream.count() should be(2) + try listStream.count() should be(2) : Unit finally listStream.close() } def expectExist(path: Path): Unit = { assert(Files.exists(path), s"$path is expected to exist") + () } def expectNotExist(path: Path): Unit = { assert(!Files.exists(path), s"$path is expected to not exist") + () } } diff --git a/common/file-manager/src/test/scala/org/enso/filemanager/WatchTests.scala b/common/file-manager/src/test/scala/org/enso/filemanager/WatchTests.scala index cc22ab72191..dfcd4c053e4 100644 --- a/common/file-manager/src/test/scala/org/enso/filemanager/WatchTests.scala +++ b/common/file-manager/src/test/scala/org/enso/filemanager/WatchTests.scala @@ -1,9 +1,9 @@ package org.enso.filemanager -import akka.actor.Scheduler import akka.actor.testkit.typed.scaladsl.ActorTestKit import akka.actor.testkit.typed.scaladsl.TestProbe import akka.actor.typed.ActorRef +import akka.actor.typed.Scheduler import akka.util.Timeout import io.methvin.watcher.DirectoryChangeEvent import java.nio.file.Files @@ -14,9 +14,9 @@ import java.util.UUID import org.apache.commons.io.FileUtils import org.enso.FileManager import org.scalatest.BeforeAndAfterAll -import org.scalatest.FunSuite -import org.scalatest.Matchers import org.scalatest.Outcome +import org.scalatest.funsuite.AnyFunSuite +import org.scalatest.matchers.should.Matchers import scala.concurrent.Await import scala.concurrent.Future @@ -26,7 +26,7 @@ import scala.util.Try // needs to be separate because watcher message are asynchronous class WatchTests - extends FunSuite + extends AnyFunSuite with BeforeAndAfterAll with Matchers with Helpers { @@ -49,11 +49,11 @@ class WatchTests try super.withFixture(test) finally if (watcherID != null) // Otherwise directory would stay blocked on Windows. - unobserve(watcherID) + unobserve(watcherID): Unit }) } - override def afterAll() { + override def afterAll(): Unit = { testKit.shutdownTestKit() } @@ -72,6 +72,7 @@ class WatchTests events.exists(matchesEvent(path, eventType)), s"not received message about $path" ) + () } def expectNextEvent( @@ -84,6 +85,7 @@ class WatchTests matchesEvent(path, eventType)(message), s"expected of type $eventType for $path, got $message" ) + () } def ask[response <: Response.Success: ClassTag]( @@ -219,6 +221,6 @@ class WatchTests expectedOfType(DirectoryChangeEvent.EventType.DELETE) symlinkEventProbe.expectNoMessage(50.millis) - } finally unobserve(id) + } finally unobserve(id): Unit } } diff --git a/common/flexer/src/main/scala/org/enso/flexer/Parser.scala b/common/flexer/src/main/scala/org/enso/flexer/Parser.scala index 4ae6621973e..1670237dc8e 100644 --- a/common/flexer/src/main/scala/org/enso/flexer/Parser.scala +++ b/common/flexer/src/main/scala/org/enso/flexer/Parser.scala @@ -24,7 +24,7 @@ trait Parser[T] { reader.rewind.matched.set() reader.nextChar() - while (state.runCurrent() == State.Status.Exit.OK) Unit + while (state.runCurrent() == State.Status.Exit.OK) () val value: Result.Value[T] = getResult() match { case None => Result.Failure(None) diff --git a/common/flexer/src/main/scala/org/enso/flexer/automata/NFA.scala b/common/flexer/src/main/scala/org/enso/flexer/automata/NFA.scala index 032dc1efb3b..5b28e2cf0fd 100644 --- a/common/flexer/src/main/scala/org/enso/flexer/automata/NFA.scala +++ b/common/flexer/src/main/scala/org/enso/flexer/automata/NFA.scala @@ -9,6 +9,8 @@ final class NFA { val states: mutable.ArrayBuffer[State] = new mutable.ArrayBuffer() val vocabulary = new Dict() + import State.Implicits._ + //// API //// def addState(): Int = { @@ -65,7 +67,7 @@ final class NFA { private def epsMatrix(): IndexedSeq[Set[Int]] = { val arr = new Array[EpsMatrix](states.size) states.indices.foreach(fillEpsMatrix(_, arr)) - arr.map(_.links) + arr.toIndexedSeq.map(_.links) } private def nfaMatrix(): Array[Array[Int]] = { @@ -74,7 +76,7 @@ final class NFA { for (stateIx <- states.indices) { val s = state(stateIx) for ((range, vocIx) <- vocabulary) { - s.links.ranged.get(range.start) match { + s.links.ranged.getOption(range.start) match { case Some(tgt) => matrix(stateIx)(vocIx) = tgt case None => matrix(stateIx)(vocIx) = State.missing } @@ -167,7 +169,7 @@ final class NFA { } else { lines += s"""$source""" } - for ((range, target) <- state.links.ranged.asMapOfRanges()) { + state.links.ranged.asMapOfRanges().forEach { (range, target) => lines += s"""$source -> $target [label="$range"]""" } for (target <- state.links.epsilon) { diff --git a/common/flexer/src/main/scala/org/enso/flexer/automata/State.scala b/common/flexer/src/main/scala/org/enso/flexer/automata/State.scala index 04047886c30..13ed597e472 100644 --- a/common/flexer/src/main/scala/org/enso/flexer/automata/State.scala +++ b/common/flexer/src/main/scala/org/enso/flexer/automata/State.scala @@ -1,6 +1,6 @@ package org.enso.flexer.automata -import org.feijoas.mango.common.{collect => Guava} +import com.google.common.{collect => guava} import scala.collection.mutable @@ -10,23 +10,36 @@ class State { } object State { + + object Implicits { + + final implicit class RangeMapWrapper[K <: Comparable[_], V](underlying: guava.RangeMap[K, V]) { + + def getOption(key: K): Option[V] = + Option(underlying.get(key)) + + def isEmpty: Boolean = + underlying.asMapOfRanges().isEmpty() + } + } + val missing = -1 case class Desc(priority: Int, rule: String) object Link { + class Registry { - private type IntOrd = Ordering.Int.type val epsilon: mutable.ArrayBuffer[Int] = new mutable.ArrayBuffer() - val ranged: Guava.mutable.RangeMap[Int, Int, IntOrd] = - Guava.mutable.RangeMap() + val ranged: guava.RangeMap[java.lang.Integer, Int] = + guava.TreeRangeMap.create[java.lang.Integer, Int]() def add(target: Int): Unit = epsilon += target def add(target: Int, range: Range) = if (range.start <= range.end) - ranged.put(Guava.Range.closed(range.start, range.end), target) + ranged.put(guava.Range.closed(range.start, range.end), target) } } } diff --git a/common/graph/src/main/scala/org/enso/graph/Graph.scala b/common/graph/src/main/scala/org/enso/graph/Graph.scala index 6b40ee073e8..a0399bacbfa 100644 --- a/common/graph/src/main/scala/org/enso/graph/Graph.scala +++ b/common/graph/src/main/scala/org/enso/graph/Graph.scala @@ -495,7 +495,7 @@ object Graph { */ final class GraphData[G <: Graph]()(implicit val info: GraphInfo[G]) { var components: Array[Component.Storage] = - this.componentSizes.map(size => new Component.Storage(size)).to[Array] + this.componentSizes.map(size => new Component.Storage(size)).toArray /** Gets a reference to the graph component at the specified index. * diff --git a/common/graph/src/test/scala/org/enso/graph/ComponentMacroTest.scala b/common/graph/src/test/scala/org/enso/graph/ComponentMacroTest.scala index 62824b99e2a..d8deba90a25 100644 --- a/common/graph/src/test/scala/org/enso/graph/ComponentMacroTest.scala +++ b/common/graph/src/test/scala/org/enso/graph/ComponentMacroTest.scala @@ -2,10 +2,11 @@ package org.enso.graph import org.enso.graph.{Graph => PrimGraph} import org.enso.graph.definition.Macro.component -import org.scalatest.{FlatSpec, Matchers} +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers import shapeless.test.illTyped -class ComponentMacroTest extends FlatSpec with Matchers { +class ComponentMacroTest extends AnyFlatSpec with Matchers { "The `@component` macro" should "define correct components" in { "@component case class Edges() { type Edge[G <: Graph] }" should compile diff --git a/common/graph/src/test/scala/org/enso/graph/FieldMacroTest.scala b/common/graph/src/test/scala/org/enso/graph/FieldMacroTest.scala index 4ed2fe31ca7..2d233bffa08 100644 --- a/common/graph/src/test/scala/org/enso/graph/FieldMacroTest.scala +++ b/common/graph/src/test/scala/org/enso/graph/FieldMacroTest.scala @@ -2,10 +2,11 @@ package org.enso.graph import org.enso.graph.definition.Macro.{component, field, opaque} import org.enso.graph.{Graph => PrimGraph} -import org.scalatest.{FlatSpec, Matchers} +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers import shapeless.test.illTyped -class FieldMacroTest extends FlatSpec with Matchers { +class FieldMacroTest extends AnyFlatSpec with Matchers { val subject = "The `@field` macro" diff --git a/common/graph/src/test/scala/org/enso/graph/GraphTest.scala b/common/graph/src/test/scala/org/enso/graph/GraphTest.scala index d7e38b13914..3378783927f 100644 --- a/common/graph/src/test/scala/org/enso/graph/GraphTest.scala +++ b/common/graph/src/test/scala/org/enso/graph/GraphTest.scala @@ -1,11 +1,12 @@ package org.enso.graph import org.enso.graph.{Graph => PrimGraph} -import org.scalatest.{FlatSpec, Matchers} +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers import org.enso.graph.GraphTestDefinition._ /** This file contains tests for the graph library. */ -class GraphTest extends FlatSpec with Matchers { +class GraphTest extends AnyFlatSpec with Matchers { // ========================================================================== // === Example Graph Usage ================================================== @@ -84,7 +85,6 @@ class GraphTest extends FlatSpec with Matchers { val typeResult = n1 match { case GraphImpl.Node.Shape.Nul.any(n @ _) => "Null" case GraphImpl.Node.Shape.App.any(n1 @ _) => "App1" - case GraphImpl.Node.Shape.App(_, _) => "App2" } typeResult shouldEqual "App1" diff --git a/common/graph/src/test/scala/org/enso/graph/GraphTestDefinition.scala b/common/graph/src/test/scala/org/enso/graph/GraphTestDefinition.scala index dd602e77598..d95489f1e8a 100644 --- a/common/graph/src/test/scala/org/enso/graph/GraphTestDefinition.scala +++ b/common/graph/src/test/scala/org/enso/graph/GraphTestDefinition.scala @@ -4,6 +4,7 @@ import org.enso.graph.definition.Macro.{component, field, opaque} import org.enso.graph.{Graph => PrimGraph} import shapeless.{::, HNil} +// import intentionally left unused import shapeless.nat._ /** This file provides a small graph implementation for testing purposes. diff --git a/common/graph/src/test/scala/org/enso/graph/OpaqueMacroTest.scala b/common/graph/src/test/scala/org/enso/graph/OpaqueMacroTest.scala index 5d5239f8713..2f214af80db 100644 --- a/common/graph/src/test/scala/org/enso/graph/OpaqueMacroTest.scala +++ b/common/graph/src/test/scala/org/enso/graph/OpaqueMacroTest.scala @@ -1,12 +1,13 @@ package org.enso.graph import org.enso.graph.definition.Macro.opaque -import org.scalatest.{FlatSpec, Matchers} +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers import shapeless.test.illTyped import scala.collection.mutable -class OpaqueMacroTest extends FlatSpec with Matchers { +class OpaqueMacroTest extends AnyFlatSpec with Matchers { val subject = "The @opaque macro" subject should "define proper opaque maps" in { diff --git a/common/graph/src/test/scala/org/enso/graph/TypeFunctionTest.scala b/common/graph/src/test/scala/org/enso/graph/TypeFunctionTest.scala index ba890605a22..a98cae08844 100644 --- a/common/graph/src/test/scala/org/enso/graph/TypeFunctionTest.scala +++ b/common/graph/src/test/scala/org/enso/graph/TypeFunctionTest.scala @@ -1,12 +1,13 @@ package org.enso.graph -import org.scalatest.{FlatSpec, Matchers} +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers import shapeless.{::, HNil, Nat} import shapeless.Nat._ import scala.collection.mutable -class TypeFunctionTest extends FlatSpec with Matchers { +class TypeFunctionTest extends AnyFlatSpec with Matchers { object HListSumTest { implicitly[HListSum.Aux[HNil, _0]] @@ -95,8 +96,8 @@ class TypeFunctionTest extends FlatSpec with Matchers { MapsOf.getOpaqueData[String, maps.Out](maps.instance) shouldEqual testMap - stringMap - 0 - testMap - 0 + stringMap -= 0 + testMap -= 0 MapsOf.getOpaqueData[String, maps.Out](maps.instance) shouldEqual testMap } diff --git a/common/logger/src/main/scala/org/enso/Logger.scala b/common/logger/src/main/scala/org/enso/Logger.scala index f5cc61a1fc8..4c8dd77a9be 100644 --- a/common/logger/src/main/scala/org/enso/Logger.scala +++ b/common/logger/src/main/scala/org/enso/Logger.scala @@ -1,6 +1,5 @@ package org.enso -import scala.language.experimental.macros import scala.reflect.macros.blackbox.Context import org.enso.lint.Unused diff --git a/common/parser-service/src/main/scala/org/enso/ParserService.scala b/common/parser-service/src/main/scala/org/enso/ParserService.scala index 5796a302069..77096e5aaae 100644 --- a/common/parser-service/src/main/scala/org/enso/ParserService.scala +++ b/common/parser-service/src/main/scala/org/enso/ParserService.scala @@ -1,7 +1,5 @@ package org.enso -import io.circe.syntax._ -import io.circe.generic.auto._ import org.enso.flexer.Reader import org.enso.parserservice.Protocol import org.enso.parserservice.Server diff --git a/common/parser-service/src/main/scala/org/enso/parserservice/Server.scala b/common/parser-service/src/main/scala/org/enso/parserservice/Server.scala index 8889071c798..73a5ac822ee 100644 --- a/common/parser-service/src/main/scala/org/enso/parserservice/Server.scala +++ b/common/parser-service/src/main/scala/org/enso/parserservice/Server.scala @@ -11,7 +11,6 @@ import akka.http.scaladsl.model.ws.BinaryMessage import akka.http.scaladsl.model.ws.Message import akka.http.scaladsl.model.ws.TextMessage import akka.http.scaladsl.model.ws.UpgradeToWebSocket -import akka.stream.ActorMaterializer import akka.stream.scaladsl.Flow import akka.stream.scaladsl.Sink import akka.stream.scaladsl.Source @@ -39,7 +38,6 @@ object Server { */ trait Server { implicit val system: ActorSystem = ActorSystem() - implicit val materializer: ActorMaterializer = ActorMaterializer() /** Generate text reply for given request text message. */ def handleMessage(input: String): String diff --git a/common/pkg/src/main/scala/org/enso/pkg/Package.scala b/common/pkg/src/main/scala/org/enso/pkg/Package.scala index 2aa84b2bf2c..ab47ad1b6b3 100644 --- a/common/pkg/src/main/scala/org/enso/pkg/Package.scala +++ b/common/pkg/src/main/scala/org/enso/pkg/Package.scala @@ -2,9 +2,9 @@ package org.enso.pkg import java.io.File import java.io.PrintWriter -import java.nio.file.{Files, Path} +import java.nio.file.Files -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import org.apache.commons.io.FileUtils import org.enso.pkg.Package.qualifiedNameSeparator @@ -46,7 +46,7 @@ case class Package(root: File, config: Config) { /** * Creates the package directory structure. */ - def createDirectories() { + def createDirectories(): Unit = { val created = Try(root.mkdirs).getOrElse(false) if (!created) throw CouldNotCreateDirectory createSourceDir() diff --git a/common/project-manager/src/main/scala/org/enso/projectmanager/Server.scala b/common/project-manager/src/main/scala/org/enso/projectmanager/Server.scala index 7fe931a8e85..a5f3407f419 100644 --- a/common/project-manager/src/main/scala/org/enso/projectmanager/Server.scala +++ b/common/project-manager/src/main/scala/org/enso/projectmanager/Server.scala @@ -3,14 +3,14 @@ package org.enso.projectmanager import java.io.File import java.util.concurrent.TimeUnit -import akka.actor.{ActorSystem, Scheduler} +import akka.actor.ActorSystem import akka.actor.typed.ActorRef +import akka.actor.typed.Scheduler import akka.actor.typed.scaladsl.AskPattern._ import akka.actor.typed.scaladsl.adapter._ import akka.http.scaladsl.Http import akka.http.scaladsl.model.{HttpResponse, StatusCodes, Uri} import akka.http.scaladsl.server.{Directives, Route} -import akka.stream.ActorMaterializer import akka.util.Timeout import com.typesafe.config.ConfigFactory import org.enso.projectmanager.api.{ProjectFactory, ProjectJsonSupport} @@ -29,12 +29,11 @@ case class Server( apiFactory: ProjectFactory )(implicit val system: ActorSystem, implicit val executor: ExecutionContext, - implicit val materializer: ActorMaterializer, implicit val askTimeout: Timeout) extends Directives with ProjectJsonSupport { - implicit val scheduler: Scheduler = system.scheduler + implicit val scheduler: Scheduler = system.scheduler.toTyped def projectDoesNotExistResponse(id: ProjectId): HttpResponse = HttpResponse(StatusCodes.NotFound, entity = s"Project $id does not exist") @@ -114,7 +113,7 @@ case class Server( object Server { - def main(args: Array[String]) { + def main(args: Array[String]): Unit = { val config = ConfigFactory.load.getConfig("project-manager") val serverConfig = config.getConfig("server") @@ -131,7 +130,6 @@ object Server { implicit val system: ActorSystem = ActorSystem("project-manager") implicit val executor: ExecutionContext = system.dispatcher - implicit val materializer: ActorMaterializer = ActorMaterializer() implicit val askTimeout: Timeout = new Timeout(timeout) val localProjectsPath = @@ -165,6 +163,6 @@ object Server { val apiFactory = ProjectFactory(routeHelper) val server = Server(host, port, repoActor, routeHelper, apiFactory) - server.serve + server.serve: Unit } } diff --git a/common/project-manager/src/main/scala/org/enso/projectmanager/services/ProjectsService.scala b/common/project-manager/src/main/scala/org/enso/projectmanager/services/ProjectsService.scala index 8984e57af8b..3ab847bcc0e 100644 --- a/common/project-manager/src/main/scala/org/enso/projectmanager/services/ProjectsService.scala +++ b/common/project-manager/src/main/scala/org/enso/projectmanager/services/ProjectsService.scala @@ -1,7 +1,7 @@ package org.enso.projectmanager.services import akka.actor.typed.{ActorRef, Behavior} -import akka.actor.typed.scaladsl.{Behaviors, StashBuffer} +import akka.actor.typed.scaladsl.Behaviors import org.enso.projectmanager.model.{Project, ProjectId, ProjectsRepository} import scala.collection.immutable.HashMap @@ -34,39 +34,40 @@ object ProjectsService { storageManager: StorageManager, tutorialsDownloader: TutorialsDownloader ): Behavior[ProjectsServiceCommand] = Behaviors.setup { context => - val buffer = StashBuffer[ProjectsServiceCommand](capacity = 100) + Behaviors.withStash(capacity = 100) { buffer => - def handle( - localRepo: ProjectsRepository, - tutorialsRepo: Option[ProjectsRepository] - ): Behavior[ProjectsServiceCommand] = Behaviors.receiveMessage { - case ListProjectsRequest(replyTo) => - replyTo ! ListProjectsResponse(localRepo.projects) - Behaviors.same - case msg: ListTutorialsRequest => - tutorialsRepo match { - case Some(repo) => msg.replyTo ! ListProjectsResponse(repo.projects) - case None => buffer.stash(msg) - } - Behaviors.same - case GetProjectById(id, replyTo) => - val project = - localRepo.getById(id).orElse(tutorialsRepo.flatMap(_.getById(id))) - replyTo ! GetProjectResponse(project) - Behaviors.same - case TutorialsReady => - val newTutorialsRepo = storageManager.readTutorials - buffer.unstashAll(context, handle(localRepo, Some(newTutorialsRepo))) - case msg: CreateTemporary => - val project = - storageManager.createTemporary(msg.name) - val (projectId, newProjectsRepo) = localRepo.insert(project) - msg.replyTo ! CreateTemporaryResponse(projectId, project) - handle(newProjectsRepo, tutorialsRepo) + def handle( + localRepo: ProjectsRepository, + tutorialsRepo: Option[ProjectsRepository] + ): Behavior[ProjectsServiceCommand] = Behaviors.receiveMessage { + case ListProjectsRequest(replyTo) => + replyTo ! ListProjectsResponse(localRepo.projects) + Behaviors.same + case msg: ListTutorialsRequest => + tutorialsRepo match { + case Some(repo) => msg.replyTo ! ListProjectsResponse(repo.projects) + case None => buffer.stash(msg) + } + Behaviors.same + case GetProjectById(id, replyTo) => + val project = + localRepo.getById(id).orElse(tutorialsRepo.flatMap(_.getById(id))) + replyTo ! GetProjectResponse(project) + Behaviors.same + case TutorialsReady => + val newTutorialsRepo = storageManager.readTutorials + buffer.unstashAll(handle(localRepo, Some(newTutorialsRepo))) + case msg: CreateTemporary => + val project = + storageManager.createTemporary(msg.name) + val (projectId, newProjectsRepo) = localRepo.insert(project) + msg.replyTo ! CreateTemporaryResponse(projectId, project) + handle(newProjectsRepo, tutorialsRepo) + } + + context.pipeToSelf(tutorialsDownloader.run())(_ => TutorialsReady) + + handle(storageManager.readLocalProjects, None) } - - context.pipeToSelf(tutorialsDownloader.run())(_ => TutorialsReady) - - handle(storageManager.readLocalProjects, None) } } diff --git a/common/project-manager/src/main/scala/org/enso/projectmanager/services/TutorialsDownloader.scala b/common/project-manager/src/main/scala/org/enso/projectmanager/services/TutorialsDownloader.scala index 0eeb307a9ee..e252dabff6a 100644 --- a/common/project-manager/src/main/scala/org/enso/projectmanager/services/TutorialsDownloader.scala +++ b/common/project-manager/src/main/scala/org/enso/projectmanager/services/TutorialsDownloader.scala @@ -15,15 +15,14 @@ import akka.http.scaladsl.model.HttpResponse import akka.http.scaladsl.model.StatusCodes import akka.http.scaladsl.model.headers.Location import akka.http.scaladsl.unmarshalling.Unmarshal -import akka.stream.ActorMaterializer import akka.stream.scaladsl.FileIO import org.apache.commons.io.IOUtils import spray.json.DefaultJsonProtocol import spray.json.JsonParser -import scala.collection.JavaConverters._ import scala.concurrent.ExecutionContext import scala.concurrent.Future +import scala.jdk.CollectionConverters._ import scala.util.Try case class GithubTutorial(name: String, lastPushString: String) { @@ -37,8 +36,7 @@ trait GithubJsonProtocol extends SprayJsonSupport with DefaultJsonProtocol { case class HttpHelper()( implicit val executor: ExecutionContext, - implicit val system: ActorSystem, - implicit val materializer: ActorMaterializer) { + implicit val system: ActorSystem) { def performWithRedirects(request: HttpRequest): Future[HttpResponse] = Http().singleRequest(request).flatMap(followRedirects) @@ -59,8 +57,7 @@ case class TutorialsDownloader( cacheDir: File, packagesGithubOrganisation: String )(implicit val system: ActorSystem, - implicit val executor: ExecutionContext, - implicit val materializer: ActorMaterializer) + implicit val executor: ExecutionContext) extends GithubJsonProtocol { val packagesGithubUrl = diff --git a/common/syntax/definition/src/main/scala/org/enso/data/Tree.scala b/common/syntax/definition/src/main/scala/org/enso/data/Tree.scala index 48aa1f6526e..306e37870fb 100644 --- a/common/syntax/definition/src/main/scala/org/enso/data/Tree.scala +++ b/common/syntax/definition/src/main/scala/org/enso/data/Tree.scala @@ -14,7 +14,7 @@ final case class Tree[K, V](value: Option[V], branches: Map[K, Tree[K, V]]) { } def map[S](f: V => S): Tree[K, S] = - Tree(value.map(f), branches.mapValues(_.map(f))) + Tree(value.map(f), branches.view.mapValues(_.map(f)).toMap) def dropValues(): Tree[K, Unit] = map(_ => ()) diff --git a/common/syntax/definition/src/main/scala/org/enso/syntax/text/AST.scala b/common/syntax/definition/src/main/scala/org/enso/syntax/text/AST.scala index a452386d9ca..a8f09e631dd 100644 --- a/common/syntax/definition/src/main/scala/org/enso/syntax/text/AST.scala +++ b/common/syntax/definition/src/main/scala/org/enso/syntax/text/AST.scala @@ -917,7 +917,7 @@ object Shape extends ShapeImplicit { R + symbol + symbol + _.lines.mkString("\n") // FIXME: How to make it automatic for non-spaced AST? implicit def ozip[T]: OffsetZip[Comment, T] = _.map(Index.Start -> _) - implicit def span[T]: HasSpan[Comment[T]] = t => 0 + implicit def span[T]: HasSpan[Comment[T]] = _ => 0 } object Documented { @@ -932,7 +932,7 @@ object Shape extends ShapeImplicit { } implicit def offsetZip[T]: OffsetZip[Documented, T] = _.map(Index.Start -> _) - implicit def span[T: HasSpan]: HasSpan[Documented[T]] = t => 0 + implicit def span[T: HasSpan]: HasSpan[Documented[T]] = _ => 0 implicit def toJson[T]: Encoder[Documented[T]] = _ => throw new NotImplementedError() @@ -946,7 +946,7 @@ object Shape extends ShapeImplicit { // FIXME: How to make it automatic for non-spaced AST? implicit def ozip[T]: OffsetZip[Import, T] = _.map(Index.Start -> _) - implicit def span[T]: HasSpan[Import[T]] = t => 0 + implicit def span[T]: HasSpan[Import[T]] = _ => 0 } object Mixfix { @@ -956,11 +956,11 @@ object Shape extends ShapeImplicit { val lastRepr = if (t.name.length == t.args.length) List() else List(R) val argsRepr = t.args.toList.map(R + " " + _) ++ lastRepr val nameRepr = t.name.toList.map(Repr(_)) - R + (nameRepr, argsRepr).zipped.map(_ + _) + R + nameRepr.lazyZip(argsRepr).map(_ + _) } // FIXME: How to make it automatic for non-spaced AST? implicit def ozip[T]: OffsetZip[Mixfix, T] = _.map(Index.Start -> _) - implicit def span[T]: HasSpan[Mixfix[T]] = t => 0 + implicit def span[T]: HasSpan[Mixfix[T]] = _ => 0 } object Group { @@ -970,7 +970,7 @@ object Shape extends ShapeImplicit { R + "(" + _.body + ")" // FIXME: How to make it automatic for non-spaced AST? implicit def ozip[T]: OffsetZip[Group, T] = _.map(Index.Start -> _) - implicit def span[T]: HasSpan[Group[T]] = t => 0 + implicit def span[T]: HasSpan[Group[T]] = _ => 0 } object Def { @@ -980,7 +980,7 @@ object Shape extends ShapeImplicit { t => R + Def.symbol + 1 + t.name + t.args.map(R + 1 + _) + t.body // FIXME: How to make it automatic for non-spaced AST? implicit def ozip[T]: OffsetZip[Def, T] = _.map(Index.Start -> _) - implicit def span[T]: HasSpan[Def[T]] = t => 0 + implicit def span[T]: HasSpan[Def[T]] = _ => 0 val symbol = "def" } @@ -994,7 +994,7 @@ object Shape extends ShapeImplicit { } // FIXME: How to make it automatic for non-spaced AST? implicit def ozip[T]: OffsetZip[Foreign, T] = _.map(Index.Start -> _) - implicit def span[T]: HasSpan[Foreign[T]] = t => 0 + implicit def span[T]: HasSpan[Foreign[T]] = _ => 0 } //// Implicits //// @@ -1480,7 +1480,7 @@ object AST { import io.circe.generic.auto._ // Note (below) [JSON Format Customizations] - implicit def blockEncoder[T: Encoder]: Encoder[Shape.Block[T]] = + implicit def blockEncoder[A: Encoder]: Encoder[Shape.Block[A]] = block => Json.obj( "ty" -> block.ty.asJson, @@ -1721,10 +1721,10 @@ object AST { def unapply(t: AST) = Unapply[Unclosed].run(t => t.line)(t) def apply(segment: Segment.Fmt*): Unclosed = - Shape.TextUnclosed(Line.Fmt(segment.to[List])) + Shape.TextUnclosed(Line.Fmt(segment.toList)) object Raw { def apply(segment: Segment.Raw*): Unclosed = - Shape.TextUnclosed(Line.Raw(segment.to[List])) + Shape.TextUnclosed(Line.Raw(segment.toList)) } } type InvalidQuote = ASTOf[Shape.InvalidQuote] @@ -1743,23 +1743,23 @@ object AST { } def apply(text: Shape.Text[AST]): Text = text - def apply(segment: Segment.Fmt*): Text = Text(Line.Fmt(segment.to[List])) + def apply(segment: Segment.Fmt*): Text = Text(Line.Fmt(segment.toList)) def apply( spaces: Int, off: Int, line: Shape.TextBlockLine[Segment.Fmt]* ): Text = - Text(Shape.TextBlockFmt(line.to[List], spaces, off)) + Text(Shape.TextBlockFmt(line.toList, spaces, off)) object Raw { def apply(segment: Segment.Raw*): Text = - Text(Line.Raw(segment.to[List])) + Text(Line.Raw(segment.toList)) def apply( spaces: Int, off: Int, line: Shape.TextBlockLine[Segment.Raw]* ): Text = - Text(Shape.TextBlockRaw(line.to[List], spaces, off)) + Text(Shape.TextBlockRaw(line.toList, spaces, off)) } ///////////////// @@ -1941,7 +1941,7 @@ object AST { indent, List(), Line(firstLine), - lines.to[List].map(ast => Line(Some(ast))) + lines.toList.map(ast => Line(Some(ast))) ) val any = UnapplyByType[Block] @@ -1979,7 +1979,7 @@ object AST { def unapply(t: AST) = Unapply[M].run(_.lines)(t) def apply(ls: List1[OptLine]): M = Shape.Module(ls) def apply(l: OptLine): M = Module(List1(l)) - def apply(l: OptLine, ls: OptLine*): M = Module(List1(l, ls.to[List])) + def apply(l: OptLine, ls: OptLine*): M = Module(List1(l, ls.toList)) def apply(l: OptLine, ls: List[OptLine]): M = Module(List1(l, ls)) def traverseWithOff(m: M)(f: (Index, AST) => AST): M = { val lines2 = m.lines.map { line: OptLine => @@ -2297,9 +2297,9 @@ object AST { val any = UnapplyByType[Foreign] } - def main() { + def main(): Unit = { val v1 = Ident.Var("foo") - val v1_ = v1: AST + // val v1_ = v1: AST println(v1.span) println((v1: AST.Ident).span) @@ -2308,7 +2308,7 @@ object AST { // println(v1_.asJson) // val opr1 = Ident.Opr("+") val v2 = App.Prefix(Ident.Var("x"), 10, Ident.Var("z")) - val v2_ = v2: AST + // val v2_ = v2: AST // // println(v2.asJson) // println(v2_.asJson) diff --git a/common/syntax/definition/src/main/scala/org/enso/syntax/text/ast/Repr2.scala b/common/syntax/definition/src/main/scala/org/enso/syntax/text/ast/Repr2.scala index d130b040058..e8800191ec1 100644 --- a/common/syntax/definition/src/main/scala/org/enso/syntax/text/ast/Repr2.scala +++ b/common/syntax/definition/src/main/scala/org/enso/syntax/text/ast/Repr2.scala @@ -160,7 +160,7 @@ object Repr { }) } - def Empty() = Builder(0, identity(_)) + def Empty() = Builder(0, identity(_): Unit) def Space(span: Int) = Builder(span, _ ++= (" " * span)) def Letter(char: Char) = Builder(1, _ += char) def Text(str: String) = Builder(str.length, _ ++= str) diff --git a/common/syntax/definition/src/main/scala/org/enso/syntax/text/ast/meta/Pattern.scala b/common/syntax/definition/src/main/scala/org/enso/syntax/text/ast/meta/Pattern.scala index ffe69f3b611..a7e18a8134d 100644 --- a/common/syntax/definition/src/main/scala/org/enso/syntax/text/ast/meta/Pattern.scala +++ b/common/syntax/definition/src/main/scala/org/enso/syntax/text/ast/meta/Pattern.scala @@ -1,7 +1,6 @@ package org.enso.syntax.text.ast.meta import org.enso.syntax.text.{AST, HasSpan, OffsetZip} -import org.enso.syntax.text.HasSpan.implicits._ import org.enso.syntax.text.AST.SAST import org.enso.syntax.text.prec.Operator import org.enso.syntax.text.ast.Repr diff --git a/common/syntax/definition/src/main/scala/org/enso/syntax/text/ast/text/Escape.scala b/common/syntax/definition/src/main/scala/org/enso/syntax/text/ast/text/Escape.scala index a8034899866..f9d42eb6f4f 100644 --- a/common/syntax/definition/src/main/scala/org/enso/syntax/text/ast/text/Escape.scala +++ b/common/syntax/definition/src/main/scala/org/enso/syntax/text/ast/text/Escape.scala @@ -1,7 +1,6 @@ package org.enso.syntax.text.ast.text import org.enso.flexer.ADT -import org.enso.syntax.text.ast.text.Escape.Slash.toString sealed trait Escape { val repr: String diff --git a/common/syntax/definition/src/main/scala/org/enso/syntax/text/spec/DocParserDef.scala b/common/syntax/definition/src/main/scala/org/enso/syntax/text/spec/DocParserDef.scala index 3e81c8d4ed6..985ba1bad82 100644 --- a/common/syntax/definition/src/main/scala/org/enso/syntax/text/spec/DocParserDef.scala +++ b/common/syntax/definition/src/main/scala/org/enso/syntax/text/spec/DocParserDef.scala @@ -125,7 +125,7 @@ case class DocParserDef() extends Parser[Doc] { if (details.nonEmpty) { var det = text.removeWhitespaces(details) if (tagType != Tags.Tag.Unrecognized) { - det = ' ' + det + det = s" $det" } stack +:= Tags.Tag(indent, tagType, Some(det)) } else { diff --git a/common/syntax/specialization/shared/src/main/scala/org/enso/syntax/text/DocParser.scala b/common/syntax/specialization/shared/src/main/scala/org/enso/syntax/text/DocParser.scala index 3f9d67096a6..d6e3d22cb16 100644 --- a/common/syntax/specialization/shared/src/main/scala/org/enso/syntax/text/DocParser.scala +++ b/common/syntax/specialization/shared/src/main/scala/org/enso/syntax/text/DocParser.scala @@ -305,7 +305,7 @@ object DocParserHTMLGenerator { generateHTMLForEveryDocumented(elem, path, cssFileName) } elem - } + } : Unit } ////////////////////////////////////////////////////////////////////////////// diff --git a/common/syntax/specialization/shared/src/main/scala/org/enso/syntax/text/Parser.scala b/common/syntax/specialization/shared/src/main/scala/org/enso/syntax/text/Parser.scala index 5c92acd7df0..2fec8f66577 100644 --- a/common/syntax/specialization/shared/src/main/scala/org/enso/syntax/text/Parser.scala +++ b/common/syntax/specialization/shared/src/main/scala/org/enso/syntax/text/Parser.scala @@ -2,16 +2,14 @@ package org.enso.syntax.text import java.util.UUID -import cats.{Foldable, Monoid} -import org.enso.data.{Index, List1, Shifted, Span} +import cats.Foldable +import org.enso.data.{List1, Span} import org.enso.flexer import org.enso.flexer.Reader import org.enso.syntax.text.AST.Block.{Line, OptLine} import org.enso.syntax.text.AST.Macro.Match.SegmentOps -import org.enso.syntax.text.AST.{App, Module} +import org.enso.syntax.text.AST.App import org.enso.syntax.text.ast.meta.Builtin -import org.enso.syntax.text.ast.opr.Prec -import org.enso.syntax.text.prec.Distance import org.enso.syntax.text.prec.Macro import org.enso.syntax.text.spec.ParserDef import cats.implicits._ @@ -398,24 +396,24 @@ object Main extends scala.App { | UPCOMING | ALAMAKOTA a kot ma Ale | This is a test of Enso Documentation Parser. This is a short synopsis. - | + | | Here you can write the body of documentation. On top you can see tags | added to this piece of code. You can customise your text with _Italic_ | ~Strikethrough~ or *Bold*. ~_*Combined*_~ is funny - | - | + | + | | There are 3 kinds of sections | - Important | - Info | - Example | * You can use example to add multiline code to your documentation - | + | | ! Important | Here is a small test of Important Section - | + | | ? Info | Here is a small test of Info Section - | + | | > Example | Here is a small test of Example Section | Import Foo @@ -426,7 +424,7 @@ object Main extends scala.App { | ##DEPRECATED | foo bar baz | type Nothing - | + | | ## The pow function calculates power of integers. | pow x y = x ** y |""".stripMargin @@ -461,7 +459,7 @@ object Main extends scala.App { | Also, `None` is the return value of functions which do not return an | explicit value. | type None - | + | | ## The pow function calculates power of integers. | pow x y = x ** y |""".stripMargin diff --git a/common/syntax/specialization/shared/src/test/scala/org/enso/syntax/text/DocParserTests.scala b/common/syntax/specialization/shared/src/test/scala/org/enso/syntax/text/DocParserTests.scala index b7ddd1f1c39..fe910dba658 100644 --- a/common/syntax/specialization/shared/src/test/scala/org/enso/syntax/text/DocParserTests.scala +++ b/common/syntax/specialization/shared/src/test/scala/org/enso/syntax/text/DocParserTests.scala @@ -7,11 +7,11 @@ import org.enso.Logger import org.enso.flexer.Parser.Result import org.enso.flexer.Reader import org.enso.syntax.text.ast.Doc.Tags.Tag -import org.scalatest.FlatSpec -import org.scalatest.Matchers import org.scalatest.Assertion +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers -class DocParserTests extends FlatSpec with Matchers { +class DocParserTests extends AnyFlatSpec with Matchers { val logger = new Logger() def assertExpr(input: String, result: Doc): Assertion = { diff --git a/common/syntax/specialization/shared/src/test/scala/org/enso/syntax/text/ParserTest.scala b/common/syntax/specialization/shared/src/test/scala/org/enso/syntax/text/ParserTest.scala index c81f2f0359f..981292d95ab 100644 --- a/common/syntax/specialization/shared/src/test/scala/org/enso/syntax/text/ParserTest.scala +++ b/common/syntax/specialization/shared/src/test/scala/org/enso/syntax/text/ParserTest.scala @@ -9,8 +9,10 @@ import org.enso.syntax.text.AST._ import org.enso.syntax.text.AST.conversions._ import org.enso.syntax.text.ast.DSL._ import org.scalatest._ +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers -class ParserTest extends FlatSpec with Matchers { +class ParserTest extends AnyFlatSpec with Matchers { def assertSpan(input: String, ast: AST): Assertion = { val gotSpan = ast.span @@ -65,7 +67,7 @@ class ParserTest extends FlatSpec with Matchers { def ?=(out: AST) = testBase in { assertExpr(input, out) } def ??=(out: Module) = testBase in { assertModule(input, out) } - def testIdentity = testBase in { assertIdentity(input) } + def testIdentity() = testBase in { assertIdentity(input) } } ////////////////////////////////////////////////////////////////////////////// @@ -181,9 +183,9 @@ class ParserTest extends FlatSpec with Matchers { import Shape.SegmentPlain.txtFromString def line(s: String, empty: Int*) = - Shape.TextBlockLine(empty.to[List], List(txtFromString[AST](s))) + Shape.TextBlockLine(empty.toList, List(txtFromString[AST](s))) def line(segment: AST.Text.Segment.Fmt, empty: Int*) = - Shape.TextBlockLine(empty.to[List], List(segment)) + Shape.TextBlockLine(empty.toList, List(segment)) "'" ?= Text.Unclosed() "''" ?= Text() @@ -398,20 +400,20 @@ class ParserTest extends FlatSpec with Matchers { //// Large Input ///////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -// ("(" * 33000).testIdentity // FIXME Stack Overflow -// ("OVERFLOW " * 5000).testIdentity -// ("\uD800\uDF1E " * 10000).testIdentity +// ("(" * 33000).testIdentity() // FIXME Stack Overflow +// ("OVERFLOW " * 5000).testIdentity() +// ("\uD800\uDF1E " * 10000).testIdentity() ////////////////////////////////////////////////////////////////////////////// //// OTHER (TO BE PARTITIONED)//////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// - "\na \nb \n".testIdentity - "f = \n\n\n".testIdentity - " \n\n\n f\nf".testIdentity - "f = \n\n x ".testIdentity - " a\n b\n c".testIdentity - "f =\n\n x\n\n y".testIdentity + "\na \nb \n".testIdentity() + "f = \n\n\n".testIdentity() + " \n\n\n f\nf".testIdentity() + "f = \n\n x ".testIdentity() + " a\n b\n c".testIdentity() + "f =\n\n x\n\n y".testIdentity() """ a @@ -420,7 +422,7 @@ class ParserTest extends FlatSpec with Matchers { d e f g h - """.testIdentity + """.testIdentity() """ # adults: old population @@ -438,7 +440,7 @@ class ParserTest extends FlatSpec with Matchers { isUnique xs i #### = xs.at(i).score != xs.at(i-1).score adults++children++mutants . sorted . unique . take (length pop1) . pure - """.testIdentity + """.testIdentity() /////////////////////// //// Preprocessing //// diff --git a/engine/gateway/src/main/scala/org/enso/gateway/Server.scala b/engine/gateway/src/main/scala/org/enso/gateway/Server.scala index 0b84b4bc9a6..285ebb8407e 100644 --- a/engine/gateway/src/main/scala/org/enso/gateway/Server.scala +++ b/engine/gateway/src/main/scala/org/enso/gateway/Server.scala @@ -7,7 +7,6 @@ import akka.http.scaladsl.Http import akka.http.scaladsl.model.ws.{BinaryMessage, Message, TextMessage} import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.Route -import akka.stream.ActorMaterializer import akka.stream.scaladsl.Flow import akka.stream.scaladsl.Sink import akka.stream.scaladsl.Source @@ -32,9 +31,7 @@ import scala.util.Success * @param config Server config. */ class Server(jsonRpcController: JsonRpcController, config: Config)( - implicit - system: ActorSystem, - materializer: ActorMaterializer + implicit system: ActorSystem ) { import system.dispatcher @@ -57,7 +54,7 @@ class Server(jsonRpcController: JsonRpcController, config: Config)( .flatMapConcat( input => Source - .fromFuture( + .future( jsonRpcController.getTextOutput(input) ) ) diff --git a/engine/gateway/src/test/scala/org/enso/gateway/GatewayJsonSpec.scala b/engine/gateway/src/test/scala/org/enso/gateway/GatewayJsonSpec.scala index a455de7f8ec..7104bd5d1a9 100644 --- a/engine/gateway/src/test/scala/org/enso/gateway/GatewayJsonSpec.scala +++ b/engine/gateway/src/test/scala/org/enso/gateway/GatewayJsonSpec.scala @@ -4,25 +4,20 @@ import akka.NotUsed import akka.actor.{ActorRef, ActorSystem} import akka.http.scaladsl.Http import akka.http.scaladsl.model.ws.{Message, TextMessage, WebSocketRequest} -import akka.stream.ActorMaterializer import akka.stream.scaladsl.{Flow, Keep, Sink, Source} import io.circe.Json +import io.circe.parser.parse +import org.enso.{Gateway, LanguageServer} import org.enso.gateway.TestJson.{ Initialize, Shutdown, WrongJsonrpc, WrongMethod } -import org.enso.{Gateway, LanguageServer} -import org.scalatest.{ - Assertion, - AsyncFlatSpec, - BeforeAndAfterAll, - GivenWhenThen, - Matchers -} -import io.circe.parser.parse import org.enso.gateway.server.Config +import org.scalatest.{Assertion, BeforeAndAfterAll, GivenWhenThen} +import org.scalatest.flatspec.AsyncFlatSpec +import org.scalatest.matchers.should.Matchers import scala.concurrent.{Await, Future} import scala.concurrent.duration._ @@ -33,8 +28,6 @@ class GatewayJsonSpec with BeforeAndAfterAll with GivenWhenThen { implicit private val system: ActorSystem = ActorSystem() - implicit private val materializer: ActorMaterializer = - ActorMaterializer.create(system) import system.dispatcher diff --git a/engine/gateway/src/test/scala/org/enso/gateway/GatewayMessageSpec.scala b/engine/gateway/src/test/scala/org/enso/gateway/GatewayMessageSpec.scala index 0a546fdebec..62b73e502c4 100644 --- a/engine/gateway/src/test/scala/org/enso/gateway/GatewayMessageSpec.scala +++ b/engine/gateway/src/test/scala/org/enso/gateway/GatewayMessageSpec.scala @@ -3,14 +3,16 @@ package org.enso.gateway import akka.actor.{ActorRef, ActorSystem} import akka.testkit.{ImplicitSender, TestKit} import org.enso.{Gateway, LanguageServer} -import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike} import org.enso.gateway.TestMessage.{Initialize, Shutdown} import org.enso.gateway.TestNotification.{Exit, Initialized} +import org.scalatest.BeforeAndAfterAll +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike class GatewayMessageSpec() extends TestKit(ActorSystem("GatewayMessageSpec")) with ImplicitSender - with WordSpecLike + with AnyWordSpecLike with Matchers with BeforeAndAfterAll { diff --git a/engine/json-rpc-server/src/test/scala/org/enso/jsonrpcserver/MessageHandlerTest.scala b/engine/json-rpc-server/src/test/scala/org/enso/jsonrpcserver/MessageHandlerTest.scala index 84f0e33696a..9cf8cedd436 100644 --- a/engine/json-rpc-server/src/test/scala/org/enso/jsonrpcserver/MessageHandlerTest.scala +++ b/engine/json-rpc-server/src/test/scala/org/enso/jsonrpcserver/MessageHandlerTest.scala @@ -2,7 +2,9 @@ package org.enso.jsonrpcserver import akka.actor.{ActorRef, ActorSystem, Props} import akka.testkit.{ImplicitSender, TestKit, TestProbe} import io.circe.{Decoder, Encoder, Json} -import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike} +import org.scalatest.EitherValues +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike import scala.concurrent.duration._ import io.circe.parser._ @@ -12,7 +14,7 @@ import org.enso.jsonrpcserver.MessageHandler.{Connected, WebMessage} class MessageHandlerTest extends TestKit(ActorSystem("TestSystem")) with ImplicitSender - with WordSpecLike + with AnyWordSpecLike with Matchers with BeforeAndAfterAll { @@ -240,7 +242,7 @@ class MessageHandlerTest msg shouldBe an[WebMessage] val contents = msg.asInstanceOf[WebMessage].message val maybeJson = parse(contents) - maybeJson shouldBe 'right - maybeJson.right.get shouldEqual expectedJson + maybeJson shouldBe Symbol("right") + maybeJson.foreach(_ shouldEqual expectedJson) } } diff --git a/engine/language-server/src/test/scala/org/enso/languageserver/LanguageServerSpec.scala b/engine/language-server/src/test/scala/org/enso/languageserver/LanguageServerSpec.scala index a0f695ab58d..935f8aa9b5c 100644 --- a/engine/language-server/src/test/scala/org/enso/languageserver/LanguageServerSpec.scala +++ b/engine/language-server/src/test/scala/org/enso/languageserver/LanguageServerSpec.scala @@ -5,12 +5,14 @@ import akka.testkit.{ImplicitSender, TestKit, TestProbe} import org.enso.LanguageServer import org.enso.languageserver.Notifications.{Exit, Initialized} import org.enso.languageserver.Requests.{Initialize, Shutdown} -import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike} +import org.scalatest.BeforeAndAfterAll +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike class LanguageServerSpec() extends TestKit(ActorSystem("LanguageServerSpec")) with ImplicitSender - with WordSpecLike + with AnyWordSpecLike with Matchers with BeforeAndAfterAll { diff --git a/engine/polyglot-api/src/main/scala/org/enso/polyglot/Module.scala b/engine/polyglot-api/src/main/scala/org/enso/polyglot/Module.scala index 3a697b6fd2d..e112b0e7047 100644 --- a/engine/polyglot-api/src/main/scala/org/enso/polyglot/Module.scala +++ b/engine/polyglot-api/src/main/scala/org/enso/polyglot/Module.scala @@ -1,7 +1,5 @@ package org.enso.polyglot -import java.io.File - import org.graalvm.polyglot.Value /** @@ -45,7 +43,7 @@ class Module(private val value: Value) { * @param additionalSource the new source to parse */ def patch(additionalSource: String): Unit = - value.invokeMember(PATCH, additionalSource) + value.invokeMember(PATCH, additionalSource): Unit /** * Evaluates an arbitrary expression as if it were placed in a function @@ -60,13 +58,15 @@ class Module(private val value: Value) { * Triggers reparsing of module sources. Used to notify the module that * sources have changed. */ - def reparse(): Unit = { value.invokeMember(REPARSE) } + def reparse(): Unit = { + value.invokeMember(REPARSE): Unit + } def setSource(source: String): Unit = { - value.invokeMember(SET_SOURCE, source) + value.invokeMember(SET_SOURCE, source): Unit } def setSourceFile(file: String): Unit = { - value.invokeMember(SET_SOURCE_FILE, file) + value.invokeMember(SET_SOURCE_FILE, file): Unit } } diff --git a/engine/polyglot-api/src/main/scala/org/enso/polyglot/TopScope.scala b/engine/polyglot-api/src/main/scala/org/enso/polyglot/TopScope.scala index 64024f4527f..085eeb110ab 100644 --- a/engine/polyglot-api/src/main/scala/org/enso/polyglot/TopScope.scala +++ b/engine/polyglot-api/src/main/scala/org/enso/polyglot/TopScope.scala @@ -1,6 +1,6 @@ package org.enso.polyglot -import org.graalvm.polyglot.{Context, Value} +import org.graalvm.polyglot.Value /** * Represents the top scope of Enso execution context @@ -33,6 +33,6 @@ class TopScope(private val value: Value) { new Module(value.invokeMember(REGISTER_MODULE, qualifiedName, filePath)) def unregisterModule(qualifiedName: String): Unit = { - value.invokeMember(UNREGISTER_MODULE, qualifiedName) + value.invokeMember(UNREGISTER_MODULE, qualifiedName): Unit } } diff --git a/engine/polyglot-api/src/test/scala/org/enso/polyglot/ApiTest.scala b/engine/polyglot-api/src/test/scala/org/enso/polyglot/ApiTest.scala index 147445ad947..0a32c1d14f2 100644 --- a/engine/polyglot-api/src/test/scala/org/enso/polyglot/ApiTest.scala +++ b/engine/polyglot-api/src/test/scala/org/enso/polyglot/ApiTest.scala @@ -1,8 +1,10 @@ package org.enso.polyglot -import org.graalvm.polyglot.Context -import org.scalatest.{FlatSpec, Matchers} -class ApiTest extends FlatSpec with Matchers { +import org.graalvm.polyglot.Context +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +class ApiTest extends AnyFlatSpec with Matchers { import LanguageInfo._ val executionContext = new ExecutionContext(Context.newBuilder(ID).build()) diff --git a/engine/polyglot-api/src/test/scala/org/enso/polyglot/ModuleManagementTest.scala b/engine/polyglot-api/src/test/scala/org/enso/polyglot/ModuleManagementTest.scala index 26861d45532..0581759c08f 100644 --- a/engine/polyglot-api/src/test/scala/org/enso/polyglot/ModuleManagementTest.scala +++ b/engine/polyglot-api/src/test/scala/org/enso/polyglot/ModuleManagementTest.scala @@ -1,14 +1,14 @@ package org.enso.polyglot + import java.io.File import java.nio.file.Files +import org.enso.pkg.Package import org.graalvm.polyglot.{Context, PolyglotException} -import org.scalatest.{FlatSpec, Matchers} -import org.enso.pkg.{Package, QualifiedName} +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers -import scala.util.Try - -class ModuleManagementTest extends FlatSpec with Matchers { +class ModuleManagementTest extends AnyFlatSpec with Matchers { class TestContext(packageName: String) { val tmpDir: File = Files.createTempDirectory("enso-test-packages").toFile val pkg: Package = Package.create(tmpDir, packageName) @@ -24,11 +24,11 @@ class ModuleManagementTest extends FlatSpec with Matchers { def mkFile(name: String): File = new File(tmpDir, name) def writeFile(name: String, contents: String): Unit = { - Files.write(mkFile(name).toPath, contents.getBytes) + Files.write(mkFile(name).toPath, contents.getBytes): Unit } def writeMain(contents: String): Unit = { - Files.write(pkg.mainFile.toPath, contents.getBytes) + Files.write(pkg.mainFile.toPath, contents.getBytes): Unit } } diff --git a/engine/runner/src/main/scala/org/enso/runner/ContextFactory.scala b/engine/runner/src/main/scala/org/enso/runner/ContextFactory.scala index fe4c777f7d8..537c07db9f9 100644 --- a/engine/runner/src/main/scala/org/enso/runner/ContextFactory.scala +++ b/engine/runner/src/main/scala/org/enso/runner/ContextFactory.scala @@ -3,7 +3,6 @@ package org.enso.runner import java.io.InputStream import java.io.OutputStream -import org.enso.interpreter.Constants import org.enso.interpreter.instrument.ReplDebuggerInstrument import org.enso.polyglot.{ExecutionContext, LanguageInfo, RuntimeOptions} import org.graalvm.polyglot.Context diff --git a/engine/runner/src/main/scala/org/enso/runner/JupyterKernel.scala b/engine/runner/src/main/scala/org/enso/runner/JupyterKernel.scala index 4e615654fe8..3713896972a 100644 --- a/engine/runner/src/main/scala/org/enso/runner/JupyterKernel.scala +++ b/engine/runner/src/main/scala/org/enso/runner/JupyterKernel.scala @@ -11,8 +11,8 @@ import io.github.spencerpark.jupyter.kernel.KernelConnectionProperties import io.github.spencerpark.jupyter.kernel import io.github.spencerpark.jupyter.kernel.display.DisplayData import org.enso.polyglot -import org.enso.polyglot.{ExecutionContext, LanguageInfo, Module, TopScope} -import org.graalvm.polyglot.{Context, Value} +import org.enso.polyglot.{ExecutionContext, LanguageInfo, Module} +import org.graalvm.polyglot.Value /** * A wrapper for Enso interpreter for use by Jupyter diff --git a/engine/runner/src/main/scala/org/enso/runner/Main.scala b/engine/runner/src/main/scala/org/enso/runner/Main.scala index 5eb23420f23..b45c53c49b4 100644 --- a/engine/runner/src/main/scala/org/enso/runner/Main.scala +++ b/engine/runner/src/main/scala/org/enso/runner/Main.scala @@ -9,7 +9,6 @@ import org.enso import org.enso.polyglot.{ExecutionContext, LanguageInfo, Module} import org.enso.{Gateway, LanguageServer} import akka.actor.{ActorRef, ActorSystem} -import akka.stream.ActorMaterializer import org.enso.gateway.JsonRpcController import scala.io.StdIn @@ -97,7 +96,7 @@ object Main { * * @param path root path of the newly created project */ - private def createNew(path: String) { + private def createNew(path: String): Unit = { Package.getOrCreate(new File(path)) exitSuccess() } @@ -145,12 +144,12 @@ object Main { ): Unit = { val topScope = context.getTopScope val mainModule = topScope.getModule(mainModuleName) - runMain(mainModule) + runMain(mainModule): Unit } private def runSingleFile(context: ExecutionContext, file: File): Unit = { val mainModule = context.evalModule(file) - runMain(mainModule) + runMain(mainModule): Unit } private def runMain(mainModule: Module): Value = { @@ -185,8 +184,6 @@ object Main { ) implicit val system: ActorSystem = ActorSystem() - implicit val materializer: ActorMaterializer = - ActorMaterializer.create(system) import system.dispatcher val languageServerActorName = "languageServer" diff --git a/engine/runner/src/main/scala/org/enso/runner/Repl.scala b/engine/runner/src/main/scala/org/enso/runner/Repl.scala index 7f54490d4af..54fd3f37c38 100644 --- a/engine/runner/src/main/scala/org/enso/runner/Repl.scala +++ b/engine/runner/src/main/scala/org/enso/runner/Repl.scala @@ -7,7 +7,7 @@ import org.enso.interpreter.instrument.ReplDebuggerInstrument import org.jline.reader.{LineReader, LineReaderBuilder} import org.jline.terminal.{Terminal, TerminalBuilder} -import collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.util.Try /** diff --git a/engine/runtime/src/bench/scala/org/enso/interpreter/bench/RegressionTest.scala b/engine/runtime/src/bench/scala/org/enso/interpreter/bench/RegressionTest.scala index b26862d023f..8bffd18bb60 100644 --- a/engine/runtime/src/bench/scala/org/enso/interpreter/bench/RegressionTest.scala +++ b/engine/runtime/src/bench/scala/org/enso/interpreter/bench/RegressionTest.scala @@ -1,15 +1,17 @@ package org.enso.interpreter.bench -import org.scalatest.{FlatSpec, Matchers} +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ +import scala.math.Ordering.Double.IeeeOrdering -class RegressionTest extends FlatSpec with Matchers { +class RegressionTest extends AnyFlatSpec with Matchers { // This tolerance may be adjusted depending on the stability of CI final val TOLERANCE = 0.2 val runner = new BenchmarksRunner - val benchmarks = List(runner.getAvailable.asScala: _*) + val benchmarks = runner.getAvailable.asScala benchmarks.foreach { benchmark => benchmark should "not be slower than before" in { diff --git a/engine/runtime/src/bench/scala/org/enso/interpreter/bench/fixtures/semantic/AtomFixtures.scala b/engine/runtime/src/bench/scala/org/enso/interpreter/bench/fixtures/semantic/AtomFixtures.scala index c9bc37f8571..a29a27eb235 100644 --- a/engine/runtime/src/bench/scala/org/enso/interpreter/bench/fixtures/semantic/AtomFixtures.scala +++ b/engine/runtime/src/bench/scala/org/enso/interpreter/bench/fixtures/semantic/AtomFixtures.scala @@ -1,12 +1,8 @@ package org.enso.interpreter.bench.fixtures.semantic -import org.enso.interpreter.Constants import org.enso.interpreter.runtime.Builtins -import org.enso.interpreter.runtime.scope.TopLevelScope -import org.enso.interpreter.test.{InterpreterException, InterpreterRunner} -import org.graalvm.polyglot.{PolyglotException, Value} - -import scala.util.Try +import org.enso.interpreter.test.InterpreterRunner +import org.graalvm.polyglot.Value class AtomFixtures extends InterpreterRunner { val million: Long = 1000000 diff --git a/engine/runtime/src/main/java/org/enso/interpreter/util/ScalaConversions.java b/engine/runtime/src/main/java/org/enso/interpreter/util/ScalaConversions.java index b57a4fbe8eb..071ca7bf2f9 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/util/ScalaConversions.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/util/ScalaConversions.java @@ -1,7 +1,9 @@ package org.enso.interpreter.util; import scala.Option; -import scala.collection.JavaConverters; +import scala.jdk.javaapi.CollectionConverters; +import scala.jdk.javaapi.OptionConverters; + import scala.collection.Seq; import java.util.List; @@ -16,7 +18,7 @@ public class ScalaConversions { * @return the corresponding java optional */ public static Optional asJava(Option option) { - return Optional.ofNullable(option.getOrElse(() -> null)); + return OptionConverters.toJava(option); } /** @@ -26,6 +28,6 @@ public class ScalaConversions { * @return the corresponding java list */ public static List asJava(Seq list) { - return JavaConverters.seqAsJavaList(list); + return CollectionConverters.asJava(list); } } diff --git a/engine/runtime/src/main/scala/org/enso/compiler/Compiler.scala b/engine/runtime/src/main/scala/org/enso/compiler/Compiler.scala index bca830e5d4c..2fdb3dc95da 100644 --- a/engine/runtime/src/main/scala/org/enso/compiler/Compiler.scala +++ b/engine/runtime/src/main/scala/org/enso/compiler/Compiler.scala @@ -1,7 +1,6 @@ package org.enso.compiler import java.io.StringReader -import java.util.Optional import com.oracle.truffle.api.TruffleFile import com.oracle.truffle.api.source.Source @@ -10,17 +9,13 @@ import org.enso.compiler.generate.AstToAstExpression import org.enso.flexer.Reader import org.enso.interpreter.builder.{ExpressionFactory, ModuleScopeExpressionFactory} import org.enso.interpreter.node.ExpressionNode -import org.enso.interpreter.runtime.callable.function.Function import org.enso.interpreter.runtime.error.ModuleDoesNotExistException import org.enso.interpreter.runtime.scope.{LocalScope, ModuleScope, TopLevelScope} -import org.enso.interpreter.runtime.{Context, Module} -import org.enso.interpreter.{Constants, Language} +import org.enso.interpreter.runtime.Context +import org.enso.interpreter.Language import org.enso.polyglot.LanguageInfo import org.enso.syntax.text.{AST, Parser} -import scala.collection.JavaConverters._ -import scala.collection.mutable - /** * This class encapsulates the static transformation processes that take place * on source code, including parsing, desugaring, type-checking, static diff --git a/engine/runtime/src/main/scala/org/enso/compiler/core/OldAST.scala b/engine/runtime/src/main/scala/org/enso/compiler/core/OldAST.scala index a31884af72e..caa97418bb5 100644 --- a/engine/runtime/src/main/scala/org/enso/compiler/core/OldAST.scala +++ b/engine/runtime/src/main/scala/org/enso/compiler/core/OldAST.scala @@ -4,8 +4,7 @@ import java.util.Optional import org.enso.syntax.text.Location -import scala.collection.JavaConverters._ -import scala.language.postfixOps +import scala.jdk.CollectionConverters._ trait AstExpressionVisitor[+T] { def visitLong(l: AstLong): T diff --git a/engine/runtime/src/main/scala/org/enso/compiler/generate/AstToAstExpression.scala b/engine/runtime/src/main/scala/org/enso/compiler/generate/AstToAstExpression.scala index c6becbf6a91..919cef949e7 100644 --- a/engine/runtime/src/main/scala/org/enso/compiler/generate/AstToAstExpression.scala +++ b/engine/runtime/src/main/scala/org/enso/compiler/generate/AstToAstExpression.scala @@ -6,7 +6,6 @@ import org.enso.compiler.core import org.enso.compiler.core._ import org.enso.compiler.exception.UnhandledEntity import org.enso.interpreter.Constants -import org.enso.interpreter.Constants.Names import org.enso.syntax.text.{AST, Location} // FIXME [AA] All places where we currently throw a `RuntimeException` should @@ -307,7 +306,7 @@ object AstToAstExpression { case _ => true } - val suspendPositions = args.view.zipWithIndex.collect { + val suspendPositions = args.zipWithIndex.collect { case (AstView.SuspendDefaultsOperator(_), ix) => ix } diff --git a/engine/runtime/src/test/scala/org/enso/compiler/test/CompilerTest.scala b/engine/runtime/src/test/scala/org/enso/compiler/test/CompilerTest.scala index 036efd00a08..b4c32e1db9b 100644 --- a/engine/runtime/src/test/scala/org/enso/compiler/test/CompilerTest.scala +++ b/engine/runtime/src/test/scala/org/enso/compiler/test/CompilerTest.scala @@ -1,7 +1,8 @@ package org.enso.compiler.test -import org.scalatest.{FlatSpec, Matchers} +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers trait CompilerRunner {} -trait CompilerTest extends FlatSpec with Matchers with CompilerRunner +trait CompilerTest extends AnyFlatSpec with Matchers with CompilerRunner diff --git a/engine/runtime/src/test/scala/org/enso/compiler/test/core/SmartConstructorsTest.scala b/engine/runtime/src/test/scala/org/enso/compiler/test/core/SmartConstructorsTest.scala index bf977ee97a6..d738c5a01a9 100644 --- a/engine/runtime/src/test/scala/org/enso/compiler/test/core/SmartConstructorsTest.scala +++ b/engine/runtime/src/test/scala/org/enso/compiler/test/core/SmartConstructorsTest.scala @@ -7,10 +7,12 @@ import org.enso.core.CoreGraph.DefinitionGen.Node.{Shape => NodeShape} import org.enso.core.CoreGraph.{DefinitionGen => CoreDef} import org.enso.graph.{Graph => PrimGraph} import org.enso.syntax.text.{AST, Location => AstLocation} -import org.scalatest.{Assertion, BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatest.{Assertion, BeforeAndAfterEach} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike class SmartConstructorsTest - extends WordSpec + extends AnyWordSpecLike with Matchers with BeforeAndAfterEach { diff --git a/engine/runtime/src/test/scala/org/enso/interpreter/test/InterpreterTest.scala b/engine/runtime/src/test/scala/org/enso/interpreter/test/InterpreterTest.scala index 9cc66d988c0..a1b86a1a2b1 100644 --- a/engine/runtime/src/test/scala/org/enso/interpreter/test/InterpreterTest.scala +++ b/engine/runtime/src/test/scala/org/enso/interpreter/test/InterpreterTest.scala @@ -12,7 +12,9 @@ import org.enso.interpreter.instrument.{ import org.enso.interpreter.test.CodeLocationsTestInstrument.LocationsEventListener import org.enso.polyglot.{ExecutionContext, Function, LanguageInfo} import org.graalvm.polyglot.{Context, Value} -import org.scalatest.{Assertions, FlatSpec, Matchers} +import org.scalatest.Assertions +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers case class LocationsInstrumenter(instrument: CodeLocationsTestInstrument) { var bindings: List[EventBinding[LocationsEventListener]] = List() @@ -87,7 +89,7 @@ trait InterpreterRunner { def consumeOut: List[String] = { val result = output.toString output.reset() - result.lines.toList + result.linesIterator.toList } def getReplInstrument: ReplDebuggerInstrument = { @@ -119,7 +121,7 @@ trait InterpreterRunner { } trait InterpreterTest - extends FlatSpec + extends AnyFlatSpec with Matchers with InterpreterRunner with ValueEquality diff --git a/engine/runtime/src/test/scala/org/enso/interpreter/test/PackageTest.scala b/engine/runtime/src/test/scala/org/enso/interpreter/test/PackageTest.scala index 6b513238a5f..84da388104b 100644 --- a/engine/runtime/src/test/scala/org/enso/interpreter/test/PackageTest.scala +++ b/engine/runtime/src/test/scala/org/enso/interpreter/test/PackageTest.scala @@ -5,9 +5,10 @@ import java.io.File import org.enso.pkg.Package import org.enso.polyglot.{ExecutionContext, LanguageInfo, RuntimeOptions} import org.graalvm.polyglot.{Context, Value} -import org.scalatest.{FlatSpec, Matchers} +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers -trait PackageTest extends FlatSpec with Matchers with ValueEquality { +trait PackageTest extends AnyFlatSpec with Matchers with ValueEquality { def evalTestProject(name: String): Value = { val pkgPath = diff --git a/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/ReplTest.scala b/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/ReplTest.scala index 03bedbfa993..67ae81d9024 100644 --- a/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/ReplTest.scala +++ b/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/ReplTest.scala @@ -1,7 +1,7 @@ package org.enso.interpreter.test.instrument import org.enso.interpreter.test.InterpreterTest -import collection.JavaConverters._ +import scala.jdk.CollectionConverters._ class ReplTest extends InterpreterTest { "Repl" should "be able to list local variables in its scope" in { @@ -20,7 +20,7 @@ class ReplTest extends InterpreterTest { executor.exit() } eval(code) - scopeResult.mapValues(_.toString) shouldEqual Map( + scopeResult.view.mapValues(_.toString).toMap shouldEqual Map( "this" -> "Test", "x" -> "10", "y" -> "20", diff --git a/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/ValueExtractorTest.scala b/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/ValueExtractorTest.scala index d32e21e586c..acc90ce611e 100644 --- a/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/ValueExtractorTest.scala +++ b/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/ValueExtractorTest.scala @@ -131,9 +131,9 @@ class ValueExtractorTest extends InterpreterTest { val visualizationExpr = "val -> here.foo val * 3" val visualization = module.evalExpression(visualizationExpr) val results = - values.mapValues( + values.view.mapValues( v => visualization.execute(v.asInstanceOf[AnyRef]).asLong - ) + ).toMap results shouldEqual Map("x" -> 33L, "y" -> 153L) } diff --git a/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/CodeLocationsTest.scala b/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/CodeLocationsTest.scala index 0e42ca109e6..9a9db372a44 100644 --- a/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/CodeLocationsTest.scala +++ b/engine/runtime/src/test/scala/org/enso/interpreter/test/semantic/CodeLocationsTest.scala @@ -11,7 +11,7 @@ import org.enso.interpreter.test.InterpreterTest class CodeLocationsTest extends InterpreterTest { def debugPrintCodeLocations(code: String): Unit = { var off = 0 - code.lines.toList.foreach { line => + code.linesIterator.toList.foreach { line => val chars: List[Any] = line.toList.map { c => s" ${if (c == ' ') '_' else c} " } :+ '↵'