From ffe658e2e10d62a7e47d9b834cbaac4042165cb2 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Fri, 3 Jun 2022 14:09:36 +0200 Subject: [PATCH] refactor: Migrate Metals server to Scala 3 This mostly involved: - changing imports - moving things between MtagsEnrichements variants - adding () - fixing bugs reported now as warning or errors (things previously not reported at all) --- .scalafix.conf | 12 +- .scalafix2.conf | 19 ++ .scalafix3.conf | 14 -- .scalafmt.conf | 3 +- build.sbt | 104 +++++++---- .../src/main/scala/bench/MetalsBench.scala | 43 ----- .../internal/bsp/BspConfigGenerator.scala | 6 +- .../meta/internal/bsp/BspConnector.scala | 7 +- .../meta/internal/builds/BloopInstall.scala | 2 +- .../scala/meta/internal/builds/BspOnly.scala | 1 - .../internal/builds/BuildToolSelector.scala | 4 +- .../meta/internal/builds/BuildTools.scala | 2 +- .../scala/meta/internal/builds/Digest.scala | 4 +- .../meta/internal/builds/GradleDigest.scala | 2 +- .../meta/internal/builds/MavenBuildTool.scala | 2 +- .../meta/internal/builds/MavenDigest.scala | 2 +- .../internal/builds/NewProjectProvider.scala | 2 +- .../meta/internal/builds/SbtBuildTool.scala | 4 +- .../meta/internal/builds/SbtDigest.scala | 2 +- .../meta/internal/builds/ShellRunner.scala | 2 +- .../internal/builds/WorkspaceReload.scala | 2 +- .../ImplementationProvider.scala | 2 +- .../implementation/Supermethods.scala | 2 +- .../meta/internal/metals/ActiveFiles.scala | 2 +- .../meta/internal/metals/AdjustLspData.scala | 5 +- .../internal/metals/BatchedFunction.scala | 2 +- .../meta/internal/metals/BloopServers.scala | 22 ++- .../scala/meta/internal/metals/Buffers.scala | 2 +- .../metals/BuildServerConnection.scala | 2 +- .../internal/metals/BuildTargetInfo.scala | 6 +- .../meta/internal/metals/BuildTargets.scala | 2 +- .../internal/metals/CancelableFuture.scala | 2 +- .../internal/metals/ClientConfiguration.scala | 2 +- .../scala/meta/internal/metals/Command.scala | 2 +- .../meta/internal/metals/Compilations.scala | 6 +- .../internal/metals/CompilerPlugins.scala | 2 +- .../meta/internal/metals/Compilers.scala | 10 +- .../internal/metals/DefinitionProvider.scala | 5 +- .../meta/internal/metals/Diagnostics.scala | 6 +- .../scala/meta/internal/metals/Embedded.scala | 2 +- .../metals/FallbackMetalsLspService.scala | 2 +- .../internal/metals/FileDecoderProvider.scala | 3 +- .../metals/FileSystemSemanticdbs.scala | 2 +- .../meta/internal/metals/Fingerprints.scala | 1 - .../internal/metals/FormattingProvider.scala | 4 +- .../metals/ForwardingMetalsBuildClient.scala | 10 +- .../meta/internal/metals/ImportedBuild.scala | 2 +- .../scala/meta/internal/metals/Indexer.scala | 4 +- .../metals/InitializationOptions.scala | 2 +- .../metals/InteractiveSemanticdbs.scala | 2 +- .../meta/internal/metals/JarTopLevels.scala | 2 +- .../metals/JavaFormattingProvider.scala | 5 +- .../metals/JavaInteractiveSemanticdb.scala | 2 +- .../meta/internal/metals/JavaTarget.scala | 4 +- .../internal/metals/MetalsEnrichments.scala | 16 +- .../internal/metals/MetalsHttpServer.scala | 2 +- .../internal/metals/MetalsLspService.scala | 35 ++-- .../internal/metals/MetalsServerInputs.scala | 7 - .../internal/metals/MetalsSymbolSearch.scala | 2 +- .../meta/internal/metals/MtagsResolver.scala | 2 - .../internal/metals/PackageProvider.scala | 17 +- .../internal/metals/PopupChoiceReset.scala | 2 +- .../metals/ProjectMetalsLspService.scala | 14 +- .../internal/metals/ReferenceProvider.scala | 3 +- .../meta/internal/metals/ScalaTarget.scala | 4 +- .../metals/ScalaVersionSelector.scala | 2 +- .../internal/metals/ScalafixProvider.scala | 2 +- .../internal/metals/SemanticdbIndexer.scala | 8 +- .../meta/internal/metals/ServerCommands.scala | 3 +- .../meta/internal/metals/SourceMapper.scala | 2 +- .../internal/metals/StacktraceAnalyzer.scala | 2 +- .../metals/StandaloneSymbolSearch.scala | 2 +- .../meta/internal/metals/StatusBar.scala | 2 +- .../scala/meta/internal/metals/Tables.scala | 2 +- .../meta/internal/metals/TargetData.scala | 2 +- .../scala/meta/internal/metals/Warnings.scala | 2 +- .../metals/WorksheetDependencySources.scala | 2 +- .../internal/metals/WorkspaceLspService.scala | 18 +- .../metals/WorkspaceSearchVisitor.scala | 2 +- .../internal/metals/ammonite/Ammonite.scala | 2 +- .../callHierarchy/OutgoingCallsFinder.scala | 2 +- .../language/ConfiguredLanguageClient.scala | 19 +- .../clients/language/MetalsHttpClient.scala | 4 +- .../metals/codeactions/CodeAction.scala | 4 +- .../codeactions/CodeActionProvider.scala | 1 - .../ConvertCommentCodeAction.scala | 2 +- .../codeactions/ConvertToNamedArguments.scala | 8 +- .../CreateCompanionObjectCodeAction.scala | 4 +- .../metals/codeactions/CreateNewSymbol.scala | 4 +- .../codeactions/ExtractRenameMember.scala | 7 +- .../codeactions/ExtractValueCodeAction.scala | 4 +- .../FlatMapToForComprehensionCodeAction.scala | 2 - .../ImplementAbstractMembers.scala | 4 +- .../codeactions/ImportMissingSymbol.scala | 3 +- .../codeactions/InlineValueCodeAction.scala | 1 - .../codeactions/InsertInferredType.scala | 4 +- .../MillifyDependencyCodeAction.scala | 3 +- .../MillifyScalaCliDependencyCodeAction.scala | 1 - .../metals/codeactions/OrganizeImports.scala | 2 - .../codeactions/PatternMatchRefactor.scala | 4 +- .../RewriteBracesParensCodeAction.scala | 6 +- .../metals/codeactions/StringActions.scala | 6 +- .../metals/codelenses/RunTestCodeLens.scala | 4 +- .../codelenses/SuperMethodCodeLens.scala | 6 +- .../metals/codelenses/WorksheetCodeLens.scala | 4 +- .../metals/debug/BuildTargetClasses.scala | 2 +- .../debug/BuildTargetClassesFinder.scala | 2 +- .../debug/ClientConfigurationAdapter.scala | 2 +- .../internal/metals/debug/DebugProtocol.scala | 2 +- .../internal/metals/debug/DebugProvider.scala | 8 +- .../internal/metals/debug/DebugProxy.scala | 5 +- .../metals/debug/DotEnvFileParser.scala | 2 +- .../metals/debug/EndpointLogger.scala | 4 +- .../metals/debug/SourcePathAdapter.scala | 2 +- .../meta/internal/metals/doctor/Doctor.scala | 8 +- .../internal/metals/doctor/HeadDoctor.scala | 5 +- .../metals/doctor/ProblemResolver.scala | 2 +- .../findfiles/FindTextInDependencyJars.scala | 2 +- .../metals/formatting/IndentOnPaste.scala | 2 +- .../formatting/OnTypeFormattingProvider.scala | 2 +- .../formatting/RangeFormattingProvider.scala | 2 +- .../metals/newScalaFile/NewFileProvider.scala | 7 +- .../metals/scalacli/ScalaCliServers.scala | 6 +- .../testProvider/BuildTargetUpdate.scala | 2 +- .../testProvider/TestSuitesProvider.scala | 4 +- .../frameworks/JunitTestFinder.scala | 2 +- .../frameworks/MunitTestFinder.scala | 2 +- .../frameworks/ScalatestTestFinder.scala | 11 +- .../meta/internal/parsing/ClassFinder.scala | 3 +- .../parsing/DocumentSymbolProvider.scala | 2 +- .../parsing/FoldingRangeExtractor.scala | 8 +- .../parsing/FoldingRangeProvider.scala | 2 +- .../parsing/JavaFoldingRangeExtractor.scala | 2 +- .../internal/parsing/TokenEditDistance.scala | 2 +- .../scala/meta/internal/parsing/Trees.scala | 2 +- .../meta/internal/rename/RenameProvider.scala | 13 +- .../meta/internal/tvp/ClasspathTreeView.scala | 2 +- .../internal/tvp/MetalsTreeViewProvider.scala | 4 +- .../DecorationWorksheetPublisher.scala | 2 +- .../internal/worksheets/MdocEnrichments.scala | 1 - .../worksheets/WorksheetProvider.scala | 2 +- .../WorkspaceEditWorksheetPublisher.scala | 2 +- .../scala/meta/internal/pc/JavaHover.scala | 2 +- .../internal/mtags/MtagsEnrichments.scala | 172 ------------------ .../scala/meta/internal/pc/Keywords.scala | 1 - .../internal/mtags/MtagsEnrichments.scala | 3 +- .../meta/internal/metals/PositionSyntax.scala | 2 +- .../internal/metals/URIEncoderDecoder.scala | 2 +- .../mtags/ScalametaCommonEnrichments.scala | 163 +++++++++++++++++ .../scala/meta/internal/pc/LogMessages.scala | 0 project/JavaPcSettings.scala | 2 +- .../scala/tests/BaseExtractMethodSuite.scala | 1 - .../feature/InlayHintsScala3ExpectSuite.scala | 2 +- .../tests/feature/RenameCrossLspSuite.scala | 108 ++++++++--- .../SemanticTokensScala3ExpectSuite.scala | 15 +- .../scala/tests/feature/SlowSaveExpect.scala | 4 +- .../feature/WorksheetCrossLspSuite.scala | 65 ++++++- .../test/scala/tests/sbt/SbtServerSuite.scala | 4 +- tests/unit/src/main/scala/bill/Bill.scala | 93 +++++----- .../meta/internal/metals/debug/Debugger.scala | 3 - .../tests/BaseAnalyzeStacktraceSuite.scala | 2 +- .../scala/tests/BaseInlayHintsLspSuite.scala | 2 - .../src/main/scala/tests/BaseLspSuite.scala | 11 +- .../main/scala/tests/BaseRenameLspSuite.scala | 13 +- .../scala/tests/BaseWorksheetLspSuite.scala | 8 +- .../scala/tests/BuildServerInitializer.scala | 5 - tests/unit/src/main/scala/tests/Library.scala | 5 +- .../src/main/scala/tests/QuickBuild.scala | 4 +- .../main/scala/tests/TestScala3Compiler.scala | 8 +- .../src/main/scala/tests/TestingClient.scala | 2 +- .../codeactions/BaseCodeActionLspSuite.scala | 2 +- .../tests/debug/BaseStackFrameDapSuite.scala | 19 +- .../src/test/scala/tests/BillLspSuite.scala | 12 +- .../scala/tests/BloopJavaHomeLspSuite.scala | 10 +- .../scala/tests/BuildTargetsLspSuite.scala | 2 +- .../test/scala/tests/CascadeLspSuite.scala | 7 +- .../test/scala/tests/CodeLensLspSuite.scala | 2 +- .../test/scala/tests/CompletionLspSuite.scala | 2 +- .../scala/tests/DiagnosticsLspSuite.scala | 75 ++++---- .../test/scala/tests/DidFocusLspSuite.scala | 10 +- .../tests/FindTextInDependencyJarsSuite.scala | 27 ++- .../src/test/scala/tests/HoverLspSuite.scala | 2 +- .../test/scala/tests/NewFileLspSuite.scala | 2 +- .../src/test/scala/tests/RenameLspSuite.scala | 107 +++++------ .../scala/tests/ResetWorkspaceLspSuite.scala | 5 +- .../tests/SemanticTokensExpectSuite.scala | 7 +- .../scala/tests/SuperHierarchyLspSuite.scala | 24 +-- .../scala/tests/SuperMethodLspSuite.scala | 14 +- .../test/scala/tests/TreeViewLspSuite.scala | 58 +++--- .../test/scala/tests/WarningsLspSuite.scala | 35 ++-- .../scala/tests/WorkspaceFoldersSuite.scala | 4 +- .../classFinder/ClassBreakpointSuite.scala | 2 +- .../classFinder/FindAllClassesSuite.scala | 6 +- .../classFinder/TastyNameResolverSuite.scala | 2 +- .../ExtractRenameMemberLspSuite.scala | 2 +- .../codeactions/ExtractValueLspSuite.scala | 4 +- .../FlatMapToForComprehensionSuite.scala | 1 + .../tests/debug/CompletionDapSuite.scala | 32 +--- .../scalafix/ScalafixProviderLspSuite.scala | 3 +- .../TestSuitesProviderSuite.scala | 2 +- .../tests/worksheets/WorksheetLspSuite.scala | 28 +-- .../WorksheetNoDecorationsLspSuite.scala | 12 +- 202 files changed, 1004 insertions(+), 985 deletions(-) create mode 100644 .scalafix2.conf delete mode 100644 .scalafix3.conf rename mtags/src/main/{scala-2 => scala}/scala/meta/internal/metals/PositionSyntax.scala (99%) rename mtags/src/main/{scala-2 => scala}/scala/meta/internal/metals/URIEncoderDecoder.scala (95%) rename mtags/src/main/{scala-2 => scala}/scala/meta/internal/pc/LogMessages.scala (100%) diff --git a/.scalafix.conf b/.scalafix.conf index 2c0c7153f08..c2690c2b9ea 100644 --- a/.scalafix.conf +++ b/.scalafix.conf @@ -1,19 +1,15 @@ rules = [ - OrganizeImports, - ExplicitResultTypes, - RemoveUnused + OrganizeImports ] -ExplicitResultTypes.rewriteStructuralTypesToNamedSubclass = false - -RemoveUnused.imports = false - OrganizeImports.groupedImports = Explode OrganizeImports.expandRelative = true -OrganizeImports.removeUnused = true +OrganizeImports.removeUnused = false OrganizeImports.groups = [ "re:javax?\\." "scala." "scala.meta." "*" ] + +OrganizeImports.targetDialect = StandardLayout \ No newline at end of file diff --git a/.scalafix2.conf b/.scalafix2.conf new file mode 100644 index 00000000000..2c0c7153f08 --- /dev/null +++ b/.scalafix2.conf @@ -0,0 +1,19 @@ +rules = [ + OrganizeImports, + ExplicitResultTypes, + RemoveUnused +] + +ExplicitResultTypes.rewriteStructuralTypesToNamedSubclass = false + +RemoveUnused.imports = false + +OrganizeImports.groupedImports = Explode +OrganizeImports.expandRelative = true +OrganizeImports.removeUnused = true +OrganizeImports.groups = [ + "re:javax?\\." + "scala." + "scala.meta." + "*" +] diff --git a/.scalafix3.conf b/.scalafix3.conf deleted file mode 100644 index 24d6b64c9bd..00000000000 --- a/.scalafix3.conf +++ /dev/null @@ -1,14 +0,0 @@ -rules = [ - OrganizeImports -] - -OrganizeImports.groupedImports = Explode -OrganizeImports.expandRelative = true -OrganizeImports.removeUnused = false -OrganizeImports.groups = [ - "re:javax?\\." - "scala." - "scala.meta." - "*" -] -OrganizeImports.targetDialect = StandardLayout diff --git a/.scalafmt.conf b/.scalafmt.conf index 71080cdf93a..67602705c52 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,5 +1,5 @@ version = "3.8.1" -runner.dialect = scala213source3 +runner.dialect = scala3 project.git = true align.preset = none align.stripMargin = true @@ -37,6 +37,7 @@ fileOverride { }, "glob:**/mtags*/**" { trailingCommas = never + runner.dialect = scala213 } "glob:**/tests/cross/src/**" { trailingCommas = never diff --git a/build.sbt b/build.sbt index aa1bdd73960..46657be28da 100644 --- a/build.sbt +++ b/build.sbt @@ -36,7 +36,7 @@ def crossSetting[A]( logo := Welcome.logo usefulTasks := Welcome.tasks -ThisBuild / scalafixScalaBinaryVersion := scalaBinaryVersion.value +ThisBuild / scalafixScalaBinaryVersion := "2.13" inThisBuild( List( @@ -44,8 +44,8 @@ inThisBuild( if (isCI) dynVer else localSnapshotVersion // only for local publishing }, - scalaVersion := V.scala213, - crossScalaVersions := List(V.scala213), + scalaVersion := V.scala3, + crossScalaVersions := List(V.scala3), organization := "org.scalameta", licenses := Seq( "Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0") @@ -128,7 +128,7 @@ commands ++= Seq( runMtagsPublishLocal(st, v, localSnapshotVersion) } "interfaces/publishLocal" :: - s"++${V.scala213} metals/publishLocal" :: + s"++${V.scala3} metals/publishLocal" :: "mtags-java/publishLocal" :: publishMtags }, @@ -218,6 +218,27 @@ val sharedSettings = sharedJavacOptions ++ sharedScalacOptions ++ List( ) ), ), + excludeDependencies ++= crossSetting( + scalaVersion.value, + if3 = { + // Exclude cross published version dependencies leading to conflicts in Scala 3 vs 2.13 + // When using Scala 3 exclude Scala 2.13 standard native libraries, + // when using Scala 2.13 exclude Scala 3 standard native libraries + // Use full name, Maven style published artifacts cannot use artifact/cross version for exclusion rules + List( + ExclusionRule() + .withOrganization("org.scala-lang.modules") + .withName( + "scala-collection-compat_2.13" + ), + ExclusionRule() + .withOrganization("org.scala-lang.modules") + .withName( + "scala-xml_2.13" + ), + ) + }, + ), scalacOptions ++= lintingOptions(scalaVersion.value), ) @@ -284,21 +305,19 @@ def multiScalaDirectories(root: File, scalaVersion: String) = { result.toList } -def scala3ScalametaDependency = - ("org.scalameta" %% "scalameta" % V.scalameta) - .cross(CrossVersion.for3Use2_13) - .exclude("org.scala-lang", "scala-reflect") - .exclude("org.scala-lang", "scala-compiler") - // the correct one should be brought in by the scala 3 compiler - .exclude("org.scala-lang", "scala-library") - .exclude( - "com.lihaoyi", - "geny_2.13", - ) // avoid 2.13 and 3 on the classpath since we rely on it directly - .exclude( - "com.lihaoyi", - "sourcecode_2.13", - ) // avoid 2.13 and 3 on the classpath since it comes in via pprint +def scalametaDependency = ("org.scalameta" %% "scalameta" % V.scalameta) + .cross(CrossVersion.for3Use2_13) + .exclude("org.scala-lang", "scala-reflect") + .exclude("org.scala-lang", "scala-compiler") + .exclude("org.scala-lang.modules", "scala-collection-compat") + .exclude( + "com.lihaoyi", + "geny_2.13", + ) // avoid 2.13 and 3 on the classpath since we rely on it directly + .exclude( + "com.lihaoyi", + "sourcecode_2.13", + ) val mtagsSettings = List( crossScalaVersions := V.supportedScalaVersions, @@ -331,7 +350,7 @@ val mtagsSettings = List( ), if3 = List( "org.scala-lang" %% "scala3-compiler" % scalaVersion.value, - scala3ScalametaDependency, + scalametaDependency, ), ), }, @@ -360,7 +379,7 @@ val mtagsSettings = List( }, ) -lazy val mtags3 = project +lazy val mtags2 = project .in(file(".mtags")) .settings( Compile / unmanagedSourceDirectories := Seq(), @@ -368,14 +387,14 @@ lazy val mtags3 = project mtagsSettings, Compile / unmanagedSourceDirectories += (ThisBuild / baseDirectory).value / "mtags" / "src" / "main" / "scala", Compile / unmanagedSourceDirectories += (ThisBuild / baseDirectory).value / "mtags-shared" / "src" / "main" / "scala", - Compile / unmanagedSourceDirectories += (ThisBuild / baseDirectory).value / "mtags-shared" / "src" / "main" / "scala-3", - moduleName := "mtags3", - scalaVersion := V.scala3, - target := (ThisBuild / baseDirectory).value / "mtags" / "target" / "target3", + Compile / unmanagedSourceDirectories += (ThisBuild / baseDirectory).value / "mtags-shared" / "src" / "main" / "scala-2.13", + moduleName := "mtags2", + scalaVersion := V.scala213, + target := (ThisBuild / baseDirectory).value / "mtags" / "target" / "target2", publish / skip := true, libraryDependencies += V.guava, scalafixConfig := Some( - (ThisBuild / baseDirectory).value / ".scalafix3.conf" + (ThisBuild / baseDirectory).value / ".scalafix2.conf" ), ) .dependsOn(interfaces) @@ -421,7 +440,8 @@ lazy val metals = project // for BSP "org.scala-sbt.ipcsocket" % "ipcsocket" % "1.6.2", "ch.epfl.scala" % "bsp4j" % V.bsp, - "ch.epfl.scala" %% "bloop-launcher-core" % V.bloop, + ("ch.epfl.scala" %% "bloop-launcher-core" % V.bloop) + .cross(CrossVersion.for3Use2_13), // for LSP V.lsp4j, // for DAP @@ -451,14 +471,20 @@ lazy val metals = project // Scala dependencies // ================== "org.scalameta" % "mdoc-interfaces" % V.mdoc, - "org.scalameta" %% "scalafmt-dynamic" % V.scalafmt, + ("org.scalameta" %% "scalafmt-dynamic" % V.scalafmt) + .cross(CrossVersion.for3Use2_13), + "com.googlecode.java-diff-utils" % "diffutils" % "1.3.0", "ch.epfl.scala" % "scalafix-interfaces" % V.scalafix, // For reading classpaths. // for fetching ch.epfl.scala:bloop-frontend and other library dependencies "io.get-coursier" % "interface" % V.coursierInterfaces, // for comparing versions && fetching from sbt maven repository - "io.get-coursier" %% "coursier" % V.coursier, - "io.get-coursier" %% "coursier-sbt-maven-repository" % V.coursier, + ("io.get-coursier" %% "versions" % "0.3.2") + .cross(CrossVersion.for3Use2_13), + ("io.get-coursier" %% "coursier-sbt-maven-repository" % V.coursier) + .cross(CrossVersion.for3Use2_13), + ("io.get-coursier" %% "coursier" % V.coursier) + .cross(CrossVersion.for3Use2_13), // for logging "com.outr" %% "scribe" % V.scribe, "com.outr" %% "scribe-file" % V.scribe, @@ -467,13 +493,11 @@ lazy val metals = project "com.lihaoyi" %% "ujson" % "3.3.1", // For fetching projects' templates "com.lihaoyi" %% "requests" % "0.8.2", - // for producing SemanticDB from Scala source files, to be sure we want the same version of scalameta - "org.scalameta" %% "scalameta" % V.semanticdb(scalaVersion.value), - "org.scalameta" % "semanticdb-scalac-core" % V.semanticdb( - scalaVersion.value - ) cross CrossVersion.full, + // for producing SemanticDB from Scala source files + scalametaDependency, // For starting Ammonite - "io.github.alexarchambault.ammonite" %% "ammonite-runner" % "0.4.0", + ("io.github.alexarchambault.ammonite" %% "ammonite-runner" % "0.4.0") + .cross(CrossVersion.for3Use2_13), "org.scala-lang.modules" %% "scala-xml" % "2.3.0", "org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4", ("org.virtuslab.scala-cli" % "scala-cli-bsp" % V.scalaCli) @@ -543,6 +567,7 @@ lazy val input = project .in(file("tests/input")) .settings( sharedSettings, + scalaVersion := V.scala213, scalacOptions -= "-Xsource:3", publish / skip := true, libraryDependencies ++= List( @@ -719,6 +744,7 @@ lazy val metalsDependencies = project .in(file("target/.dependencies")) .settings( publish / skip := true, + scalaVersion := V.scala213, // silent the intransitive dependency warning publishMavenStyle := false, libraryDependencies ++= List( @@ -749,8 +775,10 @@ lazy val unit = project sharedSettings, Test / javaOptions += "-Xmx2G", libraryDependencies ++= List( - "io.get-coursier" %% "coursier" % V.coursier, // for jars - "ch.epfl.scala" %% "bloop-config" % V.bloopConfig, + ("io.get-coursier" %% "coursier" % V.coursier) + .cross(CrossVersion.for3Use2_13), // for jars + ("ch.epfl.scala" %% "bloop-config" % V.bloopConfig) + .cross(CrossVersion.for3Use2_13), "org.scalameta" %% "munit" % V.munit, ), buildInfoPackage := "tests", diff --git a/metals-bench/src/main/scala/bench/MetalsBench.scala b/metals-bench/src/main/scala/bench/MetalsBench.scala index 6442d0c9b07..cfe28aea76a 100644 --- a/metals-bench/src/main/scala/bench/MetalsBench.scala +++ b/metals-bench/src/main/scala/bench/MetalsBench.scala @@ -1,11 +1,6 @@ package bench -import scala.reflect.internal.util.BatchSourceFile -import scala.reflect.io.VirtualFile -import scala.tools.nsc.interactive.Global - import scala.meta.dialects -import scala.meta.interactive.InteractiveSemanticdb import scala.meta.internal.metals.EmptyReportContext import scala.meta.internal.metals.IdentifierIndex import scala.meta.internal.metals.JdkSources @@ -22,7 +17,6 @@ import scala.meta.internal.mtags.SemanticdbClasspath import scala.meta.internal.parsing.Trees import scala.meta.internal.semanticdb.TextDocument import scala.meta.internal.tokenizers.LegacyScanner -import scala.meta.internal.tokenizers.LegacyToken import scala.meta.io.AbsolutePath import scala.meta.io.Classpath @@ -128,22 +122,6 @@ class MetalsBench { } } - @Benchmark - @BenchmarkMode(Array(Mode.SingleShotTime)) - def scalacTokenize(): Unit = { - val g = global - scalaDependencySources.foreach { input => - val unit = new g.CompilationUnit( - new BatchSourceFile(new VirtualFile(input.path), input.chars) - ) - val scanner = g.newUnitScanner(unit) - scanner.init() - while (scanner.token != LegacyToken.EOF) { - scanner.nextToken() - } - } - } - @Benchmark @BenchmarkMode(Array(Mode.SingleShotTime)) def scalametaParse(): Unit = { @@ -153,27 +131,6 @@ class MetalsBench { } } - lazy val global: Global = InteractiveSemanticdb.newCompiler() - - @Benchmark - @BenchmarkMode(Array(Mode.SingleShotTime)) - def scalacParse(): Unit = { - val g = global - scalaDependencySources.foreach { input => - val unit = new g.CompilationUnit( - new BatchSourceFile(new VirtualFile(input.path), input.chars) - ) - val tree = g.newUnitParser(unit).parse() - var i = 0 - new g.Traverser { - override def apply[T <: g.Tree](tree: T): T = { - i += 1 - super.apply(tree) - } - }.traverse(tree) - } - } - @Benchmark @BenchmarkMode(Array(Mode.SingleShotTime)) def mtagsJavaParse(): Unit = { diff --git a/metals/src/main/scala/scala/meta/internal/bsp/BspConfigGenerator.scala b/metals/src/main/scala/scala/meta/internal/bsp/BspConfigGenerator.scala index be0a783f211..eca737e213a 100644 --- a/metals/src/main/scala/scala/meta/internal/bsp/BspConfigGenerator.scala +++ b/metals/src/main/scala/scala/meta/internal/bsp/BspConfigGenerator.scala @@ -12,9 +12,9 @@ import scala.meta.internal.builds.BuildServerProvider import scala.meta.internal.builds.ShellRunner import scala.meta.internal.metals.Directories import scala.meta.internal.metals.Messages.BspProvider -import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.StatusBar import scala.meta.internal.metals.UserConfiguration +import scala.meta.internal.metals.StatusBar +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.io.AbsolutePath @@ -75,7 +75,7 @@ final class BspConfigGenerator( buildTools: List[BuildServerProvider] ): Future[(BuildServerProvider, BspConfigGenerationStatus)] = { for { - Some(buildTool) <- chooseBuildServerProvider(buildTools) + case Some(buildTool) <- chooseBuildServerProvider(buildTools) status <- buildTool.generateBspConfig( workspace, args => runUnconditionally(buildTool, args), diff --git a/metals/src/main/scala/scala/meta/internal/bsp/BspConnector.scala b/metals/src/main/scala/scala/meta/internal/bsp/BspConnector.scala index 48a21bc2061..36c338d1e66 100644 --- a/metals/src/main/scala/scala/meta/internal/bsp/BspConnector.scala +++ b/metals/src/main/scala/scala/meta/internal/bsp/BspConnector.scala @@ -16,7 +16,7 @@ import scala.meta.internal.metals.BloopServers import scala.meta.internal.metals.BuildServerConnection import scala.meta.internal.metals.Messages import scala.meta.internal.metals.Messages.BspSwitch -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.StatusBar import scala.meta.internal.metals.Tables import scala.meta.internal.metals.UserConfiguration @@ -190,7 +190,7 @@ class BspConnector( None, ) for { - Some(item) <- client + case Some(item) <- client .showMessageRequest(query.params) .asScala .map(item => @@ -239,7 +239,8 @@ class BspConnector( * Only for `bloop` there will be no matching build tool and the previously chosen one remains. */ private def optSetBuildTool(buildServerName: String): Unit = - buildTools.loadSupported + buildTools + .loadSupported() .find { case _: ScalaCliBuildTool if ScalaCli.names(buildServerName) => true case buildTool => buildTool.buildServerName == buildServerName diff --git a/metals/src/main/scala/scala/meta/internal/builds/BloopInstall.scala b/metals/src/main/scala/scala/meta/internal/builds/BloopInstall.scala index 44fed0a0699..e0a16b0dfac 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/BloopInstall.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/BloopInstall.scala @@ -10,7 +10,7 @@ import scala.meta.internal.builds.Digest.Status import scala.meta.internal.metals.BuildInfo import scala.meta.internal.metals.Confirmation import scala.meta.internal.metals.Messages._ -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.Tables import scala.meta.internal.metals.UserConfiguration import scala.meta.internal.metals.clients.language.MetalsLanguageClient diff --git a/metals/src/main/scala/scala/meta/internal/builds/BspOnly.scala b/metals/src/main/scala/scala/meta/internal/builds/BspOnly.scala index 0afb015a63d..7a624bc0e90 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/BspOnly.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/BspOnly.scala @@ -2,7 +2,6 @@ package scala.meta.internal.builds import java.security.MessageDigest -import scala.meta.internal.builds.Digest import scala.meta.internal.mtags.MD5 import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/builds/BuildToolSelector.scala b/metals/src/main/scala/scala/meta/internal/builds/BuildToolSelector.scala index b7d526b75d9..0f36e266c7c 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/BuildToolSelector.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/BuildToolSelector.scala @@ -5,7 +5,7 @@ import scala.concurrent.Future import scala.meta.internal.metals.Messages import scala.meta.internal.metals.Messages.ChooseBuildTool -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.Tables import scala.meta.internal.metals.clients.language.MetalsLanguageClient @@ -22,7 +22,7 @@ final class BuildToolSelector( def checkForChosenBuildTool( buildTools: List[BuildTool] ): Future[Option[BuildTool]] = - tables.buildTool.selectedBuildTool match { + tables.buildTool.selectedBuildTool() match { case Some(chosen) if buildTools.exists(_.executableName == chosen) => Future(buildTools.find(_.executableName == chosen)) case _ => diff --git a/metals/src/main/scala/scala/meta/internal/builds/BuildTools.scala b/metals/src/main/scala/scala/meta/internal/builds/BuildTools.scala index 4d968cfa0dc..ab9319686ce 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/BuildTools.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/BuildTools.scala @@ -11,7 +11,7 @@ import scala.meta.internal.bsp.ScalaCliBspScope import scala.meta.internal.io.PathIO import scala.meta.internal.metals.BloopServers import scala.meta.internal.metals.Directories -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.UserConfiguration import scala.meta.internal.metals.scalacli.ScalaCli import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/builds/Digest.scala b/metals/src/main/scala/scala/meta/internal/builds/Digest.scala index e97b1584161..43af138e6dd 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/Digest.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/Digest.scala @@ -14,7 +14,7 @@ import scala.meta.XtensionDialectApply import scala.meta.XtensionTokenizeDialectInput import scala.meta.internal.builds.Digest.Status import scala.meta.internal.io.PathIO -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.mtags.MD5 import scala.meta.internal.parsing.Trees import scala.meta.io.AbsolutePath @@ -185,7 +185,7 @@ object Digest { ): Boolean = { try { val input = file.toInput - val tokens = Trees.defaultTokenizerDialect(input).tokenize.get + val tokens = Trees.defaultTokenizerDialect.apply(input).tokenize.get tokens.foreach { case token if token.isWhiteSpaceOrComment => // Do nothing case token => diff --git a/metals/src/main/scala/scala/meta/internal/builds/GradleDigest.scala b/metals/src/main/scala/scala/meta/internal/builds/GradleDigest.scala index b66999bb77e..bb90d9195b6 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/GradleDigest.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/GradleDigest.scala @@ -2,7 +2,7 @@ package scala.meta.internal.builds import java.security.MessageDigest -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.io.AbsolutePath object GradleDigest extends Digestable { diff --git a/metals/src/main/scala/scala/meta/internal/builds/MavenBuildTool.scala b/metals/src/main/scala/scala/meta/internal/builds/MavenBuildTool.scala index ba655d9f601..b7ba2bb37f9 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/MavenBuildTool.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/MavenBuildTool.scala @@ -2,7 +2,7 @@ package scala.meta.internal.builds import scala.meta.internal.metals.BuildInfo import scala.meta.internal.metals.JavaBinary -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.UserConfiguration import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/builds/MavenDigest.scala b/metals/src/main/scala/scala/meta/internal/builds/MavenDigest.scala index 513bcad9dae..c1515028e7d 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/MavenDigest.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/MavenDigest.scala @@ -2,7 +2,7 @@ package scala.meta.internal.builds import java.security.MessageDigest -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.io.AbsolutePath object MavenDigest extends Digestable { diff --git a/metals/src/main/scala/scala/meta/internal/builds/NewProjectProvider.scala b/metals/src/main/scala/scala/meta/internal/builds/NewProjectProvider.scala index 1d5088a4321..4b39532d4d3 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/NewProjectProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/NewProjectProvider.scala @@ -12,7 +12,7 @@ import scala.meta.internal.metals.ClientCommands import scala.meta.internal.metals.ClientConfiguration import scala.meta.internal.metals.Icons import scala.meta.internal.metals.Messages._ -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.WorkDoneProgress import scala.meta.internal.metals.clients.language.MetalsInputBoxParams import scala.meta.internal.metals.clients.language.MetalsLanguageClient diff --git a/metals/src/main/scala/scala/meta/internal/builds/SbtBuildTool.scala b/metals/src/main/scala/scala/meta/internal/builds/SbtBuildTool.scala index 3a8603c88fc..7895b62a8e4 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/SbtBuildTool.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/SbtBuildTool.scala @@ -11,7 +11,7 @@ import scala.concurrent.Future import scala.concurrent.Promise import scala.meta.inputs.Input -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals._ import scala.meta.internal.semver.SemVer import scala.meta.internal.semver.SemVer.isCompatibleVersion @@ -307,7 +307,7 @@ object SbtBuildTool { writtenPlugin || writtenMeta } - private case class PluginDetails( + case class PluginDetails( description: Seq[String], artifact: String, resolver: Option[String], diff --git a/metals/src/main/scala/scala/meta/internal/builds/SbtDigest.scala b/metals/src/main/scala/scala/meta/internal/builds/SbtDigest.scala index f129711ab95..5ab7089841f 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/SbtDigest.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/SbtDigest.scala @@ -3,7 +3,7 @@ package scala.meta.internal.builds import java.security.MessageDigest import scala.meta.internal.builds.Digest.digestScala -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.io.AbsolutePath object SbtDigest extends Digestable { diff --git a/metals/src/main/scala/scala/meta/internal/builds/ShellRunner.scala b/metals/src/main/scala/scala/meta/internal/builds/ShellRunner.scala index da87b120603..ac40cc00eee 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/ShellRunner.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/ShellRunner.scala @@ -13,7 +13,7 @@ import scala.util.Properties import scala.meta.internal.metals.Cancelable import scala.meta.internal.metals.JavaBinary import scala.meta.internal.metals.JdkSources -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.MutableCancelable import scala.meta.internal.metals.Time import scala.meta.internal.metals.Timer diff --git a/metals/src/main/scala/scala/meta/internal/builds/WorkspaceReload.scala b/metals/src/main/scala/scala/meta/internal/builds/WorkspaceReload.scala index c2b8338838a..b85d0ea3475 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/WorkspaceReload.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/WorkspaceReload.scala @@ -7,7 +7,7 @@ import scala.meta.internal.builds.Digest.Status import scala.meta.internal.metals.Confirmation import scala.meta.internal.metals.Messages.ImportBuildChanges import scala.meta.internal.metals.Messages.dontShowAgain -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.Tables import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/implementation/ImplementationProvider.scala b/metals/src/main/scala/scala/meta/internal/implementation/ImplementationProvider.scala index 6cf59eab16c..7511718e0dc 100644 --- a/metals/src/main/scala/scala/meta/internal/implementation/ImplementationProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/implementation/ImplementationProvider.scala @@ -14,8 +14,8 @@ import scala.meta.internal.metals.Buffers import scala.meta.internal.metals.BuildTargets import scala.meta.internal.metals.Compilers import scala.meta.internal.metals.DefinitionProvider -import scala.meta.internal.metals.MetalsEnrichments._ import scala.meta.internal.metals.Report +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.ReportContext import scala.meta.internal.metals.ScalaVersionSelector import scala.meta.internal.metals.ScalaVersions diff --git a/metals/src/main/scala/scala/meta/internal/implementation/Supermethods.scala b/metals/src/main/scala/scala/meta/internal/implementation/Supermethods.scala index 2bef1344c08..e6fff1f3217 100644 --- a/metals/src/main/scala/scala/meta/internal/implementation/Supermethods.scala +++ b/metals/src/main/scala/scala/meta/internal/implementation/Supermethods.scala @@ -6,7 +6,7 @@ import scala.concurrent.Future import scala.meta.internal.implementation.Supermethods.formatMethodSymbolForQuickPick import scala.meta.internal.metals.ClientCommands import scala.meta.internal.metals.DefinitionProvider -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.ReportContext import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.internal.metals.clients.language.MetalsQuickPickItem diff --git a/metals/src/main/scala/scala/meta/internal/metals/ActiveFiles.scala b/metals/src/main/scala/scala/meta/internal/metals/ActiveFiles.scala index e588e0e8302..459fd40dedc 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ActiveFiles.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ActiveFiles.scala @@ -2,7 +2,7 @@ package scala.meta.internal.metals import java.util.concurrent.ConcurrentLinkedQueue -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.io.AbsolutePath /** diff --git a/metals/src/main/scala/scala/meta/internal/metals/AdjustLspData.scala b/metals/src/main/scala/scala/meta/internal/metals/AdjustLspData.scala index ab50702d156..d03c1ad4758 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/AdjustLspData.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/AdjustLspData.scala @@ -2,8 +2,8 @@ package scala.meta.internal.metals import java.{util => ju} -import scala.meta.internal.metals.MetalsEnrichments._ import scala.meta.pc +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.pc.AutoImportsResult import scala.meta.pc.HoverSignature @@ -67,8 +67,7 @@ trait AdjustLspData { ): ju.List[Location] def adjustHoverResp(hover: Hover): Hover = - if (hover.getRange == null) - hover + if (hover.getRange == null) hover else { val newRange = adjustRange(hover.getRange) val newHover = new Hover diff --git a/metals/src/main/scala/scala/meta/internal/metals/BatchedFunction.scala b/metals/src/main/scala/scala/meta/internal/metals/BatchedFunction.scala index 3070cccbf25..8ba060bd332 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/BatchedFunction.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/BatchedFunction.scala @@ -182,7 +182,7 @@ object BatchedFunction { ec: ExecutionContext ): BatchedFunction[A, B] = new BatchedFunction( - fn.andThen(CancelableFuture(_)), + fn.andThen(CancelableFuture(_, Cancelable.empty)), functionId, shouldLogQueue, default, diff --git a/metals/src/main/scala/scala/meta/internal/metals/BloopServers.scala b/metals/src/main/scala/scala/meta/internal/metals/BloopServers.scala index 3326590341a..5d3ab55bfbf 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/BloopServers.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/BloopServers.scala @@ -17,7 +17,7 @@ import scala.util.Try import scala.meta.internal.bsp.BuildChange import scala.meta.internal.bsp.ConnectionBspStatus -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.io.AbsolutePath @@ -46,6 +46,16 @@ final class BloopServers( workDoneProgress: WorkDoneProgress, )(implicit ec: ExecutionContextExecutorService) { + class BloopOutputStream extends OutputStream { + private lazy val b = new StringBuilder + + override def write(byte: Int): Unit = byte.toChar match { + case c => b.append(c) + } + + def logs = b.result.linesIterator + } + import BloopServers._ private val bloopJsonPath: Option[AbsolutePath] = @@ -354,15 +364,7 @@ final class BloopServers( val launcherOut = Channels.newOutputStream(clientInOutPipe.sink()) val serverStarted = Promise[Unit]() - val bloopLogs = new OutputStream { - private lazy val b = new StringBuilder - - override def write(byte: Int): Unit = byte.toChar match { - case c => b.append(c) - } - - def logs = b.result.linesIterator - } + val bloopLogs = new BloopOutputStream() val launcher = new LauncherMain( diff --git a/metals/src/main/scala/scala/meta/internal/metals/Buffers.scala b/metals/src/main/scala/scala/meta/internal/metals/Buffers.scala index 4ac56b33a5f..0f8ad5e8ed8 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Buffers.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Buffers.scala @@ -3,7 +3,7 @@ package scala.meta.internal.metals import scala.collection.concurrent.TrieMap import scala.meta.inputs.Input -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.parsing.TokenEditDistance import scala.meta.internal.parsing.Trees import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/metals/BuildServerConnection.scala b/metals/src/main/scala/scala/meta/internal/metals/BuildServerConnection.scala index ff3819c98cd..2b680d99952 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/BuildServerConnection.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/BuildServerConnection.scala @@ -26,7 +26,7 @@ import scala.meta.internal.bsp.ConnectionBspStatus import scala.meta.internal.builds.BazelBuildTool import scala.meta.internal.builds.MillBuildTool import scala.meta.internal.builds.SbtBuildTool -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.ammonite.Ammonite import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.internal.metals.scalacli.ScalaCli diff --git a/metals/src/main/scala/scala/meta/internal/metals/BuildTargetInfo.scala b/metals/src/main/scala/scala/meta/internal/metals/BuildTargetInfo.scala index b1a63580c2d..f466a17638e 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/BuildTargetInfo.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/BuildTargetInfo.scala @@ -2,7 +2,7 @@ package scala.meta.internal.metals import scala.collection.mutable.ListBuffer -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.mtags.URIEncoderDecoder import scala.meta.io.AbsolutePath @@ -13,7 +13,7 @@ class BuildTargetInfo(buildTargets: BuildTargets) { def buildTargetDetails(targetName: String, uri: String): String = { buildTargets.all - .find(_.getName == targetName) + .find(_.getName() == targetName) .orElse(buildTargets.all.find(_.getId.getUri.toString == uri)) .orElse( buildTargets.all.find( @@ -36,7 +36,7 @@ class BuildTargetInfo(buildTargets: BuildTargets) { commonInfo.foreach(info => { output += "Target" - output += s" ${info.getName}" + output += s" ${info.getName()}" if (!info.getTags.isEmpty) output ++= getSection("Tags", info.getTags.asScala.toList) diff --git a/metals/src/main/scala/scala/meta/internal/metals/BuildTargets.scala b/metals/src/main/scala/scala/meta/internal/metals/BuildTargets.scala index a70b00e99dd..f6af3ebe234 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/BuildTargets.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/BuildTargets.scala @@ -13,7 +13,7 @@ import scala.concurrent.Promise import scala.util.control.NonFatal import scala.meta.internal.io.PathIO -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.mtags.Symbol import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/metals/CancelableFuture.scala b/metals/src/main/scala/scala/meta/internal/metals/CancelableFuture.scala index 984437b8f77..c108429f245 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/CancelableFuture.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/CancelableFuture.scala @@ -26,7 +26,7 @@ object CancelableFuture { CancelableFuture(Future(thunk), Cancelable.empty) } def successful[T](value: T): CancelableFuture[T] = - CancelableFuture(Future.successful(value)) + CancelableFuture(Future.successful(value), Cancelable.empty) def sequence[T]( futures: Seq[CancelableFuture[T]] )(implicit ec: ExecutionContext): CancelableFuture[Seq[T]] = diff --git a/metals/src/main/scala/scala/meta/internal/metals/ClientConfiguration.scala b/metals/src/main/scala/scala/meta/internal/metals/ClientConfiguration.scala index fa676c7262e..efb57a805f5 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ClientConfiguration.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ClientConfiguration.scala @@ -158,7 +158,7 @@ final class ClientConfiguration( for { capabilities <- clientCapabilities textDocumentCapabilities <- Option(capabilities.getTextDocument()) - inlayHintsCapabilities <- Option(textDocumentCapabilities.getInlayHint()) + _ <- Option(textDocumentCapabilities.getInlayHint()) } yield true }.getOrElse(false) diff --git a/metals/src/main/scala/scala/meta/internal/metals/Command.scala b/metals/src/main/scala/scala/meta/internal/metals/Command.scala index b7fc310e42b..5def4914db7 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Command.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Command.scala @@ -4,7 +4,7 @@ import scala.reflect.ClassTag import scala.util.matching.Regex import scala.meta.internal.metals.JsonParser._ -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import org.eclipse.{lsp4j => l} diff --git a/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala b/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala index 871fa02d3ae..bf7291079eb 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala @@ -11,7 +11,7 @@ import scala.util.Failure import scala.util.Success import scala.util.Try -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.internal.metals.debug.BuildTargetClasses import scala.meta.internal.metals.utils.Timeout @@ -96,6 +96,7 @@ final class Compilations( def compileFile(path: AbsolutePath): Future[b.CompileResult] = { def empty = new b.CompileResult(b.StatusCode.CANCELLED) + for { targetOpt <- expand(path) result <- targetOpt match { @@ -196,8 +197,7 @@ final class Compilations( } targetOpt - } else - Future.successful(None) + } else Future.successful(None) } def expand(paths: Seq[AbsolutePath]): Future[Seq[b.BuildTargetIdentifier]] = { diff --git a/metals/src/main/scala/scala/meta/internal/metals/CompilerPlugins.scala b/metals/src/main/scala/scala/meta/internal/metals/CompilerPlugins.scala index 908e8d42e80..4c25bc4136f 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/CompilerPlugins.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/CompilerPlugins.scala @@ -7,7 +7,7 @@ import scala.util.control.NonFatal import scala.xml.XML import scala.meta.internal.io.FileIO -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.io.AbsolutePath /** diff --git a/metals/src/main/scala/scala/meta/internal/metals/Compilers.scala b/metals/src/main/scala/scala/meta/internal/metals/Compilers.scala index 5e46d7be02e..adb3340ebb5 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Compilers.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Compilers.scala @@ -17,10 +17,8 @@ import scala.meta.inputs.Input import scala.meta.inputs.Position import scala.meta.internal import scala.meta.internal.builds.SbtBuildTool -import scala.meta.internal.metals.CompilerOffsetParamsUtils -import scala.meta.internal.metals.CompilerRangeParamsUtils import scala.meta.internal.metals.Compilers.PresentationCompilerKey -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.mtags.MD5 import scala.meta.internal.parsing.Trees import scala.meta.internal.pc.LogMessages @@ -1089,7 +1087,7 @@ class Compilers( jworksheetsCache.put( path, workDoneProgress.trackBlocking( - s"${config.icons.sync}Loading worksheet presentation compiler" + s"${config.icons().sync}Loading worksheet presentation compiler" ) { ScalaLazyCompiler.forWorksheet( scalaTarget, @@ -1126,7 +1124,7 @@ class Compilers( PresentationCompilerKey.JavaBuildTarget(targetId), { _ => workDoneProgress.trackBlocking( - s"${config.icons.sync}Loading presentation compiler" + s"${config.icons().sync}Loading presentation compiler" ) { JavaLazyCompiler(targetId, search) } @@ -1153,7 +1151,7 @@ class Compilers( case Some(mtags) => def default() = workDoneProgress.trackBlocking( - s"${config.icons.sync}Loading presentation compiler" + s"${config.icons().sync}Loading presentation compiler" ) { ScalaLazyCompiler(scalaTarget, mtags, search) } diff --git a/metals/src/main/scala/scala/meta/internal/metals/DefinitionProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/DefinitionProvider.scala index bbccce5d996..a6073bb784d 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/DefinitionProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/DefinitionProvider.scala @@ -10,7 +10,7 @@ import scala.meta.Type import scala.meta.XtensionClassifiable import scala.meta.inputs.Input import scala.meta.inputs.Position.Range -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.mtags.GlobalSymbolIndex import scala.meta.internal.mtags.Mtags import scala.meta.internal.mtags.Semanticdbs @@ -496,8 +496,7 @@ class DestinationProvider( allowedBuildTargets: Set[BuildTargetIdentifier], ): Option[SymbolDefinition] = { val definitions = index.definitions(Symbol(symbol)).filter(_.path.exists) - if (allowedBuildTargets.isEmpty) - definitions.headOption + if (allowedBuildTargets.isEmpty) definitions.headOption else { val matched = definitions.find { defn => sourceBuildTargets(defn.path).exists(id => diff --git a/metals/src/main/scala/scala/meta/internal/metals/Diagnostics.scala b/metals/src/main/scala/scala/meta/internal/metals/Diagnostics.scala index 09d9b38754f..eea42000057 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Diagnostics.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Diagnostics.scala @@ -9,9 +9,9 @@ import scala.collection.mutable import scala.util.Try import scala.meta.inputs.Input -import scala.meta.internal.metals.JsonParser._ -import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.PositionSyntax._ +import scala.meta.internal.metals.MetalsEnrichments.given +import scala.meta.internal.metals.PositionSyntax.given +import scala.meta.internal.metals.JsonParser.given import scala.meta.internal.parsing.TokenEditDistance import scala.meta.internal.parsing.Trees import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/metals/Embedded.scala b/metals/src/main/scala/scala/meta/internal/metals/Embedded.scala index 4cf8f568ad8..5d98f2a6a5e 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Embedded.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Embedded.scala @@ -7,7 +7,7 @@ import java.util.ServiceLoader import scala.collection.concurrent.TrieMap import scala.util.Properties -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.pc.ScalaPresentationCompiler import scala.meta.internal.worksheets.MdocClassLoader import scala.meta.io.Classpath diff --git a/metals/src/main/scala/scala/meta/internal/metals/FallbackMetalsLspService.scala b/metals/src/main/scala/scala/meta/internal/metals/FallbackMetalsLspService.scala index dcfc0a317b0..e17f66eaa0e 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/FallbackMetalsLspService.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/FallbackMetalsLspService.scala @@ -68,7 +68,7 @@ class FallbackMetalsLspService( parseTrees :: compilations.pauseables ) - override protected val semanticdbs: Semanticdbs = interactiveSemanticdbs + override protected def semanticdbs(): Semanticdbs = interactiveSemanticdbs override val fileWatcher: FileWatcher = NoopFileWatcher override val projectInfo: MetalsServiceInfo = MetalsServiceInfo.FallbackService diff --git a/metals/src/main/scala/scala/meta/internal/metals/FileDecoderProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/FileDecoderProvider.scala index c24501c421d..6c1ddb70fc1 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/FileDecoderProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/FileDecoderProvider.scala @@ -461,8 +461,9 @@ final class FileDecoderProvider( .metalsQuickPick(quickPickParams) .asScala .mapOptionInside(_.itemId) - } else + } else { Future.successful(Some(classes.head.resourcePath)) + } private def findSemanticDbPathInfo( sourceFile: AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/metals/FileSystemSemanticdbs.scala b/metals/src/main/scala/scala/meta/internal/metals/FileSystemSemanticdbs.scala index 8d6efb43c79..f95ef7522fe 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/FileSystemSemanticdbs.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/FileSystemSemanticdbs.scala @@ -2,8 +2,8 @@ package scala.meta.internal.metals import java.nio.charset.Charset -import scala.meta.internal.metals.MetalsEnrichments._ import scala.meta.internal.metals.scalacli.ScalaCliServers +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.mtags.Md5Fingerprints import scala.meta.internal.mtags.SemanticdbClasspath import scala.meta.internal.mtags.Semanticdbs diff --git a/metals/src/main/scala/scala/meta/internal/metals/Fingerprints.scala b/metals/src/main/scala/scala/meta/internal/metals/Fingerprints.scala index 09d82a3be9c..e5808ace82e 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Fingerprints.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Fingerprints.scala @@ -4,7 +4,6 @@ import java.nio.file.Paths import java.sql.Connection import java.sql.PreparedStatement -import scala.meta.internal.metals.Fingerprint import scala.meta.internal.metals.JdbcEnrichments._ import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/metals/FormattingProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/FormattingProvider.scala index 3f4bcdfd806..270c8c08960 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/FormattingProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/FormattingProvider.scala @@ -24,7 +24,7 @@ import scala.meta.internal.io.FileIO import scala.meta.internal.metals.Messages.MissingScalafmtConf import scala.meta.internal.metals.Messages.MissingScalafmtVersion import scala.meta.internal.metals.Messages.UpdateScalafmtConf -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.internal.semver.SemVer import scala.meta.io.AbsolutePath @@ -190,7 +190,7 @@ final class FormattingProvider( private def askScalafmtVersion(): Future[Option[String]] = { if (!tables.dismissedNotifications.ChangeScalafmtVersion.isDismissed) { - if (clientConfig.isInputBoxEnabled) { + if (clientConfig.isInputBoxEnabled()) { client .metalsInputBox(MissingScalafmtVersion.inputBox()) .asScala diff --git a/metals/src/main/scala/scala/meta/internal/metals/ForwardingMetalsBuildClient.scala b/metals/src/main/scala/scala/meta/internal/metals/ForwardingMetalsBuildClient.scala index 59f2cf0fd7f..104fe6dca32 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ForwardingMetalsBuildClient.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ForwardingMetalsBuildClient.scala @@ -15,7 +15,8 @@ import scala.meta.internal.metals.ClientConfiguration import scala.meta.internal.metals.ConcurrentHashSet import scala.meta.internal.metals.Diagnostics import scala.meta.internal.metals.MetalsBuildClient -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given +import scala.meta.internal.metals.MetalsEnrichments import scala.meta.internal.metals.StatusBar import scala.meta.internal.metals.TaskProgress import scala.meta.internal.metals.Time @@ -129,7 +130,8 @@ final class ForwardingMetalsBuildClient( def onBuildLogMessage(params: l.MessageParams): Unit = { // NOTE: BazelBsp adds coloring to the log message after `workspaceBuildTargets` request - val noANSICodes = filterANSIColorCodes(params.getMessage).trim() + val noANSICodes = + MetalsEnrichments.filterANSIColorCodes(params.getMessage).trim() if (noANSICodes.nonEmpty) { params.getType match { case l.MessageType.Error => @@ -212,8 +214,8 @@ final class ForwardingMetalsBuildClient( } val isSuccess = report.getErrors == 0 val icon = - if (isSuccess) clientConfig.icons.check - else clientConfig.icons.alert + if (isSuccess) clientConfig.icons().check + else clientConfig.icons().alert val message = s"${icon}Compiled $name (${compilation.timer})" scribe.info(s"time: compiled $name in ${compilation.timer}") if (isSuccess) { diff --git a/metals/src/main/scala/scala/meta/internal/metals/ImportedBuild.scala b/metals/src/main/scala/scala/meta/internal/metals/ImportedBuild.scala index b08d7049ba3..971b7b3746b 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ImportedBuild.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ImportedBuild.scala @@ -7,7 +7,7 @@ import scala.build.bsp.WrappedSourcesResult import scala.concurrent.ExecutionContext import scala.concurrent.Future -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import ch.epfl.scala.bsp4j._ diff --git a/metals/src/main/scala/scala/meta/internal/metals/Indexer.scala b/metals/src/main/scala/scala/meta/internal/metals/Indexer.scala index fda41a0dc1c..87a0d49ba1b 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Indexer.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Indexer.scala @@ -24,7 +24,7 @@ import scala.meta.internal.builds.BuildTool import scala.meta.internal.builds.Digest.Status import scala.meta.internal.builds.WorkspaceReload import scala.meta.internal.implementation.ImplementationProvider -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.clients.language.DelegatingLanguageClient import scala.meta.internal.metals.debug.BuildTargetClasses import scala.meta.internal.metals.watcher.FileWatcher @@ -167,7 +167,7 @@ final case class Indexer( ) tracked.foreach { _ => statusBar().addMessage( - s"${clientConfig.icons.rocket} Indexing complete!" + s"${clientConfig.icons().rocket} Indexing complete!" ) if (clientConfig.initialConfig.statistics.isMemory) { Memory.logMemory( diff --git a/metals/src/main/scala/scala/meta/internal/metals/InitializationOptions.scala b/metals/src/main/scala/scala/meta/internal/metals/InitializationOptions.scala index 3b6cea590d5..d414cf74b8c 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/InitializationOptions.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/InitializationOptions.scala @@ -228,7 +228,7 @@ object CommandHTMLFormat { // The lib used to convert markdown to html in sublime doesn't properly // recognize URL encoding so we have to use hexadecimal html encoding args.flatMap { - case char if toEscape.contains(char) => s"&#x${char.toHexString};" + case char if toEscape.contains(char) => s"&#x${char.toInt.toHexString};" case char => char.toString } } 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 ff9c77e11c8..3b097e3e9a2 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/InteractiveSemanticdbs.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/InteractiveSemanticdbs.scala @@ -6,7 +6,7 @@ import java.util.Collections import scala.util.Success import scala.util.Try -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.scalacli.ScalaCliServers import scala.meta.internal.mtags.MD5 import scala.meta.internal.mtags.Semanticdbs diff --git a/metals/src/main/scala/scala/meta/internal/metals/JarTopLevels.scala b/metals/src/main/scala/scala/meta/internal/metals/JarTopLevels.scala index 2d218d9189e..83d692505aa 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/JarTopLevels.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/JarTopLevels.scala @@ -12,7 +12,7 @@ import java.util.zip.ZipException import scala.meta.internal.io.PlatformFileIO import scala.meta.internal.metals.JarTopLevels.getFileSystem import scala.meta.internal.metals.JdbcEnrichments._ -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.mtags.MD5 import scala.meta.internal.mtags.OverriddenSymbol import scala.meta.internal.mtags.ResolvedOverriddenSymbol diff --git a/metals/src/main/scala/scala/meta/internal/metals/JavaFormattingProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/JavaFormattingProvider.scala index eceb0eae26c..e36e434bf64 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/JavaFormattingProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/JavaFormattingProvider.scala @@ -10,7 +10,7 @@ import scala.util.Try import scala.xml.Node import scala.meta._ -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.io.AbsolutePath import scala.meta.{inputs => m} @@ -63,8 +63,7 @@ final class JavaFormattingProvider( else scribe.error(s"Java formatting profile ${profileName.get} not found") defaultSettings - } else - decodeProfile(profiles.head) + } else decodeProfile(profiles.head) } } diff --git a/metals/src/main/scala/scala/meta/internal/metals/JavaInteractiveSemanticdb.scala b/metals/src/main/scala/scala/meta/internal/metals/JavaInteractiveSemanticdb.scala index 67730a2ee64..54f9d38cdd4 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/JavaInteractiveSemanticdb.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/JavaInteractiveSemanticdb.scala @@ -14,7 +14,7 @@ import scala.util.Try import scala.meta.internal.builds.ShellRunner import scala.meta.internal.io.FileIO -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.mtags.MD5 import scala.meta.internal.pc.JavaMetalsGlobal import scala.meta.internal.{semanticdb => s} diff --git a/metals/src/main/scala/scala/meta/internal/metals/JavaTarget.scala b/metals/src/main/scala/scala/meta/internal/metals/JavaTarget.scala index 5922f1735a7..747dea1c87d 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/JavaTarget.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/JavaTarget.scala @@ -1,7 +1,7 @@ package scala.meta.internal.metals import scala.meta.internal.builds.MillBuildTool -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.semver.SemVer import scala.meta.io.AbsolutePath @@ -14,7 +14,7 @@ case class JavaTarget( javac: JavacOptionsItem, bspConnection: Option[BuildServerConnection], ) extends JvmTarget { - def displayName: String = info.getName + def displayName: String = info.getName() def dataKind: String = info.dataKind diff --git a/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala b/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala index 14b0213cf98..be2c5af6d39 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala @@ -66,7 +66,7 @@ import org.eclipse.{lsp4j => l} * One stop shop for all extension methods that are used in the metals build. * * Usage: {{{ - * import scala.meta.internal.metals.MetalsEnrichments._ + * import scala.meta.internal.metals.MetalsEnrichments.given * List(1).asJava * Future(1).asJava * // ... @@ -215,7 +215,7 @@ object MetalsEnrichments implicit class XtensionScalaFuture[A](future: Future[A]) { def asCancelable: CancelableFuture[A] = - CancelableFuture(future) + CancelableFuture(future, Cancelable.empty) def asJava: CompletableFuture[A] = FutureConverters.toJava(future).toCompletableFuture @@ -443,8 +443,7 @@ object MetalsEnrichments def toRelativeInside(prefix: AbsolutePath): Option[RelativePath] = { // windows throws an exception on toRelative when on different drives - if (path.toNIO.getRoot() != prefix.toNIO.getRoot()) - None + if (path.toNIO.getRoot() != prefix.toNIO.getRoot()) None else { val relative = path.toRelative(prefix) if (relative.toNIO.getName(0).filename != "..") Some(relative) @@ -757,16 +756,13 @@ object MetalsEnrichments def replaceAllBetween(start: String, end: String)( replacement: String ): String = - if (start.isEmpty || end.isEmpty) - value + if (start.isEmpty || end.isEmpty) value else { val startIdx = value.indexOf(start) - if (startIdx < 0) - value + if (startIdx < 0) value else { val endIdx = value.indexOf(end, startIdx + start.length) - if (endIdx < 0) - value + if (endIdx < 0) value else { val b = new java.lang.StringBuilder b.append(value, 0, startIdx) diff --git a/metals/src/main/scala/scala/meta/internal/metals/MetalsHttpServer.scala b/metals/src/main/scala/scala/meta/internal/metals/MetalsHttpServer.scala index 137820cc11b..99b8fd1a7c1 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsHttpServer.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsHttpServer.scala @@ -15,7 +15,7 @@ import scala.util.Success import scala.util.control.NonFatal import scala.meta.internal.io.InputStreamIO -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import io.undertow.Handlers.path import io.undertow.Handlers.websocket diff --git a/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala b/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala index 38e54b01231..5affdcdbc06 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala @@ -28,8 +28,7 @@ import scala.meta.internal.builds.WorkspaceReload import scala.meta.internal.implementation.ImplementationProvider import scala.meta.internal.implementation.Supermethods import scala.meta.internal.io.FileIO -import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.StdReportContext +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.callHierarchy.CallHierarchyProvider import scala.meta.internal.metals.clients.language.ConfiguredLanguageClient import scala.meta.internal.metals.clients.language.ForwardingMetalsBuildClient @@ -308,7 +307,7 @@ abstract class MetalsLspService( folder, buffers, definitionProvider, - clientConfig.icons, + clientConfig.icons(), clientConfig.commandInHtmlFormat(), ) @@ -365,7 +364,7 @@ abstract class MetalsLspService( clientConfig, statusBar, workDoneProgress, - clientConfig.icons, + clientConfig.icons(), tables, buildTargets, ) @@ -408,7 +407,7 @@ abstract class MetalsLspService( val worksheetProvider: WorksheetProvider = { val worksheetPublisher = - if (clientConfig.isDecorationProvider) + if (clientConfig.isDecorationProvider()) new DecorationWorksheetPublisher( clientConfig.isInlineDecorationProvider() ) @@ -478,7 +477,7 @@ abstract class MetalsLspService( languageClient, packageProvider, scalaVersionSelector, - clientConfig.icons, + clientConfig.icons(), onCreate = path => { onCreate(path) onChange(List(path)) @@ -537,7 +536,7 @@ abstract class MetalsLspService( semanticdbs, definitionProvider, referencesProvider, - clientConfig.icons, + clientConfig.icons(), () => compilers, trees, buildTargets, @@ -670,9 +669,11 @@ abstract class MetalsLspService( new Registration( "1", "workspace/didChangeWatchedFiles", - clientConfig.globSyntax.registrationOptions( - this.folder - ), + clientConfig + .globSyntax() + .registrationOptions( + this.folder + ), ) ).asJava ) @@ -1165,7 +1166,7 @@ abstract class MetalsLspService( s"Found new symbol references for $names, try running again." scribe.info(message) statusBar - .addMessage(clientConfig.icons.info + message) + .addMessage(clientConfig.icons().info + message) } } } @@ -1239,7 +1240,7 @@ abstract class MetalsLspService( item: CompletionItem ): CompletableFuture[CompletionItem] = CancelTokens.future { _ => - if (clientConfig.isCompletionItemResolve) { + if (clientConfig.isCompletionItemResolve()) { compilers.completionItemResolve(item) } else { Future.successful(item) @@ -1281,9 +1282,9 @@ abstract class MetalsLspService( CancelTokens.future { _ => val path = params.getTextDocument().getUri().toAbsolutePath if (path.isScala) - parseTrees.currentFuture.map(_ => - foldingRangeProvider.getRangedForScala(path) - ) + parseTrees + .currentFuture() + .map(_ => foldingRangeProvider.getRangedForScala(path)) else Future { foldingRangeProvider.getRangedForJava(path) @@ -1672,7 +1673,7 @@ abstract class MetalsLspService( ): Future[Unit] = { paths .find { path => - if (clientConfig.isDidFocusProvider || focusedDocument().isDefined) { + if (clientConfig.isDidFocusProvider() || focusedDocument().isDefined) { focusedDocument().contains(path) && path.isWorksheet } else { @@ -1702,7 +1703,7 @@ abstract class MetalsLspService( val source = positionParams.getTextDocument.getUri.toAbsolutePath if (source.isScalaFilename || source.isJavaFilename) { val semanticDBDoc = - semanticdbs.textDocument(source).documentIncludingStale + semanticdbs().textDocument(source).documentIncludingStale (for { doc <- semanticDBDoc positionOccurrence = definitionProvider.positionOccurrence( diff --git a/metals/src/main/scala/scala/meta/internal/metals/MetalsServerInputs.scala b/metals/src/main/scala/scala/meta/internal/metals/MetalsServerInputs.scala index 50adbbc106c..b35f887de93 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsServerInputs.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsServerInputs.scala @@ -4,13 +4,6 @@ import java.nio.charset.Charset import java.nio.charset.StandardCharsets import scala.meta.internal.bsp.BspServers -import scala.meta.internal.metals.Buffers -import scala.meta.internal.metals.ClasspathSearch -import scala.meta.internal.metals.MetalsServerConfig -import scala.meta.internal.metals.MtagsResolver -import scala.meta.internal.metals.ProgressTicks -import scala.meta.internal.metals.Time -import scala.meta.internal.metals.UserConfiguration import scala.meta.io.AbsolutePath /** diff --git a/metals/src/main/scala/scala/meta/internal/metals/MetalsSymbolSearch.scala b/metals/src/main/scala/scala/meta/internal/metals/MetalsSymbolSearch.scala index c62598657c8..b701993b12c 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsSymbolSearch.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsSymbolSearch.scala @@ -6,7 +6,7 @@ import java.{util => ju} import scala.collection.concurrent.TrieMap -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.mtags.Mtags import scala.meta.io.AbsolutePath import scala.meta.pc.ContentType 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 0f9ce9de61c..e64b6435c9b 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MtagsResolver.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MtagsResolver.scala @@ -5,7 +5,6 @@ import java.util.concurrent.ConcurrentHashMap import scala.concurrent.duration._ import scala.util.control.NonFatal -import scala.meta.internal.metals.BuildInfo import scala.meta.internal.semver.SemVer trait MtagsResolver { @@ -176,7 +175,6 @@ object MtagsResolver { s"Failed to resolve Scala 3 presentation compiler for $scalaVersion" } scribe.error(errorMsg, fail.exception) - case _ => } state } diff --git a/metals/src/main/scala/scala/meta/internal/metals/PackageProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/PackageProvider.scala index 7a5e0ede4f5..4301f1ca964 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/PackageProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/PackageProvider.scala @@ -6,10 +6,10 @@ import scala.concurrent.Future import scala.{meta => m} import scala.meta._ -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.newScalaFile.NewFileTemplate +import scala.meta.internal.mtags.KeywordWrapper import scala.meta.internal.parsing.Trees -import scala.meta.internal.pc.Identifier import scala.meta.internal.semanticdb.Scala._ import scala.meta.internal.semanticdb.XtensionSemanticdbSymbolInformation import scala.meta.internal.{semanticdb => s} @@ -795,12 +795,14 @@ class PackageProvider( case _ => acc } tree match { - case Source(List(pk: Pkg)) => extractOuterPackage(pk).reverse + case Source(List(pk: Pkg)) => extractOuterPackage(pk).reverse() case _ => PackagesStructure.empty } } - private def wrap(str: String): String = Identifier.backtickWrap(str) + // TODO wrap with correct dialect + private def wrap(str: String): String = + KeywordWrapper.Scala2.backtickWrap(str) private def workspaceEdit( path: AbsolutePath, @@ -891,7 +893,10 @@ class PackageProvider( oldPath: AbsoluteFile, ): WorkspaceEdit = { val extend: (Int, Int) => (Int, Int) = - extendRangeToIncludeWhiteCharsAndTheFollowingNewLine(source, List(':')) + MetalsEnrichments.extendRangeToIncludeWhiteCharsAndTheFollowingNewLine( + source, + List(':'), + ) edits.flatMap { // delete package declaration case PackageEdit(pkg, Nil) => @@ -975,7 +980,7 @@ object PackageProvider { PackagesStructure(pkgs.reverse, pkgObject) def allPackagesParts(): List[List[String]] = pkgs.map(_.name) ++ pkgObject.map(obj => List(obj.name.value)).toList - def allParts(): List[String] = allPackagesParts.flatten + def allParts(): List[String] = allPackagesParts().flatten } object PackagesStructure { diff --git a/metals/src/main/scala/scala/meta/internal/metals/PopupChoiceReset.scala b/metals/src/main/scala/scala/meta/internal/metals/PopupChoiceReset.scala index 746e81205ce..a5641188008 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/PopupChoiceReset.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/PopupChoiceReset.scala @@ -4,7 +4,7 @@ import scala.concurrent.ExecutionContext import scala.concurrent.Future import scala.meta.internal.bsp.BuildChange -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.clients.language.MetalsLanguageClient import org.eclipse.lsp4j.MessageActionItem diff --git a/metals/src/main/scala/scala/meta/internal/metals/ProjectMetalsLspService.scala b/metals/src/main/scala/scala/meta/internal/metals/ProjectMetalsLspService.scala index 4f82ee779b8..6a793690718 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ProjectMetalsLspService.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ProjectMetalsLspService.scala @@ -161,7 +161,7 @@ class ProjectMetalsLspService( folder, buildTargets, statusBar, - clientConfig.icons, + clientConfig.icons(), buildTools, compilations.isCurrentlyCompiling, ) @@ -178,13 +178,15 @@ class ProjectMetalsLspService( compilations.pauseables ) - protected val semanticdbs: Semanticdbs = AggregateSemanticdbs( + private val agregateSemanticdbs: AggregateSemanticdbs = AggregateSemanticdbs( List( fileSystemSemanticdbs, interactiveSemanticdbs, ) ) + protected def semanticdbs(): Semanticdbs = agregateSemanticdbs + val gitHubIssueFolderInfo: GitHubIssueFolderInfo = new GitHubIssueFolderInfo( () => tables.buildTool.selectedBuildTool(), buildTargets, @@ -390,7 +392,7 @@ class ProjectMetalsLspService( def maybeSetupScalaCli(): Future[Unit] = { if ( !buildTools.isAutoConnectable() - && buildTools.loadSupported.isEmpty + && buildTools.loadSupported().isEmpty && (folder.isScalaProject() || focusedDocument().exists(_.isScala)) ) { scalaCli.setupIDE(folder) @@ -767,7 +769,7 @@ class ProjectMetalsLspService( protected def buildTool: Option[BuildTool] = for { name <- tables.buildTool.selectedBuildTool() - buildTool <- buildTools.loadSupported.find(_.executableName == name) + buildTool <- buildTools.loadSupported().find(_.executableName == name) found <- isCompatibleVersion(buildTool) match { case BuildTool.Found(bt, _) => Some(bt) case _ => None @@ -792,7 +794,7 @@ class ProjectMetalsLspService( } def supportedBuildTool(): Future[Option[BuildTool.Found]] = { - buildTools.loadSupported match { + buildTools.loadSupported() match { case Nil => { if (!buildTools.isAutoConnectable()) { warnings.noBuildTool() @@ -1059,7 +1061,7 @@ class ProjectMetalsLspService( session.version, userConfig.bloopVersion.nonEmpty, old.bloopVersion.isDefined, - () => autoConnectToBuildServer, + () => autoConnectToBuildServer(), ) .flatMap { _ => userConfig.bloopJvmProperties diff --git a/metals/src/main/scala/scala/meta/internal/metals/ReferenceProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/ReferenceProvider.scala index d67667b7f47..c210714b343 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ReferenceProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ReferenceProvider.scala @@ -11,8 +11,7 @@ import scala.util.control.NonFatal import scala.util.matching.Regex import scala.meta.Importee -import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.ResolvedSymbolOccurrence +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.mtags.DefinitionAlternatives.GlobalSymbol import scala.meta.internal.mtags.Semanticdbs import scala.meta.internal.mtags.Symbol diff --git a/metals/src/main/scala/scala/meta/internal/metals/ScalaTarget.scala b/metals/src/main/scala/scala/meta/internal/metals/ScalaTarget.scala index ece6bf43800..2cc202990a4 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ScalaTarget.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ScalaTarget.scala @@ -4,7 +4,7 @@ import scala.meta.Dialect import scala.meta.dialects._ import scala.meta.internal.builds.BazelBuildTool import scala.meta.internal.builds.MillBuildTool -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.semver.SemVer import scala.meta.io.AbsolutePath @@ -51,7 +51,7 @@ case class ScalaTarget( } } - def displayName: String = info.getName + def displayName: String = info.getName() def dataKind: String = info.dataKind diff --git a/metals/src/main/scala/scala/meta/internal/metals/ScalaVersionSelector.scala b/metals/src/main/scala/scala/meta/internal/metals/ScalaVersionSelector.scala index 22666a220f3..b4bf5f8c65d 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ScalaVersionSelector.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ScalaVersionSelector.scala @@ -1,7 +1,7 @@ package scala.meta.internal.metals import scala.meta._ -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.semver.SemVer import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/metals/ScalafixProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/ScalafixProvider.scala index 19ed6d09ffd..fade6654908 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ScalafixProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ScalafixProvider.scala @@ -17,7 +17,7 @@ import scala.util.Try import scala.util.control.NonFatal import scala.meta._ -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.internal.metals.clients.language.MetalsQuickPickItem import scala.meta.internal.metals.clients.language.MetalsQuickPickParams diff --git a/metals/src/main/scala/scala/meta/internal/metals/SemanticdbIndexer.scala b/metals/src/main/scala/scala/meta/internal/metals/SemanticdbIndexer.scala index 75740ec7cc2..14a0ff226be 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/SemanticdbIndexer.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/SemanticdbIndexer.scala @@ -6,7 +6,7 @@ import java.nio.file.Path import scala.util.control.NonFatal -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.mtags.SemanticdbClasspath import scala.meta.internal.mtags.SemanticdbPath import scala.meta.internal.semanticdb.TextDocument @@ -59,11 +59,7 @@ class SemanticdbIndexer( * In case of a null path, we re-index `META-INF/semanticdb` for all targets */ def onOverflow(path: SemanticdbPath): Unit = { - if (path == null) { - onTargetRoots() - } else { - path.semanticdbRoot.foreach(onChangeDirectory(_)) - } + path.semanticdbRoot.foreach(onChangeDirectory(_)) } private def onChangeDirectory(dir: Path): Unit = { diff --git a/metals/src/main/scala/scala/meta/internal/metals/ServerCommands.scala b/metals/src/main/scala/scala/meta/internal/metals/ServerCommands.scala index db3d492e065..8b7fb29a35b 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ServerCommands.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ServerCommands.scala @@ -1,6 +1,5 @@ package scala.meta.internal.metals -import java.{util => ju} import javax.annotation.Nullable import scala.meta.internal.metals.newScalaFile.NewFileTypes @@ -649,7 +648,7 @@ object ServerCommands { final case class ConvertToNamedArgsRequest( position: TextDocumentPositionParams, - argIndices: ju.List[Integer], + argIndices: Array[Integer], ) val ConvertToNamedArguments = new ParametrizedCommand[ConvertToNamedArgsRequest]( diff --git a/metals/src/main/scala/scala/meta/internal/metals/SourceMapper.scala b/metals/src/main/scala/scala/meta/internal/metals/SourceMapper.scala index 2501ac1360f..dc36dcb0cb2 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/SourceMapper.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/SourceMapper.scala @@ -2,7 +2,7 @@ package scala.meta.internal.metals import scala.meta.inputs.Input import scala.meta.internal.builds.SbtBuildTool -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.worksheets.WorksheetProvider import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/metals/StacktraceAnalyzer.scala b/metals/src/main/scala/scala/meta/internal/metals/StacktraceAnalyzer.scala index 3337498fad8..a78256a7004 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/StacktraceAnalyzer.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/StacktraceAnalyzer.scala @@ -5,7 +5,7 @@ import java.io.FileWriter import scala.util.Try import scala.util.matching.Regex -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.StacktraceAnalyzer._ import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/metals/StandaloneSymbolSearch.scala b/metals/src/main/scala/scala/meta/internal/metals/StandaloneSymbolSearch.scala index c9f257dabe1..9fca21e0cd5 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/StandaloneSymbolSearch.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/StandaloneSymbolSearch.scala @@ -6,7 +6,7 @@ import java.{util => ju} import scala.collection.concurrent.TrieMap -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.mtags.Mtags import scala.meta.internal.mtags.OnDemandSymbolIndex import scala.meta.internal.parsing.Trees diff --git a/metals/src/main/scala/scala/meta/internal/metals/StatusBar.scala b/metals/src/main/scala/scala/meta/internal/metals/StatusBar.scala index 523ee4c9147..4d96408b813 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/StatusBar.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/StatusBar.scala @@ -7,7 +7,7 @@ import java.util.concurrent.TimeUnit import scala.util.control.NonFatal -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.internal.metals.clients.language.MetalsStatusParams diff --git a/metals/src/main/scala/scala/meta/internal/metals/Tables.scala b/metals/src/main/scala/scala/meta/internal/metals/Tables.scala index 7b8f10f8f35..cf6fe8da1b0 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Tables.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Tables.scala @@ -10,7 +10,7 @@ import java.util.concurrent.atomic.AtomicReference import scala.util.control.NonFatal import scala.meta.internal.builds.Digests -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.pc.InterruptException import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/metals/TargetData.scala b/metals/src/main/scala/scala/meta/internal/metals/TargetData.scala index 5029720f789..12594502b8e 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/TargetData.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/TargetData.scala @@ -15,7 +15,7 @@ import scala.concurrent.Promise import scala.util.Properties import scala.meta.inputs.Input -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.io.AbsolutePath import ch.epfl.scala.bsp4j.BuildTarget diff --git a/metals/src/main/scala/scala/meta/internal/metals/Warnings.scala b/metals/src/main/scala/scala/meta/internal/metals/Warnings.scala index 2e2e6f5c08c..56e4a9a3d48 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Warnings.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Warnings.scala @@ -1,7 +1,7 @@ package scala.meta.internal.metals import scala.meta.internal.builds.BuildTools -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.ScalaVersions._ import scala.meta.internal.metals.clients.language.MetalsStatusParams import scala.meta.internal.metals.logging.MetalsLogger.{silentInTests => logger} diff --git a/metals/src/main/scala/scala/meta/internal/metals/WorksheetDependencySources.scala b/metals/src/main/scala/scala/meta/internal/metals/WorksheetDependencySources.scala index a374f6c879f..c204c643175 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/WorksheetDependencySources.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/WorksheetDependencySources.scala @@ -3,7 +3,7 @@ package scala.meta.internal.metals import java.sql.Connection import scala.meta.internal.metals.JdbcEnrichments._ -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.io.AbsolutePath final class WorksheetDependencySources(conn: () => Connection) { diff --git a/metals/src/main/scala/scala/meta/internal/metals/WorkspaceLspService.scala b/metals/src/main/scala/scala/meta/internal/metals/WorkspaceLspService.scala index a6dd98a1e55..35589e9039c 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/WorkspaceLspService.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/WorkspaceLspService.scala @@ -15,11 +15,7 @@ import scala.util.control.NonFatal import scala.meta.internal.bsp.BuildChange import scala.meta.internal.builds.NewProjectProvider import scala.meta.internal.builds.ShellRunner -import scala.meta.internal.metals.DidFocusResult -import scala.meta.internal.metals.HoverExtParams import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.MetalsLspService -import scala.meta.internal.metals.WindowStateDidChangeParams import scala.meta.internal.metals.clients.language.ConfiguredLanguageClient import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.internal.metals.config.StatusBarState @@ -229,7 +225,7 @@ class WorkspaceLspService( Option.when(fallbackIsInitialized.get())(fallbackService) val treeView: TreeViewProvider = - if (clientConfig.isTreeViewProvider) { + if (clientConfig.isTreeViewProvider()) { new MetalsTreeViewProvider( () => folderServices.map(_.treeView), languageClient, @@ -248,7 +244,7 @@ class WorkspaceLspService( workDoneProgress, clientConfig, shellRunner, - clientConfig.icons, + clientConfig.icons(), () => currentOrHeadOrFallback.path, ) @@ -1152,7 +1148,7 @@ class WorkspaceLspService( ) capabilities.setCompletionProvider( new lsp4j.CompletionOptions( - clientConfig.isCompletionItemResolve, + clientConfig.isCompletionItemResolve(), List(".", "*").asJava, ) ) @@ -1233,7 +1229,7 @@ class WorkspaceLspService( } private def startHttpServer(): Unit = { - if (clientConfig.isHttpEnabled) { + if (clientConfig.isHttpEnabled()) { val host = "localhost" val port = 5031 var url = s"http://$host:$port" @@ -1258,7 +1254,7 @@ class WorkspaceLspService( () => url, languageClient.underlying, () => server.reload(), - clientConfig.icons, + clientConfig.icons(), clientConfig, ) render = () => newClient.renderHtml @@ -1279,14 +1275,14 @@ class WorkspaceLspService( if (shutdownPromise.compareAndSet(null, promise)) { scribe.info("shutting down Metals") try { - folderServices.foreach(_.onShutdown) + folderServices.foreach(_.onShutdown()) } catch { case NonFatal(e) => scribe.error("cancellation error", e) } finally { promise.success(()) } - if (clientConfig.isExitOnShutdown) { + if (clientConfig.isExitOnShutdown()) { System.exit(0) } promise.future.asJava diff --git a/metals/src/main/scala/scala/meta/internal/metals/WorkspaceSearchVisitor.scala b/metals/src/main/scala/scala/meta/internal/metals/WorkspaceSearchVisitor.scala index 8652ed785f7..48e1643976a 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/WorkspaceSearchVisitor.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/WorkspaceSearchVisitor.scala @@ -5,7 +5,7 @@ import java.{util => ju} import scala.collection.mutable -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.mtags.GlobalSymbolIndex import scala.meta.internal.mtags.Symbol import scala.meta.internal.mtags.SymbolDefinition diff --git a/metals/src/main/scala/scala/meta/internal/metals/ammonite/Ammonite.scala b/metals/src/main/scala/scala/meta/internal/metals/ammonite/Ammonite.scala index fe53e2d40d4..50e678aa32e 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ammonite/Ammonite.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ammonite/Ammonite.scala @@ -20,7 +20,7 @@ import scala.util.control.NonFatal import scala.meta.inputs.Input import scala.meta.internal.bsp.BuildChange -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals._ import scala.meta.internal.metals.ammonite.Ammonite.AmmoniteMetalsException import scala.meta.internal.metals.clients.language.ForwardingMetalsBuildClient diff --git a/metals/src/main/scala/scala/meta/internal/metals/callHierarchy/OutgoingCallsFinder.scala b/metals/src/main/scala/scala/meta/internal/metals/callHierarchy/OutgoingCallsFinder.scala index 800373e71f9..33660b30fb3 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/callHierarchy/OutgoingCallsFinder.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/callHierarchy/OutgoingCallsFinder.scala @@ -74,7 +74,7 @@ class OutgoingCallsFinder( range.toLsp ) ) - case _ => false + case null => false } } diff --git a/metals/src/main/scala/scala/meta/internal/metals/clients/language/ConfiguredLanguageClient.scala b/metals/src/main/scala/scala/meta/internal/metals/clients/language/ConfiguredLanguageClient.scala index ab8e8c8ef28..ed7131fbe49 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/clients/language/ConfiguredLanguageClient.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/clients/language/ConfiguredLanguageClient.scala @@ -8,9 +8,9 @@ import scala.concurrent.ExecutionContext import scala.meta.internal.decorations.PublishDecorationsParams import scala.meta.internal.metals.ClientCommands import scala.meta.internal.metals.ClientConfiguration -import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.ServerCommands +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.WorkspaceLspService +import scala.meta.internal.metals.ServerCommands import scala.meta.internal.metals.config.StatusBarState import scala.meta.internal.metals.config.StatusBarState.LogMessage import scala.meta.internal.metals.config.StatusBarState.On @@ -104,7 +104,8 @@ final class ConfiguredLanguageClient( override def logMessage(message: MessageParams): Unit = { if ( - clientConfig.statusBarState == StatusBarState.LogMessage && message.getType == MessageType.Log + clientConfig + .statusBarState() == StatusBarState.LogMessage && message.getType == MessageType.Log ) { // window/logMessage is reserved for the status bar so we don't publish // scribe.{info,warn,error} logs here. Users should look at .metals/metals.log instead. @@ -115,11 +116,11 @@ final class ConfiguredLanguageClient( } override def refreshModel(): CompletableFuture[Unit] = { - if (clientConfig.codeLenseRefreshSupport) + if (clientConfig.codeLenseRefreshSupport()) underlying.refreshCodeLenses.thenApply(_ => ()) else if ( - clientConfig.isExecuteClientCommandProvider && - (clientConfig.isDebuggingProvider || clientConfig.isRunProvider()) + clientConfig.isExecuteClientCommandProvider() && + (clientConfig.isDebuggingProvider() || clientConfig.isRunProvider()) ) { val params = ClientCommands.RefreshModel.toExecuteCommandParams() CompletableFuture.completedFuture(metalsExecuteClientCommand(params)) @@ -158,7 +159,7 @@ final class ConfiguredLanguageClient( override def rawMetalsInputBox( params: MetalsInputBoxParams ): CompletableFuture[RawMetalsInputBoxResult] = { - if (clientConfig.isInputBoxEnabled) { + if (clientConfig.isInputBoxEnabled()) { underlying.rawMetalsInputBox(params) } else { CompletableFuture.completedFuture( @@ -170,7 +171,7 @@ final class ConfiguredLanguageClient( override def rawMetalsQuickPick( params: MetalsQuickPickParams ): CompletableFuture[RawMetalsQuickPickResult] = { - if (clientConfig.isQuickPickProvider) { + if (clientConfig.isQuickPickProvider()) { underlying.rawMetalsQuickPick(params) } else { showMessageRequest( @@ -187,7 +188,7 @@ final class ConfiguredLanguageClient( override def metalsPublishDecorations( params: PublishDecorationsParams ): Unit = { - if (clientConfig.isDecorationProvider) { + if (clientConfig.isDecorationProvider()) { underlying.metalsPublishDecorations(params) } } diff --git a/metals/src/main/scala/scala/meta/internal/metals/clients/language/MetalsHttpClient.scala b/metals/src/main/scala/scala/meta/internal/metals/clients/language/MetalsHttpClient.scala index c950cefad99..51e006e5af0 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/clients/language/MetalsHttpClient.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/clients/language/MetalsHttpClient.scala @@ -10,7 +10,7 @@ import scala.util.Try import scala.meta.internal.decorations.PublishDecorationsParams import scala.meta.internal.io.PathIO -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.clients.language.DelegatingLanguageClient import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.internal.metals.clients.language.MetalsStatusParams @@ -138,7 +138,7 @@ final class MetalsHttpClient( override def metalsPublishDecorations( params: PublishDecorationsParams ): Unit = { - if (clientConfig.isDecorationProvider) { + if (clientConfig.isDecorationProvider()) { underlying.metalsPublishDecorations(params) } } diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/CodeAction.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/CodeAction.scala index 9a1d59c2a39..4e23ef95845 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/CodeAction.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/CodeAction.scala @@ -1,10 +1,9 @@ package scala.meta.internal.metals.codeactions -import scala.annotation.nowarn import scala.concurrent.ExecutionContext import scala.concurrent.Future -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.ParametrizedCommand import scala.meta.pc.CancelToken @@ -22,7 +21,6 @@ trait CodeAction { type ActionCommand = ParametrizedCommand[CommandData] def command: Option[ActionCommand] = None - @nowarn def handleCommand(data: CommandData, token: CancelToken)(implicit ec: ExecutionContext ): Future[Unit] = Future.unit diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/CodeActionProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/CodeActionProvider.scala index b3f7475b8a9..9058b4d1319 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/CodeActionProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/CodeActionProvider.scala @@ -6,7 +6,6 @@ import scala.concurrent.Future import scala.meta.internal.metals._ import scala.meta.internal.metals.clients.language.MetalsLanguageClient -import scala.meta.internal.metals.codeactions.CodeAction import scala.meta.internal.parsing.Trees import scala.meta.pc.CancelToken diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/ConvertCommentCodeAction.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/ConvertCommentCodeAction.scala index b7240872a11..c4e773bbe75 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/ConvertCommentCodeAction.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/ConvertCommentCodeAction.scala @@ -7,7 +7,7 @@ import scala.meta.XtensionDialectApply import scala.meta.XtensionTokenizeDialectInput import scala.meta.internal.metals.Buffers import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.codeactions.CodeAction +import scala.meta._ import scala.meta.internal.metals.codeactions.MillifyScalaCliDependencyCodeAction._ import scala.meta.internal.parsing.Trees import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/ConvertToNamedArguments.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/ConvertToNamedArguments.scala index 692f9ef5423..ad74b46f7d9 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/ConvertToNamedArguments.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/ConvertToNamedArguments.scala @@ -10,8 +10,6 @@ import scala.meta.internal.metals.Compilers import scala.meta.internal.metals.MetalsEnrichments._ import scala.meta.internal.metals.ServerCommands import scala.meta.internal.metals.clients.language.MetalsLanguageClient -import scala.meta.internal.metals.codeactions.CodeAction -import scala.meta.internal.metals.codeactions.CodeActionBuilder import scala.meta.internal.metals.logging import scala.meta.internal.parsing.Trees import scala.meta.pc.CancelToken @@ -41,12 +39,12 @@ class ConvertToNamedArguments( for { edits <- compilers.convertToNamedArguments( data.position, - data.argIndices, + data.argIndices.toList.asJava, token, ) _ = logging.logErrorWhen( edits.isEmpty(), - s"Could not find the correct names for arguments at ${data.position} with indices ${data.argIndices.asScala + s"Could not find the correct names for arguments at ${data.position} with indices ${data.argIndices.toList .mkString(",")}", ) workspaceEdit = new l.WorkspaceEdit(Map(uri -> edits).asJava) @@ -137,7 +135,7 @@ class ConvertToNamedArguments( ServerCommands .ConvertToNamedArgsRequest( position, - apply.argIndices.map(new Integer(_)).asJava, + apply.argIndices.map(new Integer(_)).toArray, ) ) diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/CreateCompanionObjectCodeAction.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/CreateCompanionObjectCodeAction.scala index edc1b248e96..40127f1c8f4 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/CreateCompanionObjectCodeAction.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/CreateCompanionObjectCodeAction.scala @@ -9,10 +9,8 @@ import scala.meta.Term import scala.meta.Tree import scala.meta.inputs.Position import scala.meta.internal.metals.Buffers -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.ServerCommands -import scala.meta.internal.metals.codeactions.CodeAction -import scala.meta.internal.metals.codeactions.CodeActionBuilder import scala.meta.internal.parsing.Trees import scala.meta.io.AbsolutePath import scala.meta.pc.CancelToken diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/CreateNewSymbol.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/CreateNewSymbol.scala index ad143dfa7c5..15b03b040fc 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/CreateNewSymbol.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/CreateNewSymbol.scala @@ -3,10 +3,10 @@ package scala.meta.internal.metals.codeactions import scala.concurrent.ExecutionContext import scala.concurrent.Future -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.ScalacDiagnostic import scala.meta.internal.metals.ServerCommands -import scala.meta.internal.metals.codeactions.CodeAction +import scala.meta.internal.metals._ import scala.meta.pc.CancelToken import org.eclipse.{lsp4j => l} 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..1c156aa1856 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 @@ -17,18 +17,17 @@ import scala.meta.Type import scala.meta.XtensionCollectionLikeUI import scala.meta.XtensionDialectApply import scala.meta.XtensionTokenizeDialectInput -import scala.meta.inputs.Position -import scala.meta.internal.metals.Buffers import scala.meta.internal.metals.ClientCommands -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.ServerCommands +import scala.meta.internal.metals.Buffers import scala.meta.internal.metals.clients.language.MetalsLanguageClient -import scala.meta.internal.metals.codeactions.CodeAction import scala.meta.internal.metals.codeactions.ExtractRenameMember.CodeActionCommandNotFoundException import scala.meta.internal.metals.codeactions.ExtractRenameMember.getMemberType import scala.meta.internal.parsing.Trees import scala.meta.io.AbsolutePath import scala.meta.pc.CancelToken +import scala.meta.Position import scala.meta.tokens.Token import scala.meta.transversers.SimpleTraverser diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/ExtractValueCodeAction.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/ExtractValueCodeAction.scala index a590063f2a4..6d42409d34e 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/ExtractValueCodeAction.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/ExtractValueCodeAction.scala @@ -12,9 +12,7 @@ import scala.meta.Tree import scala.meta.XtensionClassifiable import scala.meta.inputs.Position import scala.meta.internal.metals.Buffers -import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.codeactions.CodeAction -import scala.meta.internal.metals.codeactions.CodeActionBuilder +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.parsing.Trees import scala.meta.pc.CancelToken import scala.meta.tokens.Token diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/FlatMapToForComprehensionCodeAction.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/FlatMapToForComprehensionCodeAction.scala index 43752c30a52..87e98644376 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/FlatMapToForComprehensionCodeAction.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/FlatMapToForComprehensionCodeAction.scala @@ -17,8 +17,6 @@ import scala.meta.XtensionSyntax import scala.meta.inputs.Position import scala.meta.internal.metals.Buffers import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.codeactions.CodeAction -import scala.meta.internal.metals.codeactions.CodeActionBuilder import scala.meta.internal.parsing.Trees import scala.meta.io.AbsolutePath import scala.meta.pc.CancelToken diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/ImplementAbstractMembers.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/ImplementAbstractMembers.scala index e19519db98a..b48ce153d5f 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/ImplementAbstractMembers.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/ImplementAbstractMembers.scala @@ -4,9 +4,9 @@ import scala.concurrent.ExecutionContext import scala.concurrent.Future import scala.meta.internal.metals.Compilers -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.ScalacDiagnostic -import scala.meta.internal.metals.codeactions.CodeAction +import scala.meta.internal.metals._ import scala.meta.pc.CancelToken import org.eclipse.{lsp4j => l} diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/ImportMissingSymbol.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/ImportMissingSymbol.scala index 2b192473917..23d91ae192b 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/ImportMissingSymbol.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/ImportMissingSymbol.scala @@ -5,10 +5,9 @@ import scala.concurrent.Future import scala.meta.internal.metals.BuildTargets import scala.meta.internal.metals.Compilers -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.ScalaVersions import scala.meta.internal.metals.ScalacDiagnostic -import scala.meta.internal.metals.codeactions.CodeAction import scala.meta.pc.CancelToken import org.eclipse.{lsp4j => l} diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/InlineValueCodeAction.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/InlineValueCodeAction.scala index 30350144479..1ded0884df2 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/InlineValueCodeAction.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/InlineValueCodeAction.scala @@ -12,7 +12,6 @@ import scala.meta.internal.metals.Compilers import scala.meta.internal.metals.MetalsEnrichments._ import scala.meta.internal.metals.ServerCommands import scala.meta.internal.metals.clients.language.MetalsLanguageClient -import scala.meta.internal.metals.codeactions.CodeAction import scala.meta.internal.parsing.Trees import scala.meta.io.AbsolutePath import scala.meta.pc.CancelToken diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/InsertInferredType.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/InsertInferredType.scala index b48cb37b498..0b4e762ff82 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/InsertInferredType.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/InsertInferredType.scala @@ -8,12 +8,10 @@ import scala.meta.Enumerator import scala.meta.Pat import scala.meta.Term import scala.meta.internal.metals.Compilers -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.ScalacDiagnostic import scala.meta.internal.metals.ServerCommands import scala.meta.internal.metals.clients.language.MetalsLanguageClient -import scala.meta.internal.metals.codeactions.CodeAction -import scala.meta.internal.metals.codeactions.CodeActionBuilder import scala.meta.internal.parsing.Trees import scala.meta.pc.CancelToken diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/MillifyDependencyCodeAction.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/MillifyDependencyCodeAction.scala index 7a8af7ce431..9c49b8a1c44 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/MillifyDependencyCodeAction.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/MillifyDependencyCodeAction.scala @@ -6,8 +6,7 @@ import scala.concurrent.Future import scala.meta.XtensionDialectApply import scala.meta.XtensionTokenizeDialectInput import scala.meta.internal.metals.Buffers -import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.codeactions.CodeAction +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.parsing.Trees import scala.meta.pc.CancelToken import scala.meta.tokens.Token._ diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/MillifyScalaCliDependencyCodeAction.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/MillifyScalaCliDependencyCodeAction.scala index ffee8ee3742..28d451e9bd1 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/MillifyScalaCliDependencyCodeAction.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/MillifyScalaCliDependencyCodeAction.scala @@ -7,7 +7,6 @@ import scala.meta.XtensionDialectApply import scala.meta.XtensionTokenizeDialectInput import scala.meta.internal.metals.Buffers import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.codeactions.CodeAction import scala.meta.internal.metals.codeactions.MillifyScalaCliDependencyCodeAction._ import scala.meta.internal.parsing.Trees import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/OrganizeImports.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/OrganizeImports.scala index 818da536ef3..515b9d45b92 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/OrganizeImports.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/OrganizeImports.scala @@ -10,8 +10,6 @@ import scala.meta.internal.metals.ScalaTarget import scala.meta.internal.metals.ScalacDiagnostic import scala.meta.internal.metals.ScalafixProvider import scala.meta.internal.metals.clients.language.MetalsLanguageClient -import scala.meta.internal.metals.codeactions.CodeAction -import scala.meta.internal.metals.codeactions.CodeActionBuilder import scala.meta.io.AbsolutePath import scala.meta.pc.CancelToken diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/PatternMatchRefactor.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/PatternMatchRefactor.scala index ce3802dbb57..13772740bcd 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/PatternMatchRefactor.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/PatternMatchRefactor.scala @@ -4,9 +4,7 @@ import scala.concurrent.ExecutionContext import scala.concurrent.Future import scala.meta.Term -import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.codeactions.CodeAction -import scala.meta.internal.metals.codeactions.CodeActionBuilder +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.parsing.Trees import scala.meta.io.AbsolutePath import scala.meta.pc.CancelToken diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/RewriteBracesParensCodeAction.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/RewriteBracesParensCodeAction.scala index e9f022dfc03..e7da6622ccf 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/RewriteBracesParensCodeAction.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/RewriteBracesParensCodeAction.scala @@ -5,9 +5,7 @@ import scala.concurrent.Future import scala.reflect.ClassTag import scala.meta.Term -import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.codeactions.CodeAction -import scala.meta.internal.metals.codeactions.CodeActionBuilder +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.parsing.Trees import scala.meta.io.AbsolutePath import scala.meta.pc.CancelToken @@ -65,7 +63,7 @@ class RewriteBracesParensCodeAction( .getOrElse(Nil) } - private def switchFrom[L: ClassTag, R: ClassTag]( + private def switchFrom[L <: Token: ClassTag, R <: Token: ClassTag]( path: AbsolutePath, appl: Term.Apply, ): Seq[l.CodeAction] = { diff --git a/metals/src/main/scala/scala/meta/internal/metals/codeactions/StringActions.scala b/metals/src/main/scala/scala/meta/internal/metals/codeactions/StringActions.scala index 489770bb155..80abf1d1225 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codeactions/StringActions.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codeactions/StringActions.scala @@ -7,9 +7,7 @@ import scala.meta.XtensionClassifiable import scala.meta.XtensionDialectApply import scala.meta.XtensionTokenizeDialectInput import scala.meta.internal.metals.Buffers -import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.codeactions.CodeAction -import scala.meta.internal.metals.codeactions.CodeActionBuilder +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.parsing.Trees import scala.meta.pc.CancelToken import scala.meta.tokens.Token @@ -33,7 +31,7 @@ class StringActions(buffers: Buffers) extends CodeAction { val tokenized = buffers .get(path) .flatMap(source => - Trees.defaultTokenizerDialect(source).tokenize.toOption + Trees.defaultTokenizerDialect.apply(source).tokenize.toOption ) tokenized match { case Some(tokens) => { diff --git a/metals/src/main/scala/scala/meta/internal/metals/codelenses/RunTestCodeLens.scala b/metals/src/main/scala/scala/meta/internal/metals/codelenses/RunTestCodeLens.scala index b8513241d28..4f645514e11 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codelenses/RunTestCodeLens.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codelenses/RunTestCodeLens.scala @@ -14,7 +14,7 @@ import scala.meta.internal.metals.ClientCommands.StartRunSession import scala.meta.internal.metals.ClientConfiguration import scala.meta.internal.metals.JavaBinary import scala.meta.internal.metals.JsonParser._ -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.TestUserInterfaceKind import scala.meta.internal.metals.UserConfiguration import scala.meta.internal.metals.debug.BuildTargetClasses @@ -333,7 +333,7 @@ final class RunTestCodeLens( .flatMap(scalaTarget => JavaBinary.javaBinaryFromPath(scalaTarget.jvmHome) ) - .orElse(userConfig().usedJavaBinary) + .orElse(userConfig().usedJavaBinary()) val (data, shellCommandAdded) = if (!isJVM) (main.toJson, false) else diff --git a/metals/src/main/scala/scala/meta/internal/metals/codelenses/SuperMethodCodeLens.scala b/metals/src/main/scala/scala/meta/internal/metals/codelenses/SuperMethodCodeLens.scala index 49d8311fea5..a8d5c0966ab 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codelenses/SuperMethodCodeLens.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codelenses/SuperMethodCodeLens.scala @@ -7,7 +7,7 @@ import scala.meta.internal.implementation.SuperMethodProvider import scala.meta.internal.implementation.TextDocumentWithPath import scala.meta.internal.metals.Buffers import scala.meta.internal.metals.ClientConfiguration -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.ServerCommands import scala.meta.internal.metals.UserConfiguration import scala.meta.internal.parsing.Trees @@ -91,13 +91,13 @@ final class SuperMethodCodeLens( ) => val location = new l.Location(path.toURI.toString(), range.toLsp) val command = ServerCommands.GotoPosition.toLsp(location) - command.setTitle(s"${clientConfig.icons.findsuper} ${name}") + command.setTitle(s"${clientConfig.icons().findsuper} ${name}") command } else Some { val command = ServerCommands.GotoSymbol.toLsp(symbol) - command.setTitle(s"${clientConfig.icons.findsuper} ${name}") + command.setTitle(s"${clientConfig.icons().findsuper} ${name}") command } } diff --git a/metals/src/main/scala/scala/meta/internal/metals/codelenses/WorksheetCodeLens.scala b/metals/src/main/scala/scala/meta/internal/metals/codelenses/WorksheetCodeLens.scala index 52e661dbab8..00e24f80e53 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/codelenses/WorksheetCodeLens.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/codelenses/WorksheetCodeLens.scala @@ -5,7 +5,7 @@ import scala.concurrent.Future import scala.meta.internal.metals.ClientCommands.CopyWorksheetOutput import scala.meta.internal.metals.ClientConfiguration -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.io.AbsolutePath import org.eclipse.{lsp4j => l} @@ -14,7 +14,7 @@ class WorksheetCodeLens(clientConfig: ClientConfiguration)(implicit val ec: ExecutionContext ) extends CodeLens { - override def isEnabled: Boolean = clientConfig.isCopyWorksheetOutputProvider + override def isEnabled: Boolean = clientConfig.isCopyWorksheetOutputProvider() override def codeLenses( path: AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/metals/debug/BuildTargetClasses.scala b/metals/src/main/scala/scala/meta/internal/metals/debug/BuildTargetClasses.scala index 0f659c9c101..dfcee8a2a6f 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/debug/BuildTargetClasses.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/debug/BuildTargetClasses.scala @@ -6,7 +6,7 @@ import scala.concurrent.Future import scala.meta.internal.metals.BatchedFunction import scala.meta.internal.metals.BuildTargets -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.debug.BuildTargetClasses.Classes import scala.meta.internal.semanticdb.Scala.Descriptor import scala.meta.internal.semanticdb.Scala.Symbols diff --git a/metals/src/main/scala/scala/meta/internal/metals/debug/BuildTargetClassesFinder.scala b/metals/src/main/scala/scala/meta/internal/metals/debug/BuildTargetClassesFinder.scala index 004202bbc92..a0fca92db3e 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/debug/BuildTargetClassesFinder.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/debug/BuildTargetClassesFinder.scala @@ -33,7 +33,7 @@ class BuildTargetClassesFinder( .classesOf(_) .mainClasses .values, - { (clazz: b.ScalaMainClass) => clazz.getClassName }, + { (clazz: b.ScalaMainClass) => clazz.getClassName() }, ).recoverWith { case ex => val found = ex match { // We check whether there is a main in dependencies that is not reported via BSP diff --git a/metals/src/main/scala/scala/meta/internal/metals/debug/ClientConfigurationAdapter.scala b/metals/src/main/scala/scala/meta/internal/metals/debug/ClientConfigurationAdapter.scala index 8f285ca7c15..aeba2d381f2 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/debug/ClientConfigurationAdapter.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/debug/ClientConfigurationAdapter.scala @@ -4,7 +4,7 @@ import java.nio.file.Paths import scala.util.control.NonFatal -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.SourceMapper import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProtocol.scala b/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProtocol.scala index ce9399b1ed9..1786450761c 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProtocol.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProtocol.scala @@ -5,7 +5,7 @@ import scala.util.Failure import scala.util.Success import scala.util.Try -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.debug.DebugProxy.DebugMode import com.google.gson.JsonElement diff --git a/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProvider.scala index c67b97b925a..2f528a4d632 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProvider.scala @@ -34,7 +34,7 @@ import scala.meta.internal.metals.JsonParser._ import scala.meta.internal.metals.Messages import scala.meta.internal.metals.Messages.UnresolvedDebugSessionParams import scala.meta.internal.metals.MetalsBuildClient -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.MutableCancelable import scala.meta.internal.metals.ScalaTestSuites import scala.meta.internal.metals.ScalaTestSuitesDebugRequest @@ -501,7 +501,7 @@ class DebugProvider( debugParams: DebugSessionParams )(implicit ec: ExecutionContext): Future[DebugSession] = { for { - server <- start(debugParams), + server <- start(debugParams) } yield { statusBar.addMessage("Started debug server!") DebugSession(server.sessionName, server.uri.toString) @@ -533,7 +533,7 @@ class DebugProvider( .flatMap(scalaTarget => JavaBinary.javaBinaryFromPath(scalaTarget.jvmHome) ) - .orElse(userConfig().usedJavaBinary) + .orElse(userConfig().usedJavaBinary()) buildTargetClasses .jvmRunEnvironment(params.getTargets().get(0)) .map { envItem => @@ -801,7 +801,7 @@ class DebugProvider( case e @ SemanticDbNotFoundException => languageClient.metalsStatus( MetalsStatusParams( - text = s"${clientConfig.icons.alert}Build misconfiguration", + text = s"${clientConfig.icons().alert}Build misconfiguration", tooltip = e.getMessage(), command = ClientCommands.RunDoctor.id, ) diff --git a/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProxy.scala b/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProxy.scala index 914ad5ad8c3..b7b26c0ea49 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProxy.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/debug/DebugProxy.scala @@ -18,7 +18,8 @@ import scala.meta.internal.metals.Compilations import scala.meta.internal.metals.Compilers import scala.meta.internal.metals.EmptyCancelToken import scala.meta.internal.metals.JsonParser._ -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.SourceMapper import scala.meta.internal.metals.StacktraceAnalyzer import scala.meta.internal.metals.Trace @@ -272,7 +273,7 @@ private[debug] final class DebugProxy( case message @ OutputNotification(output) if stripColor => val raw = output.getOutput() - val msgWithoutColorCodes = filterANSIColorCodes(raw) + val msgWithoutColorCodes = MetalsEnrichments.filterANSIColorCodes(raw) output.setOutput(msgWithoutColorCodes) message.setParams(output) client.consume(message) diff --git a/metals/src/main/scala/scala/meta/internal/metals/debug/DotEnvFileParser.scala b/metals/src/main/scala/scala/meta/internal/metals/debug/DotEnvFileParser.scala index 4d307cd202d..b04bc4428f9 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/debug/DotEnvFileParser.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/debug/DotEnvFileParser.scala @@ -8,7 +8,7 @@ import scala.util.matching.Regex import scala.util.matching.Regex.Groups import scala.meta.internal.io.FileIO -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.io.AbsolutePath object DotEnvFileParser { diff --git a/metals/src/main/scala/scala/meta/internal/metals/debug/EndpointLogger.scala b/metals/src/main/scala/scala/meta/internal/metals/debug/EndpointLogger.scala index 67febe12dc5..ab0e99ad946 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/debug/EndpointLogger.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/debug/EndpointLogger.scala @@ -60,8 +60,8 @@ final class EndpointLogger(endpoint: RemoteEndpoint, logger: PrintWriter) object EndpointLogger { sealed trait Direction - final case object Received extends Direction - final case object Sent extends Direction + case object Received extends Direction + case object Sent extends Direction private def serializer: MessageJsonHandler = { val configure: Consumer[GsonBuilder] = { gson => gson.setPrettyPrinting() } diff --git a/metals/src/main/scala/scala/meta/internal/metals/debug/SourcePathAdapter.scala b/metals/src/main/scala/scala/meta/internal/metals/debug/SourcePathAdapter.scala index 56b89cf2ced..90929d60b0e 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/debug/SourcePathAdapter.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/debug/SourcePathAdapter.scala @@ -5,7 +5,7 @@ import java.net.URI import scala.meta.internal.io.FileIO import scala.meta.internal.metals.BuildTargets import scala.meta.internal.metals.Directories -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.io.AbsolutePath import ch.epfl.scala.bsp4j.BuildTargetIdentifier diff --git a/metals/src/main/scala/scala/meta/internal/metals/doctor/Doctor.scala b/metals/src/main/scala/scala/meta/internal/metals/doctor/Doctor.scala index c2e69ee1e7d..af18fa983f5 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/doctor/Doctor.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/doctor/Doctor.scala @@ -30,7 +30,7 @@ import scala.meta.internal.metals.JavaTarget import scala.meta.internal.metals.JdkSources import scala.meta.internal.metals.JdkVersion import scala.meta.internal.metals.Messages.CheckDoctor -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.MtagsResolver import scala.meta.internal.metals.PopupChoiceReset import scala.meta.internal.metals.Report @@ -341,7 +341,7 @@ final class Doctor( selectedBuildToolMessage().foreach { case (msg, explicitChoice) => html.element("p")( _.text(msg) - .optionally(!clientConfig.isHttpEnabled && explicitChoice)( + .optionally(!clientConfig.isHttpEnabled() && explicitChoice)( _.text(" (") .link(resetChoiceCommand(PopupChoiceReset.BuildTool), "Reset") .text(")") @@ -352,7 +352,7 @@ final class Doctor( selectedImportBuildMessage().foreach { msg => html.element("p")( _.text(msg) - .optionally(!clientConfig.isHttpEnabled)( + .optionally(!clientConfig.isHttpEnabled())( _.text(" (") .link(resetChoiceCommand(PopupChoiceReset.BuildImport), "Reset") .text(")") @@ -369,7 +369,7 @@ final class Doctor( if (explicitChoice) { html.element("p")( _.text(message) - .optionally(!clientConfig.isHttpEnabled)( + .optionally(!clientConfig.isHttpEnabled())( _.text(" (") .link(resetChoiceCommand(PopupChoiceReset.BuildServer), "Reset") .text(")") diff --git a/metals/src/main/scala/scala/meta/internal/metals/doctor/HeadDoctor.scala b/metals/src/main/scala/scala/meta/internal/metals/doctor/HeadDoctor.scala index 8b6b974ab13..6d1b4343fe5 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/doctor/HeadDoctor.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/doctor/HeadDoctor.scala @@ -73,9 +73,10 @@ class HeadDoctor( val shouldDisplay = isVisibilityProvider && isVisible.get() if (shouldDisplay || !isVisibilityProvider) { if ( - clientConfig.isExecuteClientCommandProvider && !clientConfig.isHttpEnabled + clientConfig.isExecuteClientCommandProvider() && !clientConfig + .isHttpEnabled() ) { - val output = clientConfig.doctorFormat match { + val output = clientConfig.doctorFormat() match { case DoctorFormat.Json => buildTargetsJson() case DoctorFormat.Html => buildTargetsHtml() } diff --git a/metals/src/main/scala/scala/meta/internal/metals/doctor/ProblemResolver.scala b/metals/src/main/scala/scala/meta/internal/metals/doctor/ProblemResolver.scala index c745e6f0e22..3e83eadef1d 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/doctor/ProblemResolver.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/doctor/ProblemResolver.scala @@ -9,7 +9,7 @@ import scala.meta.internal.metals.JavaTarget import scala.meta.internal.metals.JdkSources import scala.meta.internal.metals.JdkVersion import scala.meta.internal.metals.Messages -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.MtagsResolver import scala.meta.internal.metals.ScalaTarget import scala.meta.internal.metals.ScalaVersions diff --git a/metals/src/main/scala/scala/meta/internal/metals/findfiles/FindTextInDependencyJars.scala b/metals/src/main/scala/scala/meta/internal/metals/findfiles/FindTextInDependencyJars.scala index a3562f396e5..3fd895bf15f 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/findfiles/FindTextInDependencyJars.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/findfiles/FindTextInDependencyJars.scala @@ -11,7 +11,7 @@ import scala.util.control.NonFatal import scala.meta.internal.io.FileIO import scala.meta.internal.metals.BuildTargets -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.PathMatcher.Nio import scala.meta.internal.metals.clients.language.MetalsInputBoxParams import scala.meta.internal.metals.clients.language.MetalsLanguageClient diff --git a/metals/src/main/scala/scala/meta/internal/metals/formatting/IndentOnPaste.scala b/metals/src/main/scala/scala/meta/internal/metals/formatting/IndentOnPaste.scala index 9756eb6aa66..ebcfc825983 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/formatting/IndentOnPaste.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/formatting/IndentOnPaste.scala @@ -1,7 +1,7 @@ package scala.meta.internal.metals.formatting import scala.util.matching.Regex -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.UserConfiguration import org.eclipse.lsp4j.Position diff --git a/metals/src/main/scala/scala/meta/internal/metals/formatting/OnTypeFormattingProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/formatting/OnTypeFormattingProvider.scala index a4bad0f0366..bf9fff2d2df 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/formatting/OnTypeFormattingProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/formatting/OnTypeFormattingProvider.scala @@ -2,7 +2,7 @@ package scala.meta.internal.metals.formatting import scala.meta.inputs.Input import scala.meta.internal.metals.Buffers -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.UserConfiguration import scala.meta.internal.parsing.Trees import scala.meta.tokens.Tokens diff --git a/metals/src/main/scala/scala/meta/internal/metals/formatting/RangeFormattingProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/formatting/RangeFormattingProvider.scala index 57d2b0f33ba..ae73173b834 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/formatting/RangeFormattingProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/formatting/RangeFormattingProvider.scala @@ -2,7 +2,7 @@ package scala.meta.internal.metals.formatting import scala.meta.inputs.Input import scala.meta.internal.metals.Buffers -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.UserConfiguration import scala.meta.internal.parsing.Trees import scala.meta.tokens.Tokens diff --git a/metals/src/main/scala/scala/meta/internal/metals/newScalaFile/NewFileProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/newScalaFile/NewFileProvider.scala index 99c8391b48e..383fea111b8 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/newScalaFile/NewFileProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/newScalaFile/NewFileProvider.scala @@ -12,7 +12,7 @@ import scala.meta.internal.builds.NewProjectProvider import scala.meta.internal.metals.ClientCommands import scala.meta.internal.metals.Icons import scala.meta.internal.metals.Messages.NewScalaFile -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.PackageProvider import scala.meta.internal.metals.ScalaVersionSelector import scala.meta.internal.metals.ScalaVersions @@ -20,7 +20,7 @@ import scala.meta.internal.metals.clients.language.MetalsInputBoxParams import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.internal.metals.clients.language.MetalsQuickPickParams import scala.meta.internal.metals.newScalaFile.NewFileTypes._ -import scala.meta.internal.pc.Identifier +import scala.meta.internal.mtags.KeywordWrapper import scala.meta.io.AbsolutePath import org.eclipse.lsp4j.Location @@ -191,7 +191,8 @@ class NewFileProvider( ): Future[(AbsolutePath, Range)] = { val path = directory.resolve(name + ext) // name can be actually be "foo/Name", where "foo" is a folder to create - val className = Identifier.backtickWrap( + // TODO use correct wrapper + val className = KeywordWrapper.Scala2.backtickWrap( directory.resolve(name).filename ) val template = kind match { diff --git a/metals/src/main/scala/scala/meta/internal/metals/scalacli/ScalaCliServers.scala b/metals/src/main/scala/scala/meta/internal/metals/scalacli/ScalaCliServers.scala index 96499b78562..439a2ca675f 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/scalacli/ScalaCliServers.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/scalacli/ScalaCliServers.scala @@ -112,7 +112,7 @@ class ScalaCliServers( def cancel(): Unit = { val servers = serversRef.getAndSet(Queue.empty) servers.foreach(_.cancel()) - servers.foreach(_.customWorkspace.foreach(_.deleteRecursively)) + servers.foreach(_.customWorkspace.foreach(_.deleteRecursively())) } def loaded(path: AbsolutePath): Boolean = @@ -136,12 +136,12 @@ class ScalaCliServers( AbsolutePath( Files.createTempDirectory(s"metals-scala-cli") ) - val Some(workspace) = + val workspace = scalaCliBuildDirectory.updateAndGet { case None => Some(tmpFile) case some => some } - workspace + workspace.get } // When path and workspace have different roots on Windows `scala-cli` throws an error, diff --git a/metals/src/main/scala/scala/meta/internal/metals/testProvider/BuildTargetUpdate.scala b/metals/src/main/scala/scala/meta/internal/metals/testProvider/BuildTargetUpdate.scala index b23cf4ccb14..64d54a20df5 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/testProvider/BuildTargetUpdate.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/testProvider/BuildTargetUpdate.scala @@ -1,6 +1,6 @@ package scala.meta.internal.metals.testProvider -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.io.AbsolutePath import ch.epfl.scala.bsp4j.BuildTarget diff --git a/metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuitesProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuitesProvider.scala index 27dcb82dde7..f6988ade6d2 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuitesProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuitesProvider.scala @@ -12,7 +12,7 @@ import scala.meta.internal.metals.BuildTargets import scala.meta.internal.metals.ClientCommands import scala.meta.internal.metals.ClientConfiguration import scala.meta.internal.metals.JsonParser._ -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.ScalaTestSuiteSelection import scala.meta.internal.metals.ScalaTestSuites import scala.meta.internal.metals.SemanticdbFeatureProvider @@ -365,7 +365,7 @@ final class TestSuitesProvider( // filter out sbt builds .filterNot(_.isSbtBuild) .map { buildTarget => - SymbolsPerTarget( + SymbolsPerTarget.apply( buildTarget, buildTargetClasses.classesOf(buildTarget.getId).testClasses, ) diff --git a/metals/src/main/scala/scala/meta/internal/metals/testProvider/frameworks/JunitTestFinder.scala b/metals/src/main/scala/scala/meta/internal/metals/testProvider/frameworks/JunitTestFinder.scala index da6ea3ebae7..4a1748ed04c 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/testProvider/frameworks/JunitTestFinder.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/testProvider/frameworks/JunitTestFinder.scala @@ -2,7 +2,7 @@ package scala.meta.internal.metals.testProvider.frameworks import scala.reflect.NameTransformer -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.testProvider.TestCaseEntry import scala.meta.internal.mtags import scala.meta.internal.semanticdb.SymbolInformation 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 d3f869647c5..88df27acace 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 @@ -9,7 +9,7 @@ import scala.meta.Lit import scala.meta.Template import scala.meta.Term import scala.meta.Tree -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.testProvider.FullyQualifiedName import scala.meta.internal.metals.testProvider.TestCaseEntry import scala.meta.internal.metals.testProvider.frameworks.TreeUtils._ diff --git a/metals/src/main/scala/scala/meta/internal/metals/testProvider/frameworks/ScalatestTestFinder.scala b/metals/src/main/scala/scala/meta/internal/metals/testProvider/frameworks/ScalatestTestFinder.scala index 633c7857420..4ab8e49b0b9 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/testProvider/frameworks/ScalatestTestFinder.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/testProvider/frameworks/ScalatestTestFinder.scala @@ -5,12 +5,11 @@ import scala.meta.Stat import scala.meta.Template import scala.meta.Term import scala.meta.Tree -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.testProvider.FullyQualifiedName import scala.meta.internal.metals.testProvider.TestCaseEntry import scala.meta.internal.metals.testProvider.frameworks.ScalatestStyle._ import scala.meta.internal.metals.testProvider.frameworks.ScalatestTestFinder._ -import scala.meta.internal.metals.testProvider.frameworks.TreeUtils import scala.meta.internal.mtags import scala.meta.internal.parsing.Trees import scala.meta.internal.semanticdb.ClassSignature @@ -114,10 +113,10 @@ object ScalatestTestFinder { ): Vector[TestCaseEntry] = { // collect all entries like test("testname") { ... } template.stats.collect { - // format: off - case Term.Apply(appl @ Term.Apply(Term.Name(funName), Lit.String(testname) :: _), _) - if style.leafMethods.contains(funName) => - // format: on + case Term.Apply( + appl @ Term.Apply(Term.Name(funName), Lit.String(testname) :: _), + _, + ) if style.leafMethods.contains(funName) => TestCaseEntry(testname, appl.pos.toLsp.toLocation(path.toURI)) }.toVector } diff --git a/metals/src/main/scala/scala/meta/internal/parsing/ClassFinder.scala b/metals/src/main/scala/scala/meta/internal/parsing/ClassFinder.scala index 8c041b7f9a1..5dc0dbd9231 100644 --- a/metals/src/main/scala/scala/meta/internal/parsing/ClassFinder.scala +++ b/metals/src/main/scala/scala/meta/internal/parsing/ClassFinder.scala @@ -12,8 +12,7 @@ import scala.meta.Self import scala.meta.Tree import scala.meta.Type import scala.meta.XtensionClassifiable -import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.parsing.Trees +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.parsing.finder.ClassKind import scala.meta.internal.parsing.finder.MangledClassName import scala.meta.internal.parsing.finder.ShortClassName 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..63917a2a18c 100644 --- a/metals/src/main/scala/scala/meta/internal/parsing/DocumentSymbolProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/parsing/DocumentSymbolProvider.scala @@ -3,7 +3,7 @@ package scala.meta.internal.parsing import java.util import scala.meta._ -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.transversers.SimpleTraverser import scala.meta.trees.Origin diff --git a/metals/src/main/scala/scala/meta/internal/parsing/FoldingRangeExtractor.scala b/metals/src/main/scala/scala/meta/internal/parsing/FoldingRangeExtractor.scala index e0c494ae09b..e388e6e70b0 100644 --- a/metals/src/main/scala/scala/meta/internal/parsing/FoldingRangeExtractor.scala +++ b/metals/src/main/scala/scala/meta/internal/parsing/FoldingRangeExtractor.scala @@ -7,8 +7,8 @@ import scala.collection.mutable import scala.reflect.ClassTag import scala.meta._ -import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.PositionSyntax._ +import scala.meta.internal.metals.MetalsEnrichments.given +import scala.meta.internal.metals.PositionSyntax.given import scala.meta.tokens.Token import org.eclipse.lsp4j.FoldingRange @@ -333,7 +333,7 @@ final class FoldingRangeExtractor( } } - private def findTermFoldStartAndAdjustment[T: ClassTag]( + private def findTermFoldStartAndAdjustment[T <: Token: ClassTag]( trailingTokens: Iterator[Token], startFoldIfEOL: Boolean, ): Option[(Int, Boolean)] = { @@ -361,7 +361,7 @@ final class FoldingRangeExtractor( } } - private def getFoldingRangeForBlockAfterKeyword[T: ClassTag]( + private def getFoldingRangeForBlockAfterKeyword[T <: Token: ClassTag]( block: Term.Block ): Option[Position] = { val firstToken = block.leadingTokens diff --git a/metals/src/main/scala/scala/meta/internal/parsing/FoldingRangeProvider.scala b/metals/src/main/scala/scala/meta/internal/parsing/FoldingRangeProvider.scala index 762e11cb607..1fe4bfea377 100644 --- a/metals/src/main/scala/scala/meta/internal/parsing/FoldingRangeProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/parsing/FoldingRangeProvider.scala @@ -6,7 +6,7 @@ import java.util.Collections import scala.meta.inputs.Input import scala.meta.inputs.Position import scala.meta.internal.metals.Buffers -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.parsing.FoldingRangeProvider._ import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/parsing/JavaFoldingRangeExtractor.scala b/metals/src/main/scala/scala/meta/internal/parsing/JavaFoldingRangeExtractor.scala index b4d8ee7c722..da4396abe41 100644 --- a/metals/src/main/scala/scala/meta/internal/parsing/JavaFoldingRangeExtractor.scala +++ b/metals/src/main/scala/scala/meta/internal/parsing/JavaFoldingRangeExtractor.scala @@ -19,7 +19,7 @@ import com.sun.source.util.Trees import org.eclipse.lsp4j.FoldingRange import org.eclipse.lsp4j.FoldingRangeKind -final object JavaFoldingRangeExtractor { +object JavaFoldingRangeExtractor { private val spanThreshold = 2 private case class Range( diff --git a/metals/src/main/scala/scala/meta/internal/parsing/TokenEditDistance.scala b/metals/src/main/scala/scala/meta/internal/parsing/TokenEditDistance.scala index e3fda760469..c078a9c38b9 100644 --- a/metals/src/main/scala/scala/meta/internal/parsing/TokenEditDistance.scala +++ b/metals/src/main/scala/scala/meta/internal/parsing/TokenEditDistance.scala @@ -10,7 +10,7 @@ import scala.util.Success import scala.meta.Input import scala.meta.Position -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.parsing.TokenOps.syntax._ import scala.meta.internal.{semanticdb => s} import scala.meta.tokenizers.Tokenized diff --git a/metals/src/main/scala/scala/meta/internal/parsing/Trees.scala b/metals/src/main/scala/scala/meta/internal/parsing/Trees.scala index 56803003e9c..3c9bda5cdd1 100644 --- a/metals/src/main/scala/scala/meta/internal/parsing/Trees.scala +++ b/metals/src/main/scala/scala/meta/internal/parsing/Trees.scala @@ -6,7 +6,7 @@ import scala.reflect.ClassTag import scala.meta._ import scala.meta.inputs.Position import scala.meta.internal.metals.Buffers -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.Report import scala.meta.internal.metals.ReportContext import scala.meta.internal.metals.ScalaVersionSelector diff --git a/metals/src/main/scala/scala/meta/internal/rename/RenameProvider.scala b/metals/src/main/scala/scala/meta/internal/rename/RenameProvider.scala index be7557106ac..dd4ac5c5170 100644 --- a/metals/src/main/scala/scala/meta/internal/rename/RenameProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/rename/RenameProvider.scala @@ -14,13 +14,13 @@ import scala.meta.internal.metals.ClientConfiguration import scala.meta.internal.metals.Compilations import scala.meta.internal.metals.Compilers import scala.meta.internal.metals.DefinitionProvider -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.ReferenceProvider import scala.meta.internal.metals.ReportContext import scala.meta.internal.metals.TextEdits import scala.meta.internal.metals.clients.language.MetalsLanguageClient +import scala.meta.internal.mtags.KeywordWrapper import scala.meta.internal.parsing.Trees -import scala.meta.internal.pc.Identifier import scala.meta.internal.search.SymbolHierarchyOps import scala.meta.internal.semanticdb.Scala._ import scala.meta.internal.semanticdb.SelectTree @@ -161,7 +161,8 @@ final class RenameProvider( if (suggestedName.isBackticked) suggestedName.stripBackticks else suggestedName - val newName = Identifier.backtickWrap(withoutBackticks) + val newName = + KeywordWrapper.Scala2.backtickWrap(withoutBackticks) def isNotRenamedSymbol( textDocument: TextDocument, @@ -287,10 +288,12 @@ final class RenameProvider( } val fileChanges = allChanges.flatten.toMap val shouldRenameInBackground = - !clientConfig.isOpenFilesOnRenameProvider || fileChanges.keySet.size >= clientConfig.renameFileThreshold + !clientConfig + .isOpenFilesOnRenameProvider() || fileChanges.keySet.size >= clientConfig + .renameFileThreshold() val (openedEdits, closedEdits) = if (shouldRenameInBackground) { - if (clientConfig.isOpenFilesOnRenameProvider) { + if (clientConfig.isOpenFilesOnRenameProvider()) { client.showMessage(fileThreshold(fileChanges.keySet.size)) } fileChanges.partition { case (path, _) => diff --git a/metals/src/main/scala/scala/meta/internal/tvp/ClasspathTreeView.scala b/metals/src/main/scala/scala/meta/internal/tvp/ClasspathTreeView.scala index f94ea152f67..26cb95f725d 100644 --- a/metals/src/main/scala/scala/meta/internal/tvp/ClasspathTreeView.scala +++ b/metals/src/main/scala/scala/meta/internal/tvp/ClasspathTreeView.scala @@ -1,7 +1,7 @@ package scala.meta.internal.tvp import scala.meta.internal.metals.Folder -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.mtags.GlobalSymbolIndex import scala.meta.internal.mtags.Symbol import scala.meta.internal.semanticdb.Scala._ diff --git a/metals/src/main/scala/scala/meta/internal/tvp/MetalsTreeViewProvider.scala b/metals/src/main/scala/scala/meta/internal/tvp/MetalsTreeViewProvider.scala index 7ffb0429971..866a85b6ec3 100644 --- a/metals/src/main/scala/scala/meta/internal/tvp/MetalsTreeViewProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/tvp/MetalsTreeViewProvider.scala @@ -7,7 +7,7 @@ import scala.collection.concurrent.TrieMap import scala.meta.Dialect import scala.meta.dialects -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.ReportContext import scala.meta.internal.metals._ import scala.meta.internal.metals.clients.language.MetalsLanguageClient @@ -198,7 +198,7 @@ class MetalsTreeViewProvider( if (params.visible) { params.viewId match { case TreeViewProvider.Project => - val toUpdate = trees.map(_.flushPendingProjectUpdates).collect { + val toUpdate = trees.map(_.flushPendingProjectUpdates()).collect { case Some(value) => value } if (toUpdate.nonEmpty) { diff --git a/metals/src/main/scala/scala/meta/internal/worksheets/DecorationWorksheetPublisher.scala b/metals/src/main/scala/scala/meta/internal/worksheets/DecorationWorksheetPublisher.scala index 1445c8f0693..2811b87c842 100644 --- a/metals/src/main/scala/scala/meta/internal/worksheets/DecorationWorksheetPublisher.scala +++ b/metals/src/main/scala/scala/meta/internal/worksheets/DecorationWorksheetPublisher.scala @@ -4,7 +4,7 @@ import scala.meta.internal.decorations.DecorationOptions import scala.meta.internal.decorations.PublishDecorationsParams import scala.meta.internal.decorations.ThemableDecorationAttachmentRenderOptions import scala.meta.internal.decorations.ThemableDecorationInstanceRenderOptions -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.internal.pc.HoverMarkup import scala.meta.internal.worksheets.MdocEnrichments._ diff --git a/metals/src/main/scala/scala/meta/internal/worksheets/MdocEnrichments.scala b/metals/src/main/scala/scala/meta/internal/worksheets/MdocEnrichments.scala index d8ae80113a3..2a039bec292 100644 --- a/metals/src/main/scala/scala/meta/internal/worksheets/MdocEnrichments.scala +++ b/metals/src/main/scala/scala/meta/internal/worksheets/MdocEnrichments.scala @@ -45,7 +45,6 @@ object MdocEnrichments { case i.DiagnosticSeverity.Info => l.DiagnosticSeverity.Information case i.DiagnosticSeverity.Warning => l.DiagnosticSeverity.Warning case i.DiagnosticSeverity.Error => l.DiagnosticSeverity.Error - case _ => l.DiagnosticSeverity.Error }, "mdoc", ) diff --git a/metals/src/main/scala/scala/meta/internal/worksheets/WorksheetProvider.scala b/metals/src/main/scala/scala/meta/internal/worksheets/WorksheetProvider.scala index 66c5110d320..a29830332a2 100644 --- a/metals/src/main/scala/scala/meta/internal/worksheets/WorksheetProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/worksheets/WorksheetProvider.scala @@ -27,7 +27,7 @@ import scala.meta.internal.metals.Compilations import scala.meta.internal.metals.Diagnostics import scala.meta.internal.metals.Embedded import scala.meta.internal.metals.Messages -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.MetalsServerConfig import scala.meta.internal.metals.MutableCancelable import scala.meta.internal.metals.ScalaVersionSelector diff --git a/metals/src/main/scala/scala/meta/internal/worksheets/WorkspaceEditWorksheetPublisher.scala b/metals/src/main/scala/scala/meta/internal/worksheets/WorkspaceEditWorksheetPublisher.scala index 3bafadd3d7a..04704b11192 100644 --- a/metals/src/main/scala/scala/meta/internal/worksheets/WorkspaceEditWorksheetPublisher.scala +++ b/metals/src/main/scala/scala/meta/internal/worksheets/WorkspaceEditWorksheetPublisher.scala @@ -2,7 +2,7 @@ package scala.meta.internal.worksheets import scala.meta.inputs.Input import scala.meta.internal.metals.Buffers -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.internal.parsing.Trees import scala.meta.internal.pc.HoverMarkup diff --git a/mtags-java/src/main/scala/scala/meta/internal/pc/JavaHover.scala b/mtags-java/src/main/scala/scala/meta/internal/pc/JavaHover.scala index 3e1bb16e996..fbc708ee214 100644 --- a/mtags-java/src/main/scala/scala/meta/internal/pc/JavaHover.scala +++ b/mtags-java/src/main/scala/scala/meta/internal/pc/JavaHover.scala @@ -2,7 +2,7 @@ package scala.meta.internal.pc import java.util.Optional -import scala.meta.internal.mtags.CommonMtagsEnrichments._ +import scala.meta.internal.mtags.CommonMtagsEnrichments.given import scala.meta.pc.ContentType import scala.meta.pc.ContentType.MARKDOWN import scala.meta.pc.HoverSignature diff --git a/mtags/src/main/scala-2/scala/meta/internal/mtags/MtagsEnrichments.scala b/mtags/src/main/scala-2/scala/meta/internal/mtags/MtagsEnrichments.scala index 1db80b39651..790dfce0afa 100644 --- a/mtags/src/main/scala-2/scala/meta/internal/mtags/MtagsEnrichments.scala +++ b/mtags/src/main/scala-2/scala/meta/internal/mtags/MtagsEnrichments.scala @@ -1,43 +1,14 @@ package scala.meta.internal.mtags -import java.net.URI -import java.net.URLDecoder -import java.nio.file.FileSystemNotFoundException -import java.nio.file.NoSuchFileException -import java.nio.file.Paths -import java.util.concurrent.CancellationException - import scala.collection.mutable import scala.reflect.internal.util.Position -import scala.util.Failure -import scala.util.Properties -import scala.util.Success -import scala.util.Try -import scala.{meta => m} -import scala.meta.internal.semanticdb.SymbolInformation.{Property => p} -import scala.meta.io.AbsolutePath import scala.meta.pc.OffsetParams import scala.meta.pc.RangeParams -import org.eclipse.lsp4j.jsonrpc.CancelChecker -import org.eclipse.{lsp4j => l} - object MtagsEnrichments extends MtagsEnrichments trait MtagsEnrichments extends ScalametaCommonEnrichments { - implicit class XtensionIteratorCollection[T](it: Iterator[T]) { - def headOption: Option[T] = { - if (it.hasNext) Some(it.next()) - else None - } - def lastOption: Option[T] = { - it.foldLeft(Option.empty[T]) { case (_, e) => - Some(e) - } - } - } - implicit class XtensionOffsetParams(params: OffsetParams) { def isDelimiter: Boolean = { params.offset() < 0 || @@ -83,149 +54,6 @@ trait MtagsEnrichments extends ScalametaCommonEnrichments { buf.result() } } - implicit class XtensionCancelChecker(token: CancelChecker) { - def isCancelled: Boolean = - try { - token.checkCanceled() - false - } catch { - case _: CancellationException => - true - } - } - implicit class XtensionSemanticdbProperties(properties: Int) { - def isEnum: Boolean = (properties & p.ENUM.value) != 0 - def isVar: Boolean = (properties & p.VAR.value) != 0 - def isVal: Boolean = (properties & p.VAL.value) != 0 - } - - implicit class XtensionToken(token: m.Token) { - def isWhiteSpaceOrComment: Boolean = - token match { - case _: m.Token.Space | _: m.Token.Tab | _: m.Token.CR | _: m.Token.LF | - _: m.Token.LFLF | _: m.Token.FF | _: m.Token.Comment | - _: m.Token.BOF | _: m.Token.EOF => - true - case _ => false - } - } - - implicit class XtensionURIMtags(value: URI) { - def toAbsolutePath: AbsolutePath = toAbsolutePath(followSymlink = true) - def toAbsolutePath(followSymlink: Boolean): AbsolutePath = { - val path = - if (value.getScheme() == "jar") - Try { - AbsolutePath(Paths.get(value)) - } match { - case Success(path) => path - case Failure(_) => - // don't close - put up with the resource staying open so all AbsolutePath methods don't have to be wrapped - m.internal.io.PlatformFileIO.newFileSystem( - value, - new java.util.HashMap[String, String]() - ) - AbsolutePath(Paths.get(value)) - } - else - AbsolutePath(Paths.get(value)) - if (followSymlink) - path.dealias - else - path - } - } - - implicit class XtensionStringMtags(value: String) { - - def stripBackticks: String = value.stripPrefix("`").stripSuffix("`") - def isBackticked: Boolean = - value.size > 1 && value.head == '`' && value.last == '`' - def toAbsolutePath: AbsolutePath = toAbsolutePath(true) - def toAbsolutePath(followSymlink: Boolean): AbsolutePath = { - - /* Windows sometimes treats % literally, but not sure if it's always the case. - * https://learn.microsoft.com/en-us/troubleshoot/windows-client/networking/url-encoding-unc-paths-not-url-decoded - * This function tries to apply different heuristics to get the proper file system. - */ - def withTryDecode(value: String)(f: String => AbsolutePath) = { - try { - if (Properties.isWin) f(URLDecoder.decode(value, "UTF-8")) - else f(value) - } catch { - // fallback to try without decoding - case _: FileSystemNotFoundException if Properties.isWin => - f(value) - // prevents infinity recursion and double check for double escaped % - case _: NoSuchFileException | _: FileSystemNotFoundException - if value.contains("%25") => - f(URLDecoder.decode(value, "UTF-8")) - } - } - - // jar schemes must have "jar:file:"" instead of "jar:file%3A" or jar file system won't recognise the URI. - // but don't overdecode as URIs may not be recognised e.g. "com-microsoft-java-debug-core-0.32.0%2B1.jar" is correct - if (value.toUpperCase.startsWith("JAR%3AFILE")) - withTryDecode(value)( - URLDecoder.decode(_, "UTF-8").toAbsolutePath(followSymlink) - ) - else if (value.toUpperCase.startsWith("JAR:FILE%3A")) - withTryDecode(value)( - URLDecoder.decode(_, "UTF-8").toAbsolutePath(followSymlink) - ) - else if (value.toUpperCase.startsWith("JAR")) { - try URI.create(value).toAbsolutePath(followSymlink) - catch { - case _: NoSuchFileException | _: FileSystemNotFoundException => - withTryDecode(value.stripPrefix("jar:"))( - new URI("jar", _, null).toAbsolutePath(followSymlink) - ) - } - } else { - val stripped = value.stripPrefix("metals:") - val percentEncoded = URIEncoderDecoder.encode(stripped) - URI.create(percentEncoded).toAbsolutePath(followSymlink) - } - } - def lastIndexBetween( - char: Char, - lowerBound: Int, - upperBound: Int - ): Int = { - val safeLowerBound = Math.max(0, lowerBound) - var index = upperBound - while (index >= safeLowerBound && value(index) != char) { - index -= 1 - } - if (index < safeLowerBound) -1 else index - } - } - - implicit class XtensionRangeLspInverse(range: l.Range) { - def toLocation(uri: URI): l.Location = new l.Location(uri.toString(), range) - } - - implicit class XtensionPositionLspInverse(pos: l.Position) { - - /** - * LSP position translated to scalameta position. Might return None if - * pos is not contained in input - * - * @param input file input the position relates to - * @return scalameta position with offset if the pos is contained in the file - */ - def toMeta(input: m.Input): Option[m.Position] = { - Try( - m.Position.Range( - input, - pos.getLine, - pos.getCharacter, - pos.getLine, - pos.getCharacter - ) - ).toOption - } - } implicit class XtensionPosition(pos: Position) { def encloses(other: Position): Boolean = diff --git a/mtags/src/main/scala-2/scala/meta/internal/pc/Keywords.scala b/mtags/src/main/scala-2/scala/meta/internal/pc/Keywords.scala index 662edf0fe83..c6410933edf 100644 --- a/mtags/src/main/scala-2/scala/meta/internal/pc/Keywords.scala +++ b/mtags/src/main/scala-2/scala/meta/internal/pc/Keywords.scala @@ -4,7 +4,6 @@ import scala.tools.nsc.reporters.StoreReporter import scala.meta._ import scala.meta.internal.mtags.MtagsEnrichments._ -import scala.meta.internal.pc.KeywordCompletionsUtils import org.eclipse.{lsp4j => l} diff --git a/mtags/src/main/scala-3/scala/meta/internal/mtags/MtagsEnrichments.scala b/mtags/src/main/scala-3/scala/meta/internal/mtags/MtagsEnrichments.scala index fa70710f208..b2bf24e3975 100644 --- a/mtags/src/main/scala-3/scala/meta/internal/mtags/MtagsEnrichments.scala +++ b/mtags/src/main/scala-3/scala/meta/internal/mtags/MtagsEnrichments.scala @@ -33,7 +33,8 @@ import dotty.tools.dotc.util.Spans import dotty.tools.dotc.util.Spans.Span import org.eclipse.lsp4j as l -object MtagsEnrichments extends ScalametaCommonEnrichments: +object MtagsEnrichments extends MtagsEnrichments +trait MtagsEnrichments extends ScalametaCommonEnrichments: extension (driver: InteractiveDriver) diff --git a/mtags/src/main/scala-2/scala/meta/internal/metals/PositionSyntax.scala b/mtags/src/main/scala/scala/meta/internal/metals/PositionSyntax.scala similarity index 99% rename from mtags/src/main/scala-2/scala/meta/internal/metals/PositionSyntax.scala rename to mtags/src/main/scala/scala/meta/internal/metals/PositionSyntax.scala index d29c28f4260..8a1311b34c5 100644 --- a/mtags/src/main/scala-2/scala/meta/internal/metals/PositionSyntax.scala +++ b/mtags/src/main/scala/scala/meta/internal/metals/PositionSyntax.scala @@ -67,7 +67,7 @@ object PositionSyntax { .append("\n") .append(pos.lineContent) .append("\n") - .append(pos.lineCaret) + .append(lineCaret) .toString() } def multilines: String = { diff --git a/mtags/src/main/scala-2/scala/meta/internal/metals/URIEncoderDecoder.scala b/mtags/src/main/scala/scala/meta/internal/metals/URIEncoderDecoder.scala similarity index 95% rename from mtags/src/main/scala-2/scala/meta/internal/metals/URIEncoderDecoder.scala rename to mtags/src/main/scala/scala/meta/internal/metals/URIEncoderDecoder.scala index 091fcad4497..db34109fd65 100644 --- a/mtags/src/main/scala-2/scala/meta/internal/metals/URIEncoderDecoder.scala +++ b/mtags/src/main/scala/scala/meta/internal/metals/URIEncoderDecoder.scala @@ -6,7 +6,7 @@ object URIEncoderDecoder { // Currently Metals doesn't encode `:` but does decode it private val toEscape: Map[Char, String] = Set('"', '<', '>', '&', '\'', '[', ']', '{', '}', ' ', '+', '!') - .map(char => char -> ("%" + char.toHexString)) + .map(char => char -> ("%" + char.toInt.toHexString)) .toMap private val toDecode: Map[String, Char] = toEscape.map { case (k, v) => diff --git a/mtags/src/main/scala/scala/meta/internal/mtags/ScalametaCommonEnrichments.scala b/mtags/src/main/scala/scala/meta/internal/mtags/ScalametaCommonEnrichments.scala index 094828e3490..9248f573328 100644 --- a/mtags/src/main/scala/scala/meta/internal/mtags/ScalametaCommonEnrichments.scala +++ b/mtags/src/main/scala/scala/meta/internal/mtags/ScalametaCommonEnrichments.scala @@ -1,17 +1,22 @@ package scala.meta.internal.mtags import java.net.URI +import java.net.URLDecoder import java.nio.charset.Charset import java.nio.charset.StandardCharsets +import java.nio.file.FileSystemNotFoundException import java.nio.file.Files +import java.nio.file.NoSuchFileException import java.nio.file.Path import java.nio.file.Paths import java.nio.file.StandardCopyOption import java.nio.file.StandardOpenOption +import java.util.concurrent.CancellationException import java.util.logging.Logger import scala.annotation.tailrec import scala.util.Failure +import scala.util.Properties import scala.util.Success import scala.util.Try import scala.util.control.NonFatal @@ -23,6 +28,7 @@ import scala.meta.internal.io.FileIO import scala.meta.internal.io.PathIO import scala.meta.internal.semanticdb.Language import scala.meta.internal.semanticdb.SymbolInformation.{Kind => k} +import scala.meta.internal.semanticdb.SymbolInformation.{Property => p} import scala.meta.internal.{semanticdb => s} import scala.meta.io.AbsolutePath import scala.meta.io.RelativePath @@ -558,4 +564,161 @@ trait ScalametaCommonEnrichments extends CommonMtagsEnrichments { } + implicit class XtensionToken(token: m.Token) { + def isWhiteSpaceOrComment: Boolean = + token match { + case _: m.Token.Space | _: m.Token.Tab | _: m.Token.CR | _: m.Token.LF | + _: m.Token.LFLF | _: m.Token.FF | _: m.Token.Comment | + _: m.Token.BOF | _: m.Token.EOF => + true + case _ => false + } + } + + implicit class XtensionURIMtags(value: URI) { + def toAbsolutePath: AbsolutePath = toAbsolutePath(followSymlink = true) + def toAbsolutePath(followSymlink: Boolean): AbsolutePath = { + val path = + if (value.getScheme() == "jar") + Try { + AbsolutePath(Paths.get(value)) + } match { + case Success(path) => path + case Failure(_) => + // don't close - put up with the resource staying open so all AbsolutePath methods don't have to be wrapped + m.internal.io.PlatformFileIO.newFileSystem( + value, + new java.util.HashMap[String, String]() + ) + AbsolutePath(Paths.get(value)) + } + else + AbsolutePath(Paths.get(value)) + if (followSymlink) + path.dealias + else + path + } + } + + implicit class XtensionIteratorCollection[T](it: Iterator[T]) { + def headOption: Option[T] = { + if (it.hasNext) Some(it.next()) + else None + } + def lastOption: Option[T] = { + it.foldLeft(Option.empty[T]) { case (_, e) => + Some(e) + } + } + } + + implicit class XtensionSemanticdbProperties(properties: Int) { + def isEnum: Boolean = (properties & p.ENUM.value) != 0 + def isVar: Boolean = (properties & p.VAR.value) != 0 + def isVal: Boolean = (properties & p.VAL.value) != 0 + } + + implicit class XtensionStringMtags(value: String) { + + def stripBackticks: String = value.stripPrefix("`").stripSuffix("`") + def isBackticked: Boolean = + value.size > 1 && value.head == '`' && value.last == '`' + def toAbsolutePath: AbsolutePath = toAbsolutePath(true) + def toAbsolutePath(followSymlink: Boolean): AbsolutePath = { + + /* Windows sometimes treats % literally, but not sure if it's always the case. + * https://learn.microsoft.com/en-us/troubleshoot/windows-client/networking/url-encoding-unc-paths-not-url-decoded + * This function tries to apply different heuristics to get the proper file system. + */ + def withTryDecode(value: String)(f: String => AbsolutePath) = { + try { + if (Properties.isWin) f(URLDecoder.decode(value, "UTF-8")) + else f(value) + } catch { + // fallback to try without decoding + case _: FileSystemNotFoundException if Properties.isWin => + f(value) + // prevents infinity recursion and double check for double escaped % + case _: NoSuchFileException | _: FileSystemNotFoundException + if value.contains("%25") => + f(URLDecoder.decode(value, "UTF-8")) + } + } + + // jar schemes must have "jar:file:"" instead of "jar:file%3A" or jar file system won't recognise the URI. + // but don't overdecode as URIs may not be recognised e.g. "com-microsoft-java-debug-core-0.32.0%2B1.jar" is correct + if (value.toUpperCase.startsWith("JAR%3AFILE")) + withTryDecode(value)( + URLDecoder.decode(_, "UTF-8").toAbsolutePath(followSymlink) + ) + else if (value.toUpperCase.startsWith("JAR:FILE%3A")) + withTryDecode(value)( + URLDecoder.decode(_, "UTF-8").toAbsolutePath(followSymlink) + ) + else if (value.toUpperCase.startsWith("JAR")) { + try URI.create(value).toAbsolutePath(followSymlink) + catch { + case _: NoSuchFileException | _: FileSystemNotFoundException => + withTryDecode(value.stripPrefix("jar:"))( + new URI("jar", _, null).toAbsolutePath(followSymlink) + ) + } + } else { + val stripped = value.stripPrefix("metals:") + val percentEncoded = URIEncoderDecoder.encode(stripped) + URI.create(percentEncoded).toAbsolutePath(followSymlink) + } + } + def lastIndexBetween( + char: Char, + lowerBound: Int, + upperBound: Int + ): Int = { + val safeLowerBound = Math.max(0, lowerBound) + var index = upperBound + while (index >= safeLowerBound && value(index) != char) { + index -= 1 + } + if (index < safeLowerBound) -1 else index + } + } + + implicit class XtensionPositionLspInverse(pos: l.Position) { + + /** + * LSP position translated to scalameta position. Might return None if + * pos is not contained in input + * + * @param input file input the position relates to + * @return scalameta position with offset if the pos is contained in the file + */ + def toMeta(input: m.Input): Option[m.Position] = { + Try( + m.Position.Range( + input, + pos.getLine, + pos.getCharacter, + pos.getLine, + pos.getCharacter + ) + ).toOption + } + } + + implicit class XtensionRangeLspInverse(range: l.Range) { + def toLocation(uri: URI): l.Location = new l.Location(uri.toString(), range) + } + + implicit class XtensionCancelChecker(token: l.jsonrpc.CancelChecker) { + def isCancelled: Boolean = + try { + token.checkCanceled() + false + } catch { + case _: CancellationException => + true + } + } + } diff --git a/mtags/src/main/scala-2/scala/meta/internal/pc/LogMessages.scala b/mtags/src/main/scala/scala/meta/internal/pc/LogMessages.scala similarity index 100% rename from mtags/src/main/scala-2/scala/meta/internal/pc/LogMessages.scala rename to mtags/src/main/scala/scala/meta/internal/pc/LogMessages.scala diff --git a/project/JavaPcSettings.scala b/project/JavaPcSettings.scala index 54ae3b9d89d..372ddbe58a5 100644 --- a/project/JavaPcSettings.scala +++ b/project/JavaPcSettings.scala @@ -12,7 +12,7 @@ object JavaPcSettings { prj.settings( sharedSettings, moduleName := "mtags-java", - scalaVersion := V.scala213, + scalaVersion := V.scala3, currentJavaHome := file(System.getProperty("java.home")), currentJavaVersion := { val version = System.getProperty("java.version") diff --git a/tests/cross/src/main/scala/tests/BaseExtractMethodSuite.scala b/tests/cross/src/main/scala/tests/BaseExtractMethodSuite.scala index 480bc0125f1..320ca0e3471 100644 --- a/tests/cross/src/main/scala/tests/BaseExtractMethodSuite.scala +++ b/tests/cross/src/main/scala/tests/BaseExtractMethodSuite.scala @@ -10,7 +10,6 @@ import scala.meta.internal.metals.TextEdits import munit.Location import munit.TestOptions import org.eclipse.{lsp4j => l} -import tests.BaseCodeActionSuite class BaseExtractMethodSuite extends BaseCodeActionSuite { def checkEdit( diff --git a/tests/slow/src/test/scala/tests/feature/InlayHintsScala3ExpectSuite.scala b/tests/slow/src/test/scala/tests/feature/InlayHintsScala3ExpectSuite.scala index 1af8ead0daf..d5e6a7e53c2 100644 --- a/tests/slow/src/test/scala/tests/feature/InlayHintsScala3ExpectSuite.scala +++ b/tests/slow/src/test/scala/tests/feature/InlayHintsScala3ExpectSuite.scala @@ -5,7 +5,7 @@ import scala.meta.pc.PresentationCompiler import tests.BaseInlayHintsExpectSuite import tests.InputProperties -import tests.TestScala3Compiler +import tests.TestScala2Compiler class InlayHintsScala3ExpectSuite( ) extends BaseInlayHintsExpectSuite( diff --git a/tests/slow/src/test/scala/tests/feature/RenameCrossLspSuite.scala b/tests/slow/src/test/scala/tests/feature/RenameCrossLspSuite.scala index 1ddf2ac75cd..3b7bc50664f 100644 --- a/tests/slow/src/test/scala/tests/feature/RenameCrossLspSuite.scala +++ b/tests/slow/src/test/scala/tests/feature/RenameCrossLspSuite.scala @@ -7,45 +7,103 @@ import tests.BaseRenameLspSuite class RenameCrossLspSuite extends BaseRenameLspSuite("rename-cross") { renamed( - "scala3-outer", + "macro", """|/a/src/main/scala/a/Main.scala - | - |@main def run() = { - | <>("Mark") - | <>("Anne") + |package a + |import io.circe.generic.JsonCodec + |trait LivingBeing + |@JsonCodec sealed trait <> extends LivingBeing + |object <> { + | case object Dog extends <> + | case object Cat extends <> |} - |def <>(name : String) : Unit = { - | println(s"Hello $name") + |""".stripMargin, + "Tree", + scalaVersion = Some(V.scala213), + ) + + renamed( + "macro1", + """|/a/src/main/scala/a/Main.scala + |package a + |import io.circe.generic.JsonCodec + |trait <> + |@JsonCodec sealed trait Animal extends <> + |object Animal { + | case object Dog extends Animal + | case object Cat extends Animal |} |""".stripMargin, - newName = "greeting", - scalaVersion = Some(V.scala3), + "Tree", + scalaVersion = Some(V.scala213), ) renamed( - "scala3-extension-params", + "macro2", """|/a/src/main/scala/a/Main.scala - | - |extension (<>: String) - | def double = <> + <> - | def double2 = <> + <> - |end extension + |package a + |import io.circe.generic.JsonCodec + |@JsonCodec + |final case class <>(name: String) |""".stripMargin, - newName = "greeting", - scalaVersion = Some(V.scala3), + "Tree", + scalaVersion = Some(V.scala213), ) renamed( - "scala3-extension-params-ref", + "macro3", """|/a/src/main/scala/a/Main.scala - | - |extension (<>: String) - | def double = <> + <> - | def double2 = <> + <> - |end extension + |package a + |import io.circe.generic.JsonCodec + |trait LivingBeing + |@JsonCodec sealed trait <> extends LivingBeing + |object <>{ + | case object Dog extends <> + | case object Cat extends <> + |} + |/a/src/main/scala/a/Use.scala + |package a + |object Use { + | val dog : <> = <>.Dog + |} |""".stripMargin, - newName = "greeting", - scalaVersion = Some(V.scala3), + "Tree", + scalaVersion = Some(V.scala213), ) + renamed( + "colon-good", + """|/a/src/main/scala/a/Main.scala + |package a + |class User{ + | def <<:@@:>>(name : String) = name + |} + |object Main{ + | val user = new User() + | "" <<::>> user + |} + |""".stripMargin, + newName = "+++:", + ) + + renamed( + "apply", + """|/a/src/main/scala/a/Main.scala + |package a + |object User{ + | def <>(name : String) = name + | def apply(name : String, age: Int) = name + |} + |object Main{ + | val toRename = User##.##<<>>("abc") + |} + |""".stripMargin, + newName = "name", + ) + + override protected def libraryDependencies: List[String] = + List("org.scalatest::scalatest:3.2.12", "io.circe::circe-generic:0.14.1") + + override def scalacOptions: List[String] = List("-Ymacro-annotations") + } diff --git a/tests/slow/src/test/scala/tests/feature/SemanticTokensScala3ExpectSuite.scala b/tests/slow/src/test/scala/tests/feature/SemanticTokensScala3ExpectSuite.scala index bcfd4a69157..5a354e3b33d 100644 --- a/tests/slow/src/test/scala/tests/feature/SemanticTokensScala3ExpectSuite.scala +++ b/tests/slow/src/test/scala/tests/feature/SemanticTokensScala3ExpectSuite.scala @@ -9,16 +9,17 @@ import scala.meta.internal.metals.{BuildInfo => V} import tests.DirectoryExpectSuite import tests.ExpectTestCase import tests.InputProperties -import tests.TestScala3Compiler +import tests.TestScala2Compiler import tests.TestSemanticTokens -class SemanticTokensScala3ExpectSuite( -) extends DirectoryExpectSuite("semanticTokens3") { - override lazy val input: InputProperties = InputProperties.scala3() +class SemanticTokensScala2ExpectSuite( +) extends DirectoryExpectSuite("semanticTokens") { + override lazy val input: InputProperties = InputProperties.scala2() + private val compiler = - TestScala3Compiler.compiler("tokens", input)(munitExecutionContext) match { + TestScala2Compiler.compiler("tokens", input)(munitExecutionContext) match { case Some(pc) => pc - case _ => fail(s"Could not load ${V.scala3} presentation compiler") + case _ => fail(s"Could not load ${V.scala213} presentation compiler") } override def testCases(): List[ExpectTestCase] = { @@ -36,7 +37,7 @@ class SemanticTokensScala3ExpectSuite( val tokens = SemanticTokensProvider.provide( nodes, params, - isScala3 = true, + isScala3 = false, ) TestSemanticTokens.semanticString( diff --git a/tests/slow/src/test/scala/tests/feature/SlowSaveExpect.scala b/tests/slow/src/test/scala/tests/feature/SlowSaveExpect.scala index 8a3d55a40aa..17a2549aea2 100644 --- a/tests/slow/src/test/scala/tests/feature/SlowSaveExpect.scala +++ b/tests/slow/src/test/scala/tests/feature/SlowSaveExpect.scala @@ -5,8 +5,8 @@ import tests.BaseExpectSuite object SlowSaveExpect { def main(args: Array[String]): Unit = { List[BaseExpectSuite]( - new SemanticTokensScala3ExpectSuite(), - new InlayHintsScala3ExpectSuite(), + new SemanticTokensScala2ExpectSuite(), + new InlayHintsScala2ExpectSuite(), ).foreach { suite => val header = suite.suiteName.length + 2 println("=" * header) diff --git a/tests/slow/src/test/scala/tests/feature/WorksheetCrossLspSuite.scala b/tests/slow/src/test/scala/tests/feature/WorksheetCrossLspSuite.scala index 822c8eaa0f7..218c1ee8d14 100644 --- a/tests/slow/src/test/scala/tests/feature/WorksheetCrossLspSuite.scala +++ b/tests/slow/src/test/scala/tests/feature/WorksheetCrossLspSuite.scala @@ -8,15 +8,6 @@ import coursierapi.Complete class Worksheet211LspSuite extends tests.BaseWorksheetLspSuite(V.scala211) -class Worksheet3LspSuite extends tests.BaseWorksheetLspSuite(V.scala3) { - override def versionSpecificCodeToValidate: String = - """given str: String = """"" - - override def versionSpecificScalacOptionsToValidate: List[String] = List( - "-Ycheck-reentrant" - ) -} - class LatestWorksheet3LspSuite extends tests.BaseWorksheetLspSuite( V.supportedScala3Versions @@ -53,3 +44,59 @@ object Worksheet3NextSuite { } class Worksheet212LspSuite extends tests.BaseWorksheetLspSuite(V.scala212) + +class Worksheet213LspSuite extends tests.BaseWorksheetLspSuite(V.scala213) { + + test("akka") { + cleanWorkspace() + val path = "hi.worksheet.sc" + for { + _ <- initialize( + s""" + |/metals.json + |{ + | "a": {} + |} + |/${path} + |import $$dep.`com.typesafe.akka::akka-stream:2.6.13` + | + |import akka.actor.ActorSystem + |import akka.NotUsed + |import akka.stream.scaladsl.Source + |import akka.stream.scaladsl.Sink + |import java.io.File + |import scala.concurrent.Await + |import scala.concurrent.duration.DurationInt + | + | + |implicit val system: ActorSystem = ActorSystem("QuickStart") + |val source: Source[Int, NotUsed] = Source(1 to 2) + |val future = source.runWith(Sink.foreach(_ => ())) + |Await.result(future, 3.seconds) + | + |""".stripMargin + ) + _ <- server.didOpen(path) + _ = assertNoDiff( + // it seems that part of the string is always different, so let's remove it + client.workspaceDecorations(path).replaceAll(".out\\(.*", ".out(..."), + """|import $dep.`com.typesafe.akka::akka-stream:2.6.13` + | + |import akka.actor.ActorSystem + |import akka.NotUsed + |import akka.stream.scaladsl.Source + |import akka.stream.scaladsl.Sink + |import java.io.File + |import scala.concurrent.Await + |import scala.concurrent.duration.DurationInt + | + | + |implicit val system: ActorSystem = ActorSystem("QuickStart") // : ActorSystem = akka://QuickStart + |val source: Source[Int, NotUsed] = Source(1 to 2) // : Source[Int, NotUsed] = Source(SourceShape(StatefulMapConcat.out(... + |val future = source.runWith(Sink.foreach(_ => ())) // : concurrent.Future[akka.Done] = Future(Success(Done)) + |Await.result(future, 3.seconds) // : akka.Done = Done + |""".stripMargin, + ) + } yield () + } +} diff --git a/tests/slow/src/test/scala/tests/sbt/SbtServerSuite.scala b/tests/slow/src/test/scala/tests/sbt/SbtServerSuite.scala index 9a5a5b4f98a..4db09550791 100644 --- a/tests/slow/src/test/scala/tests/sbt/SbtServerSuite.scala +++ b/tests/slow/src/test/scala/tests/sbt/SbtServerSuite.scala @@ -144,7 +144,7 @@ class SbtServerSuite test("reload plugins") { // should reload existing server after writing the metals.sbt plugin file - cleanWorkspace + cleanWorkspace() val layout = SbtBuildLayout("", V.scala213) writeLayout(layout) assert(workspace.exists) @@ -158,7 +158,7 @@ class SbtServerSuite sbtProcess.complete } for { - code <- startSbtServer + code <- startSbtServer() _ = assert(code == 0) _ = assert(workspace.resolve(".bsp/sbt.json").exists) _ <- initializer.initialize(workspace, server, client, false) diff --git a/tests/unit/src/main/scala/bill/Bill.scala b/tests/unit/src/main/scala/bill/Bill.scala index 6911afb5059..781a9d2aeb4 100644 --- a/tests/unit/src/main/scala/bill/Bill.scala +++ b/tests/unit/src/main/scala/bill/Bill.scala @@ -20,12 +20,6 @@ import scala.concurrent.Await import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.Future import scala.concurrent.duration.Duration -import scala.reflect.internal.util.BatchSourceFile -import scala.reflect.internal.{util => r} -import scala.reflect.io.AbstractFile -import scala.reflect.io.VirtualFile -import scala.tools.nsc -import scala.tools.nsc.reporters.StoreReporter import scala.util.Try import scala.util.control.NonFatal @@ -36,6 +30,7 @@ import scala.meta.internal.metals.MetalsEnrichments._ import scala.meta.internal.metals.PositionSyntax._ import scala.meta.internal.metals.RecursivelyDelete import scala.meta.internal.mtags +import scala.meta.internal.pc.ScalaPresentationCompiler import scala.meta.io.AbsolutePath import ch.epfl.scala.bsp4j._ @@ -43,6 +38,12 @@ import ch.epfl.scala.{bsp4j => b} import com.google.gson.GsonBuilder import coursierapi.Dependency import coursierapi.Fetch +import dotty.tools.dotc.interfaces.Diagnostic as DottyDiagnostic +import dotty.tools.dotc.reporting.StoreReporter +import dotty.tools.dotc.util.SourceFile +import dotty.tools.dotc.util.SourcePosition +import dotty.tools.dotc.util.Spans +import dotty.tools.io.AbstractFile import org.eclipse.lsp4j.jsonrpc.Launcher /** @@ -147,17 +148,11 @@ object Bill { result.setDataKind("scala") result } - val reporter = new StoreReporter val out: AbsolutePath = AbsolutePath(workspace.resolve("out.jar")) Files.createDirectories(out.toNIO.getParent()) - lazy val g: nsc.Global = { - val settings = new nsc.Settings() - settings.classpath.value = - myClasspath.map(_.toString).mkString(File.pathSeparator) - settings.Yrangepos.value = true - settings.d.value = out.toString - new nsc.Global(settings, reporter) - } + lazy val driver = + ScalaPresentationCompiler(classpath = myClasspath).newDriver + val reporter = new StoreReporter() override def buildInitialize( params: InitializeBuildParams @@ -236,7 +231,7 @@ object Bill { val scalaLib = Dependency.of( "org.scala-lang", "scala-library", - mtags.BuildInfo.scalaCompilerVersion, + BuildInfo.scala213, ) CompletableFuture.completedFuture { @@ -264,12 +259,15 @@ object Bill { private val hasError = mutable.Set.empty[AbstractFile] def publishDiagnostics(): Unit = { - val byFile = reporter.infos.groupBy(_.pos.source.file) + val byFile = reporter + .pendingMessages(using driver.currentCtx) + .groupBy(_.pos.source.file) + val fixedErrors = hasError.filterNot(byFile.contains) fixedErrors.foreach { file => client.onBuildPublishDiagnostics( new PublishDiagnosticsParams( - new TextDocumentIdentifier(file.name), + new TextDocumentIdentifier(file.path), target.getId, List().asJava, true, @@ -278,32 +276,33 @@ object Bill { } hasError --= fixedErrors byFile.foreach { case (file, infos) => - def toBspPos(pos: r.Position, offset: Int): b.Position = { + def toBspPos(pos: SourcePosition, offset: Int): b.Position = { val line = pos.source.offsetToLine(offset) val column0 = pos.source.lineToOffset(line) val column = offset - column0 new b.Position(line, column) } val diagnostics = infos.iterator - .filter(_.pos.isDefined) + .filter(_.pos.span != Spans.NoSpan) .map { info => val p = info.pos val start = - toBspPos(info.pos, if (p.isRange) p.start else p.point) + toBspPos(info.pos, if (p.span.isZeroExtent) p.point else p.start) val end = - toBspPos(info.pos, if (p.isRange) p.end else p.point) - val severity = info.severity match { - case reporter.ERROR => DiagnosticSeverity.ERROR - case reporter.WARNING => DiagnosticSeverity.WARNING - case reporter.INFO => DiagnosticSeverity.INFORMATION + toBspPos(info.pos, if (p.span.isZeroExtent) p.point else p.end) + val severity = info.level match { + case DottyDiagnostic.ERROR => DiagnosticSeverity.ERROR + case DottyDiagnostic.WARNING => DiagnosticSeverity.WARNING + case DottyDiagnostic.INFO => DiagnosticSeverity.INFORMATION case _ => DiagnosticSeverity.HINT } - val diagnostic = new Diagnostic(new b.Range(start, end), info.msg) + val diagnostic = + new Diagnostic(new b.Range(start, end), info.message) diagnostic.setSeverity(severity) diagnostic } .toList - val uri = file.name + val uri = file.path val params = new PublishDiagnosticsParams( new TextDocumentIdentifier(uri), @@ -325,27 +324,22 @@ object Bill { ) } CompletableFuture.completedFuture { - reporter.reset() - val run = new g.Run() - val sources: List[BatchSourceFile] = - if (Files.isDirectory(src)) { - Files - .walk(src) - .collect(Collectors.toList()) - .asScala - .iterator - .filter(_.getFileName.toString.endsWith(".scala")) - .map(path => { - val text = - new String(Files.readAllBytes(path), StandardCharsets.UTF_8) - val chars = text.toCharArray - new BatchSourceFile(new VirtualFile(path.toUri.toString), chars) - }) - .toList - } else { - Nil - } - run.compileSources(sources) + if (Files.isDirectory(src)) { + Files + .walk(src) + .collect(Collectors.toList()) + .asScala + .iterator + .filter(_.getFileName.toString.endsWith(".scala")) + .foreach(path => { + val text = + new String(Files.readAllBytes(path), StandardCharsets.UTF_8) + val source = SourceFile.virtual(path.toUri().toString, text) + + val diags = driver.run(path.toUri, source) + diags.foreach(reporter.doReport(_)(using driver.currentCtx)) + }) + } publishDiagnostics() val exit = if (reporter.hasErrors) StatusCode.ERROR @@ -387,6 +381,7 @@ object Bill { ) } } + override def buildTargetScalaTestClasses( params: ScalaTestClassesParams ): CompletableFuture[ScalaTestClassesResult] = diff --git a/tests/unit/src/main/scala/scala/meta/internal/metals/debug/Debugger.scala b/tests/unit/src/main/scala/scala/meta/internal/metals/debug/Debugger.scala index cba3e10bd73..b38b4795d9d 100644 --- a/tests/unit/src/main/scala/scala/meta/internal/metals/debug/Debugger.scala +++ b/tests/unit/src/main/scala/scala/meta/internal/metals/debug/Debugger.scala @@ -127,9 +127,6 @@ final class Debugger(server: RemoteServer)(implicit ec: ExecutionContext) { callback(completions) step(threadId, DebugStep.Continue) } - case cause => - val error = s"Unsupported debug step $cause" - Future.failed(new IllegalStateException(error)) } } diff --git a/tests/unit/src/main/scala/tests/BaseAnalyzeStacktraceSuite.scala b/tests/unit/src/main/scala/tests/BaseAnalyzeStacktraceSuite.scala index fde1cab9837..7bd910d7282 100644 --- a/tests/unit/src/main/scala/tests/BaseAnalyzeStacktraceSuite.scala +++ b/tests/unit/src/main/scala/tests/BaseAnalyzeStacktraceSuite.scala @@ -34,7 +34,7 @@ abstract class BaseAnalyzeStacktraceSuite(name: String) code: String, stacktrace: String, filename: String = "Main.scala", - scalaVersion: String = V.scala213, + scalaVersion: String = V.scala3, dependency: String = "", )(implicit loc: munit.Location): Unit = { val locationParser = new JsonParser.Of[l.Location] diff --git a/tests/unit/src/main/scala/tests/BaseInlayHintsLspSuite.scala b/tests/unit/src/main/scala/tests/BaseInlayHintsLspSuite.scala index e5de66e1533..b8730b7ce06 100644 --- a/tests/unit/src/main/scala/tests/BaseInlayHintsLspSuite.scala +++ b/tests/unit/src/main/scala/tests/BaseInlayHintsLspSuite.scala @@ -2,8 +2,6 @@ package tests import munit.Location import munit.TestOptions -import tests.BaseLspSuite -import tests.TestInlayHints abstract class BaseInlayHintsLspSuite(name: String, scalaVersion: String) extends BaseLspSuite(name) { diff --git a/tests/unit/src/main/scala/tests/BaseLspSuite.scala b/tests/unit/src/main/scala/tests/BaseLspSuite.scala index 703ea3fa55e..15e1c562c48 100644 --- a/tests/unit/src/main/scala/tests/BaseLspSuite.scala +++ b/tests/unit/src/main/scala/tests/BaseLspSuite.scala @@ -123,16 +123,16 @@ abstract class BaseLspSuite( } } if (withoutVirtualDocs) { - test(testOpts.withName(s"${testOpts.name}-readonly")) { + super.test(testOpts.withName(s"${testOpts.name}-readonly")) { functionRetry(maxRetry) } - test( + super.test( testOpts .withName(s"${testOpts.name}-virtualdoc") .withTags(Set(TestingServer.virtualDocTag)) ) { functionRetry(maxRetry) } } else { - test(testOpts)(functionRetry(maxRetry)) + super.test(testOpts)(functionRetry(maxRetry)) } } @@ -176,12 +176,15 @@ abstract class BaseLspSuite( } override def beforeEach(context: BeforeEach): Unit = { - cancelServer() if (context.test.tags.contains(Ignore)) return useVirtualDocs = context.test.tags.contains(TestingServer.virtualDocTag) newServer(context.test.name) } + override def afterEach(context: AfterEach): Unit = { + cancelServer() + } + protected def createWorkspace(name: String): AbsolutePath = { val pathToSuite = PathIO.workingDirectory .resolve("target") diff --git a/tests/unit/src/main/scala/tests/BaseRenameLspSuite.scala b/tests/unit/src/main/scala/tests/BaseRenameLspSuite.scala index f6900414300..83f587e050e 100644 --- a/tests/unit/src/main/scala/tests/BaseRenameLspSuite.scala +++ b/tests/unit/src/main/scala/tests/BaseRenameLspSuite.scala @@ -2,7 +2,8 @@ package tests import scala.concurrent.Future -import scala.meta.internal.pc.Identifier +import scala.meta.internal.metals.ScalaVersions +import scala.meta.internal.mtags.KeywordWrapper import munit.Location import munit.TestOptions @@ -11,6 +12,7 @@ abstract class BaseRenameLspSuite(name: String) extends BaseLspSuite(name) { protected def libraryDependencies: List[String] = Nil protected def compilerPlugins: List[String] = Nil + protected def scalacOptions: List[String] = Nil def same( name: String, @@ -64,7 +66,12 @@ abstract class BaseRenameLspSuite(name: String) extends BaseLspSuite(name) { cleanWorkspace() val allMarkersRegex = "(<<|>>|@@|##.*##)" val files = FileLayout.mapFromString(input) - val expectedName = Identifier.backtickWrap(newName) + val actualScalaVersion = scalaVersion.getOrElse(BuildInfo.scalaVersion) + val expectedName = + if (ScalaVersions.isScala3Version(actualScalaVersion)) + KeywordWrapper.Scala3.backtickWrap(newName) + else + KeywordWrapper.Scala2.backtickWrap(newName) val expectedFiles = files.map { case (file, code) => fileRenames.getOrElse(file, file) -> { val expected = if (!notRenamed) { @@ -128,7 +135,7 @@ abstract class BaseRenameLspSuite(name: String) extends BaseLspSuite(name) { | "scalaVersion": "$actualScalaVersion", | "compilerPlugins": ${toJsonArray(compilerPlugins)}, | "libraryDependencies": ${toJsonArray(libraryDependencies)}, - | "scalacOptions" : ["-Ymacro-annotations"] + | "scalacOptions" : ${toJsonArray(scalacOptions)} | }, | "b" : { | "scalaVersion": "$actualScalaVersion", diff --git a/tests/unit/src/main/scala/tests/BaseWorksheetLspSuite.scala b/tests/unit/src/main/scala/tests/BaseWorksheetLspSuite.scala index 55cf8eb1dfb..8078e53419a 100644 --- a/tests/unit/src/main/scala/tests/BaseWorksheetLspSuite.scala +++ b/tests/unit/src/main/scala/tests/BaseWorksheetLspSuite.scala @@ -726,11 +726,11 @@ abstract class BaseWorksheetLspSuite( ) _ <- server.didOpen("a/src/main/scala/foo/Main.worksheet.sc") _ <- server.didSave("a/src/main/scala/foo/Main.worksheet.sc")(identity) - export = server.exportEvaluation( + exportedEvaluation = server.exportEvaluation( "a/src/main/scala/foo/Main.worksheet.sc" ) _ = assertEquals( - export, + exportedEvaluation, Some( getExpected( """| @@ -775,11 +775,11 @@ abstract class BaseWorksheetLspSuite( "Hi(7, 8, 9)", ) ) - export = server.exportEvaluation( + exportedEvaluation = server.exportEvaluation( "a/src/main/scala/foo/Main.worksheet.sc" ) _ = assertEquals( - export, + exportedEvaluation, Some( getExpected( """| diff --git a/tests/unit/src/main/scala/tests/BuildServerInitializer.scala b/tests/unit/src/main/scala/tests/BuildServerInitializer.scala index 6b72e24ef1b..c8eb064f92c 100644 --- a/tests/unit/src/main/scala/tests/BuildServerInitializer.scala +++ b/tests/unit/src/main/scala/tests/BuildServerInitializer.scala @@ -34,7 +34,6 @@ sealed trait BuildServerInitializer { * This will take your `metals.json` file and quickly produce `.bloop/` files from it. */ object QuickBuildInitializer extends BuildServerInitializer { - this: BaseLspSuite => override def initialize( workspace: AbsolutePath, server: TestingServer, @@ -65,7 +64,6 @@ object QuickBuildInitializer extends BuildServerInitializer { * run Bloop Install via the build tool being used. */ object BloopImportInitializer extends BuildServerInitializer { - this: BaseLspSuite => override def initialize( workspace: AbsolutePath, server: TestingServer, @@ -93,7 +91,6 @@ object BloopImportInitializer extends BuildServerInitializer { * with sbt as the build server. */ object SbtServerInitializer extends BuildServerInitializer { - this: BaseLspSuite => override def initialize( workspace: AbsolutePath, server: TestingServer, @@ -173,7 +170,6 @@ object SbtServerInitializer extends BuildServerInitializer { } object MillServerInitializer extends BuildServerInitializer { - this: BaseLspSuite => override def initialize( workspace: AbsolutePath, server: TestingServer, @@ -197,7 +193,6 @@ object MillServerInitializer extends BuildServerInitializer { } object BazelServerInitializer extends BuildServerInitializer { - this: BaseLspSuite => override def initialize( workspace: AbsolutePath, server: TestingServer, diff --git a/tests/unit/src/main/scala/tests/Library.scala b/tests/unit/src/main/scala/tests/Library.scala index 4cbd7d416d4..d853f4a8f8d 100644 --- a/tests/unit/src/main/scala/tests/Library.scala +++ b/tests/unit/src/main/scala/tests/Library.scala @@ -5,7 +5,7 @@ import scala.collection.JavaConverters._ import scala.meta.internal.metals.JdkSources import scala.meta.internal.metals.PackageIndex import scala.meta.internal.metals.ScalaVersions -import scala.meta.internal.mtags +import scala.meta.internal.metals.{BuildInfo => V} import scala.meta.io.AbsolutePath import scala.meta.io.Classpath @@ -63,7 +63,6 @@ object Library { .filter(_.toString.endsWith("bindings-rxjava-2.0.0-sources.jar")) def allScala2: List[Library] = { - import mtags.BuildInfo.scalaCompilerVersion val dependencies = List( Dependency.of("com.lihaoyi", "acyclic_2.12", "0.1.8"), @@ -78,7 +77,7 @@ object Library { Dependency.of("org.apache.spark", "spark-sql_2.11", "2.2.1"), Dependency.of("org.eclipse.jetty", "jetty-servlet", "9.3.11.v20160721"), Dependency.of("org.scalameta", "scalameta_2.12", "4.1.4"), - Dependency.of("org.scala-lang", "scala-compiler", scalaCompilerVersion), + Dependency.of("org.scala-lang", "scala-compiler", V.scala213), ) List(fetchSources("scala2-suite", dependencies)) } diff --git a/tests/unit/src/main/scala/tests/QuickBuild.scala b/tests/unit/src/main/scala/tests/QuickBuild.scala index 850626ba17c..c5a53b266de 100644 --- a/tests/unit/src/main/scala/tests/QuickBuild.scala +++ b/tests/unit/src/main/scala/tests/QuickBuild.scala @@ -76,7 +76,7 @@ case class QuickBuild( def withId(id: String): QuickBuild = QuickBuild( id, - if (scalaVersion == null) V.scala213 + if (scalaVersion == null) V.scala3 else scalaVersion, orEmpty(libraryDependencies), orEmpty(compilerPlugins), @@ -370,7 +370,7 @@ object QuickBuild { val newDigest = { val digest = MessageDigest.getInstance("MD5") digest.update(version.getBytes(StandardCharsets.UTF_8)) - digest.update(V.scala213.getBytes(StandardCharsets.UTF_8)) + digest.update(V.scala3.getBytes(StandardCharsets.UTF_8)) def update(file: AbsolutePath): Unit = { if (file.isFile) { digest.update(file.readAllBytes) diff --git a/tests/unit/src/main/scala/tests/TestScala3Compiler.scala b/tests/unit/src/main/scala/tests/TestScala3Compiler.scala index 0c47cfda507..cb004bfb3d8 100644 --- a/tests/unit/src/main/scala/tests/TestScala3Compiler.scala +++ b/tests/unit/src/main/scala/tests/TestScala3Compiler.scala @@ -11,16 +11,12 @@ import scala.meta.internal.metals.WorkDoneProgress import scala.meta.internal.metals.{BuildInfo => V} import scala.meta.pc.PresentationCompiler -import tests.InputProperties -import tests.TestMtagsResolver -import tests.TestingClient - -object TestScala3Compiler { +object TestScala2Compiler { def compiler(name: String, input: InputProperties)(implicit ec: ExecutionContext ): Option[PresentationCompiler] = { val resolver = new TestMtagsResolver(checkCoursier = true) - resolver.resolve(V.scala3) match { + resolver.resolve(V.scala213) match { case Some(mtags: MtagsBinaries.Artifacts) => val time = new FakeTime val client = new TestingClient(PathIO.workingDirectory, Buffers()) diff --git a/tests/unit/src/main/scala/tests/TestingClient.scala b/tests/unit/src/main/scala/tests/TestingClient.scala index 004cc24a68d..a8002bd53c5 100644 --- a/tests/unit/src/main/scala/tests/TestingClient.scala +++ b/tests/unit/src/main/scala/tests/TestingClient.scala @@ -354,7 +354,7 @@ class TestingClient(workspace: AbsolutePath, val buffers: Buffers) showMessageRequestHandler(params).getOrElse { if (isSameMessage(ImportBuildChanges.params)) { importBuildChanges - } else if (isSameGenerateBspAndConnectMessage) { + } else if (isSameGenerateBspAndConnectMessage()) { generateBspAndConnect } else if (isSameMessage(ImportBuild.params)) { importBuild diff --git a/tests/unit/src/main/scala/tests/codeactions/BaseCodeActionLspSuite.scala b/tests/unit/src/main/scala/tests/codeactions/BaseCodeActionLspSuite.scala index 6350030fa41..a4c0492a3b0 100644 --- a/tests/unit/src/main/scala/tests/codeactions/BaseCodeActionLspSuite.scala +++ b/tests/unit/src/main/scala/tests/codeactions/BaseCodeActionLspSuite.scala @@ -15,7 +15,7 @@ abstract class BaseCodeActionLspSuite( suiteName: String ) extends BaseLspSuite(suiteName) { - protected val scalaVersion: String = V.scala213 + protected val scalaVersion: String = V.scala3 def checkNoAction( name: TestOptions, diff --git a/tests/unit/src/main/scala/tests/debug/BaseStackFrameDapSuite.scala b/tests/unit/src/main/scala/tests/debug/BaseStackFrameDapSuite.scala index 1aff518ed63..f9be84cefce 100644 --- a/tests/unit/src/main/scala/tests/debug/BaseStackFrameDapSuite.scala +++ b/tests/unit/src/main/scala/tests/debug/BaseStackFrameDapSuite.scala @@ -134,13 +134,17 @@ abstract class BaseStackFrameDapSuite( | } |}""".stripMargin, expectedFrames = List( + inScopeLocal( + assertNoDiff(_, "args: String[]"), + assertNoDiff(_, "this: Main$"), + ), inScopeLocal( assertNoDiff(_, "value: int = 1"), - assertNoDiff(_, "MODULE$: Main$"), + assertNoDiff(_, "this: Main$"), ), inScopeLocal( assertNoDiff(_, "value: int = 2"), - assertNoDiff(_, "MODULE$: Main$"), + assertNoDiff(_, "this: Main$"), ), ), ) @@ -158,23 +162,28 @@ abstract class BaseStackFrameDapSuite( |} |""".stripMargin, expectedFrames = List( + inScopeLocal( + assertNoDiff(_, "args: String[]"), + assertNoDiff(_, "this: Main$"), + ), // before calculating `z` inScopeLocal( assertNoDiff(_, "x: int = 1"), - assertNoDiff(_, "MODULE$: Main$"), + assertNoDiff(_, "this: Main$"), ), // after calculating `z` inScopeLocal( assertNoDiff(_, "x: int = 1"), assertNoDiff(_, "z: int = 3"), - assertNoDiff(_, "MODULE$: Main$"), + assertNoDiff(_, "this: Main$"), ), inScopeLocal( v => { assert(v.contains("x$1: Tuple2$mcII$sp")) assert(v.contains("\"(1,3)\"")) }, - assertNoDiff(_, "MODULE$: Main$"), + assertNoDiff(_, "x: int = 1"), + assertNoDiff(_, "this: Main$"), ), ), ) diff --git a/tests/unit/src/test/scala/tests/BillLspSuite.scala b/tests/unit/src/test/scala/tests/BillLspSuite.scala index 3ee4e79973a..f23cfc82b9b 100644 --- a/tests/unit/src/test/scala/tests/BillLspSuite.scala +++ b/tests/unit/src/test/scala/tests/BillLspSuite.scala @@ -30,13 +30,11 @@ class BillLspSuite extends BaseLspSuite("bill") { _ <- server.didOpen("src/com/App.scala") _ = assertNoDiff( client.workspaceDiagnostics, - """ - |src/com/App.scala:2:16: error: type mismatch; - | found : String("") - | required: Int - | val x: Int = "" - | ^^ - """.stripMargin, + """|src/com/App.scala:2:16: error: Found: ("" : String) + |Required: Int + | val x: Int = "" + | ^^ + |""".stripMargin, ) _ <- server.didSave("src/com/App.scala")(_ => "object App") _ = assertNoDiff( diff --git a/tests/unit/src/test/scala/tests/BloopJavaHomeLspSuite.scala b/tests/unit/src/test/scala/tests/BloopJavaHomeLspSuite.scala index 268165b97d5..23f51ed3e75 100644 --- a/tests/unit/src/test/scala/tests/BloopJavaHomeLspSuite.scala +++ b/tests/unit/src/test/scala/tests/BloopJavaHomeLspSuite.scala @@ -61,9 +61,8 @@ class BloopJavaHomeLspSuite extends BaseLspSuite("java-home") { _ <- server.didOpen("a/src/main/scala/a/A.scala") _ = assertNoDiff( client.workspaceDiagnostics, - """|a/src/main/scala/a/A.scala:2:29: error: type mismatch; - | found : Int(1) - | required: String + """|a/src/main/scala/a/A.scala:2:29: error: Found: (1 : Int) + |Required: String |object A { val x : String = 1 } | ^ |""".stripMargin, @@ -139,9 +138,8 @@ class BloopJavaHomeLspSuite extends BaseLspSuite("java-home") { _ <- server.didOpen("a/src/main/scala/a/A.scala") _ = assertNoDiff( client.workspaceDiagnostics, - """|a/src/main/scala/a/A.scala:2:29: error: type mismatch; - | found : Int(1) - | required: String + """|a/src/main/scala/a/A.scala:2:29: error: Found: (1 : Int) + |Required: String |object A { val x : String = 1 } | ^ |""".stripMargin, diff --git a/tests/unit/src/test/scala/tests/BuildTargetsLspSuite.scala b/tests/unit/src/test/scala/tests/BuildTargetsLspSuite.scala index 3fe7d8b7c2c..339c1a21cfe 100644 --- a/tests/unit/src/test/scala/tests/BuildTargetsLspSuite.scala +++ b/tests/unit/src/test/scala/tests/BuildTargetsLspSuite.scala @@ -18,7 +18,7 @@ class BuildTargetsLspSuite | }, | "b": { | "scalaVersion": "${BuildInfo.scalaVersion}", - | "libraryDependencies": ["com.lihaoyi::sourcecode:0.1.7"], + | "libraryDependencies": ["com.lihaoyi::sourcecode:0.2.7"], | "additionalSources": [ "shared/Main.scala" ] | } |} diff --git a/tests/unit/src/test/scala/tests/CascadeLspSuite.scala b/tests/unit/src/test/scala/tests/CascadeLspSuite.scala index 160ddeb4899..38bafcbcfee 100644 --- a/tests/unit/src/test/scala/tests/CascadeLspSuite.scala +++ b/tests/unit/src/test/scala/tests/CascadeLspSuite.scala @@ -37,12 +37,11 @@ class CascadeLspSuite extends BaseLspSuite("cascade") { // but not independent project "c". _ = assertNoDiff( client.workspaceDiagnostics, - """|b/src/main/scala/b/B.scala:3:19: error: type mismatch; - | found : Int - | required: String + """|b/src/main/scala/b/B.scala:3:19: error: Found: (a.A.n : Int) + |Required: String | val n: String = a.A.n | ^^^^^ - """.stripMargin, + |""".stripMargin, ) } yield () } diff --git a/tests/unit/src/test/scala/tests/CodeLensLspSuite.scala b/tests/unit/src/test/scala/tests/CodeLensLspSuite.scala index 1363d062472..6f83297799a 100644 --- a/tests/unit/src/test/scala/tests/CodeLensLspSuite.scala +++ b/tests/unit/src/test/scala/tests/CodeLensLspSuite.scala @@ -72,7 +72,7 @@ class CodeLensLspSuite extends BaseCodeLensLspSuite("codeLenses") { check( "test-suite-object", - library = Some("com.lihaoyi::utest:0.7.3"), + library = Some("com.lihaoyi::utest:0.8.1"), minExpectedLenses = 3, )( """|package foo.bar diff --git a/tests/unit/src/test/scala/tests/CompletionLspSuite.scala b/tests/unit/src/test/scala/tests/CompletionLspSuite.scala index b0ec99ee428..a147ce6919b 100644 --- a/tests/unit/src/test/scala/tests/CompletionLspSuite.scala +++ b/tests/unit/src/test/scala/tests/CompletionLspSuite.scala @@ -11,7 +11,7 @@ class CompletionLspSuite extends BaseCompletionLspSuite("completion") { override def munitIgnore: Boolean = isWindows test("basic-213") { - basicTest(V.scala213) + basicTest(V.scala3) } test("workspace".flaky) { diff --git a/tests/unit/src/test/scala/tests/DiagnosticsLspSuite.scala b/tests/unit/src/test/scala/tests/DiagnosticsLspSuite.scala index 035321e8b65..20851f348ed 100644 --- a/tests/unit/src/test/scala/tests/DiagnosticsLspSuite.scala +++ b/tests/unit/src/test/scala/tests/DiagnosticsLspSuite.scala @@ -14,12 +14,12 @@ class DiagnosticsLspSuite extends BaseLspSuite("diagnostics") { |{ | "a": { | "scalacOptions": [ - | "-Ywarn-unused" + | "-Wunused:all" | ] | }, | "b": { | "scalacOptions": [ - | "-Ywarn-unused" + | "-Wunused:all" | ] | } |} @@ -43,21 +43,21 @@ class DiagnosticsLspSuite extends BaseLspSuite("diagnostics") { _ = assertNoDiff(client.workspaceDiagnostics, "") _ <- server.didOpen("a/src/main/scala/a/Main.scala") exampleDiagnostics = { - """|a/src/main/scala/a/Example.scala:2:1: warning: Unused import + """|a/src/main/scala/a/Example.scala:2:29: warning: unused import |import java.util.concurrent.Future // unused - |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - |a/src/main/scala/a/Example.scala:3:1: warning: Unused import + | ^^^^^^ + |a/src/main/scala/a/Example.scala:3:19: warning: unused import |import scala.util.Failure // unused - |^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ |""".stripMargin } mainDiagnostics = { - """|a/src/main/scala/a/Main.scala:2:1: warning: Unused import + """|a/src/main/scala/a/Main.scala:2:29: warning: unused import |import java.util.concurrent.Future // unused - |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - |a/src/main/scala/a/Main.scala:3:1: warning: Unused import + | ^^^^^^ + |a/src/main/scala/a/Main.scala:3:19: warning: unused import |import scala.util.Failure // unused - |^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ |""".stripMargin } _ = assertNoDiff( @@ -66,12 +66,12 @@ class DiagnosticsLspSuite extends BaseLspSuite("diagnostics") { ) _ <- server.didOpen("b/src/main/scala/a/MainSuite.scala") testDiagnostics = { - """|b/src/main/scala/a/MainSuite.scala:2:1: warning: Unused import + """|b/src/main/scala/a/MainSuite.scala:2:29: warning: unused import |import java.util.concurrent.Future // unused - |^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - |b/src/main/scala/a/MainSuite.scala:3:1: warning: Unused import + | ^^^^^^ + |b/src/main/scala/a/MainSuite.scala:3:19: warning: unused import |import scala.util.Failure // unused - |^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ |""".stripMargin } _ = assertNoDiff( @@ -79,17 +79,17 @@ class DiagnosticsLspSuite extends BaseLspSuite("diagnostics") { testDiagnostics, ) // This seems to be currently broken on CI - diagnostics not being refreshed - // _ <- server.didSave("b/src/main/scala/a/MainSuite.scala")( - // _.linesIterator.filterNot(_.startsWith("import")).mkString("\n") - // ) - // _ = assertNoDiff( - // client.workspaceDiagnostics, - // exampleDiagnostics + mainDiagnostics - // ) - // _ <- server.didSave("a/src/main/scala/a/Main.scala")( - // _.linesIterator.filterNot(_.startsWith("import")).mkString("\n") - // ) - // _ = assertNoDiff(client.workspaceDiagnostics, exampleDiagnostics) + _ <- server.didSave("b/src/main/scala/a/MainSuite.scala")( + _.linesIterator.filterNot(_.startsWith("import")).mkString("\n") + ) + _ = assertNoDiff( + client.workspaceDiagnostics, + exampleDiagnostics + mainDiagnostics, + ) + _ <- server.didSave("a/src/main/scala/a/Main.scala")( + _.linesIterator.filterNot(_.startsWith("import")).mkString("\n") + ) + _ = assertNoDiff(client.workspaceDiagnostics, exampleDiagnostics) } yield () } @@ -179,7 +179,10 @@ class DiagnosticsLspSuite extends BaseLspSuite("diagnostics") { _ <- server.didOpen("a/src/main/scala/a/Deprecation.scala") _ = assertNoDiff( client.workspaceDiagnostics, - """|a/src/main/scala/a/Deprecation.scala:3:16: error: value Stream in package scala is deprecated (since 2.13.0): Use LazyList instead of Stream + """|a/src/main/scala/a/Deprecation.scala:3:13: error: class Stream in package scala.collection.immutable is deprecated since 2.13.0: Use LazyList (which is fully lazy) instead of Stream (which has a lazy tail only) + | val stream = Stream.empty + | ^ + |a/src/main/scala/a/Deprecation.scala:3:16: error: getter Stream in package scala is deprecated since 2.13.0: Use LazyList instead of Stream | val stream = Stream.empty | ^^^^^^ |""".stripMargin, @@ -248,9 +251,8 @@ class DiagnosticsLspSuite extends BaseLspSuite("diagnostics") { _ <- server.didOpen("a/src/main/scala/a/B.scala") _ = assertNoDiff( client.workspaceDiagnostics, - """|a/src/main/scala/a/B.scala:3:19: error: type mismatch; - | found : Int(42) - | required: String + """|a/src/main/scala/a/B.scala:3:19: error: Found: (42 : Int) + |Required: String | val x: String = 42 | ^^ |""".stripMargin, @@ -287,9 +289,8 @@ class DiagnosticsLspSuite extends BaseLspSuite("diagnostics") { _ <- server.didOpen("a/src/main/scala/a/A.scala") _ = assertNoDiff( client.workspaceDiagnostics, - """|a/src/main/scala/a/B.scala:2:19: error: type mismatch; - | found : Int(2) - | required: String + """|a/src/main/scala/a/B.scala:2:19: error: Found: (2 : Int) + |Required: String | val a: String = 2 | ^ |""".stripMargin, @@ -320,9 +321,8 @@ class DiagnosticsLspSuite extends BaseLspSuite("diagnostics") { _ <- server.didOpen("a/weird/path/A.scala") _ = assertNoDiff( client.workspaceDiagnostics, - """|a/weird/path/A.scala:2:16: error: type mismatch; - | found : String("") - | required: Int + """|a/weird/path/A.scala:2:16: error: Found: ("" : String) + |Required: Int | val n: Int = "" | ^^ |""".stripMargin, @@ -348,9 +348,8 @@ class DiagnosticsLspSuite extends BaseLspSuite("diagnostics") { _ <- server.didOpen("a/src/main/scala/a/A.scala") _ = assertNoDiff( client.workspaceDiagnostics, - """|a/src/main/scala/a/A.scala:2:16: error: type mismatch; - | found : String("") - | required: Int + """|a/src/main/scala/a/A.scala:2:16: error: Found: ("" : String) + |Required: Int | val n: Int = "" | ^^ |""".stripMargin, diff --git a/tests/unit/src/test/scala/tests/DidFocusLspSuite.scala b/tests/unit/src/test/scala/tests/DidFocusLspSuite.scala index 82028556f37..f18cc4338ae 100644 --- a/tests/unit/src/test/scala/tests/DidFocusLspSuite.scala +++ b/tests/unit/src/test/scala/tests/DidFocusLspSuite.scala @@ -177,9 +177,8 @@ class DidFocusWhileCompilingLspSuite _ <- server.didOpen("b/src/main/scala/b/B.scala") _ = assertNoDiagnostics() xMismatch = { - """|a/src/main/scala/a/A.scala:3:16: error: type mismatch; - | found : String("") - | required: Int + """|a/src/main/scala/a/A.scala:3:16: error: Found: ("" : String) + |Required: Int | val x: Int = "" | ^^ |""".stripMargin @@ -204,9 +203,8 @@ class DidFocusWhileCompilingLspSuite ) _ = assertNoDiff( client.workspaceDiagnostics, - """|b/src/main/scala/b/B.scala:3:16: error: type mismatch; - | found : String("") - | required: Int + """|b/src/main/scala/b/B.scala:3:16: error: Found: ("" : String) + |Required: Int | val y: Int = "" | ^^ |""".stripMargin, diff --git a/tests/unit/src/test/scala/tests/FindTextInDependencyJarsSuite.scala b/tests/unit/src/test/scala/tests/FindTextInDependencyJarsSuite.scala index cc6acd57d44..5fa609a730f 100644 --- a/tests/unit/src/test/scala/tests/FindTextInDependencyJarsSuite.scala +++ b/tests/unit/src/test/scala/tests/FindTextInDependencyJarsSuite.scala @@ -49,20 +49,19 @@ class FindTextInDependencyJarsSuite assertLocations( akkaLocations, - s"""| - |akka-actor_2.12-${akkaVersion}.jar/reference.conf:96:3: info: result - | jvm-shutdown-hooks = on - | ^^^^^^^^^^^^^^^^^^ - |akka-actor_2.12-${akkaVersion}.jar/reference.conf:1178:41: info: result - | # This property is related to `akka.jvm-shutdown-hooks` above. - | ^^^^^^^^^^^^^^^^^^ - |akka-actor_2.12-${akkaVersion}-sources.jar/reference.conf:96:3: info: result - | jvm-shutdown-hooks = on - | ^^^^^^^^^^^^^^^^^^ - |akka-actor_2.12-${akkaVersion}-sources.jar/reference.conf:1178:41: info: result - | # This property is related to `akka.jvm-shutdown-hooks` above. - | ^^^^^^^^^^^^^^^^^^ - |""".stripMargin, + """|akka-actor_2.12-2.6.16.jar/reference.conf:96:3: info: result + | jvm-shutdown-hooks = on + | ^^^^^^^^^^^^^^^^^^ + |akka-actor_2.12-2.6.16.jar/reference.conf:1178:41: info: result + | # This property is related to `akka.jvm-shutdown-hooks` above. + | ^^^^^^^^^^^^^^^^^^ + |akka-actor_2.12-2.6.16-sources.jar/reference.conf:96:3: info: result + | jvm-shutdown-hooks = on + | ^^^^^^^^^^^^^^^^^^ + |akka-actor_2.12-2.6.16-sources.jar/reference.conf:1178:41: info: result + | # This property is related to `akka.jvm-shutdown-hooks` above. + | ^^^^^^^^^^^^^^^^^^ + |""".stripMargin, ) assertLocations( diff --git a/tests/unit/src/test/scala/tests/HoverLspSuite.scala b/tests/unit/src/test/scala/tests/HoverLspSuite.scala index 961440772e2..baea86a6d2a 100644 --- a/tests/unit/src/test/scala/tests/HoverLspSuite.scala +++ b/tests/unit/src/test/scala/tests/HoverLspSuite.scala @@ -72,7 +72,7 @@ class HoverLspSuite extends BaseLspSuite("hover-") with TestHovers { for { _ <- initialize( s"""|/metals.json - |{"a":{"scalaVersion" : ${V.scala213}}} + |{"a":{"scalaVersion" : ${V.scala3}}} |/Main.scala |object Main extends App { | // @@ diff --git a/tests/unit/src/test/scala/tests/NewFileLspSuite.scala b/tests/unit/src/test/scala/tests/NewFileLspSuite.scala index 4d12ddc008f..efe1c65a4df 100644 --- a/tests/unit/src/test/scala/tests/NewFileLspSuite.scala +++ b/tests/unit/src/test/scala/tests/NewFileLspSuite.scala @@ -583,7 +583,7 @@ class NewFileLspSuite extends BaseLspSuite("new-file") { scalaVersion: Option[String], )(implicit loc: Location): Unit = test(testName) { - val localScalaVersion = scalaVersion.getOrElse(V.scala213) + val localScalaVersion = scalaVersion.getOrElse(V.scala3) val directoryUri = directory.fold(null.asInstanceOf[String])( workspace.resolve(_).toURI.toString() ) diff --git a/tests/unit/src/test/scala/tests/RenameLspSuite.scala b/tests/unit/src/test/scala/tests/RenameLspSuite.scala index a2d0f1af639..ef2cf538690 100644 --- a/tests/unit/src/test/scala/tests/RenameLspSuite.scala +++ b/tests/unit/src/test/scala/tests/RenameLspSuite.scala @@ -1,6 +1,7 @@ package tests import scala.meta.internal.metals.InitializationOptions +import scala.meta.internal.metals.{BuildInfo => V} class RenameLspSuite extends BaseRenameLspSuite(s"rename") { @@ -296,8 +297,9 @@ class RenameLspSuite extends BaseRenameLspSuite(s"rename") { |""".stripMargin, ) + // https://github.com/lampepfl/dotty/issues/18389 renamed( - "colon-good", + "colon-good".ignore, """|/a/src/main/scala/a/Main.scala |package a |class User{ @@ -521,67 +523,6 @@ class RenameLspSuite extends BaseRenameLspSuite(s"rename") { expectedError = true, ) - renamed( - "macro", - """|/a/src/main/scala/a/Main.scala - |package a - |import io.circe.generic.JsonCodec - |trait LivingBeing - |@JsonCodec sealed trait <> extends LivingBeing - |object <> { - | case object Dog extends <> - | case object Cat extends <> - |} - |""".stripMargin, - "Tree", - ) - - renamed( - "macro1", - """|/a/src/main/scala/a/Main.scala - |package a - |import io.circe.generic.JsonCodec - |trait <> - |@JsonCodec sealed trait Animal extends <> - |object Animal { - | case object Dog extends Animal - | case object Cat extends Animal - |} - |""".stripMargin, - "Tree", - ) - - renamed( - "macro2", - """|/a/src/main/scala/a/Main.scala - |package a - |import io.circe.generic.JsonCodec - |@JsonCodec - |final case class <>(name: String) - |""".stripMargin, - "Tree", - ) - - renamed( - "macro3", - """|/a/src/main/scala/a/Main.scala - |package a - |import io.circe.generic.JsonCodec - |trait LivingBeing - |@JsonCodec sealed trait <> extends LivingBeing - |object <>{ - | case object Dog extends <> - | case object Cat extends <> - |} - |/a/src/main/scala/a/Use.scala - |package a - |object Use { - | val dog : <> = <>.Dog - |} - |""".stripMargin, - "Tree", - ) - renamed( "implicit-param", """|/a/src/main/scala/a/Main.scala @@ -922,6 +863,48 @@ class RenameLspSuite extends BaseRenameLspSuite(s"rename") { nonOpened = Set("b/src/main/scala/b/B.scala"), ) + renamed( + "scala3-outer", + """|/a/src/main/scala/a/Main.scala + | + |@main def run() = { + | <>("Mark") + | <>("Anne") + |} + |def <>(name : String) : Unit = { + | println(s"Hello $name") + |} + |""".stripMargin, + newName = "greeting", + scalaVersion = Some(V.scala3), + ) + + renamed( + "scala3-extension-params", + """|/a/src/main/scala/a/Main.scala + | + |extension (<>: String) + | def double = <> + <> + | def double2 = <> + <> + |end extension + |""".stripMargin, + newName = "greeting", + scalaVersion = Some(V.scala3), + ) + + renamed( + "scala3-extension-params-ref", + """|/a/src/main/scala/a/Main.scala + | + |extension (<>: String) + | def double = <> + <> + | def double2 = <> + <> + |end extension + |""".stripMargin, + newName = "greeting", + scalaVersion = Some(V.scala3), + ) + override protected def libraryDependencies: List[String] = List("org.scalatest::scalatest:3.2.12", "io.circe::circe-generic:0.14.1") diff --git a/tests/unit/src/test/scala/tests/ResetWorkspaceLspSuite.scala b/tests/unit/src/test/scala/tests/ResetWorkspaceLspSuite.scala index df388220557..35cc545ee8a 100644 --- a/tests/unit/src/test/scala/tests/ResetWorkspaceLspSuite.scala +++ b/tests/unit/src/test/scala/tests/ResetWorkspaceLspSuite.scala @@ -58,9 +58,8 @@ class ResetWorkspaceLspSuite extends BaseLspSuite(s"reset-workspace") { ) _ = assertNoDiff( client.workspaceDiagnostics, - """|a/src/main/scala/b/B.scala:4:19: error: type mismatch; - | found : Int(42) - | required: String + """|a/src/main/scala/b/B.scala:4:19: error: Found: (42 : Int) + |Required: String | val x: String = 42 | ^^ |""".stripMargin, diff --git a/tests/unit/src/test/scala/tests/SemanticTokensExpectSuite.scala b/tests/unit/src/test/scala/tests/SemanticTokensExpectSuite.scala index f554da1d439..ca97601441e 100644 --- a/tests/unit/src/test/scala/tests/SemanticTokensExpectSuite.scala +++ b/tests/unit/src/test/scala/tests/SemanticTokensExpectSuite.scala @@ -6,9 +6,10 @@ import scala.meta.internal.metals.MetalsEnrichments._ import scala.meta.internal.metals.SemanticTokensProvider import scala.meta.internal.pc.ScalaPresentationCompiler -class SemanticTokensExpectSuite extends DirectoryExpectSuite("semanticTokens") { +class SemanticTokensExpectSuite + extends DirectoryExpectSuite("semanticTokens3") { - override lazy val input: InputProperties = InputProperties.scala2() + override lazy val input: InputProperties = InputProperties.scala3() private val compiler = new ScalaPresentationCompiler( classpath = input.classpath.entries.map(_.toNIO) ) @@ -27,7 +28,7 @@ class SemanticTokensExpectSuite extends DirectoryExpectSuite("semanticTokens") { val tokens = SemanticTokensProvider.provide( nodes, params, - isScala3 = false, + isScala3 = true, ) TestSemanticTokens.semanticString( diff --git a/tests/unit/src/test/scala/tests/SuperHierarchyLspSuite.scala b/tests/unit/src/test/scala/tests/SuperHierarchyLspSuite.scala index 5d021d81e63..4e867c6b7f8 100644 --- a/tests/unit/src/test/scala/tests/SuperHierarchyLspSuite.scala +++ b/tests/unit/src/test/scala/tests/SuperHierarchyLspSuite.scala @@ -82,22 +82,26 @@ class SuperHierarchyLspSuite extends BaseLspSuite("super-method-hierarchy") { val code = """ |package a - |import io.circe.Decoder + |import java.nio.file.FileSystem + |import java.nio.file.FileStore | - |trait CustomDecoder[X] extends Decoder[String] { - | override def <<1>>apply(c: io.circe.HCursor): Decoder.Result[String] = ??? - |} + |trait CustomFileSystem extends FileSystem { + | override def <<1>>close(): Unit = ??? | - |class CustomXDecoder extends CustomDecoder[Unit] { - | override def <<2>>apply(c: io.circe.HCursor): Decoder.Result[String] = ??? + | override def <<2>>getFileStores(): java.lang.Iterable[FileStore] = ??? |} | + | |""".stripMargin checkHierarchy( code, Map( - 1 -> List("io.circe.Decoder#apply"), - 2 -> List("a.CustomDecoder#apply", "io.circe.Decoder#apply"), + 1 -> List( + "java.nio.file.FileSystem#close", + "java.io.Closeable#close", + "java.lang.AutoCloseable#close", + ), + 2 -> List("java.nio.file.FileSystem#getFileStores"), ), ) } @@ -110,9 +114,7 @@ class SuperHierarchyLspSuite extends BaseLspSuite("super-method-hierarchy") { |/metals.json |{ | "a": { - | "libraryDependencies": [ - | "io.circe::circe-generic:0.12.0" - | ] + | "libraryDependencies": [] | } |} |/a/src/main/scala/a/A.scala diff --git a/tests/unit/src/test/scala/tests/SuperMethodLspSuite.scala b/tests/unit/src/test/scala/tests/SuperMethodLspSuite.scala index 153e93596e7..8c8c7a5e579 100644 --- a/tests/unit/src/test/scala/tests/SuperMethodLspSuite.scala +++ b/tests/unit/src/test/scala/tests/SuperMethodLspSuite.scala @@ -217,10 +217,11 @@ class SuperMethodLspSuite extends BaseLspSuite("gotosupermethod") { val code = """ |package a - |import io.circe.Decoder | - |trait CustomDecoder extends Decoder[String] { - | override def <<1->50>>apply(c: io.circe.HCursor): Decoder.Result[String] = ??? + |import java.nio.file.FileSystem + | + |trait CustomFileSystem extends FileSystem { + | override def <<4->50>>close(): Unit = ??? |} | |""".stripMargin @@ -270,7 +271,6 @@ class SuperMethodLspSuite extends BaseLspSuite("gotosupermethod") { |{ | "a": { | "libraryDependencies": [ - | "io.circe::circe-generic:0.12.0" | ] | } |} @@ -288,9 +288,9 @@ class SuperMethodLspSuite extends BaseLspSuite("gotosupermethod") { // Checked manually it is actually there and operated under artificial ID link "50" externalDep = Map( 50 -> (new Position( - 60, - 6, - ), workspace.toURI.toString + ".metals/readonly/dependencies/circe-core_2.13-0.12.0-sources.jar/io/circe/Decoder.scala") + 133, + 25, + ), workspace.toURI.toString + ".metals/readonly/dependencies/src.zip/java.base/java/nio/file/FileSystem.java") ) (context, assertions) = parseWithUri(code, path) diff --git a/tests/unit/src/test/scala/tests/TreeViewLspSuite.scala b/tests/unit/src/test/scala/tests/TreeViewLspSuite.scala index 994631ee87e..2e049c480db 100644 --- a/tests/unit/src/test/scala/tests/TreeViewLspSuite.scala +++ b/tests/unit/src/test/scala/tests/TreeViewLspSuite.scala @@ -7,6 +7,7 @@ import scala.util.Properties import scala.meta.internal.metals.InitializationOptions import scala.meta.internal.metals.JdkVersion +import scala.meta.internal.metals.BuildInfo as V import scala.meta.internal.metals.UserConfiguration import scala.meta.internal.tvp.TreeViewProvider import scala.meta.io.AbsolutePath @@ -203,18 +204,19 @@ class TreeViewLspSuite extends BaseLspSuite("tree-view") { test("libraries", withoutVirtualDocs = true) { for { _ <- initialize( - """ - |/metals.json - |{ - | "a": { - | "libraryDependencies": [ - | "io.circe::circe-core:0.14.0", - | "org.eclipse.lsp4j:org.eclipse.lsp4j:0.5.0", - | "com.lihaoyi::sourcecode:0.1.7" - | ] - | } - |} - |""".stripMargin + s""" + |/metals.json + |{ + | "a": { + | "scalaVersion" : "${V.scala213}", + | "libraryDependencies": [ + | "io.circe::circe-core:0.14.0", + | "org.eclipse.lsp4j:org.eclipse.lsp4j:0.5.0", + | "com.lihaoyi::sourcecode:0.1.7" + | ] + | } + |} + |""".stripMargin ) folder = server.server.path _ = { @@ -572,22 +574,22 @@ class TreeViewLspSuite extends BaseLspSuite("tree-view") { cleanWorkspace() for { _ <- initialize( - """ - |/metals.json - |{ - | "a": {}, - | "b": {} - |} - |/a/src/main/scala/a/First.scala - |package a - |class First - |/b/src/main/scala/b/Second.scala - |package b - |class Second { - | def a = 1 - | val b = 2 - |} - |""".stripMargin + s""" + |/metals.json + |{ + | "a": {"scalaVersion" : "${V.scala213}"}, + | "b": {"scalaVersion" : "${V.scala213}"} + |} + |/a/src/main/scala/a/First.scala + |package a + |class First + |/b/src/main/scala/b/Second.scala + |package b + |class Second { + | def a = 1 + | val b = 2 + |} + |""".stripMargin ) folder = server.server.path // Trigger a compilation of Second.scala diff --git a/tests/unit/src/test/scala/tests/WarningsLspSuite.scala b/tests/unit/src/test/scala/tests/WarningsLspSuite.scala index eff3e604c15..e465182a98d 100644 --- a/tests/unit/src/test/scala/tests/WarningsLspSuite.scala +++ b/tests/unit/src/test/scala/tests/WarningsLspSuite.scala @@ -7,13 +7,14 @@ class WarningsLspSuite extends BaseLspSuite("warnings") { test("deprecated-scala-212") { cleanWorkspace() - val using = V.deprecatedScalaVersions.filter(_.startsWith("2.12")).head + val usingVersion = + V.deprecatedScalaVersions.filter(_.startsWith("2.12")).head for { _ <- initialize( s"""/metals.json |{ | "a": { - | "scalaVersion": "${using}" + | "scalaVersion": "${usingVersion}" | } |} |/a/src/main/scala/a/Main.scala @@ -24,7 +25,7 @@ class WarningsLspSuite extends BaseLspSuite("warnings") { _ = assertNoDiff( client.workspaceMessageRequests, Messages.DeprecatedScalaVersion.message( - Set(using) + Set(usingVersion) ), ) } yield () @@ -32,14 +33,15 @@ class WarningsLspSuite extends BaseLspSuite("warnings") { test("multiple-problems-scala") { cleanWorkspace() - val using = V.deprecatedScalaVersions.filter(_.startsWith("2.12")).head + val usingVersion = + V.deprecatedScalaVersions.filter(_.startsWith("2.12")).head val older = "2.12.4" for { _ <- initialize( s"""/metals.json |{ | "a": { - | "scalaVersion": "${using}" + | "scalaVersion": "${usingVersion}" | }, | "b": { | "scalaVersion" : "$older" @@ -59,13 +61,13 @@ class WarningsLspSuite extends BaseLspSuite("warnings") { test("deprecated-scala-211") { cleanWorkspace() - val using = V.scala211 + val usingVersion = V.scala211 for { _ <- initialize( s"""/metals.json |{ | "a": { - | "scalaVersion": "${using}" + | "scalaVersion": "${usingVersion}" | } |} |/a/src/main/scala/a/Main.scala @@ -75,20 +77,20 @@ class WarningsLspSuite extends BaseLspSuite("warnings") { ) _ = assertNoDiff( client.workspaceMessageRequests, - Messages.DeprecatedScalaVersion.message(Set(using)), + Messages.DeprecatedScalaVersion.message(Set(usingVersion)), ) } yield () } test("unsupported-scala-212") { cleanWorkspace() - val using = "2.12.4" + val usingVersion = "2.12.4" for { _ <- initialize( s"""/metals.json |{ | "a": { - | "scalaVersion": "${using}" + | "scalaVersion": "${usingVersion}" | } |} |/a/src/main/scala/a/Main.scala @@ -98,20 +100,21 @@ class WarningsLspSuite extends BaseLspSuite("warnings") { ) _ = assertNoDiff( client.workspaceMessageRequests, - Messages.UnsupportedScalaVersion.message(Set(using)), + Messages.UnsupportedScalaVersion.message(Set(usingVersion)), ) } yield () } test("deprecated-scala-213") { cleanWorkspace() - val using = V.deprecatedScalaVersions.filter(_.startsWith("2.13")).head + val usingVersion = + V.deprecatedScalaVersions.filter(_.startsWith("2.13")).head for { _ <- initialize( s"""/metals.json |{ | "a": { - | "scalaVersion": "${using}" + | "scalaVersion": "${usingVersion}" | } |} |/a/src/main/scala/a/Main.scala @@ -121,20 +124,20 @@ class WarningsLspSuite extends BaseLspSuite("warnings") { ) _ = assertNoDiff( client.workspaceMessageRequests, - Messages.DeprecatedScalaVersion.message(Set(using)), + Messages.DeprecatedScalaVersion.message(Set(usingVersion)), ) } yield () } test("no-warnings-scala-3") { cleanWorkspace() - val using = V.scala3 + val usingVersion = V.scala3 for { _ <- initialize( s"""/metals.json |{ | "a": { - | "scalaVersion": "${using}" + | "scalaVersion": "${usingVersion}" | } |} |/a/src/main/scala/a/Main.scala diff --git a/tests/unit/src/test/scala/tests/WorkspaceFoldersSuite.scala b/tests/unit/src/test/scala/tests/WorkspaceFoldersSuite.scala index de29a5fe7c4..135be1c1d2c 100644 --- a/tests/unit/src/test/scala/tests/WorkspaceFoldersSuite.scala +++ b/tests/unit/src/test/scala/tests/WorkspaceFoldersSuite.scala @@ -12,14 +12,14 @@ class WorkspaceFoldersSuite Map( "testFolder" -> s"""|/metals.json - |{"a":{"scalaVersion" : ${V.scala213}}} + |{"a":{"scalaVersion" : ${V.scala3}}} |/a/src/main/scala/a/A.scala |package a |case class MyObjectA() |""".stripMargin, "otherTestFolder" -> s"""|/metals.json - |{"a":{"scalaVersion" : ${V.scala213}}} + |{"a":{"scalaVersion" : ${V.scala3}}} |/a/src/main/scala/a/B.scala |package a |case class MyObjectB() diff --git a/tests/unit/src/test/scala/tests/classFinder/ClassBreakpointSuite.scala b/tests/unit/src/test/scala/tests/classFinder/ClassBreakpointSuite.scala index d754950bbc5..4db59e879c4 100644 --- a/tests/unit/src/test/scala/tests/classFinder/ClassBreakpointSuite.scala +++ b/tests/unit/src/test/scala/tests/classFinder/ClassBreakpointSuite.scala @@ -163,7 +163,7 @@ class ClassBreakpointSuite extends BaseClassFinderSuite { name: TestOptions, original: String, expected: String, - scalaVersion: String = V.scala213, + scalaVersion: String = V.scala3, ): Unit = test(name) { val (buffers, classFinder) = init(scalaVersion) diff --git a/tests/unit/src/test/scala/tests/classFinder/FindAllClassesSuite.scala b/tests/unit/src/test/scala/tests/classFinder/FindAllClassesSuite.scala index b9f84dae1d8..db87ac63871 100644 --- a/tests/unit/src/test/scala/tests/classFinder/FindAllClassesSuite.scala +++ b/tests/unit/src/test/scala/tests/classFinder/FindAllClassesSuite.scala @@ -129,7 +129,7 @@ class FindAllClassesSuite extends BaseClassFinderSuite { "Class FooOps a.Foo$FooOps.class", "Object FooOps a.Foo$FooOps$.class", ), - scalaVersion = V.scala213, + scalaVersion = V.scala3, searchGranularity = ClassFinderGranularity.ClassFiles, ) @@ -142,7 +142,7 @@ class FindAllClassesSuite extends BaseClassFinderSuite { "Class Foo a.Foo.class", "Object Foo a.Foo$.class", ), - scalaVersion = V.scala213, + scalaVersion = V.scala3, searchGranularity = ClassFinderGranularity.ClassFiles, ) @@ -152,7 +152,7 @@ class FindAllClassesSuite extends BaseClassFinderSuite { expected: Vector[String], searchGranularity: ClassFinderGranularity, filename: String = "Main.scala", - scalaVersion: String = V.scala213, + scalaVersion: String = V.scala3, )(implicit loc: Location): Unit = test(name) { val (buffers, classFinder) = init(scalaVersion) diff --git a/tests/unit/src/test/scala/tests/classFinder/TastyNameResolverSuite.scala b/tests/unit/src/test/scala/tests/classFinder/TastyNameResolverSuite.scala index 5d27716c0cf..124daa19b09 100644 --- a/tests/unit/src/test/scala/tests/classFinder/TastyNameResolverSuite.scala +++ b/tests/unit/src/test/scala/tests/classFinder/TastyNameResolverSuite.scala @@ -135,7 +135,7 @@ class ClassNameResolverSuite extends BaseClassFinderSuite { original: String, expected: String, filename: String = "Main.scala", - scalaVersion: String = V.scala213, + scalaVersion: String = V.scala3, ): Unit = test(name) { val (buffers, classFinder) = init(scalaVersion) diff --git a/tests/unit/src/test/scala/tests/codeactions/ExtractRenameMemberLspSuite.scala b/tests/unit/src/test/scala/tests/codeactions/ExtractRenameMemberLspSuite.scala index b494a70e62d..33acda93457 100644 --- a/tests/unit/src/test/scala/tests/codeactions/ExtractRenameMemberLspSuite.scala +++ b/tests/unit/src/test/scala/tests/codeactions/ExtractRenameMemberLspSuite.scala @@ -465,7 +465,7 @@ class ExtractRenameMemberLspSuite name: TestOptions, original: String, codeActionExpected: Boolean = true, - scalaVersion: String = V.scala213, + scalaVersion: String = V.scala3, fileName: String = "A.scala", ): Unit = test(name) { diff --git a/tests/unit/src/test/scala/tests/codeactions/ExtractValueLspSuite.scala b/tests/unit/src/test/scala/tests/codeactions/ExtractValueLspSuite.scala index 71cd0f9513d..aa9a9e602a6 100644 --- a/tests/unit/src/test/scala/tests/codeactions/ExtractValueLspSuite.scala +++ b/tests/unit/src/test/scala/tests/codeactions/ExtractValueLspSuite.scala @@ -346,7 +346,7 @@ class ExtractValueLspSuite "extract-new", """|class Car(age: Int) |object Main{ - | new Car(age = <<1>>) + | val car = new Car(age = <<1>>) |} |""".stripMargin, s"""|${ExtractValueCodeAction.title("1")} @@ -354,7 +354,7 @@ class ExtractValueLspSuite """|class Car(age: Int) |object Main{ | val newValue = 1 - | new Car(age = newValue) + | val car = new Car(age = newValue) |} |""".stripMargin, ) diff --git a/tests/unit/src/test/scala/tests/codeactions/FlatMapToForComprehensionSuite.scala b/tests/unit/src/test/scala/tests/codeactions/FlatMapToForComprehensionSuite.scala index 58588abb564..616d05f3f41 100644 --- a/tests/unit/src/test/scala/tests/codeactions/FlatMapToForComprehensionSuite.scala +++ b/tests/unit/src/test/scala/tests/codeactions/FlatMapToForComprehensionSuite.scala @@ -53,6 +53,7 @@ class FlatMapToForComprehensionSuite |} |""".stripMargin, selectedActionIndex = 1, + expectNoDiagnostics = false, ) check( diff --git a/tests/unit/src/test/scala/tests/debug/CompletionDapSuite.scala b/tests/unit/src/test/scala/tests/debug/CompletionDapSuite.scala index 80aa43ac79c..8290e8ee8ca 100644 --- a/tests/unit/src/test/scala/tests/debug/CompletionDapSuite.scala +++ b/tests/unit/src/test/scala/tests/debug/CompletionDapSuite.scala @@ -20,11 +20,6 @@ class CompletionDapSuite "basic", expression = "1.toS@@", expectedCompletions = """|toShort: Short - |toBinaryString: String - |toDegrees: Double - |toHexString: String - |toOctalString: String - |toRadians: Double |toString(): String |""".stripMargin, expectedEdit = "1.toShort", @@ -71,12 +66,11 @@ class CompletionDapSuite assertCompletion( "advanced-snippet", expression = "1.until@@", - expectedCompletions = - """|until(end: Long): NumericRange.Exclusive[Long] - |until(end: Long, step: Long): NumericRange.Exclusive[Long] - |until(end: Int): Range - |until(end: Int, step: Int): Range - |""".stripMargin, + expectedCompletions = """|until(end: T): Exclusive[T] + |until(end: T, step: T): Exclusive[T] + |until(end: Int): Range + |until(end: Int, step: Int): Range + |""".stripMargin, expectedEdit = "1.until(@@)", topLines = Some(4), )( @@ -121,13 +115,10 @@ class CompletionDapSuite "multiline", expression = """|val a = 123 |a.toStri@@""".stripMargin, - expectedCompletions = """|toBinaryString: String - |toHexString: String - |toOctalString: String - |toString(): String + expectedCompletions = """|toString(): String |""".stripMargin, expectedEdit = """|val a = 123 - |a.toBinaryString""".stripMargin, + |a.toString()""".stripMargin, topLines = Some(4), )( """|/a/src/main/scala/a/Main.scala @@ -152,16 +143,13 @@ class CompletionDapSuite |val d = 111 |a.toStri@@ |1 + 234""".stripMargin, - expectedCompletions = """|toBinaryString: String - |toHexString: String - |toOctalString: String - |toString(): String + expectedCompletions = """|toString(): String |""".stripMargin, expectedEdit = """|val a = 123 |val b = 111 |val c = 111 |val d = 111 - |a.toBinaryString + |a.toString() |1 + 234 |""".stripMargin, topLines = Some(4), @@ -184,8 +172,8 @@ class CompletionDapSuite "single-dot", expression = "Main.@@", expectedCompletions = """|name: Option[String] - |args: Array[String] |executionStart: Long + |args: Array[String] |main(args: Array[String]): Unit |""".stripMargin, expectedEdit = "Main.name", diff --git a/tests/unit/src/test/scala/tests/scalafix/ScalafixProviderLspSuite.scala b/tests/unit/src/test/scala/tests/scalafix/ScalafixProviderLspSuite.scala index 32764248f4f..fc9f6a9be88 100644 --- a/tests/unit/src/test/scala/tests/scalafix/ScalafixProviderLspSuite.scala +++ b/tests/unit/src/test/scala/tests/scalafix/ScalafixProviderLspSuite.scala @@ -120,8 +120,7 @@ class ScalafixProviderLspSuite extends BaseLspSuite("scalafix-provider") { | |} |""".stripMargin, - ), - + ) } yield () } diff --git a/tests/unit/src/test/scala/tests/testProvider/TestSuitesProviderSuite.scala b/tests/unit/src/test/scala/tests/testProvider/TestSuitesProviderSuite.scala index ef39e7b3738..54e9f8a718a 100644 --- a/tests/unit/src/test/scala/tests/testProvider/TestSuitesProviderSuite.scala +++ b/tests/unit/src/test/scala/tests/testProvider/TestSuitesProviderSuite.scala @@ -574,7 +574,7 @@ class TestSuitesProviderSuite extends BaseLspSuite("testSuitesFinderSuite") { TestCaseEntry( "test$minusbacktick", "test-backtick", - QuickLocation(classUriFor(file), (3, 6, 3, 21)).toLsp, + QuickLocation(classUriFor(file), (3, 7, 3, 20)).toLsp, ) ).asJava, ), diff --git a/tests/unit/src/test/scala/tests/worksheets/WorksheetLspSuite.scala b/tests/unit/src/test/scala/tests/worksheets/WorksheetLspSuite.scala index 5726834a4ed..d3bf43baa76 100644 --- a/tests/unit/src/test/scala/tests/worksheets/WorksheetLspSuite.scala +++ b/tests/unit/src/test/scala/tests/worksheets/WorksheetLspSuite.scala @@ -4,8 +4,14 @@ import scala.meta.internal.metals.{BuildInfo => V} import munit.TestOptions -class WorksheetLspSuite extends tests.BaseWorksheetLspSuite(V.scala213) { +class WorksheetLspSuite extends tests.BaseWorksheetLspSuite(V.scala3) { + override def versionSpecificCodeToValidate: String = + """given str: String = """"" + + override def versionSpecificScalacOptionsToValidate: List[String] = List( + "-Ycheck-reentrant" + ) checkWorksheetDeps( "imports-inside", "a/src/main/scala/foo/Main.worksheet.sc", @@ -24,7 +30,7 @@ class WorksheetLspSuite extends tests.BaseWorksheetLspSuite(V.scala213) { | "a": {} |} |/$path - |import $$dep.`com.lihaoyi::scalatags:0.9.0` + |import $$dep.`com.lihaoyi::scalatags:0.12.0` |import scalatags.Text.all._ |val htmlFile = html( | body( @@ -43,11 +49,11 @@ class WorksheetLspSuite extends tests.BaseWorksheetLspSuite(V.scala213) { _ = assertNoDiff( server.workspaceDefinitions, s"""|/$path - |import $$dep/**/.`com.lihaoyi::scalatags:0.9.0`/**/ + |import $$dep/**/.`com.lihaoyi::scalatags:0.12.0`/**/ |import scalatags.Text/*Text.scala*/.all/*Text.scala*/._ - |val htmlFile/*L2*/ = html/*Text.scala*/( - | body/*Text.scala*/( - | p/*Text.scala*/("This is a big paragraph of text") + |val htmlFile/*L2*/ = html/*Tags.scala*/( + | body/*Tags.scala*/( + | p/*Tags.scala*/("This is a big paragraph of text") | ) |) |htmlFile/*L2*/.render/*Text.scala*/ @@ -58,14 +64,14 @@ class WorksheetLspSuite extends tests.BaseWorksheetLspSuite(V.scala213) { _ = assertNoDiagnostics() _ = assertNoDiff( client.workspaceDecorations(path), - """|import $dep.`com.lihaoyi::scalatags:0.9.0` + """|import $dep.`com.lihaoyi::scalatags:0.12.0` |import scalatags.Text.all._ |val htmlFile = html( | body( | p("This is a big paragraph of text") | ) - |) // : scalatags.Text.TypedTag[String] = TypedTag(tag = "html",modifiers = List(ArraySeq(TypedTag(tag = "body",modifiers = L… - |htmlFile.render // : String = "

This is a big paragraph of text

" + |) // : TypedTag[String] =

This is a big paragraph of text

+ |htmlFile.render // : String =

This is a big paragraph of text

|""".stripMargin, ) } yield () @@ -89,7 +95,7 @@ class WorksheetLspSuite extends tests.BaseWorksheetLspSuite(V.scala213) { _ <- server.didOpen(path) _ = assertNoDiff( client.workspaceErrorShowMessages, - "Error downloading com.lihaoyi:scalatags_2.13:0.999.0", + "Error downloading com.lihaoyi:scalatags_3:0.999.0", ) } yield () } @@ -113,7 +119,7 @@ class WorksheetLspSuite extends tests.BaseWorksheetLspSuite(V.scala213) { _ <- server.didOpen(path) _ = assertNoDiff( client.syntheticDecorations, - "new java.sql.Date(100L) // : java.sql.Date = 1970-01-01", + "new java.sql.Date(100L) // : Date = 1970-01-01", ) } yield () } diff --git a/tests/unit/src/test/scala/tests/worksheets/WorksheetNoDecorationsLspSuite.scala b/tests/unit/src/test/scala/tests/worksheets/WorksheetNoDecorationsLspSuite.scala index e5af14318f5..c794d69a0af 100644 --- a/tests/unit/src/test/scala/tests/worksheets/WorksheetNoDecorationsLspSuite.scala +++ b/tests/unit/src/test/scala/tests/worksheets/WorksheetNoDecorationsLspSuite.scala @@ -32,7 +32,7 @@ class WorksheetNoDecorationsLspSuite workspace.resolve("a/src/main/scala/foo/Main.worksheet.sc").readText, """ |val x = 1 /*> : Int = 1 */ - |val foo = "bar" /*> : String = "bar" */ + |val foo = "bar" /*> : String = bar */ |println("metals") /*> metals */ |""".stripMargin, ) @@ -40,11 +40,11 @@ class WorksheetNoDecorationsLspSuite "a/src/main/scala/foo/Main.worksheet.sc", """ |val x = 1 /*> : Int@@ = 1 */ - |val foo = "bar" /*> : @@String = "bar" */ + |val foo = "bar" /*> : @@String = bar */ |println("metals") /*> @@metals */ |""".stripMargin, """x: Int = 1""".hover, - """foo: String = "bar"""".hover, + """foo: String = bar""".hover, """// metals""".hover, ) } yield () @@ -70,7 +70,7 @@ class WorksheetNoDecorationsLspSuite workspace.resolve("a/src/main/scala/foo/Main.worksheet.sc").readText, """ |val x = 2 /*> : Int = 2 */ - |val foo = "baz" /*> : String = "baz" */ + |val foo = "baz" /*> : String = baz */ |println("meta ls") /*> meta ls */ |""".stripMargin, ) @@ -78,11 +78,11 @@ class WorksheetNoDecorationsLspSuite "a/src/main/scala/foo/Main.worksheet.sc", """ |val x = 2 /*> : Int @@= 2 */ - |val foo = "baz" /*> : String = "baz"@@ */ + |val foo = "baz" /*> : String = baz@@ */ |println("meta ls") /*> meta@@ ls */ |""".stripMargin, """x: Int = 2""".hover, - """foo: String = "baz"""".hover, + """foo: String = baz""".hover, """// meta ls""".hover, ) } yield ()