Skip to content

Commit

Permalink
improvement: Fixes for scalafix error and some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Oct 10, 2024
1 parent 1c91ed0 commit 2fcf0bc
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 40 deletions.
5 changes: 3 additions & 2 deletions project/TestGroups.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ object TestGroups {
"tests.inlayHints.InlayHintsHoverSuite", "tests.Java8Suite",
"tests.RequestRegistrySuite", "tests.inlayHints.InlayHintsExpectSuite",
"tests.worksheets.WorksheetInfiniteLoopSuite", "tests.TimeoutSuite",
"tests.SingleFileSuite", "tests.SupportedScalaSuite"),
"tests.SingleFileSuite", "tests.SupportedScalaSuite",
"tests.bestEffort.BestEffortCompilationSuite"),
Set("tests.AmmoniteSuite", "tests.debug.BreakpointDapSuite",
"tests.OnTypeFormattingSuite", "tests.ReferenceLspSuite",
"tests.SuperMethodLspSuite", "tests.SyntaxErrorLspSuite",
Expand Down Expand Up @@ -121,7 +122,7 @@ object TestGroups {
"tests.decorations.SyntheticDecorationsExpectSuite",
"tests.codeactions.ConvertSingleLineCommentLspSuite",
"tests.ServerLivenessMonitorSuite", "tests.ResetWorkspaceLspSuite",
"tests.ToplevelWithInnerScala3Suite"),
"tests.ToplevelWithInnerScala3Suite", "tests.OutlineLspSuite"),
)

}
2 changes: 1 addition & 1 deletion project/V.scala
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,6 @@ object V {
ammonite212Version,
scala213,
ammonite213Version,
ammonite3Version,
lastPublishedScala3,
).toList
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class ImportMissingSymbolCrossLspSuite
| val f = Future.successful(2)
|}
|""".stripMargin,
scalaVersion = "3.3.3",
scalaVersion = V.scala3,
scalacOptions = List("-explain"),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@ class Worksheet3LspSuite extends tests.BaseWorksheetLspSuite(V.scala3) {
)
}

class LatestWorksheet3LspSuite
extends tests.BaseWorksheetLspSuite(
V.supportedScala3Versions
.sortWith(SemVer.isCompatibleVersion)
.reverse
.head
) {
override def versionSpecificCodeToValidate: String =
"""given str: String = """""
}

class Worksheet3NextSuite
extends tests.BaseWorksheetLspSuite(Worksheet3NextSuite.scala3Next) {
override def versionSpecificCodeToValidate: String =
Expand Down
41 changes: 22 additions & 19 deletions tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import scala.meta.internal.metals.MetalsEnrichments._
import scala.meta.internal.metals.ServerCommands
import scala.meta.internal.metals.debug.TestDebugger
import scala.meta.internal.metals.scalacli.ScalaCli
import scala.meta.internal.metals.{BuildInfo => V}
import scala.meta.internal.mtags.CoursierComplete

import org.eclipse.{lsp4j => l}
import tests.FileLayout

class ScalaCliSuite extends BaseScalaCliSuite(V.scala3) {
// https://github.com/scalameta/metals/issues/6839
class ScalaCliSuite extends BaseScalaCliSuite("3.3.3") {

override protected def initializationOptions: Option[InitializationOptions] =
Some(
Expand Down Expand Up @@ -68,14 +68,14 @@ class ScalaCliSuite extends BaseScalaCliSuite(V.scala3) {

completion <- server.completion(
"MyTests.scala",
"//> using lib \"com.lihao@@yi::utest",
"//> using dep \"com.lihao@@yi::utest",
)

_ = assertNoDiff(completion, "com.lihaoyi")

completion <- server.completion(
"MyTests.scala",
"//> using lib com.lihaoyi::pprin@@t",
"//> using dep com.lihaoyi::pprin@@t",
)

_ = assertNoDiff(
Expand All @@ -95,8 +95,8 @@ class ScalaCliSuite extends BaseScalaCliSuite(V.scala3) {
s"""/MyTests.sc
|#!/usr/bin/env -S scala-cli shebang --java-opt -Xms256m --java-opt -XX:MaxRAMPercentage=80
|//> using scala "$scalaVersion"
|//> using lib "com.lihaoyi::utest::0.7.10"
|//> using lib com.lihaoyi::pprint::0.6.6
|//> using dep "com.lihaoyi::utest::0.7.10"
|//> using dep com.lihaoyi::pprint::0.6.6
|
|import foo.Foo
|import utest._
Expand Down Expand Up @@ -164,14 +164,14 @@ class ScalaCliSuite extends BaseScalaCliSuite(V.scala3) {

completion <- server.completion(
"MyTests.sc",
"//> using lib \"com.lihao@@yi::utest",
"//> using dep \"com.lihao@@yi::utest",
)

_ = assertNoDiff(completion, "com.lihaoyi")

completion <- server.completion(
"MyTests.sc",
"//> using lib com.lihaoyi::pprin@@t",
"//> using dep com.lihaoyi::pprin@@t",
)

_ = assertNoDiff(
Expand Down Expand Up @@ -199,8 +199,8 @@ class ScalaCliSuite extends BaseScalaCliSuite(V.scala3) {
"MyTests.sc",
s"""|#!/usr/bin/env -S scala-cli shebang --java-opt -Xms256m --java-opt -XX:MaxRAMPercentage=80
|//> using scala "$scalaVersion"
|//> using lib "com.lihaoyi::utest::0.7.10"
|//> using lib com.lihaoyi::pprint::0.6.6
|//> using dep "com.lihaoyi::utest::0.7.10"
|//> using dep com.lihaoyi::pprint::0.6.6
|
|import foo.Foo
|import utest._
Expand All @@ -225,8 +225,8 @@ class ScalaCliSuite extends BaseScalaCliSuite(V.scala3) {
private val simpleFileLayout =
s"""|/MyTests.scala
|//> using scala "$scalaVersion"
|//> using lib "com.lihaoyi::utest::0.7.10"
|//> using lib com.lihaoyi::pprint::0.6.6
|//> using dep "com.lihaoyi::utest::0.7.10"
|//> using dep com.lihaoyi::pprint::0.6.6
|
|import foo.Foo
|import utest._
Expand Down Expand Up @@ -333,7 +333,7 @@ class ScalaCliSuite extends BaseScalaCliSuite(V.scala3) {
_ <- scalaCliInitialize(useBsp = false)(
s"""|/inner/project.scala
|//> using scala "$scalaVersion"
|//> using lib "com.lihaoyi::utest::0.8.1"
|//> using dep "com.lihaoyi::utest::0.8.1"
|/inner/MyTests.scala
|import utest._
|
Expand All @@ -356,8 +356,8 @@ class ScalaCliSuite extends BaseScalaCliSuite(V.scala3) {
_ <- scalaCliInitialize(useBsp = false)(
s"""/scripts/MyTests.scala
|//> using scala "$scalaVersion"
|//> using lib "com.lihaoyi::utest::0.7.10"
|//> using lib com.lihaoyi::pprint::0.6.6
|//> using dep "com.lihaoyi::utest::0.7.10"
|//> using dep com.lihaoyi::pprint::0.6.6
|
|import foo.Foo
|import utest._
Expand Down Expand Up @@ -434,9 +434,9 @@ class ScalaCliSuite extends BaseScalaCliSuite(V.scala3) {
for {
_ <- initialize(
s"""|/project.scala
|//> using scala "${V.scala3}"
|//> using lib "com.lihaoyi::utest::0.8.1"
|//> using lib "com.lihaoyi::pprint::0.8.1"
|//> using scala "${scalaVersion}"
|//> using dep "com.lihaoyi::utest::0.8.1"
|//> using dep "com.lihaoyi::pprint::0.8.1"
|
|/test/MyTests.scala
|
Expand Down Expand Up @@ -759,7 +759,10 @@ class ScalaCliSuite extends BaseScalaCliSuite(V.scala3) {
)
_ = assertNoDiff(
completions,
"""|mapConserve[B >: Int <: AnyRef](f: Int => B): List[B]
"""|flatMap[B](f: Int => IterableOnce[B]): List[B]
|groupMapReduce[K, B](key: Int => K)(f: Int => B)(reduce: (B, B) => B): Map[K, B]
|groupMap[K, B](key: Int => K)(f: Int => B): Map[K, List[B]]
|mapConserve[B >: Int <: AnyRef](f: Int => B): List[B]
|map[B](f: Int => B): List[B]
|""".stripMargin,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tests.`best-effort`
package tests.bestEffort

import scala.meta.internal.metals.MetalsServerConfig

Expand All @@ -11,7 +11,8 @@ class BestEffortCompilationSuite
override def serverConfig: MetalsServerConfig =
super.serverConfig.copy(enableBestEffort = true)

override val scalaVersionConfig = s"\"scalaVersion\": \"${scalaVersion}\""
override val scalaVersionConfig: String =
s"\"scalaVersion\": \"${scalaVersion}\""
override val saveAfterChanges: Boolean = true
override val scala3Diagnostics: Boolean = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,7 @@ class ScalafixProviderLspSuite extends BaseLspSuite("scalafix-provider") {
test("amend-scalafix-conf") {
cleanWorkspace()
val newSettings = List(
"OrganizeImports.targetDialect = Scala3",
"OrganizeImports.removeUnused = false",
"OrganizeImports.targetDialect = Scala3"
)
val amendScalafixConfRequest = Messages.ScalafixConfig.amendRequest(
newSettings,
Expand All @@ -322,7 +321,10 @@ class ScalafixProviderLspSuite extends BaseLspSuite("scalafix-provider") {
client.showMessageRequestHandler = params =>
if (params.getMessage() == amendScalafixConfRequest.getMessage())
Some(Messages.ScalafixConfig.adjustScalafix)
else None
else {
scribe.error(s"Unexpected message: ${params.getMessage()}")
None
}

for {
_ <- initialize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import scala.meta.internal.metals.ScalaVersions
import scala.meta.internal.metals.doctor.DeprecatedRemovedSbtVersion
import scala.meta.internal.metals.doctor.DeprecatedRemovedScalaVersion
import scala.meta.internal.metals.doctor.DeprecatedSbtVersion
import scala.meta.internal.metals.doctor.DeprecatedScalaVersion
import scala.meta.internal.metals.doctor.FutureSbtVersion
import scala.meta.internal.metals.doctor.FutureScalaVersion
import scala.meta.internal.metals.doctor.MissingSourceRoot
Expand Down

0 comments on commit 2fcf0bc

Please sign in to comment.