From 46598af99fd6a5ff2da0944d1da5ebe852a6787d Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Fri, 27 Sep 2024 17:13:28 +0200 Subject: [PATCH] chore: Update code after fixes --- bin/test-release.sh | 1 - build.sbt | 7 +++-- .../meta/internal/metals/MtagsResolver.scala | 2 ++ .../codeactions/ExtractRenameMember.scala | 14 +++++----- .../frameworks/MunitTestFinder.scala | 4 +-- .../parsing/DocumentSymbolProvider.scala | 3 ++- .../meta/internal/mtags/AtomicTrieMap.scala | 1 + .../meta/internal/mtags/ScalaMtags.scala | 5 +++- project/V.scala | 6 ++--- .../tests/pc/CompletionScalaCliSuite.scala | 2 +- .../tests/feature/SyntaxErrorLspSuite.scala | 26 +++++++++---------- .../test/scala/tests/sbt/SbtServerSuite.scala | 2 +- .../definition/example/Scalalib.scala | 2 +- .../example/nested/DoublePackage.scala | 2 +- .../example/nested/DoublePackage.scala | 2 +- .../ExtractRenameMemberLspSuite.scala | 4 +-- 16 files changed, 42 insertions(+), 41 deletions(-) diff --git a/bin/test-release.sh b/bin/test-release.sh index e7cd2a5ef35..d5fcf33109d 100755 --- a/bin/test-release.sh +++ b/bin/test-release.sh @@ -15,7 +15,6 @@ coursier fetch \ org.scalameta:mtags_2.13.13:$version \ org.scalameta:mtags_2.13.14:$version \ org.scalameta:mtags_2.13.15:$version \ - org.scalameta:mtags_2.12.16:$version \ org.scalameta:mtags_2.12.17:$version \ org.scalameta:mtags_2.12.18:$version \ org.scalameta:mtags_2.12.19:$version \ diff --git a/build.sbt b/build.sbt index 15859035a0a..c1255907303 100644 --- a/build.sbt +++ b/build.sbt @@ -289,7 +289,8 @@ def withExcludes(moduleId: ModuleID) = ) // avoid 2.13 and 3 on the classpath since it comes in via pprint def scala3SemanticdbDependency: ModuleID = withExcludes( - ("org.scalameta" % s"semanticdb-shared_${V.scala213}" % V.scalameta) + ("org.scalameta" %% s"semanticdb-shared" % V.scalameta) + .cross(CrossVersion.for3Use2_13) ) def scala3ScalametaDependency: ModuleID = withExcludes( @@ -454,9 +455,7 @@ lazy val metals = project "org.scalameta" %% "semanticdb-metap" % V.semanticdb( scalaVersion.value ) cross CrossVersion.full, - "org.scalameta" % "semanticdb-shared" % V.semanticdb( - scalaVersion.value - ) cross CrossVersion.full, + "org.scalameta" %% "semanticdb-shared" % V.semanticdb(scalaVersion.value), // For starting Ammonite "io.github.alexarchambault.ammonite" %% "ammonite-runner" % "0.4.0", "org.scala-lang.modules" %% "scala-xml" % "2.3.0", diff --git a/metals/src/main/scala/scala/meta/internal/metals/MtagsResolver.scala b/metals/src/main/scala/scala/meta/internal/metals/MtagsResolver.scala index de9862d83bc..d3de41a2d88 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MtagsResolver.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MtagsResolver.scala @@ -88,10 +88,12 @@ object MtagsResolver { "2.12.13" -> "1.3.3", "2.12.14" -> "1.3.3", "2.12.15" -> "1.3.3", + "2.12.16" -> "1.3.5", "2.13.7" -> "1.3.3", "2.13.8" -> "1.3.3", "2.13.9" -> "1.3.3", "2.13.10" -> "1.3.3", + "2.13.11" -> "1.3.5", ) class Default extends MtagsResolver { diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/ExtractRenameMember.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/ExtractRenameMember.scala index 318d3518672..24e4c943280 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/ExtractRenameMember.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/ExtractRenameMember.scala @@ -158,8 +158,8 @@ class ExtractRenameMember( nodes += EndableMember(last.member, Some(endMarker)) case _ => } - case s: Source => - super.apply(s) + case _: Source | _: Pkg.Body => + super.apply(tree) case _ => } } @@ -175,7 +175,7 @@ class ExtractRenameMember( val traverser = new SimpleTraverser { override def apply(tree: Tree): Unit = tree match { - case p: Pkg => super.apply(p) + case p: Pkg => super.apply(p.body) case s: Source => super.apply(s) case e: Defn.ExtensionGroup => nodes += EndableDefn[Defn.ExtensionGroup](e, None) @@ -237,7 +237,7 @@ class ExtractRenameMember( t match { case o: Defn.Object => o.name.value :: completePreName(o) case po: Pkg.Object => po.name.value :: completePreName(po) - case tmpl: Template => completePreName(tmpl) + case _: Template | _: Template.Body => completePreName(t) case _ => Nil } case None => Nil @@ -286,7 +286,7 @@ class ExtractRenameMember( override def apply(tree: Tree): Unit = tree match { case p: Pkg if p.pos.toLsp.overlapsWith(range) => packages += Pkg(ref = p.ref, stats = Nil) - super.apply(p) + super.apply(p.body) case i: Import => imports += i case s: Source => @@ -561,13 +561,13 @@ class ExtractRenameMember( val packageEdit = endableMember.member.parent .flatMap { - case p: Pkg + case p: Pkg.Body if p.stats.forall(t => t.isInstanceOf[Import] || t .equals(endableMember.member) || maybeEndableMemberCompanion .exists(_.member.equals(t)) ) => - Some(p) + p.parent case _ => None } .map(tree => List(removeEdit(tree.pos))) diff --git a/metals/src/main/scala/scala/meta/internal/metals/testProvider/frameworks/MunitTestFinder.scala b/metals/src/main/scala/scala/meta/internal/metals/testProvider/frameworks/MunitTestFinder.scala index f835e5a055a..aab7e77373a 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/testProvider/frameworks/MunitTestFinder.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/testProvider/frameworks/MunitTestFinder.scala @@ -78,7 +78,7 @@ class MunitTestFinder( // let's collect all tests candidates val testcases = new mutable.ArrayBuffer[TestCaseEntry]() - template.children.foreach { + template.body.children.foreach { // test("testname".only|ignore|tag) {} case appl: Term.Apply if hasTestCall(appl, occurences) => getTestCallWithTestName(appl).foreach { case (test, testname) => @@ -231,7 +231,7 @@ class MunitTestFinder( private def extractPotentialTestMethods( clsTemplate: Template, occurences: Vector[SymbolOccurrence], - ): Set[String] = clsTemplate.children.collect { + ): Set[String] = clsTemplate.body.children.collect { case dfn: Defn.Def if hasTestCall(dfn, occurences) => dfn.name.value }.toSet diff --git a/metals/src/main/scala/scala/meta/internal/parsing/DocumentSymbolProvider.scala b/metals/src/main/scala/scala/meta/internal/parsing/DocumentSymbolProvider.scala index 836cbafe4b2..fc2d84be315 100644 --- a/metals/src/main/scala/scala/meta/internal/parsing/DocumentSymbolProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/parsing/DocumentSymbolProvider.scala @@ -123,7 +123,8 @@ final class DocumentSymbolProvider( addChild(s"new $name", SymbolKind.Interface, t.pos, selection, "") newOwner() } else continue() - case _: Source | _: Template | _: MultiSource => + case _: Source | _: Template | _: MultiSource | _: Pkg.Body | + _: Template.Body | _: Tree.CasesBlock => continue() case block: Term.Block => if (owner.getName() == "try") { diff --git a/mtags/src/main/scala/scala/meta/internal/mtags/AtomicTrieMap.scala b/mtags/src/main/scala/scala/meta/internal/mtags/AtomicTrieMap.scala index 526e08c3603..74d886dcc22 100644 --- a/mtags/src/main/scala/scala/meta/internal/mtags/AtomicTrieMap.scala +++ b/mtags/src/main/scala/scala/meta/internal/mtags/AtomicTrieMap.scala @@ -11,6 +11,7 @@ final class AtomicTrieMap[K, V] { private val trieMap = new TrieMap[K, V]() private val concurrentMap = new ConcurrentHashMap[K, V] + override def toString(): String = trieMap.toString() def get(key: K): Option[V] = trieMap.get(key) def contains(key: K): Boolean = trieMap.contains(key) diff --git a/mtags/src/main/scala/scala/meta/internal/mtags/ScalaMtags.scala b/mtags/src/main/scala/scala/meta/internal/mtags/ScalaMtags.scala index da60cf8db74..51cec60112a 100644 --- a/mtags/src/main/scala/scala/meta/internal/mtags/ScalaMtags.scala +++ b/mtags/src/main/scala/scala/meta/internal/mtags/ScalaMtags.scala @@ -402,7 +402,10 @@ class ScalaMtags( namePos.foreach { case (name, pos) => enterGiven(name, pos, t.tparams, t.sparams) } - case _ => stop() + case _: Pkg.Body | _: Template.Body => + continue() + case _ => + stop() } } diff --git a/project/V.scala b/project/V.scala index 94c89447ecd..e9a89f532f9 100644 --- a/project/V.scala +++ b/project/V.scala @@ -148,8 +148,6 @@ object V { "2.12.19", "2.12.18", "2.12.17", - "2.12.16", - "2.13.11", "2.13.12", "2.13.13", "2.13.14", @@ -157,12 +155,12 @@ object V { def minimumSupportedSbtVersion = { // Update when deprecating a Scala version together with sbt version - val sbtScalaVersion = "2.12.16" + val sbtScalaVersion = "2.12.17" if (!nonDeprecatedScala2Versions.contains(sbtScalaVersion)) throw new RuntimeException( "Please change minimalSupportedSbtVersion when removing support for a particular Scala version" ) - "1.7.0" + "1.8.0" } def scala2Versions = nonDeprecatedScala2Versions ++ deprecatedScala2Versions diff --git a/tests/cross/src/test/scala/tests/pc/CompletionScalaCliSuite.scala b/tests/cross/src/test/scala/tests/pc/CompletionScalaCliSuite.scala index 09527c8f57b..232d69cbb90 100644 --- a/tests/cross/src/test/scala/tests/pc/CompletionScalaCliSuite.scala +++ b/tests/cross/src/test/scala/tests/pc/CompletionScalaCliSuite.scala @@ -115,7 +115,7 @@ class CompletionScalaCliSuite extends BaseCompletionSuite { check( "plugin".tag( IgnoreScalaVersion(version => - Set("2.12.16", "2.13.15")(version) || + Set("2.13.15")(version) || version.contains( "NIGHTLY" ) || version.contains( diff --git a/tests/slow/src/test/scala/tests/feature/SyntaxErrorLspSuite.scala b/tests/slow/src/test/scala/tests/feature/SyntaxErrorLspSuite.scala index f8b2bfea5aa..6b7be18a7f1 100644 --- a/tests/slow/src/test/scala/tests/feature/SyntaxErrorLspSuite.scala +++ b/tests/slow/src/test/scala/tests/feature/SyntaxErrorLspSuite.scala @@ -54,7 +54,7 @@ class SyntaxErrorLspSuite extends BaseLspSuite("syntax-error") { |/metals.json |{"a": {}} |/project/plugins.sbt - |lazy lazy val x = 1 + |object object val x = 1 |/Main.scala |object object A |""".stripMargin @@ -63,14 +63,13 @@ class SyntaxErrorLspSuite extends BaseLspSuite("syntax-error") { _ <- server.didOpen("project/plugins.sbt") _ = assertNoDiff( client.workspaceDiagnostics, - """ - |Main.scala:1:8: error: `identifier` expected but `object` found - |object object A - | ^^^^^^ - |project/plugins.sbt:1:6: error: repeated modifier - |lazy lazy val x = 1 - | ^^^^ - |""".stripMargin, + """|Main.scala:1:8: error: `identifier` expected but `object` found + |object object A + | ^^^^^^ + |project/plugins.sbt:1:8: error: `identifier` expected but `object` found + |object object val x = 1 + | ^^^^^^ + |""".stripMargin, ) _ <- server.didClose("Main.scala") _ <- server.didClose("project/plugins.sbt") @@ -80,11 +79,10 @@ class SyntaxErrorLspSuite extends BaseLspSuite("syntax-error") { _ <- server.didSave("Main.scala")(_ => "object A\n") _ = assertNoDiff( client.workspaceDiagnostics, - """ - |project/plugins.sbt:1:6: error: repeated modifier - |lazy lazy val x = 1 - | ^^^^ - |""".stripMargin, + """|project/plugins.sbt:1:8: error: `identifier` expected but `object` found + |object object val x = 1 + | ^^^^^^ + |""".stripMargin, ) _ <- server.didSave("project/plugins.sbt")(_ => "lazy val x = 1\n") _ = assertNoDiff(client.workspaceDiagnostics, "") diff --git a/tests/slow/src/test/scala/tests/sbt/SbtServerSuite.scala b/tests/slow/src/test/scala/tests/sbt/SbtServerSuite.scala index 86f40b1fa21..654b85a7494 100644 --- a/tests/slow/src/test/scala/tests/sbt/SbtServerSuite.scala +++ b/tests/slow/src/test/scala/tests/sbt/SbtServerSuite.scala @@ -37,7 +37,7 @@ class SbtServerSuite with JavaHomeChangeTest { val preBspVersion = "1.3.13" - val supportedMetaBuildVersion = "1.7.0" + val supportedMetaBuildVersion = "1.8.0" val supportedBspVersion = V.sbtVersion val scalaVersion = V.scala213 val buildTool: SbtBuildTool = SbtBuildTool(None, workspace, () => userConfig) diff --git a/tests/unit/src/test/resources/definition/example/Scalalib.scala b/tests/unit/src/test/resources/definition/example/Scalalib.scala index a4f5e6b3b7f..f1aabcee50b 100644 --- a/tests/unit/src/test/resources/definition/example/Scalalib.scala +++ b/tests/unit/src/test/resources/definition/example/Scalalib.scala @@ -6,7 +6,7 @@ class Scalalib/*Scalalib.scala*/ { ( Nothing/*Nothing.scala*/, Null/*Null.scala*/, - Singleton, + Singleton/*Singleton.scala*/, Any/*Any.scala*/, AnyRef/*AnyRef.scala*/, AnyVal/*AnyVal.scala*/, diff --git a/tests/unit/src/test/resources/documentSymbol-scala3/example/nested/DoublePackage.scala b/tests/unit/src/test/resources/documentSymbol-scala3/example/nested/DoublePackage.scala index 973f5f96e39..dce44582060 100644 --- a/tests/unit/src/test/resources/documentSymbol-scala3/example/nested/DoublePackage.scala +++ b/tests/unit/src/test/resources/documentSymbol-scala3/example/nested/DoublePackage.scala @@ -1,6 +1,6 @@ /*example(Package):9*/package example -/*example.nested.x(Package):4*/package nested.x { +/*example.nested.x(Package):5*/package nested.x { /*example.nested.x.DoublePackage(Class):4*/class DoublePackage {} } diff --git a/tests/unit/src/test/resources/documentSymbol/example/nested/DoublePackage.scala b/tests/unit/src/test/resources/documentSymbol/example/nested/DoublePackage.scala index 973f5f96e39..dce44582060 100644 --- a/tests/unit/src/test/resources/documentSymbol/example/nested/DoublePackage.scala +++ b/tests/unit/src/test/resources/documentSymbol/example/nested/DoublePackage.scala @@ -1,6 +1,6 @@ /*example(Package):9*/package example -/*example.nested.x(Package):4*/package nested.x { +/*example.nested.x(Package):5*/package nested.x { /*example.nested.x.DoublePackage(Class):4*/class DoublePackage {} } diff --git a/tests/unit/src/test/scala/tests/codeactions/ExtractRenameMemberLspSuite.scala b/tests/unit/src/test/scala/tests/codeactions/ExtractRenameMemberLspSuite.scala index b494a70e62d..37f74ba55ef 100644 --- a/tests/unit/src/test/scala/tests/codeactions/ExtractRenameMemberLspSuite.scala +++ b/tests/unit/src/test/scala/tests/codeactions/ExtractRenameMemberLspSuite.scala @@ -467,7 +467,7 @@ class ExtractRenameMemberLspSuite codeActionExpected: Boolean = true, scalaVersion: String = V.scala213, fileName: String = "A.scala", - ): Unit = + )(implicit loc: munit.Location): Unit = test(name) { val (buffers, trees) = TreeUtils.getTrees(scalaVersion) val filename = fileName @@ -499,7 +499,7 @@ class ExtractRenameMemberLspSuite codeActions <- codeActionFut _ = { if (codeActionExpected) assert(codeActions.nonEmpty) - else assert(codeActions.isEmpty) + else assertEmpty(codeActions.map(_.getTitle()).mkString("\n")) } } yield () }