From 6e2074eae994629774bcc2ace6e3b91fa9ba2cff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Thu, 6 Dec 2018 16:56:00 +0100 Subject: [PATCH 1/7] Update to 2.12.8 --- build.sbt | 9 +- metals/src/main/resources/bloop.py | 19 +++- test-workspace/.dotty-ide-artifact | 0 .../src/test/scala/tests/SbtSlowSuite.scala | 96 ++++++++++--------- .../src/main/scala/tests/QuickBuild.scala | 2 +- 5 files changed, 72 insertions(+), 54 deletions(-) delete mode 100644 test-workspace/.dotty-ide-artifact diff --git a/build.sbt b/build.sbt index f1be6db2ef3..fb49720e191 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,4 @@ -import java.io.File -def localSnapshotVersion = "0.2.3-SNAPSHOT" +def localSnapshotVersion = "0.4.0-SNAPSHOT" inThisBuild( List( version ~= { dynVer => @@ -89,7 +88,7 @@ commands += Command.command("save-expect") { s => lazy val V = new { val scala210 = "2.10.7" val scala211 = "2.11.12" - val scala212 = "2.12.7" + val scala212 = "2.12.8" val scalameta = "4.1.0" val semanticdb = "4.1.0" val bsp = "2.0.0-M2" @@ -98,8 +97,8 @@ lazy val V = new { // List of supported Scala versions in SemanticDB. Needs to be manually updated // for every SemanticDB upgrade. def supportedScalaVersions = Seq( - "2.12.7", "2.12.6", "2.12.5", "2.12.4", "2.11.12", "2.11.11", "2.11.10", - "2.11.9" + "2.12.8", "2.12.7", "2.12.6", "2.12.5", "2.12.4", "2.11.12", "2.11.11", + "2.11.10", "2.11.9" ) } diff --git a/metals/src/main/resources/bloop.py b/metals/src/main/resources/bloop.py index 09eebf2697f..a1d0b6ffc30 100755 --- a/metals/src/main/resources/bloop.py +++ b/metals/src/main/resources/bloop.py @@ -1038,10 +1038,21 @@ def main(): java_cmd = ["java"] + cmd_args + ["-jar", server_location] check_call(java_cmd) except CalledProcessError as e: - print("Bloop server in %s failed to run." % server_location) - print("Command: %s" % e.cmd) - print("Return code: %d" % e.returncode) - sys.exit(e.returncode) + # The binary may be executable directly under certain package managers such as Nix + # Try running it without `java` and ignore previous error if so + try: + if cmd_args: + print("Java arguments are ignored, " + server_location + " deemed to be a binary instead of a jar.") + check_call([server_location]) + except CallProcessError as e2: + print("Bloop server in %s failed to run." % server_location) + print("First invocation attempt: %s" % e.cmd) + print("-> Return code: %d" % e.returncode) + print("Second invocation attempt: %s" % e2.cmd) + print("-> Return code: %d" % e2.returncode) + + # Only use the return code of the first attempt + sys.exit(e.returncode) except KeyboardInterrupt as e: sys.exit(0) diff --git a/test-workspace/.dotty-ide-artifact b/test-workspace/.dotty-ide-artifact deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/slow/src/test/scala/tests/SbtSlowSuite.scala b/tests/slow/src/test/scala/tests/SbtSlowSuite.scala index 426d6088df7..ebe2d007811 100644 --- a/tests/slow/src/test/scala/tests/SbtSlowSuite.scala +++ b/tests/slow/src/test/scala/tests/SbtSlowSuite.scala @@ -7,6 +7,7 @@ import scala.meta.internal.metals.Messages._ import scala.meta.internal.metals.MetalsSlowTaskResult import scala.meta.internal.metals.SbtDigest import scala.meta.internal.metals.ServerCommands +import scala.meta.internal.metals.{BuildInfo => V} object SbtSlowSuite extends BaseSlowSuite("import") { @@ -206,32 +207,36 @@ object SbtSlowSuite extends BaseSlowSuite("import") { cleanWorkspace() for { _ <- server.initialize( - """ - |/project/build.properties - |sbt.version=1.2.6 - |/build.sbt - |scalaVersion := "2.12.7" - |lazy val a = project.settings(scalaVersion := "2.12.4") - |lazy val b = project.settings(scalaVersion := "2.12.3") - |lazy val c = project.settings(scalaVersion := "2.11.12") - |lazy val d = project.settings(scalaVersion := "2.11.8") - |lazy val e = project.settings(scalaVersion := "2.10.7") - |/a/src/main/scala/a/A.scala - |package a - |object A // 2.12.4 - |/b/src/main/scala/a/A.scala - |package a // 2.12.3 - |object A - |/c/src/main/scala/a/A.scala - |package a - |object A // 2.11.12 - |/d/src/main/scala/a/A.scala - |package a - |object A // 2.11.8 - |/e/src/main/scala/a/A.scala - |package a - |object A // 2.10.7 - |""".stripMargin, + s""" + |/project/build.properties + |sbt.version=1.2.6 + |/build.sbt + |scalaVersion := "2.12.7" + |lazy val a = project.settings(scalaVersion := "2.12.4") + |lazy val b = project.settings(scalaVersion := "2.12.3") + |lazy val c = project.settings(scalaVersion := "2.11.12") + |lazy val d = project.settings(scalaVersion := "2.11.8") + |lazy val e = project.settings(scalaVersion := "2.10.7") + |lazy val f = project.settings(scalaVersion := "${V.scala212}") + |/a/src/main/scala/a/A.scala + |package a + |object A // 2.12.4 + |/b/src/main/scala/a/A.scala + |package a // 2.12.3 + |object A + |/c/src/main/scala/a/A.scala + |package a + |object A // 2.11.12 + |/d/src/main/scala/a/A.scala + |package a + |object A // 2.11.8 + |/e/src/main/scala/a/A.scala + |package a + |object A // 2.10.7 + |/f/src/main/scala/a/A.scala + |package a + |object A // ${V.scala212} + |""".stripMargin, expectError = true ) _ = assertStatus(_.isInstalled) @@ -240,30 +245,33 @@ object SbtSlowSuite extends BaseSlowSuite("import") { CheckDoctor.multipleMisconfiguredProjects(6) ) _ <- Future.sequence( - ('a' to 'e') + ('a' to 'f') .map(project => s"$project/src/main/scala/a/A.scala") .map(file => server.didOpen(file)) ) _ = assertNoDiff(client.workspaceDiagnostics, "") _ = assertNoDiff( server.workspaceDefinitions, - """ - |/a/src/main/scala/a/A.scala - |package a - |object A/*L1*/ // 2.12.4 - |/b/src/main/scala/a/A.scala - |package a/**/ // 2.12.3 - |object A/**/ - |/c/src/main/scala/a/A.scala - |package a - |object A/*L1*/ // 2.11.12 - |/d/src/main/scala/a/A.scala - |package a/**/ - |object A/**/ // 2.11.8 - |/e/src/main/scala/a/A.scala - |package a/**/ - |object A/**/ // 2.10.7 - |""".stripMargin + s""" + |/a/src/main/scala/a/A.scala + |package a + |object A/*L1*/ // 2.12.4 + |/b/src/main/scala/a/A.scala + |package a/**/ // 2.12.3 + |object A/**/ + |/c/src/main/scala/a/A.scala + |package a + |object A/*L1*/ // 2.11.12 + |/d/src/main/scala/a/A.scala + |package a/**/ + |object A/**/ // 2.11.8 + |/e/src/main/scala/a/A.scala + |package a/**/ + |object A/**/ // 2.10.7 + |/f/src/main/scala/a/A.scala + |package a + |object A/*L1*/ // ${V.scala212} + |""".stripMargin ) _ = { assertNoDiff( diff --git a/tests/unit/src/main/scala/tests/QuickBuild.scala b/tests/unit/src/main/scala/tests/QuickBuild.scala index 43aa8120fc6..c2176232a96 100644 --- a/tests/unit/src/main/scala/tests/QuickBuild.scala +++ b/tests/unit/src/main/scala/tests/QuickBuild.scala @@ -67,7 +67,7 @@ case class QuickBuild( def withId(id: String): QuickBuild = QuickBuild( id, - if (scalaVersion == null) Properties.versionNumberString + if (scalaVersion == null) V.scala212 else scalaVersion, orEmpty(libraryDependencies), orEmpty(compilerPlugins), From 9265ae08ab041f3a8fad55e84934f873057f7ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Fri, 7 Dec 2018 13:18:05 +0100 Subject: [PATCH 2/7] Upgrade mdoc for 2.12.8 --- build.sbt | 3 +-- project/plugins.sbt | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index fb49720e191..427d788fceb 100644 --- a/build.sbt +++ b/build.sbt @@ -275,8 +275,7 @@ lazy val docs = project moduleName := "metals-docs", mainClass.in(Compile) := Some("docs.Docs"), libraryDependencies ++= List( - "org.jsoup" % "jsoup" % "1.11.3", - "com.geirsson" % "mdoc" % "0.6.1" cross CrossVersion.full + "org.jsoup" % "jsoup" % "1.11.3" ) ) .dependsOn(metals) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4f7a7e99d37..d1093ca5088 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,9 +1,11 @@ addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.4") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.0") addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.2.2") -addSbtPlugin("com.geirsson" % "sbt-docusaurus" % "0.3.4") +addSbtPlugin("com.geirsson" % "sbt-docusaurus" % "0.3.5") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0") addSbtCoursier libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value + +resolvers += Resolver.sonatypeRepo("releases") From 8623e99824f171022b592284a9507049d0dcd6cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Fri, 7 Dec 2018 14:00:16 +0100 Subject: [PATCH 3/7] Remove "via Bloop" from import build dialogue Based on feedback from several people, many have been reluctant to click on the "Import build" button out of concern that they don't have Bloop installed on their machine. Yesterday I updated the message to mention "You don't need Bloop installed on your machine to run this step" but while demoing Metals today I still got a comment that it was confusing. This commit removes the mention of Bloop from the LSP dialogue and instead clarifies the website to highlight Bloop. I care most about getting a great out-of-the-box experience so I hope this change removes obstacles people have faced before. --- .../main/scala/docs/TextEditorModifier.scala | 38 +++++++++++-------- .../meta/internal/metals/BloopInstall.scala | 8 ++-- .../scala/meta/internal/metals/Messages.scala | 15 +++++--- test-workspace/build.sbt | 3 +- .../src/test/scala/tests/SbtSlowSuite.scala | 10 ++--- .../src/main/scala/tests/TestingClient.scala | 8 ++-- website/i18n/en.json | 3 ++ 7 files changed, 49 insertions(+), 36 deletions(-) diff --git a/metals-docs/src/main/scala/docs/TextEditorModifier.scala b/metals-docs/src/main/scala/docs/TextEditorModifier.scala index 40c5b0183db..e73b8dd6ead 100644 --- a/metals-docs/src/main/scala/docs/TextEditorModifier.scala +++ b/metals-docs/src/main/scala/docs/TextEditorModifier.scala @@ -14,34 +14,42 @@ class TextEditorModifier extends StringModifier { s""" |## Importing a build | - |The first time you open Metals in a new sbt build it prompts you to "Import - |build via Bloop". Click "Import build via Bloop" to start the `sbt bloopInstall` - |import step. + |The first time you open Metals in a new workspace it prompts you to import the build. + |Click "Import build" to start the installation step. | - |![Import build](../assets/$editor-import-via-bloop.png) + |![Import build](../assets/$editor-import-build.png) | - |- you don't need Bloop installed on your machine to run this step. - |- this step is required for compile errors and goto definition to work. - | - |The `sbt bloopInstall` step can take a long time, especially the first time you - |run it in a new build. The exact time depends on the complexity of the build and - |if library dependencies are cached or need to be downloaded. For example, this - |step can take everything from 10 seconds in small cached builds up to 10-15 - |minutes in large uncached builds. + |- "Not now" disables this prompt for 2 minutes. + |- "Don't show again" disables this prompt forever, use `rm -rf .metals/` to re-enable + | the prompt. + |- Behind the scenese, Metals uses [Bloop](https://scalacenter.github.io/bloop/) to + | import sbt builds, but you don't need Bloop installed on your machine to run this step. | |Once the import step completes, compilation starts for your open `*.scala` |files. | |Once the sources have compiled successfully, you can navigate the codebase with - |"goto definition" by `Cmd+Click` or `Cmd+Shift+Enter`. + |"goto definition" with `Cmd+Click`. + | + |### Speeding up import + | + |The "Import build" step can take a long time, especially the first time you + |run it in a new build. The exact time depends on the complexity of the build and + |if library dependencies need to be downloaded. For example, this step can take + |everything from 10 seconds in small cached builds up to 10-15 minutes in large + |uncached builds. + | + |Consult the [Bloop documentation](https://scalacenter.github.io/bloop/docs/build-tools/sbt#speeding-up-build-export) + |to learn how to speed up build import. + | + |### Importing changes | |When you change `build.sbt` or sources under `project/`, you will be prompted to |re-import the build. | |![Import sbt changes](assets/$editor-import-changes.png) | - |Click "Import changes" and that will restart the `sbt bloopInstall` step. Select - |"Don't show again" if you prefer to manually trigger build import. + |### Manually trigger build import | |To manually trigger a build import, execute the "Import build" command through |the command palette (`Cmd + Shift + P`). diff --git a/metals/src/main/scala/scala/meta/internal/metals/BloopInstall.scala b/metals/src/main/scala/scala/meta/internal/metals/BloopInstall.scala index 4e44f9b9112..d39d28c6f24 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/BloopInstall.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/BloopInstall.scala @@ -152,23 +152,23 @@ final class BloopInstall( tables.sbtDigests.setStatus(digest, Status.Requested) if (buildTools.isBloop) { languageClient - .showMessageRequest(ReimportSbtProject.params) + .showMessageRequest(ImportBuildChanges.params) .asScala .map { item => if (item == dontShowAgain) { notification.dismissForever() } - Confirmation.fromBoolean(item == ReimportSbtProject.yes) + Confirmation.fromBoolean(item == ImportBuildChanges.yes) } } else { languageClient - .showMessageRequest(ImportBuildViaBloop.params) + .showMessageRequest(ImportBuild.params) .asScala .map { item => if (item == dontShowAgain) { notification.dismissForever() } - Confirmation.fromBoolean(item == ImportBuildViaBloop.yes) + Confirmation.fromBoolean(item == ImportBuild.yes) } } } diff --git a/metals/src/main/scala/scala/meta/internal/metals/Messages.scala b/metals/src/main/scala/scala/meta/internal/metals/Messages.scala index 3546bd18c2f..8beeada9c05 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Messages.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Messages.scala @@ -26,16 +26,19 @@ class Messages(icons: Icons) { def dontShowAgain: MessageActionItem = new MessageActionItem("Don't show again") - object ReimportSbtProject { + def notNow: MessageActionItem = + new MessageActionItem("Not now") + object ImportBuildChanges { def yes: MessageActionItem = new MessageActionItem("Import changes") def params: ShowMessageRequestParams = { val params = new ShowMessageRequestParams() - params.setMessage("sbt projects need to be imported") + params.setMessage("sbt build needs to be re-imported") params.setType(MessageType.Info) params.setActions( List( yes, + notNow, dontShowAgain ).asJava ) @@ -43,18 +46,18 @@ class Messages(icons: Icons) { } } - object ImportBuildViaBloop { - def yes = new MessageActionItem("Import build via Bloop") + object ImportBuild { + def yes = new MessageActionItem("Import build") def params: ShowMessageRequestParams = { val params = new ShowMessageRequestParams() params.setMessage( - "sbt build detected, would you like to import via Bloop? " + - "You don't need Bloop installed on your machine to run this step." + "New sbt workspace detected, would you like to import the build?" ) params.setType(MessageType.Info) params.setActions( List( yes, + notNow, dontShowAgain ).asJava ) diff --git a/test-workspace/build.sbt b/test-workspace/build.sbt index 8ac796932ed..e55f0cb67b3 100644 --- a/test-workspace/build.sbt +++ b/test-workspace/build.sbt @@ -1,5 +1,5 @@ inThisBuild(Vector( - scalaVersion := "2.12.7", + scalaVersion := "2.12.8", scalacOptions ++= List( "-Yrangepos", "-Ywarn-unused" ), @@ -12,4 +12,3 @@ libraryDependencies ++= List( "com.lihaoyi" %% "sourcecode" % "0.1.4", "org.scalatest" %% "scalatest" % "3.0.5" ) - diff --git a/tests/slow/src/test/scala/tests/SbtSlowSuite.scala b/tests/slow/src/test/scala/tests/SbtSlowSuite.scala index ebe2d007811..e6d563f787a 100644 --- a/tests/slow/src/test/scala/tests/SbtSlowSuite.scala +++ b/tests/slow/src/test/scala/tests/SbtSlowSuite.scala @@ -46,7 +46,7 @@ object SbtSlowSuite extends BaseSlowSuite("import") { client.workspaceMessageRequests, List( // Project has no .bloop directory so user is asked to "import via bloop" - ImportBuildViaBloop.params.getMessage, + ImportBuild.params.getMessage, BloopInstallProgress.message ).mkString("\n") ) @@ -67,7 +67,7 @@ object SbtSlowSuite extends BaseSlowSuite("import") { client.workspaceMessageRequests, List( // Project has .bloop directory so user is asked to "re-import project" - ReimportSbtProject.params.getMessage, + ImportBuildChanges.params.getMessage, BloopInstallProgress.message ).mkString("\n") ) @@ -88,7 +88,7 @@ object SbtSlowSuite extends BaseSlowSuite("import") { client.workspaceMessageRequests, List( // Project has no .bloop directory so user is asked to "import via bloop" - ImportBuildViaBloop.params.getMessage, + ImportBuild.params.getMessage, BloopInstallProgress.message ).mkString("\n") ) @@ -179,7 +179,7 @@ object SbtSlowSuite extends BaseSlowSuite("import") { _ = assertNoDiff( client.workspaceMessageRequests, List( - ImportBuildViaBloop.params.getMessage, + ImportBuild.params.getMessage, BloopInstallProgress.message ).mkString("\n") ) @@ -195,7 +195,7 @@ object SbtSlowSuite extends BaseSlowSuite("import") { _ = assertNoDiff( client.workspaceMessageRequests, List( - ImportBuildViaBloop.params.getMessage, + ImportBuild.params.getMessage, BloopInstallProgress.message ).mkString("\n") ) diff --git a/tests/unit/src/main/scala/tests/TestingClient.scala b/tests/unit/src/main/scala/tests/TestingClient.scala index 5c3b61d73b3..4b58aa486f3 100644 --- a/tests/unit/src/main/scala/tests/TestingClient.scala +++ b/tests/unit/src/main/scala/tests/TestingClient.scala @@ -157,10 +157,10 @@ final class TestingClient(workspace: AbsolutePath, buffers: Buffers) ): CompletableFuture[MessageActionItem] = CompletableFuture.completedFuture { messageRequests.addLast(params.getMessage) - if (params == ReimportSbtProject.params) { - ReimportSbtProject.yes - } else if (params == ImportBuildViaBloop.params) { - ImportBuildViaBloop.yes + if (params == ImportBuildChanges.params) { + ImportBuildChanges.yes + } else if (params == ImportBuild.params) { + ImportBuild.yes } else if (params == Only212Navigation.params("2.11.12")) { Only212Navigation.dismissForever } else if (CheckDoctor.isDoctor(params)) { diff --git a/website/i18n/en.json b/website/i18n/en.json index eeae06b6b03..e6b935f8a7a 100644 --- a/website/i18n/en.json +++ b/website/i18n/en.json @@ -88,6 +88,9 @@ "users/installation": { "title": "Installation" }, + "v0.3.0": { + "title": "v0.3.0" + }, "website": { "title": "Contributing to the website" } From 37d63f57757952398783364edc7cb412feb27973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Fri, 7 Dec 2018 14:07:35 +0100 Subject: [PATCH 4/7] Fix tests for 2.12.8 --- tests/unit/src/test/scala/tests/DefinitionSlowSuite.scala | 6 +++--- tests/unit/src/test/scala/tests/FileWatcherSlowSuite.scala | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/unit/src/test/scala/tests/DefinitionSlowSuite.scala b/tests/unit/src/test/scala/tests/DefinitionSlowSuite.scala index 577653c6874..8c90c1d2417 100644 --- a/tests/unit/src/test/scala/tests/DefinitionSlowSuite.scala +++ b/tests/unit/src/test/scala/tests/DefinitionSlowSuite.scala @@ -73,7 +73,7 @@ object DefinitionSlowSuite extends BaseSlowSuite("definition") { |object Main/*L3*/ extends App/*App.scala:38*/ { | val message/*L4*/ = Message/*Message.java:1*/.message/*Message.java:2*/ | new java.io.PrintStream/*PrintStream.java:56*/(new java.io.ByteArrayOutputStream/*ByteArrayOutputStream.java:44*/()) - | println/*Predef.scala:392*/(message/*L4*/) + | println/*Predef.scala:396*/(message/*L4*/) |} |/b/src/main/scala/a/MainSuite.scala |package a @@ -111,7 +111,7 @@ object DefinitionSlowSuite extends BaseSlowSuite("definition") { |object Main/*L5*/ extends App/*App.scala:38*/ { | val helloMessage/**/ = Message/*Message.java:1*/.message/*Message.java:2*/ | new java.io.PrintStream/*PrintStream.java:56*/(new java.io.ByteArrayOutputStream/*ByteArrayOutputStream.java:44*/()) - | println/*Predef.scala:392*/(message/**/) + | println/*Predef.scala:396*/(message/**/) |} |/b/src/main/scala/a/MainSuite.scala |>>>>>>>/**/ @@ -196,7 +196,7 @@ object DefinitionSlowSuite extends BaseSlowSuite("definition") { |import cats._ |import cats.implicits/*implicits.scala:2*/._ |object Main/*L2*/ { - | println/*Predef.scala:392*/(Contravariant/*Contravariant.scala:5*/[Show/*Show.scala:9*/]) + | println/*Predef.scala:396*/(Contravariant/*Contravariant.scala:5*/[Show/*Show.scala:9*/]) |} """.stripMargin ) diff --git a/tests/unit/src/test/scala/tests/FileWatcherSlowSuite.scala b/tests/unit/src/test/scala/tests/FileWatcherSlowSuite.scala index 9490ba277f3..11ff84c8386 100644 --- a/tests/unit/src/test/scala/tests/FileWatcherSlowSuite.scala +++ b/tests/unit/src/test/scala/tests/FileWatcherSlowSuite.scala @@ -63,8 +63,8 @@ object FileWatcherSlowSuite extends BaseSlowSuite("file-watcher") { |/c/src/main/scala/C.scala |package c |object C/*L1*/ { - | println/*Predef.scala:392*/(a.ScalaFileEvent/*A.scala:3*/) - | println/*Predef.scala:392*/(new a.JavaFileEvent/*JavaFileEvent.java:2*/) + | println/*Predef.scala:396*/(a.ScalaFileEvent/*A.scala:3*/) + | println/*Predef.scala:396*/(new a.JavaFileEvent/*JavaFileEvent.java:2*/) |} |""".stripMargin ) From 35c75c9c3874070e06a8f5d7e50a594e8072734d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Fri, 7 Dec 2018 14:07:43 +0100 Subject: [PATCH 5/7] Refine QuickBuild digest algorithm to account for implicit Scala version I did not catch the CI test failures locally because quick-build didn't notice the change. --- tests/unit/src/main/scala/tests/QuickBuild.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/src/main/scala/tests/QuickBuild.scala b/tests/unit/src/main/scala/tests/QuickBuild.scala index c2176232a96..c0c7ef91c24 100644 --- a/tests/unit/src/main/scala/tests/QuickBuild.scala +++ b/tests/unit/src/main/scala/tests/QuickBuild.scala @@ -21,7 +21,6 @@ import scala.meta.internal.metals.Timer import scala.meta.internal.metals.{BuildInfo => V} import scala.meta.internal.mtags.MD5 import scala.meta.io.AbsolutePath -import scala.util.Properties import scala.util.matching.Regex /** @@ -255,6 +254,7 @@ object QuickBuild { val newDigest = { val digest = MessageDigest.getInstance("MD5") digest.update(version.getBytes(StandardCharsets.UTF_8)) + digest.update(V.scala212.getBytes(StandardCharsets.UTF_8)) def update(file: AbsolutePath): Unit = { if (file.isFile) { digest.update(file.readAllBytes) From a04c2cf6e142ddb0ac88e73f3e193e7da0544919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Fri, 7 Dec 2018 15:20:09 +0100 Subject: [PATCH 6/7] Refine "No navigation for 2.11" notifications I hit a failing test where the notification was sent twice in a row, the new logic is simpler and should avoid that in the future. --- .../meta/internal/metals/InteractiveSemanticdbs.scala | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/metals/src/main/scala/scala/meta/internal/metals/InteractiveSemanticdbs.scala b/metals/src/main/scala/scala/meta/internal/metals/InteractiveSemanticdbs.scala index e9293c7d03a..491c5ccfd4d 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/InteractiveSemanticdbs.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/InteractiveSemanticdbs.scala @@ -8,7 +8,6 @@ import java.nio.file.Files import java.nio.file.Paths import java.util.Collections import java.util.concurrent.TimeUnit -import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicReference import org.eclipse.lsp4j.DiagnosticSeverity import org.eclipse.lsp4j.PublishDiagnosticsParams @@ -165,22 +164,18 @@ final class InteractiveSemanticdbs( } yield newGlobal(scalacOptions) } - val pendingNotification = new AtomicBoolean(false) private def reportUnsupportedScalaVersion(scalaVersion: String): Unit = { statusBar.addMessage(Only212Navigation.statusBar(scalaVersion)) val notification = tables.dismissedNotifications.Only212Navigation - if (!notification.isDismissed && - pendingNotification.compareAndSet(false, true)) { + if (!notification.isDismissed) { + notification.dismiss(2, TimeUnit.MINUTES) client .showMessageRequest(Only212Navigation.params(scalaVersion)) .asScala .foreach { item => if (item == Only212Navigation.dismissForever) { notification.dismissForever() - } else if (item == Only212Navigation.ok) { - notification.dismiss(1, TimeUnit.DAYS) } - pendingNotification.set(false) } } } From d136bffe59bc5ac9b743a9a0800c308e22e7aaba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Fri, 7 Dec 2018 15:20:57 +0100 Subject: [PATCH 7/7] Remove line numbers for dependency sources This avoids repeating the situation where upgrading to 2.12.8 broke the navigation tests. We still keep line numbers in workspace sources because we test that changes in the buffers are respected. --- .../src/main/scala/tests/TestingServer.scala | 6 +- .../scala/tests/DefinitionSlowSuite.scala | 81 +++++++++---------- .../scala/tests/FileWatcherSlowSuite.scala | 4 +- .../test/scala/tests/QuickBuildSuite.scala | 37 +++++---- 4 files changed, 63 insertions(+), 65 deletions(-) diff --git a/tests/unit/src/main/scala/tests/TestingServer.scala b/tests/unit/src/main/scala/tests/TestingServer.scala index 6ef45b26d7e..53125f90d79 100644 --- a/tests/unit/src/main/scala/tests/TestingServer.scala +++ b/tests/unit/src/main/scala/tests/TestingServer.scala @@ -190,8 +190,10 @@ final class TestingServer( if (isSameFile) { s"L${location.getRange.getStart.getLine}" } else { - val filename = location.getUri.toAbsolutePath.toNIO.getFileName - s"$filename:${location.getRange.getStart.getLine}" + val path = location.getUri.toAbsolutePath + val filename = path.toNIO.getFileName + if (path.isDependencySource(workspace)) filename.toString + else s"$filename:${location.getRange.getStart.getLine}" } } val occurrence = token match { diff --git a/tests/unit/src/test/scala/tests/DefinitionSlowSuite.scala b/tests/unit/src/test/scala/tests/DefinitionSlowSuite.scala index 8c90c1d2417..0e290441933 100644 --- a/tests/unit/src/test/scala/tests/DefinitionSlowSuite.scala +++ b/tests/unit/src/test/scala/tests/DefinitionSlowSuite.scala @@ -65,25 +65,24 @@ object DefinitionSlowSuite extends BaseSlowSuite("definition") { _ = assertNoDiff(client.workspaceDiagnostics, "") _ = assertNoDiff( server.workspaceDefinitions, - """| - |/a/src/main/scala/a/Main.scala + """|/a/src/main/scala/a/Main.scala |package a - |import java.util.concurrent.Future/*Future.java:95*/ // unused - |import scala.util.Failure/*Try.scala:213*/ // unused - |object Main/*L3*/ extends App/*App.scala:38*/ { + |import java.util.concurrent.Future/*Future.java*/ // unused + |import scala.util.Failure/*Try.scala*/ // unused + |object Main/*L3*/ extends App/*App.scala*/ { | val message/*L4*/ = Message/*Message.java:1*/.message/*Message.java:2*/ - | new java.io.PrintStream/*PrintStream.java:56*/(new java.io.ByteArrayOutputStream/*ByteArrayOutputStream.java:44*/()) - | println/*Predef.scala:396*/(message/*L4*/) + | new java.io.PrintStream/*PrintStream.java*/(new java.io.ByteArrayOutputStream/*ByteArrayOutputStream.java*/()) + | println/*Predef.scala*/(message/*L4*/) |} |/b/src/main/scala/a/MainSuite.scala |package a - |import java.util.concurrent.Future/*Future.java:95*/ // unused - |import scala.util.Failure/*Try.scala:213*/ // unused - |import org.scalatest.FunSuite/*FunSuite.scala:1559*/ - |object MainSuite/*L4*/ extends FunSuite/*FunSuite.scala:1559*/ { - | test/*FunSuiteLike.scala:119*/("a") { - | val condition/*L6*/ = Main/*Main.scala:3*/.message/*Main.scala:4*/.contains/*String.java:2131*/("Hello") - | assert/*Assertions.scala:414*/(condition/*L6*/) + |import java.util.concurrent.Future/*Future.java*/ // unused + |import scala.util.Failure/*Try.scala*/ // unused + |import org.scalatest.FunSuite/*FunSuite.scala*/ + |object MainSuite/*L4*/ extends FunSuite/*FunSuite.scala*/ { + | test/*FunSuiteLike.scala*/("a") { + | val condition/*L6*/ = Main/*Main.scala:3*/.message/*Main.scala:4*/.contains/*String.java*/("Hello") + | assert/*Assertions.scala*/(condition/*L6*/) | } |} |""".stripMargin @@ -101,29 +100,28 @@ object DefinitionSlowSuite extends BaseSlowSuite("definition") { // - old references to `message` don't resolve because it has been renamed to `helloMessage` // - new references to like `testName` don't resolve server.workspaceDefinitions, - """| - |/a/src/main/scala/a/Main.scala + """|/a/src/main/scala/a/Main.scala |>>>>>>>/**/ | |package a - |import java.util.concurrent.Future/*Future.java:95*/ // unused - |import scala.util.Failure/*Try.scala:213*/ // unused - |object Main/*L5*/ extends App/*App.scala:38*/ { + |import java.util.concurrent.Future/*Future.java*/ // unused + |import scala.util.Failure/*Try.scala*/ // unused + |object Main/*L5*/ extends App/*App.scala*/ { | val helloMessage/**/ = Message/*Message.java:1*/.message/*Message.java:2*/ - | new java.io.PrintStream/*PrintStream.java:56*/(new java.io.ByteArrayOutputStream/*ByteArrayOutputStream.java:44*/()) - | println/*Predef.scala:396*/(message/**/) + | new java.io.PrintStream/*PrintStream.java*/(new java.io.ByteArrayOutputStream/*ByteArrayOutputStream.java*/()) + | println/*Predef.scala*/(message/**/) |} |/b/src/main/scala/a/MainSuite.scala |>>>>>>>/**/ | |package a - |import java.util.concurrent.Future/*Future.java:95*/ // unused - |import scala.util.Failure/*Try.scala:213*/ // unused - |import org.scalatest.FunSuite/*FunSuite.scala:1559*/ - |object MainSuite/*L6*/ extends FunSuite/*FunSuite.scala:1559*/ { - | test/*FunSuiteLike.scala:119*/(testName/**/) { - | val condition/*L8*/ = Main/*Main.scala:5*/.message/**/.contains/*String.java:2131*/("Hello") - | assert/*Assertions.scala:414*/(condition/*L8*/) + |import java.util.concurrent.Future/*Future.java*/ // unused + |import scala.util.Failure/*Try.scala*/ // unused + |import org.scalatest.FunSuite/*FunSuite.scala*/ + |object MainSuite/*L6*/ extends FunSuite/*FunSuite.scala*/ { + | test/*FunSuiteLike.scala*/(testName/**/) { + | val condition/*L8*/ = Main/*Main.scala:5*/.message/**/.contains/*String.java*/("Hello") + | assert/*Assertions.scala*/(condition/*L8*/) | } |} |""".stripMargin @@ -167,12 +165,12 @@ object DefinitionSlowSuite extends BaseSlowSuite("definition") { |/** | * Must obey the laws defined in cats.laws.ContravariantLaws. | */ - |@typeclass/**/ trait Contravariant/*L5*/[F/*L5*/[_]] extends Invariant/*Invariant.scala:7*/[F/*L5*/] { self/*L5*/ => + |@typeclass/**/ trait Contravariant/*L5*/[F/*L5*/[_]] extends Invariant/*Invariant.scala*/[F/*L5*/] { self/*L5*/ => | def contramap/*L6*/[A/*L6*/, B/*L6*/](fa/*L6*/: F/*L5*/[A/*L6*/])(f/*L6*/: B/*L6*/ => A/*L6*/): F/*L5*/[B/*L6*/] | override def imap/*L7*/[A/*L7*/, B/*L7*/](fa/*L7*/: F/*L5*/[A/*L7*/])(f/*L7*/: A/*L7*/ => B/*L7*/)(fi/*L7*/: B/*L7*/ => A/*L7*/): F/*L5*/[B/*L7*/] = contramap/*L6*/(fa/*L7*/)(fi/*L7*/) | - | def compose/*L9*/[G/*L9*/[_]: Contravariant/*L5*/]: Functor/*Functor.scala:11*/[λ/**/[α/**/ => F/**/[G/**/[α/**/]]]] = - | new ComposedContravariant/*Composed.scala:107*/[F/*L5*/, G/*L9*/] { + | def compose/*L9*/[G/*L9*/[_]: Contravariant/*L5*/]: Functor/*Functor.scala*/[λ/**/[α/**/ => F/**/[G/**/[α/**/]]]] = + | new ComposedContravariant/*Composed.scala*/[F/*L5*/, G/*L9*/] { | val F/*L11*/ = self/*L5*/ | val G/*L12*/ = Contravariant/**/[G/*L9*/] | } @@ -185,18 +183,18 @@ object DefinitionSlowSuite extends BaseSlowSuite("definition") { | | def liftContravariant/*L21*/[A/*L21*/, B/*L21*/](f/*L21*/: A/*L21*/ => B/*L21*/): F/*L5*/[B/*L21*/] => F/*L5*/[A/*L21*/] = contramap/*L6*/(_: F/*L5*/[B/*L21*/])(f/*L21*/) | - | override def composeFunctor/*L23*/[G/*L23*/[_]: Functor/*Functor.scala:11*/]: Contravariant/*L5*/[λ/**/[α/**/ => F/**/[G/**/[α/**/]]]] = - | new ComposedContravariantCovariant/*Composed.scala:115*/[F/*L5*/, G/*L23*/] { + | override def composeFunctor/*L23*/[G/*L23*/[_]: Functor/*Functor.scala*/]: Contravariant/*L5*/[λ/**/[α/**/ => F/**/[G/**/[α/**/]]]] = + | new ComposedContravariantCovariant/*Composed.scala*/[F/*L5*/, G/*L23*/] { | val F/*L25*/ = self/*L5*/ - | val G/*L26*/ = Functor/*Functor.scala:11*/[G/*L23*/] + | val G/*L26*/ = Functor/*Functor.scala*/[G/*L23*/] | } |} | |/a/src/main/scala/a/Main.scala |import cats._ - |import cats.implicits/*implicits.scala:2*/._ + |import cats.implicits/*implicits.scala*/._ |object Main/*L2*/ { - | println/*Predef.scala:396*/(Contravariant/*Contravariant.scala:5*/[Show/*Show.scala:9*/]) + | println/*Predef.scala*/(Contravariant/*Contravariant.scala*/[Show/*Show.scala*/]) |} """.stripMargin ) @@ -278,11 +276,10 @@ object DefinitionSlowSuite extends BaseSlowSuite("definition") { _ <- server.didOpen("a/src/main/scala/a/Main.scala") _ = assertNoDiff( server.workspaceDefinitions, - """ - |/a/src/main/scala/a/Main.scala - |object Main/*L0*/ { - | val x/*L1*/: Int/*Int.scala:21*/ = math.max/*package.scala:191*/(1, 2) - |} + """|/a/src/main/scala/a/Main.scala + |object Main/*L0*/ { + | val x/*L1*/: Int/*Int.scala*/ = math.max/*package.scala*/(1, 2) + |} """.stripMargin ) _ <- server.didSave("a/src/main/scala/a/Main.scala")( @@ -292,7 +289,7 @@ object DefinitionSlowSuite extends BaseSlowSuite("definition") { server.workspaceDefinitions, """|/a/src/main/scala/a/Main.scala |object Main/*L0*/ { - | val x/*L1*/: Int/*Int.scala:21*/ = math.max/*package.scala:191*/ + | val x/*L1*/: Int/*Int.scala*/ = math.max/*package.scala*/ |} |""".stripMargin ) diff --git a/tests/unit/src/test/scala/tests/FileWatcherSlowSuite.scala b/tests/unit/src/test/scala/tests/FileWatcherSlowSuite.scala index 11ff84c8386..adae97bd15d 100644 --- a/tests/unit/src/test/scala/tests/FileWatcherSlowSuite.scala +++ b/tests/unit/src/test/scala/tests/FileWatcherSlowSuite.scala @@ -63,8 +63,8 @@ object FileWatcherSlowSuite extends BaseSlowSuite("file-watcher") { |/c/src/main/scala/C.scala |package c |object C/*L1*/ { - | println/*Predef.scala:396*/(a.ScalaFileEvent/*A.scala:3*/) - | println/*Predef.scala:396*/(new a.JavaFileEvent/*JavaFileEvent.java:2*/) + | println/*Predef.scala*/(a.ScalaFileEvent/*A.scala:3*/) + | println/*Predef.scala*/(new a.JavaFileEvent/*JavaFileEvent.java:2*/) |} |""".stripMargin ) diff --git a/tests/unit/src/test/scala/tests/QuickBuildSuite.scala b/tests/unit/src/test/scala/tests/QuickBuildSuite.scala index 5f81649eaf4..93ff51a8aa3 100644 --- a/tests/unit/src/test/scala/tests/QuickBuildSuite.scala +++ b/tests/unit/src/test/scala/tests/QuickBuildSuite.scala @@ -52,25 +52,24 @@ object QuickBuildSuite extends BaseSlowSuite("quick-build") { _ <- server.didOpen("a/src/main/scala/a/A.scala") _ = assertNoDiff( server.workspaceDefinitions, - """ - |/a/src/main/scala/a/A.scala - |package a - |import com.geirsson.coursiersmall._ - |import scala.util.Success/*Try.scala:239*/ - |object A/*L3*/ { - | val settings/*L4*/ = new Settings/*Settings.scala:16*/() - |} - |/b/src/main/scala/b/B.scala - |package b - |import a._ - |import scala.util.Success/*Try.scala:239*/ - |import org.scalatest._ - |class B/*L4*/ extends FunSuite/*FunSuite.scala:1559*/ { - | test/*FunSuiteLike.scala:119*/("") { - | println/*Predef.scala:392*/(A/*A.scala:3*/.settings/*A.scala:4*/) - | } - |} - """.stripMargin + """|/a/src/main/scala/a/A.scala + |package a + |import com.geirsson.coursiersmall._ + |import scala.util.Success/*Try.scala*/ + |object A/*L3*/ { + | val settings/*L4*/ = new Settings/*Settings.scala*/() + |} + |/b/src/main/scala/b/B.scala + |package b + |import a._ + |import scala.util.Success/*Try.scala*/ + |import org.scalatest._ + |class B/*L4*/ extends FunSuite/*FunSuite.scala*/ { + | test/*FunSuiteLike.scala*/("") { + | println/*Predef.scala*/(A/*A.scala:3*/.settings/*A.scala:4*/) + | } + |} + |""".stripMargin ) } yield () }