mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 01:21:33 +03:00
Update to scala 2.13.1 (#481)
This commit is contained in:
parent
9dee1911f8
commit
8d8e95e14a
@ -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
|
||||
|
228
build.sbt
228
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)
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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] = _
|
||||
|
||||
|
@ -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")
|
||||
()
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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.
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.enso
|
||||
|
||||
import scala.language.experimental.macros
|
||||
import scala.reflect.macros.blackbox.Context
|
||||
import org.enso.lint.Unused
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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 =
|
||||
|
@ -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(_ => ())
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -305,7 +305,7 @@ object DocParserHTMLGenerator {
|
||||
generateHTMLForEveryDocumented(elem, path, cssFileName)
|
||||
}
|
||||
elem
|
||||
}
|
||||
} : Unit
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -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._
|
||||
|
@ -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 = {
|
||||
|
@ -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 ////
|
||||
|
@ -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)
|
||||
)
|
||||
)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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())
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
||||
/**
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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 <T> Optional<T> asJava(Option<T> 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 <T> List<T> asJava(Seq<T> list) {
|
||||
return JavaConverters.seqAsJavaList(list);
|
||||
return CollectionConverters.asJava(list);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 =
|
||||
|
@ -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",
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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} "
|
||||
} :+ '↵'
|
||||
|
Loading…
Reference in New Issue
Block a user