Skip to content

Commit

Permalink
chore: Update code after fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Oct 9, 2024
1 parent 3867e94 commit 46598af
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 41 deletions.
1 change: 0 additions & 1 deletion bin/test-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
7 changes: 3 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 _ =>
}
}
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 =>
Expand Down Expand Up @@ -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)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down
6 changes: 2 additions & 4 deletions project/V.scala
Original file line number Diff line number Diff line change
Expand Up @@ -148,21 +148,19 @@ 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",
)

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
26 changes: 12 additions & 14 deletions tests/slow/src/test/scala/tests/feature/SyntaxErrorLspSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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, "")
Expand Down
2 changes: 1 addition & 1 deletion tests/slow/src/test/scala/tests/sbt/SbtServerSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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*/,
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ()
}
Expand Down

0 comments on commit 46598af

Please sign in to comment.