From 61babdb4e463483ed53bcc3a2410ff0bd435e78b 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 | 10 +- .scalafix2.conf | 19 ++ .scalafix3.conf | 13 -- .scalafmt.conf | 3 +- build.sbt | 121 +++++++----- .../src/main/scala/bench/MetalsBench.scala | 43 ----- .../internal/bsp/BspConfigGenerator.scala | 6 +- .../meta/internal/bsp/BspConnector.scala | 6 +- .../meta/internal/builds/BloopInstall.scala | 2 +- .../internal/builds/BuildToolSelector.scala | 4 +- .../meta/internal/builds/BuildTools.scala | 2 +- .../scala/meta/internal/builds/Digest.scala | 5 +- .../meta/internal/builds/GradleDigest.scala | 2 +- .../meta/internal/builds/MavenBuildTool.scala | 2 +- .../meta/internal/builds/MavenDigest.scala | 2 +- .../meta/internal/builds/MillDigest.scala | 1 + .../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 +- .../decorations/SemanticdbTreePrinter.scala | 6 +- .../ImplementationProvider.scala | 6 +- .../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 +- .../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 | 6 +- .../meta/internal/metals/Diagnostics.scala | 6 +- .../scala/meta/internal/metals/Embedded.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 | 6 +- .../meta/internal/metals/ImportedBuild.scala | 2 +- .../scala/meta/internal/metals/Indexer.scala | 4 +- .../metals/InitializationOptions.scala | 2 +- .../metals/InteractiveSemanticdbs.scala | 3 +- .../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 | 47 ++--- .../internal/metals/MetalsServerInputs.scala | 7 - .../internal/metals/MetalsSymbolSearch.scala | 2 +- .../meta/internal/metals/MtagsResolver.scala | 1 - .../internal/metals/PackageProvider.scala | 18 +- .../internal/metals/PopupChoiceReset.scala | 2 +- .../internal/metals/ReferenceProvider.scala | 4 +- .../meta/internal/metals/ScalaTarget.scala | 4 +- .../metals/ScalaVersionSelector.scala | 2 +- .../metals/ScaladocDefinitionProvider.scala | 1 + .../internal/metals/ScalafixProvider.scala | 2 +- .../metals/SemanticTokensProvider.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 | 6 +- .../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 | 6 +- .../internal/metals/ammonite/Ammonite.scala | 2 +- .../callHierarchy/CallHierarchyHelpers.scala | 1 + .../CallHierarchyItemBuilder.scala | 1 + .../callHierarchy/OutgoingCallsFinder.scala | 3 +- .../language/ConfiguredLanguageClient.scala | 21 ++- .../clients/language/MetalsHttpClient.scala | 4 +- .../metals/codeactions/CodeAction.scala | 4 +- .../codeactions/CodeActionProvider.scala | 1 - .../ConvertCommentCodeAction.scala | 2 +- .../codeactions/ConvertToNamedArguments.scala | 9 +- .../CreateCompanionObjectCodeAction.scala | 4 +- .../metals/codeactions/CreateNewSymbol.scala | 4 +- .../codeactions/ExtractRenameMember.scala | 8 +- .../codeactions/ExtractValueCodeAction.scala | 5 +- .../FlatMapToForComprehensionCodeAction.scala | 3 +- .../ImplementAbstractMembers.scala | 4 +- .../codeactions/ImportMissingSymbol.scala | 3 +- .../codeactions/InlineValueCodeAction.scala | 1 - .../codeactions/InsertInferredType.scala | 4 +- .../MillifyDependencyCodeAction.scala | 2 +- .../MillifyScalaCliDependencyCodeAction.scala | 2 +- .../metals/codeactions/OrganizeImports.scala | 4 +- .../codeactions/PatternMatchRefactor.scala | 4 +- .../RewriteBracesParensCodeAction.scala | 6 +- .../metals/codeactions/StringActions.scala | 7 +- .../metals/codelenses/RunTestCodeLens.scala | 5 +- .../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 | 6 +- .../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 +- .../testProvider/BuildTargetUpdate.scala | 2 +- .../metals/testProvider/TestSuitesIndex.scala | 2 +- .../testProvider/TestSuitesProvider.scala | 4 +- .../frameworks/JunitTestFinder.scala | 2 +- .../frameworks/MunitTestFinder.scala | 2 +- .../frameworks/ScalatestTestFinder.scala | 11 +- .../internal/metals/watcher/FileWatcher.scala | 2 +- .../meta/internal/parsing/ClassFinder.scala | 4 +- .../parsing/DocumentSymbolProvider.scala | 2 +- .../parsing/FoldingRangeExtractor.scala | 8 +- .../parsing/FoldingRangeProvider.scala | 2 +- .../parsing/JavaFoldingRangeExtractor.scala | 2 +- .../internal/parsing/TokenEditDistance.scala | 2 +- .../meta/internal/parsing/TokenOps.scala | 1 + .../scala/meta/internal/parsing/Trees.scala | 2 +- .../remotels/RemoteLanguageServer.scala | 2 +- .../meta/internal/rename/RenameProvider.scala | 14 +- .../meta/internal/tvp/ClasspathTreeView.scala | 2 +- .../meta/internal/tvp/IndexedSymbols.scala | 2 +- .../internal/tvp/MetalsTreeViewProvider.scala | 4 +- .../meta/internal/tvp/ScalacpCopyPaste.scala | 2 +- .../DecorationWorksheetPublisher.scala | 2 +- .../internal/worksheets/MdocEnrichments.scala | 1 - .../worksheets/WorksheetProvider.scala | 2 +- .../WorkspaceEditWorksheetPublisher.scala | 2 +- .../scala/meta/internal/pc/JavaHover.scala | 2 +- .../meta/internal/metals/ReportContext.scala | 2 +- .../internal/mtags/MtagsEnrichments.scala | 172 ------------------ .../scala/meta/internal/pc/Keywords.scala | 1 - .../internal/mtags/MtagsEnrichments.scala | 3 +- .../meta/internal/metals/BloomFilters.scala | 0 .../meta/internal/metals/PositionSyntax.scala | 6 +- .../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 - .../tests/feature/RenameCrossLspSuite.scala | 108 ++++++++--- .../SemanticTokensScala3ExpectSuite.scala | 15 +- .../scala/tests/feature/SlowSaveExpect.scala | 4 +- ...yntheticDecorationsScala3ExpectSuite.scala | 6 +- .../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 +- .../src/main/scala/tests/BaseLspSuite.scala | 11 +- .../main/scala/tests/BaseRenameLspSuite.scala | 13 +- .../scala/tests/BaseWorksheetLspSuite.scala | 8 +- .../scala/tests/BuildServerInitializer.scala | 4 - tests/unit/src/main/scala/tests/Library.scala | 5 +- .../src/main/scala/tests/QuickBuild.scala | 4 +- .../main/scala/tests/TestScala3Compiler.scala | 9 +- .../src/main/scala/tests/TestingClient.scala | 10 +- .../src/main/scala/tests/TestingServer.scala | 2 +- .../tests/WorkspaceSymbolReferences.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/DebugDiscoverySuite.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/JavaToplevelSuite.scala | 2 +- .../test/scala/tests/NewFileLspSuite.scala | 2 +- .../src/test/scala/tests/RenameLspSuite.scala | 108 +++++------ .../scala/tests/ResetWorkspaceLspSuite.scala | 5 +- .../tests/SemanticTokensExpectSuite.scala | 7 +- .../scala/tests/SuperHierarchyLspSuite.scala | 24 +-- .../scala/tests/SuperMethodLspSuite.scala | 14 +- .../test/scala/tests/TreeViewLspSuite.scala | 126 ++++++------- .../test/scala/tests/WarningsLspSuite.scala | 35 ++-- .../scala/tests/WorkspaceFoldersSuite.scala | 4 +- .../classFinder/ClassBreakpointSuite.scala | 2 +- .../classFinder/FindAllClassesSuite.scala | 6 +- .../classFinder/TastyNameResolverSuite.scala | 2 +- .../ConvertPatternMatchLspSuite.scala | 2 +- .../ConvertToNamedArgumentsLspSuite.scala | 2 +- .../ExtractRenameMemberLspSuite.scala | 2 +- .../codeactions/ExtractValueLspSuite.scala | 4 +- .../FlatMapToForComprehensionSuite.scala | 1 + .../InsertInferredTypeLspSuite.scala | 2 +- .../tests/debug/CompletionDapSuite.scala | 32 +--- .../formatting/OnTypeFormattingSuite.scala | 2 +- ...tringRangeFormattingWhenPastingSuite.scala | 2 +- ...ingRangeFormattingWhenSelectingSuite.scala | 2 +- .../scalafix/ScalafixProviderLspSuite.scala | 3 +- .../TestSuitesProviderSuite.scala | 2 +- .../tests/worksheets/WorksheetLspSuite.scala | 28 +-- .../WorksheetNoDecorationsLspSuite.scala | 12 +- 220 files changed, 1092 insertions(+), 1048 deletions(-) create mode 100644 .scalafix2.conf delete mode 100644 .scalafix3.conf rename mtags/src/main/{scala-2 => scala}/scala/meta/internal/metals/BloomFilters.scala (100%) rename mtags/src/main/{scala-2 => scala}/scala/meta/internal/metals/PositionSyntax.scala (93%) 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..632539e2234 100644 --- a/.scalafix.conf +++ b/.scalafix.conf @@ -1,16 +1,10 @@ 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." 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 632539e2234..00000000000 --- a/.scalafix3.conf +++ /dev/null @@ -1,13 +0,0 @@ -rules = [ - OrganizeImports -] - -OrganizeImports.groupedImports = Explode -OrganizeImports.expandRelative = true -OrganizeImports.removeUnused = false -OrganizeImports.groups = [ - "re:javax?\\." - "scala." - "scala.meta." - "*" -] diff --git a/.scalafmt.conf b/.scalafmt.conf index 467090140ee..6f5905aa973 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,5 +1,5 @@ version = "3.7.17" -runner.dialect = scala213 +runner.dialect = scala3 project.git = true align.preset = none align.stripMargin = true @@ -34,6 +34,7 @@ fileOverride { }, "glob:**/mtags*/**" { trailingCommas = never + runner.dialect = scala213 } "glob:**/tests/cross/src/**" { trailingCommas = never diff --git a/build.sbt b/build.sbt index 3495085bcc4..68b32937f2b 100644 --- a/build.sbt +++ b/build.sbt @@ -44,7 +44,7 @@ def crossSetting[A]( logo := Welcome.logo usefulTasks := Welcome.tasks -ThisBuild / scalafixScalaBinaryVersion := scalaBinaryVersion.value +ThisBuild / scalafixScalaBinaryVersion := "2.13" inThisBuild( List( @@ -52,8 +52,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") @@ -136,7 +136,7 @@ commands ++= Seq( runMtagsPublishLocal(st, v, localSnapshotVersion) } "interfaces/publishLocal" :: - s"++${V.scala213} metals/publishLocal" :: + s"++${V.scala3} metals/publishLocal" :: "mtags-java/publishLocal" :: publishMtags }, @@ -224,6 +224,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), ) @@ -291,21 +312,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 ++ V.nightlyScala3Versions, @@ -338,7 +357,7 @@ val mtagsSettings = List( ), if3 = List( "org.scala-lang" %% "scala3-compiler" % scalaVersion.value, - scala3ScalametaDependency, + scalametaDependency, ), if3WithPresentationCompiler = List( "org.scala-lang" %% "scala3-presentation-compiler" % scalaVersion.value @@ -372,7 +391,7 @@ val mtagsSettings = List( }, ) -lazy val mtags3 = project +lazy val mtags2 = project .in(file(".mtags")) .settings( Compile / unmanagedSourceDirectories := Seq(), @@ -380,13 +399,13 @@ 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, scalafixConfig := Some( - (ThisBuild / baseDirectory).value / ".scalafix3.conf" + (ThisBuild / baseDirectory).value / ".scalafix2.conf" ), ) .dependsOn(interfaces) @@ -403,9 +422,6 @@ lazy val mtags3WithPresentationCompiler = project scalaVersion := V.wrapperMetalsVersion, target := (ThisBuild / baseDirectory).value / "mtags" / "target" / "target3-wrapper", publish / skip := true, - scalafixConfig := Some( - (ThisBuild / baseDirectory).value / ".scalafix3.conf" - ), ) .dependsOn(interfaces) .enablePlugins(BuildInfoPlugin) @@ -455,7 +471,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 @@ -485,14 +502,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, + // for comparing versions + ("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, @@ -501,13 +524,12 @@ lazy val metals = project "com.lihaoyi" %% "ujson" % "3.1.3", // For remote language server "com.lihaoyi" %% "requests" % "0.8.0", - // 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, + // "org.scalameta" % "semanticdb-scalac-core" % V.scalameta cross CrossVersion.full, // 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.2.0", "org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4", ("org.virtuslab.scala-cli" % "scala-cli-bsp" % V.scalaCli) @@ -575,6 +597,7 @@ lazy val `sbt-metals` = project lazy val input = project .in(file("tests/input")) .settings( + scalaVersion := V.scala213, sharedSettings, publish / skip := true, libraryDependencies ++= List( @@ -708,7 +731,7 @@ lazy val mtest = project ), libraryDependencies ++= { if (isScala3WithPresentationCompiler(scalaVersion.value)) - List(scala3ScalametaDependency) + List(scalametaDependency) else Nil }, Compile / unmanagedSourceDirectories ++= { @@ -760,6 +783,7 @@ def isInTestShard(name: String, logger: Logger): Boolean = { lazy val metalsDependencies = project .in(file("target/.dependencies")) .settings( + scalaVersion := V.scala213, publish / skip := true, // silent the intransitive dependency warning publishMavenStyle := false, @@ -768,13 +792,13 @@ lazy val metalsDependencies = project // will pick them up and update them. They aren't actually used. "com.lihaoyi" %% "ammonite-util" % V.ammonite, "org.typelevel" % "kind-projector" % V.kindProjector cross CrossVersion.full, - "com.olegpy" %% "better-monadic-for" % V.betterMonadicFor, + ("com.olegpy" %% "better-monadic-for" % V.betterMonadicFor), "com.lihaoyi" % "mill-contrib-testng" % V.mill, "org.virtuslab.scala-cli" % "cli_3" % V.scalaCli intransitive (), "ch.epfl.scala" % "bloop-maven-plugin" % V.mavenBloop, "ch.epfl.scala" %% "gradle-bloop" % V.gradleBloop, "com.sourcegraph" % "semanticdb-java" % V.javaSemanticdb, - "ch.epfl.scala" %% "scala-debug-adapter" % V.debugAdapter intransitive (), + ("ch.epfl.scala" %% "scala-debug-adapter" % V.debugAdapter) intransitive (), ), ) .disablePlugins(ScalafixPlugin) @@ -789,9 +813,16 @@ 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, + // The dependencies listed below are only listed so Scala Steward + // will pick them up and update them. They aren't actually used. + ("com.lihaoyi" %% "ammonite-util" % V.ammonite intransitive ()) + .cross(CrossVersion.for3Use2_13), + "com.lihaoyi" % "mill-contrib-testng" % V.mill intransitive (), ), buildInfoPackage := "tests", Compile / resourceGenerators += InputProperties diff --git a/metals-bench/src/main/scala/bench/MetalsBench.scala b/metals-bench/src/main/scala/bench/MetalsBench.scala index b32c5ef6d7d..1f3224e819d 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.JdkSources import scala.meta.internal.metals.ReportContext @@ -19,7 +14,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 @@ -109,22 +103,6 @@ class MetalsBench { } } - @Benchmark - @BenchmarkMode(Array(Mode.SingleShotTime)) - def scalacTokenize(): Unit = { - val g = global - scalaDependencySources.inputs.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 = { @@ -134,27 +112,6 @@ class MetalsBench { } } - lazy val global: Global = InteractiveSemanticdb.newCompiler() - - @Benchmark - @BenchmarkMode(Array(Mode.SingleShotTime)) - def scalacParse(): Unit = { - val g = global - scalaDependencySources.inputs.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 dc85352442d..b33dc7b18a0 100644 --- a/metals/src/main/scala/scala/meta/internal/bsp/BspConfigGenerator.scala +++ b/metals/src/main/scala/scala/meta/internal/bsp/BspConfigGenerator.scala @@ -11,9 +11,9 @@ import scala.meta.internal.bsp.BspConfigGenerationStatus._ import scala.meta.internal.builds.BuildServerProvider import scala.meta.internal.builds.ShellRunner 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 163119842e2..7d5739a70ff 100644 --- a/metals/src/main/scala/scala/meta/internal/bsp/BspConnector.scala +++ b/metals/src/main/scala/scala/meta/internal/bsp/BspConnector.scala @@ -14,7 +14,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 @@ -62,7 +62,7 @@ class BspConnector( bspServers .findAvailableServers() .find(_.getName == sel) - .map(ResolvedBspOne) + .map(ResolvedBspOne.apply) } } @@ -156,7 +156,7 @@ class BspConnector( None, ) for { - Some(item) <- client + case Some(item) <- client .showMessageRequest(query.params) .asScala .map(item => 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 d6593e8f1f8..2ceafd632f8 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/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 b9c44746772..f9ddea83c5c 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/BuildTools.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/BuildTools.scala @@ -7,7 +7,7 @@ import java.util.concurrent.atomic.AtomicReference import scala.meta.internal.bsp.ScalaCliBspScope import scala.meta.internal.io.PathIO import scala.meta.internal.metals.BloopServers -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/Digest.scala b/metals/src/main/scala/scala/meta/internal/builds/Digest.scala index 719e47dc3d5..af14f97a522 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/Digest.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/Digest.scala @@ -8,9 +8,10 @@ import scala.util.control.NonFatal import scala.xml.Comment import scala.xml.Node +import scala.meta.given 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 @@ -160,7 +161,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 a2ab5d48ffe..6d70ef31b7d 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/MillDigest.scala b/metals/src/main/scala/scala/meta/internal/builds/MillDigest.scala index aa6f55f6f00..5229bcc0e2e 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/MillDigest.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/MillDigest.scala @@ -5,6 +5,7 @@ import java.security.MessageDigest import scala.collection.mutable import scala.util.control.NonFatal +import scala.meta.given import scala.meta.internal.mtags.MtagsEnrichments._ import scala.meta.internal.parsing.Trees import scala.meta.io.AbsolutePath 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 e52098ca8f4..17c49671f46 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/NewProjectProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/NewProjectProvider.scala @@ -11,7 +11,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.StatusBar 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 14690d8a747..e72c38bc70c 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 @@ -278,7 +278,7 @@ object SbtBuildTool { writtenPlugin || writtenMeta } - private case class PluginDetails private ( + case class PluginDetails private[SbtBuildTool] ( 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 48a8daae766..86183bd1473 100644 --- a/metals/src/main/scala/scala/meta/internal/builds/ShellRunner.scala +++ b/metals/src/main/scala/scala/meta/internal/builds/ShellRunner.scala @@ -10,7 +10,7 @@ import scala.util.Properties import scala.meta.internal.metals.Cancelable import scala.meta.internal.metals.JavaBinary -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.MutableCancelable import scala.meta.internal.metals.StatusBar import scala.meta.internal.metals.Time 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 353635b1ed4..80b38a427f3 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/decorations/SemanticdbTreePrinter.scala b/metals/src/main/scala/scala/meta/internal/decorations/SemanticdbTreePrinter.scala index 33d2a77703a..751afcfa9f9 100644 --- a/metals/src/main/scala/scala/meta/internal/decorations/SemanticdbTreePrinter.scala +++ b/metals/src/main/scala/scala/meta/internal/decorations/SemanticdbTreePrinter.scala @@ -1,6 +1,6 @@ package scala.meta.internal.decorations -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.UserConfiguration import scala.meta.internal.metap.PrinterSymtab import scala.meta.internal.semanticdb.Print @@ -123,7 +123,9 @@ class SemanticdbTreePrinter( case _ if isTuple => typeArgs.map(printType).mkString("(", ", ", ")") case _ if isFunction => - val argTypes :+ returnType = typeArgs.map(printType) + val all = typeArgs.map(printType) + val argTypes = all.dropRight(1) + val returnType = all.last argTypes.mkString("(", ", ", ")") + s" $rightArrow $returnType" case _ => typeArgs.map(printType).mkString("[", ", ", "]") 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 f36257b9ebb..c1aeeb9a84d 100644 --- a/metals/src/main/scala/scala/meta/internal/implementation/ImplementationProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/implementation/ImplementationProvider.scala @@ -12,7 +12,7 @@ import scala.util.control.NonFatal import scala.meta.internal.metals.Buffers import scala.meta.internal.metals.BuildTargets 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.ScalaVersionSelector import scala.meta.internal.metals.SemanticdbFeatureProvider @@ -31,6 +31,7 @@ import scala.meta.internal.semanticdb.TextDocument import scala.meta.internal.semanticdb.TextDocuments import scala.meta.internal.semanticdb.TypeRef import scala.meta.internal.semanticdb.TypeSignature +import scala.meta.internal.semanticdb.given import scala.meta.internal.symtab.GlobalSymbolTable import scala.meta.io.AbsolutePath @@ -270,8 +271,7 @@ final class ImplementationProvider( implDocument: TextDocument, implReal: ClassLocation, ): Option[String] = { - if (isClassLike(parentSymbolInfo)) - Some(implReal.symbol) + if (isClassLike(parentSymbolInfo)) Some(implReal.symbol) else { val symbolSearch = defaultSymbolSearch(source, implDocument) MethodImplementation.findInherited( 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 94d1dce1154..db4ceb3419f 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 5c2494e1aae..9885b5e085e 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/AdjustLspData.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/AdjustLspData.scala @@ -2,7 +2,7 @@ package scala.meta.internal.metals import java.{util => ju} -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.pc.AutoImportsResult import scala.meta.pc.HoverSignature @@ -55,8 +55,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 287446ce1f6..9c2af925e02 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/BloopServers.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/BloopServers.scala @@ -18,7 +18,7 @@ import scala.util.Try import scala.meta.internal.bsp.BuildChange import scala.meta.internal.bsp.ConnectionBspStatus import scala.meta.internal.metals.BloopJsonUpdateCause.BloopJsonUpdateCause -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 @@ -48,6 +48,16 @@ final class BloopServers( config: MetalsServerConfig, )(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] = @@ -470,15 +480,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 fcc150eadca..1b174ea2b41 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/BuildServerConnection.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/BuildServerConnection.scala @@ -25,7 +25,7 @@ import scala.util.Try import scala.meta.internal.bsp.ConnectionBspStatus 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 0f4b946ad1a..b7ee560a8f5 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/BuildTargetInfo.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/BuildTargetInfo.scala @@ -4,7 +4,7 @@ import java.nio.file.Path 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 ch.epfl.scala.bsp4j.BuildTarget @@ -14,7 +14,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)) .map(target => buildTargetDetail(target.getId())) .getOrElse(s"Build target $targetName not found") @@ -32,7 +32,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 114553c5103..22fb82858a9 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/BuildTargets.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/BuildTargets.scala @@ -12,7 +12,7 @@ import scala.concurrent.Future 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 11f171fb6fa..b9fa82b6ff6 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/CancelableFuture.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/CancelableFuture.scala @@ -21,7 +21,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/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 0eabb90d8a5..a4fa18259ac 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala @@ -7,7 +7,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.io.AbsolutePath @@ -79,6 +79,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 { @@ -178,8 +179,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 45d1600efa4..fbc1a90d745 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Compilers.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Compilers.scala @@ -16,11 +16,8 @@ import scala.util.control.NonFatal import scala.meta.inputs.Input import scala.meta.inputs.Position -import scala.meta.internal.decorations.DecorationOptions -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.parsing.Trees import scala.meta.internal.pc.EmptySymbolSearch import scala.meta.internal.pc.JavaPresentationCompiler @@ -28,6 +25,7 @@ import scala.meta.internal.pc.LogMessages import scala.meta.internal.pc.ScalaPresentationCompiler import scala.meta.internal.worksheets.WorksheetPcData import scala.meta.internal.worksheets.WorksheetProvider +import scala.meta.internal.decorations.DecorationOptions import scala.meta.io.AbsolutePath import scala.meta.pc.AutoImportsResult import scala.meta.pc.CancelToken @@ -906,7 +904,7 @@ class Compilers( jworksheetsCache.put( path, statusBar.trackBlockingTask( - s"${config.icons.sync}Loading worksheet presentation compiler" + s"${config.icons().sync}Loading worksheet presentation compiler" ) { val worksheetSearch = new StandaloneSymbolSearch( workspace, @@ -985,7 +983,7 @@ class Compilers( PresentationCompilerKey.BuildTarget(scalaTarget.info.getId), { _ => statusBar.trackBlockingTask( - s"${config.icons.sync}Loading presentation compiler" + s"${config.icons().sync}Loading presentation compiler" ) { newCompiler(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 1569101fc1a..48e55a2522f 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/DefinitionProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/DefinitionProvider.scala @@ -7,8 +7,9 @@ import scala.concurrent.Future import scala.meta.Term import scala.meta.Type +import scala.meta.given import scala.meta.inputs.Input -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 @@ -474,8 +475,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 87453784391..51c65e0ed3c 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Diagnostics.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Diagnostics.scala @@ -8,9 +8,9 @@ import scala.collection.concurrent.TrieMap import scala.collection.mutable 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 87a1fe8b5e1..068710234fb 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/FileDecoderProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/FileDecoderProvider.scala index 7a9bb702f11..45113a8c347 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 523d2808215..e442034d1f9 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/FileSystemSemanticdbs.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/FileSystemSemanticdbs.scala @@ -2,7 +2,7 @@ package scala.meta.internal.metals import java.nio.charset.Charset -import scala.meta.internal.metals.MetalsEnrichments._ +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 fd95b12c8ec..8d390e66661 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 @@ -189,7 +189,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 59a9da7cf27..0090e9f1195 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,7 @@ 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.StatusBar import scala.meta.internal.metals.TaskProgress import scala.meta.internal.metals.Time @@ -179,8 +179,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})" if (!compilation.isNoOp) { scribe.info(s"time: compiled $name in ${compilation.timer}") 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 17229c95e09..cfb32fa6f05 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 57ddb7b2006..228dad658fd 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Indexer.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Indexer.scala @@ -23,7 +23,7 @@ import scala.meta.internal.builds.BuildTool import scala.meta.internal.builds.BuildTools import scala.meta.internal.builds.Digest.Status import scala.meta.internal.builds.WorkspaceReload -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.ForwardingMetalsBuildClient import scala.meta.internal.metals.debug.BuildTargetClasses @@ -154,7 +154,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 e850acee4c3..e853b99e360 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/InitializationOptions.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/InitializationOptions.scala @@ -232,7 +232,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 35f4e367377..3715f85ea14 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/InteractiveSemanticdbs.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/InteractiveSemanticdbs.scala @@ -7,7 +7,8 @@ import scala.util.Success import scala.util.Try import scala.meta.internal.builds.SbtBuildTool -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.Messages._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.mtags.MD5 import scala.meta.internal.mtags.Semanticdbs import scala.meta.internal.mtags.TextDocumentLookup 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 6fae84713fd..ece8cd985e7 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/JarTopLevels.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/JarTopLevels.scala @@ -10,7 +10,7 @@ import java.util.zip.ZipException import scala.meta.internal.io.PlatformFileIO 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.io.AbsolutePath 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 bc1d4f50896..af280492a98 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 b25cb98f82a..1942ad7bb8e 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/JavaTarget.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/JavaTarget.scala @@ -3,7 +3,7 @@ package scala.meta.internal.metals import java.nio.file.Path 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 @@ -16,7 +16,7 @@ case class JavaTarget( javac: JavacOptionsItem, bspConnection: Option[BuildServerConnection], ) { - 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 b31969117b4..efc973c98ce 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 * // ... @@ -197,7 +197,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 @@ -403,8 +403,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) @@ -700,16 +699,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 1625d5ae708..15319f883da 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsLspService.scala @@ -43,10 +43,8 @@ import scala.meta.internal.decorations.SyntheticHoverProvider import scala.meta.internal.implementation.ImplementationProvider import scala.meta.internal.implementation.Supermethods import scala.meta.internal.io.FileIO -import scala.meta.internal.metals.BuildInfo import scala.meta.internal.metals.Messages.IncompatibleBloopVersion import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.StdReportContext import scala.meta.internal.metals.ammonite.Ammonite import scala.meta.internal.metals.callHierarchy.CallHierarchyProvider import scala.meta.internal.metals.clients.language.ConfiguredLanguageClient @@ -64,6 +62,7 @@ import scala.meta.internal.metals.formatting.OnTypeFormattingProvider import scala.meta.internal.metals.formatting.RangeFormattingProvider import scala.meta.internal.metals.newScalaFile.NewFileProvider import scala.meta.internal.metals.scalacli.ScalaCli +import scala.meta.internal.metals.{BuildInfo => V} import scala.meta.internal.metals.testProvider.BuildTargetUpdate import scala.meta.internal.metals.testProvider.TestSuitesProvider import scala.meta.internal.metals.watcher.FileWatcher @@ -249,7 +248,7 @@ class MetalsLspService( buildTargetClasses, () => folder, languageClient, - () => testProvider.refreshTestSuites(), + () => testProvider.refreshTestSuites(()), () => { if (clientConfig.isDoctorVisibilityProvider()) headDoctor.executeRefreshDoctor() @@ -342,7 +341,7 @@ class MetalsLspService( folder, buildTargets, statusBar, - clientConfig.icons, + clientConfig.icons(), buildTools, compilations.isCurrentlyCompiling, ) @@ -482,7 +481,7 @@ class MetalsLspService( folder, buffers, definitionProvider, - clientConfig.icons, + clientConfig.icons(), clientConfig.commandInHtmlFormat(), ) @@ -593,7 +592,7 @@ class MetalsLspService( languageClient, clientConfig, statusBar, - clientConfig.icons, + clientConfig.icons(), tables, buildTargets, ) @@ -611,7 +610,7 @@ class MetalsLspService( semanticdbs, definitionProvider, referencesProvider, - clientConfig.icons, + clientConfig.icons(), () => compilers, trees, buildTargets, @@ -637,7 +636,7 @@ class MetalsLspService( languageClient, packageProvider, scalaVersionSelector, - clientConfig.icons, + clientConfig.icons(), ) private val symbolSearch: MetalsSymbolSearch = new MetalsSymbolSearch( @@ -648,7 +647,7 @@ class MetalsLspService( val worksheetProvider: WorksheetProvider = { val worksheetPublisher = - if (clientConfig.isDecorationProvider) + if (clientConfig.isDecorationProvider()) new DecorationWorksheetPublisher( clientConfig.isInlineDecorationProvider() ) @@ -895,9 +894,11 @@ class MetalsLspService( new Registration( "1", "workspace/didChangeWatchedFiles", - clientConfig.globSyntax.registrationOptions( - this.folder - ), + clientConfig + .globSyntax() + .registrationOptions( + this.folder + ), ) ).asJava ) @@ -1000,7 +1001,7 @@ class MetalsLspService( session.version, userConfig.bloopVersion.nonEmpty, old.bloopVersion.isDefined, - () => autoConnectToBuildServer, + () => autoConnectToBuildServer(), ) .flatMap { _ => bloopServers.ensureDesiredJvmSettings( @@ -1569,7 +1570,7 @@ 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) } } } @@ -1639,7 +1640,7 @@ class MetalsLspService( item: CompletionItem ): CompletableFuture[CompletionItem] = CancelTokens.future { _ => - if (clientConfig.isCompletionItemResolve) { + if (clientConfig.isCompletionItemResolve()) { compilers.completionItemResolve(item) } else { Future.successful(item) @@ -1681,9 +1682,9 @@ 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) @@ -2017,7 +2018,7 @@ class MetalsLspService( } private def buildTool(): Future[Option[BuildTool]] = { - buildTools.loadSupported match { + buildTools.loadSupported() match { case Nil => Future(None) case buildTools => for { @@ -2056,7 +2057,7 @@ class MetalsLspService( } } - buildTools.loadSupported match { + buildTools.loadSupported() match { case Nil => { if (!buildTools.isAutoConnectable()) { warnings.noBuildTool() @@ -2122,7 +2123,7 @@ class MetalsLspService( def maybeSetupScalaCli(): Future[Unit] = { if ( !buildTools.isAutoConnectable() - && buildTools.loadSupported.isEmpty + && buildTools.loadSupported().isEmpty && folder.isScalaProject() ) scalaCli.setupIDE(folder) else Future.successful(()) @@ -2431,7 +2432,7 @@ class MetalsLspService( if (!notification.isDismissed) { val messageParams = IncompatibleBloopVersion.params( bspServerVersion, - BuildInfo.bloopVersion, + V.bloopVersion, isChangedInSettings = userConfig.bloopVersion != None, ) languageClient.showMessageRequest(messageParams).asScala.foreach { @@ -2451,7 +2452,7 @@ class MetalsLspService( ): Future[Unit] = { paths .find { path => - if (clientConfig.isDidFocusProvider || focusedDocument().isDefined) { + if (clientConfig.isDidFocusProvider() || focusedDocument().isDefined) { focusedDocument().contains(path) && path.isWorksheet } else { 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 df12b6071e6..050105456e0 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.ParentSymbols 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 cc27321116d..d77fad0bac5 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MtagsResolver.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MtagsResolver.scala @@ -6,7 +6,6 @@ import scala.concurrent.duration._ import scala.util.control.NonFatal import scala.meta.internal.jdk.CollectionConverters._ -import scala.meta.internal.metals.BuildInfo import scala.meta.internal.semver.SemVer import coursierapi.error.SimpleResolutionError 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 02a720292f9..2aeed684702 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/PackageProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/PackageProvider.scala @@ -6,11 +6,12 @@ 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.given import scala.meta.internal.{semanticdb => s} import scala.meta.io.AbsolutePath @@ -762,12 +763,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, @@ -846,7 +849,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) => @@ -930,7 +936,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 dc8b63b7398..8c885dcbfc9 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/PopupChoiceReset.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/PopupChoiceReset.scala @@ -5,7 +5,7 @@ import scala.concurrent.Future import scala.meta.internal.bsp.BspConnector 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 scala.meta.io.AbsolutePath 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 f90d7b78b2e..89e358b3414 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ReferenceProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ReferenceProvider.scala @@ -10,8 +10,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 @@ -24,6 +23,7 @@ import scala.meta.internal.semanticdb.SymbolOccurrence import scala.meta.internal.semanticdb.Synthetic import scala.meta.internal.semanticdb.TextDocument import scala.meta.internal.semanticdb.TextDocuments +import scala.meta.internal.semanticdb.given import scala.meta.internal.{semanticdb => s} import scala.meta.io.AbsolutePath 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 eea0ea8a1c3..c73470b87d2 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ScalaTarget.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ScalaTarget.scala @@ -5,7 +5,7 @@ import java.nio.file.Path import scala.meta.Dialect import scala.meta.dialects._ 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 @@ -52,7 +52,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/ScaladocDefinitionProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/ScaladocDefinitionProvider.scala index 8cc49de1a3a..6ec980b08b7 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ScaladocDefinitionProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ScaladocDefinitionProvider.scala @@ -9,6 +9,7 @@ import scala.meta.Defn import scala.meta.Pkg import scala.meta.Term import scala.meta.Tree +import scala.meta.given import scala.meta.inputs.Input import scala.meta.inputs.Position import scala.meta.internal.metals.MetalsEnrichments._ 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 00143378c95..486111d3891 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ScalafixProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ScalafixProvider.scala @@ -14,7 +14,7 @@ import scala.util.Success import scala.util.Try 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/SemanticTokensProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/SemanticTokensProvider.scala index f8d7d62fdff..d32753c6f28 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/SemanticTokensProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/SemanticTokensProvider.scala @@ -414,7 +414,7 @@ object SemanticTokensProvider { var delta = initialDelta val currentPart = new StringBuilder() - def emitToken(token: String, tokenType: Int) { + def emitToken(token: String, tokenType: Int) = { val (toAdd, newDelta) = convertTokensToIntList( token, delta, 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 9cdf9551cb5..948c359ed30 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 @@ -57,11 +57,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 1d267f96855..82ea12060d3 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 12365635831..ff87f0a8cf6 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 e3e9a11d0ec..6d649b2b895 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/StatusBar.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/StatusBar.scala @@ -13,7 +13,7 @@ import scala.util.Failure import scala.util.Success 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.MetalsSlowTaskParams import scala.meta.internal.metals.clients.language.MetalsStatusParams @@ -52,7 +52,7 @@ final class StatusBar( } def trackSlowTask[T](message: String)(thunk: => T): T = { - if (!clientConfig.slowTaskIsOn) + if (!clientConfig.slowTaskIsOn()) trackBlockingTask(message)(thunk) else { val task = client.metalsSlowTask(MetalsSlowTaskParams(message)) @@ -73,7 +73,7 @@ final class StatusBar( thunk: Future[T], onCancel: () => Unit = () => (), ): Future[T] = { - if (!clientConfig.slowTaskIsOn) + if (!clientConfig.slowTaskIsOn()) trackFuture(message, thunk) else { val task = client.metalsSlowTask(MetalsSlowTaskParams(message)) 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 b51a7d9680a..1c5652910a5 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 0735e018909..9a4f982f569 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/TargetData.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/TargetData.scala @@ -11,7 +11,7 @@ import scala.collection.mutable.ListBuffer import scala.collection.mutable.{Map => MMap} 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 656ee0b1038..d4a9a887845 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 799e019bf62..0c642fed555 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 @@ -199,7 +195,7 @@ class WorkspaceLspService( def fallbackService: MetalsLspService = folderServices.head val treeView: TreeViewProvider = - if (clientConfig.isTreeViewProvider) { + if (clientConfig.isTreeViewProvider()) { new MetalsTreeViewProvider( () => folderServices.map(_.treeView), languageClient, @@ -214,7 +210,7 @@ class WorkspaceLspService( statusBar, clientConfig, shellRunner, - clientConfig.icons, + clientConfig.icons(), folders.head.path, ) @@ -1070,7 +1066,7 @@ class WorkspaceLspService( ) capabilities.setCompletionProvider( new lsp4j.CompletionOptions( - clientConfig.isCompletionItemResolve, + clientConfig.isCompletionItemResolve(), List(".", "*").asJava, ) ) @@ -1147,7 +1143,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" @@ -1172,7 +1168,7 @@ class WorkspaceLspService( () => url, languageClient.underlying, () => server.reload(), - clientConfig.icons, + clientConfig.icons(), time, sh, clientConfig, @@ -1195,14 +1191,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 437fbdda27d..f97d838284d 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/WorkspaceSearchVisitor.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/WorkspaceSearchVisitor.scala @@ -5,9 +5,7 @@ import java.{util => ju} import scala.collection.mutable -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.mtags.GlobalSymbolIndex import scala.meta.internal.mtags.Symbol import scala.meta.internal.mtags.SymbolDefinition @@ -16,6 +14,8 @@ import scala.meta.internal.semanticdb.Scala.DescriptorParser import scala.meta.internal.semanticdb.Scala.Symbols import scala.meta.io.AbsolutePath import scala.meta.pc.SymbolSearchVisitor +import scala.meta.Dialect +import scala.meta.dialects import org.eclipse.lsp4j.SymbolKind import org.eclipse.lsp4j.jsonrpc.CancelChecker 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 06f9ee42a83..7143cd4bf5a 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/CallHierarchyHelpers.scala b/metals/src/main/scala/scala/meta/internal/metals/callHierarchy/CallHierarchyHelpers.scala index 932b6050f8c..d00a6f861a4 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/callHierarchy/CallHierarchyHelpers.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/callHierarchy/CallHierarchyHelpers.scala @@ -12,6 +12,7 @@ import scala.meta.Template import scala.meta.Term import scala.meta.Tree import scala.meta.Type +import scala.meta.given import scala.meta.internal.metals.ReferenceProvider import scala.meta.internal.{semanticdb => s} import scala.meta.io.AbsolutePath diff --git a/metals/src/main/scala/scala/meta/internal/metals/callHierarchy/CallHierarchyItemBuilder.scala b/metals/src/main/scala/scala/meta/internal/metals/callHierarchy/CallHierarchyItemBuilder.scala index 5cfae2752c1..918e6cb7a78 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/callHierarchy/CallHierarchyItemBuilder.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/callHierarchy/CallHierarchyItemBuilder.scala @@ -11,6 +11,7 @@ import scala.meta.internal.metals.MetalsEnrichments._ import scala.meta.internal.semanticdb.Scala._ import scala.meta.internal.semanticdb.SymbolOccurrence import scala.meta.internal.semanticdb.TextDocument +import scala.meta.internal.semanticdb.given import scala.meta.internal.{semanticdb => s} import scala.meta.io.AbsolutePath import scala.meta.pc.CancelToken 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 d8fa8438215..10b7d4c4ba4 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 @@ -9,6 +9,7 @@ import scala.meta.Name import scala.meta.Pat import scala.meta.Term import scala.meta.Tree +import scala.meta.given import scala.meta.internal.metals.DefinitionProvider import scala.meta.internal.metals.MetalsEnrichments._ import scala.meta.internal.metals.ReferenceProvider @@ -73,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 f6cd49bd8af..a7cb75d5e05 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 @@ -89,7 +89,7 @@ final class ConfiguredLanguageClient( override def metalsSlowTask( params: MetalsSlowTaskParams ): CompletableFuture[MetalsSlowTaskResult] = { - if (clientConfig.slowTaskIsOn) { + if (clientConfig.slowTaskIsOn()) { underlying.metalsSlowTask(params) } else { new CompletableFuture[MetalsSlowTaskResult]() @@ -111,7 +111,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. @@ -122,11 +123,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)) @@ -153,7 +154,7 @@ final class ConfiguredLanguageClient( override def rawMetalsInputBox( params: MetalsInputBoxParams ): CompletableFuture[RawMetalsInputBoxResult] = { - if (clientConfig.isInputBoxEnabled) { + if (clientConfig.isInputBoxEnabled()) { underlying.rawMetalsInputBox(params) } else { CompletableFuture.completedFuture( @@ -165,7 +166,7 @@ final class ConfiguredLanguageClient( override def rawMetalsQuickPick( params: MetalsQuickPickParams ): CompletableFuture[RawMetalsQuickPickResult] = { - if (clientConfig.isQuickPickProvider) { + if (clientConfig.isQuickPickProvider()) { underlying.rawMetalsQuickPick(params) } else { showMessageRequest( @@ -182,7 +183,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 d4b88568dae..3f12f8b84a1 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 @@ -13,7 +13,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.MetalsSlowTaskParams @@ -189,7 +189,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 29b32154f5c..dcdbaf6bf62 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 @@ -5,7 +5,7 @@ import scala.concurrent.Future 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 c6183779b04..2e35d9bdf49 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 @@ -5,12 +5,11 @@ import scala.concurrent.Future import scala.meta.Term import scala.meta.Tree +import scala.meta.given 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 @@ -40,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) @@ -136,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 885e79edb07..1f68c296649 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 @@ -14,18 +14,18 @@ import scala.meta.Template import scala.meta.Term import scala.meta.Tree import scala.meta.Type -import scala.meta.inputs.Position -import scala.meta.internal.metals.Buffers +import scala.meta.given 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 03b70e9a368..b356751bc3b 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 @@ -9,11 +9,10 @@ import scala.meta.Enumerator import scala.meta.Template import scala.meta.Term import scala.meta.Tree +import scala.meta.given 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 6dfc86312bf..31bf2b32209 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 @@ -12,11 +12,10 @@ import scala.meta.Pat import scala.meta.Term import scala.meta.Tree import scala.meta.Type +import scala.meta.given 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 286af7b1497..4b0946867ff 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 bca08beffd3..93cbaad71a5 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 @@ -3,9 +3,9 @@ package scala.meta.internal.metals.codeactions import scala.concurrent.ExecutionContext import scala.concurrent.Future +import scala.meta.given import scala.meta.internal.metals.Buffers import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.metals.codeactions.CodeAction 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 a67c18beef9..87be085ec3b 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 @@ -3,9 +3,9 @@ package scala.meta.internal.metals.codeactions import scala.concurrent.ExecutionContext import scala.concurrent.Future +import scala.meta.given 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 7ee6485ccba..4be3124442d 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 @@ -6,13 +6,11 @@ import scala.concurrent.Future import scala.meta.internal.metals.BuildTargets import scala.meta.internal.metals.Diagnostics import scala.meta.internal.metals.MetalsEnrichments.XtensionString -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given 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 8053eb344e8..7675f51a8ab 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 @@ -3,10 +3,9 @@ package scala.meta.internal.metals.codeactions import scala.concurrent.ExecutionContext import scala.concurrent.Future +import scala.meta.given 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 @@ -30,7 +29,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 903e9087e2a..fcee6e7045d 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 @@ -11,7 +11,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 @@ -26,6 +26,7 @@ import scala.meta.internal.semanticdb.SymbolOccurrence import scala.meta.internal.semanticdb.TextDocument import scala.meta.internal.semanticdb.TypeRef import scala.meta.internal.semanticdb.ValueSignature +import scala.meta.internal.semanticdb.given import scala.meta.io.AbsolutePath import ch.epfl.scala.bsp4j.BuildTargetIdentifier @@ -299,7 +300,7 @@ final class RunTestCodeLens( .flatMap(scalaTarget => JavaBinary.javaBinaryFromPath(scalaTarget.jvmHome) ) - .orElse(userConfig().usedJavaBinary) + .orElse(userConfig().usedJavaBinary()) val (data, shellCommandAdded) = buildTargetClasses.jvmRunEnvironment .get(target) .zip(javaBinary) match { 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 51cab530c02..7c8e6ca614e 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 @@ -4,7 +4,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 @@ -87,13 +87,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 77fc1ec460b..deb87438acf 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 @@ -2,14 +2,14 @@ package scala.meta.internal.metals.codelenses 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} class WorksheetCodeLens(clientConfig: ClientConfiguration) 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 c6bd1d79d91..e84f26c900d 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 11931f706f2..6841ba3603f 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 db97f3ac5bf..26cebdbe768 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 @@ -2,7 +2,7 @@ package scala.meta.internal.metals.debug import java.nio.file.Paths -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 6538725a44f..cb987ead290 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 @@ -4,7 +4,7 @@ import scala.reflect.ClassTag import scala.util.Failure 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 2022b56bef6..d9ef988356a 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 @@ -433,7 +433,7 @@ class DebugProvider( .flatMap(scalaTarget => JavaBinary.javaBinaryFromPath(scalaTarget.jvmHome) ) - .orElse(userConfig().usedJavaBinary) + .orElse(userConfig().usedJavaBinary()) val updatedData = buildTargetClasses.jvmRunEnvironment .get(params.getTargets().get(0)) .zip(javaBinary) match { @@ -691,7 +691,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 47a8baf1909..d54f4112ef5 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 @@ -13,7 +13,8 @@ import scala.meta.internal.metals.Cancelable 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.StatusBar @@ -217,7 +218,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 7b04cb22b1a..1305a1c9d68 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 cfd9a673117..1efdf8df386 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 @@ -29,7 +29,7 @@ import scala.meta.internal.metals.Icons import scala.meta.internal.metals.JavaTarget 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 @@ -304,7 +304,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(")") @@ -315,7 +315,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(")") @@ -332,7 +332,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 e3476b1edf5..f802c9cd45e 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 04b4dca3620..49f15b9e851 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 2b7417aa014..4d7c84f0f92 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 41fd705ee57..1936eb01e2d 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 @@ -189,7 +189,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/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/TestSuitesIndex.scala b/metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuitesIndex.scala index b69e21202fb..8c018863a3c 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuitesIndex.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/testProvider/TestSuitesIndex.scala @@ -14,7 +14,7 @@ import org.eclipse.{lsp4j => l} final case class FullyQualifiedName(value: String) extends AnyVal final case class ClassName(value: String) extends AnyVal -private[testProvider] final case class SymbolsPerTarget private ( +private[testProvider] final case class SymbolsPerTarget( target: BuildTarget, testSymbols: TrieMap[ BuildTargetClasses.Symbol, 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 32a2f738506..cec47557b05 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 @@ -354,7 +354,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 2ad922a02dc..0cd2169482c 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 49f631be91e..8bfadfdbf4b 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/metals/watcher/FileWatcher.scala b/metals/src/main/scala/scala/meta/internal/metals/watcher/FileWatcher.scala index 8fc2905ee93..27ce48363fd 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/watcher/FileWatcher.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/watcher/FileWatcher.scala @@ -19,7 +19,7 @@ import scala.util.Try import scala.meta.internal.metals.BuildTargets import scala.meta.internal.metals.Cancelable import scala.meta.internal.metals.Directories -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.MetalsServerConfig import scala.meta.io.AbsolutePath 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 a6f27fc65c9..d0460c8d859 100644 --- a/metals/src/main/scala/scala/meta/internal/parsing/ClassFinder.scala +++ b/metals/src/main/scala/scala/meta/internal/parsing/ClassFinder.scala @@ -11,8 +11,8 @@ import scala.meta.Position import scala.meta.Self import scala.meta.Tree import scala.meta.Type -import scala.meta.internal.metals.MetalsEnrichments._ -import scala.meta.internal.parsing.Trees +import scala.meta.given +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 c45fb241ec6..b32032e2c32 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.internal.trees.Origin import scala.meta.transversers.SimpleTraverser 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 c69274ce88a..5279d1781f2 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 343467b4d1b..82855d88222 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/TokenOps.scala b/metals/src/main/scala/scala/meta/internal/parsing/TokenOps.scala index b90ed379184..3a6c3d04f01 100644 --- a/metals/src/main/scala/scala/meta/internal/parsing/TokenOps.scala +++ b/metals/src/main/scala/scala/meta/internal/parsing/TokenOps.scala @@ -1,5 +1,6 @@ package scala.meta.internal.parsing +import scala.meta.given import scala.meta.inputs.Input import scala.meta.inputs.Position import scala.meta.tokens.Token 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 4c9c6d1d4e7..93022c1e491 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/remotels/RemoteLanguageServer.scala b/metals/src/main/scala/scala/meta/internal/remotels/RemoteLanguageServer.scala index a54712498e2..d86e9bb0482 100644 --- a/metals/src/main/scala/scala/meta/internal/remotels/RemoteLanguageServer.scala +++ b/metals/src/main/scala/scala/meta/internal/remotels/RemoteLanguageServer.scala @@ -12,7 +12,7 @@ import scala.meta.internal.metals.Buffers import scala.meta.internal.metals.BuildTargets import scala.meta.internal.metals.DefinitionResult import scala.meta.internal.metals.JsonParser._ -import scala.meta.internal.metals.MetalsEnrichments._ +import scala.meta.internal.metals.MetalsEnrichments.given import scala.meta.internal.metals.MetalsServerConfig import scala.meta.internal.metals.ReferencesResult import scala.meta.internal.metals.UserConfiguration 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 50ca3f5e634..9413c281ddf 100644 --- a/metals/src/main/scala/scala/meta/internal/rename/RenameProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/rename/RenameProvider.scala @@ -14,17 +14,18 @@ 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.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.semanticdb.Scala._ import scala.meta.internal.semanticdb.SelectTree import scala.meta.internal.semanticdb.SymbolOccurrence import scala.meta.internal.semanticdb.Synthetic import scala.meta.internal.semanticdb.TextDocument +import scala.meta.internal.semanticdb.given import scala.meta.internal.{semanticdb => s} import scala.meta.io.AbsolutePath import scala.meta.pc.CancelToken @@ -157,7 +158,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, @@ -274,10 +276,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/IndexedSymbols.scala b/metals/src/main/scala/scala/meta/internal/tvp/IndexedSymbols.scala index cdbbbdcc93d..44ac5182ff9 100644 --- a/metals/src/main/scala/scala/meta/internal/tvp/IndexedSymbols.scala +++ b/metals/src/main/scala/scala/meta/internal/tvp/IndexedSymbols.scala @@ -94,7 +94,7 @@ class IndexedSymbols(isStatisticsEnabled: Boolean)(implicit rc: ReportContext) symbol: String, ): Iterator[TreeViewSymbolInformation] = withTimer(s"$in/!$symbol") { val syms = workspaceCache - .getOrElse(in, Array.empty) + .getOrElse(in, Array.empty[TreeViewSymbolInformation]) if (Symbol(symbol).isRootPackage) syms.iterator else syms.collect { 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 d712d7ee380..6ff0102a8ae 100644 --- a/metals/src/main/scala/scala/meta/internal/tvp/MetalsTreeViewProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/tvp/MetalsTreeViewProvider.scala @@ -10,7 +10,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._ import scala.meta.internal.metals.clients.language.MetalsLanguageClient import scala.meta.internal.mtags.GlobalSymbolIndex @@ -222,7 +222,7 @@ class MetalsTreeViewProvider( TimeUnit.SECONDS, ) 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/tvp/ScalacpCopyPaste.scala b/metals/src/main/scala/scala/meta/internal/tvp/ScalacpCopyPaste.scala index 7b5068f8183..6af0802ee1b 100644 --- a/metals/src/main/scala/scala/meta/internal/tvp/ScalacpCopyPaste.scala +++ b/metals/src/main/scala/scala/meta/internal/tvp/ScalacpCopyPaste.scala @@ -169,7 +169,7 @@ object ScalacpCopyPaste { val ssym = sym.ssym sbuf += ssym if (sym.isUsefulField && sym.isMutable) { - val setterSymbolName = ssym.desc.name + "_=" + val setterSymbolName = ssym.desc.name.toString + "_=" val setterSym = Symbols.Global(ssym.owner, d.Method(setterSymbolName, "()")) sbuf += setterSym 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 f8fd8ba4871..5a5ff10d97f 100644 --- a/metals/src/main/scala/scala/meta/internal/worksheets/WorksheetProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/worksheets/WorksheetProvider.scala @@ -23,7 +23,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.MutableCancelable import scala.meta.internal.metals.ScalaVersionSelector import scala.meta.internal.metals.StatusBar 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 08b8ed50b52..52d5c7cf040 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.HoverSignature import org.eclipse.lsp4j diff --git a/mtags-shared/src/main/scala/scala/meta/internal/metals/ReportContext.scala b/mtags-shared/src/main/scala/scala/meta/internal/metals/ReportContext.scala index cba45550521..bf11f8bfe34 100644 --- a/mtags-shared/src/main/scala/scala/meta/internal/metals/ReportContext.scala +++ b/mtags-shared/src/main/scala/scala/meta/internal/metals/ReportContext.scala @@ -58,7 +58,7 @@ class StdReportContext( level, "metals" ) - val bloop = + val bloop: StdReporter = new StdReporter( workspace, StdReportContext.reportsDir, 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 aef68f7763f..9889b39f938 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 @@ -30,7 +30,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/BloomFilters.scala b/mtags/src/main/scala/scala/meta/internal/metals/BloomFilters.scala similarity index 100% rename from mtags/src/main/scala-2/scala/meta/internal/metals/BloomFilters.scala rename to mtags/src/main/scala/scala/meta/internal/metals/BloomFilters.scala 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 93% 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 3c10eaeae43..0176ee77b55 100644 --- a/mtags/src/main/scala-2/scala/meta/internal/metals/PositionSyntax.scala +++ b/mtags/src/main/scala/scala/meta/internal/metals/PositionSyntax.scala @@ -1,6 +1,8 @@ package scala.meta.internal.metals import scala.meta.Position +import scala.meta.internal.inputs.XtensionInputSyntaxStructure +import scala.meta.internal.inputs.XtensionPositionFormatMessage object PositionSyntax { @@ -64,9 +66,9 @@ object PositionSyntax { def lineTextAndCaret: String = { new StringBuilder() .append("\n") - .append(pos.lineContent) + .append(XtensionPositionFormatMessage(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 af5ee1d9eec..1ce33a9f3f4 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 @@ -563,4 +569,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/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 56151e3f4e7..3474f2d1193 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 SyntheticDecorationsScala3ExpectSuite(), + new SemanticTokensScala2ExpectSuite(), + new SyntheticDecorationsScala2ExpectSuite(), // TODO should be Scala 2 ).foreach { suite => val header = suite.suiteName.length + 2 println("=" * header) diff --git a/tests/slow/src/test/scala/tests/feature/SyntheticDecorationsScala3ExpectSuite.scala b/tests/slow/src/test/scala/tests/feature/SyntheticDecorationsScala3ExpectSuite.scala index 0d7a6f3e540..92ed491a6ec 100644 --- a/tests/slow/src/test/scala/tests/feature/SyntheticDecorationsScala3ExpectSuite.scala +++ b/tests/slow/src/test/scala/tests/feature/SyntheticDecorationsScala3ExpectSuite.scala @@ -5,15 +5,15 @@ import scala.meta.pc.PresentationCompiler import tests.BaseSyntheticDecorationsExpectSuite import tests.InputProperties -import tests.TestScala3Compiler +import tests.TestScala2Compiler -class SyntheticDecorationsScala3ExpectSuite( +class SyntheticDecorationsScala2ExpectSuite( ) extends BaseSyntheticDecorationsExpectSuite( "decorations3", InputProperties.scala3(), ) { override val compiler: PresentationCompiler = { - TestScala3Compiler.compiler("decorations", input)( + TestScala2Compiler.compiler("decorations", input)( munitExecutionContext ) match { case Some(pc) => pc diff --git a/tests/slow/src/test/scala/tests/feature/WorksheetCrossLspSuite.scala b/tests/slow/src/test/scala/tests/feature/WorksheetCrossLspSuite.scala index 6062bb91e01..2568338276f 100644 --- a/tests/slow/src/test/scala/tests/feature/WorksheetCrossLspSuite.scala +++ b/tests/slow/src/test/scala/tests/feature/WorksheetCrossLspSuite.scala @@ -5,15 +5,6 @@ import scala.meta.internal.semver.SemVer 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 @@ -26,3 +17,59 @@ class LatestWorksheet3LspSuite } 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 27c2e4b3e8a..2b55e3a2acc 100644 --- a/tests/slow/src/test/scala/tests/sbt/SbtServerSuite.scala +++ b/tests/slow/src/test/scala/tests/sbt/SbtServerSuite.scala @@ -142,7 +142,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) @@ -156,7 +156,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 ea17771c5fd..f83aa432059 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 @@ -35,6 +29,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._ @@ -42,6 +37,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 /** @@ -143,17 +144,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 @@ -235,7 +230,7 @@ object Bill { val scalaLib = Dependency.of( "org.scala-lang", "scala-library", - mtags.BuildInfo.scalaCompilerVersion, + BuildInfo.scala213, ) CompletableFuture.completedFuture { @@ -263,12 +258,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, @@ -277,32 +275,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), @@ -319,27 +318,22 @@ object Bill { params: CompileParams ): CompletableFuture[CompileResult] = { 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 @@ -381,6 +375,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 8187b2ceb63..c75dcbd4d97 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 @@ -117,9 +117,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/BaseLspSuite.scala b/tests/unit/src/main/scala/tests/BaseLspSuite.scala index 7d0ebf591dd..092618c9590 100644 --- a/tests/unit/src/main/scala/tests/BaseLspSuite.scala +++ b/tests/unit/src/main/scala/tests/BaseLspSuite.scala @@ -125,16 +125,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)) } } @@ -178,12 +178,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 78216404dbf..f47eaa4ec77 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 fc9083a471a..edd75c5c188 100644 --- a/tests/unit/src/main/scala/tests/BaseWorksheetLspSuite.scala +++ b/tests/unit/src/main/scala/tests/BaseWorksheetLspSuite.scala @@ -694,11 +694,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( """| @@ -743,11 +743,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 651768c4f9a..6d2e75a00ce 100644 --- a/tests/unit/src/main/scala/tests/BuildServerInitializer.scala +++ b/tests/unit/src/main/scala/tests/BuildServerInitializer.scala @@ -32,7 +32,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, @@ -61,7 +60,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, @@ -89,7 +87,6 @@ object BloopImportInitializer extends BuildServerInitializer { * with sbt as the build server. */ object SbtServerInitializer extends BuildServerInitializer { - this: BaseLspSuite => override def initialize( workspace: AbsolutePath, server: TestingServer, @@ -168,7 +165,6 @@ object SbtServerInitializer extends BuildServerInitializer { } object MillServerInitializer 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 0671e7d0adb..6c0c4417472 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), @@ -365,7 +365,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 69980bc636b..479e9f7ceed 100644 --- a/tests/unit/src/main/scala/tests/TestScala3Compiler.scala +++ b/tests/unit/src/main/scala/tests/TestScala3Compiler.scala @@ -13,17 +13,12 @@ import scala.meta.internal.metals.StatusBar import scala.meta.internal.metals.{BuildInfo => V} import scala.meta.pc.PresentationCompiler -import tests.FakeTime -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() - 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 a8a2d8ebf77..22c63cad505 100644 --- a/tests/unit/src/main/scala/tests/TestingClient.scala +++ b/tests/unit/src/main/scala/tests/TestingClient.scala @@ -107,20 +107,20 @@ class TestingClient(workspace: AbsolutePath, val buffers: Buffers) val decorations = new ConcurrentHashMap[AbsolutePath, Set[PublishDecorationsParams]]() var slowTaskHandler: MetalsSlowTaskParams => Option[MetalsSlowTaskResult] = { - _: MetalsSlowTaskParams => None + (_: MetalsSlowTaskParams) => None } - var showMessageHandler: MessageParams => Unit = { _: MessageParams => + var showMessageHandler: MessageParams => Unit = { (_: MessageParams) => () } var showMessageRequestHandler : ShowMessageRequestParams => Option[MessageActionItem] = { - _: ShowMessageRequestParams => None + (_: ShowMessageRequestParams) => None } var inputBoxHandler: MetalsInputBoxParams => RawMetalsInputBoxResult = { - _: MetalsInputBoxParams => RawMetalsInputBoxResult(cancelled = true) + (_: MetalsInputBoxParams) => RawMetalsInputBoxResult(cancelled = true) } var quickPickHandler: MetalsQuickPickParams => RawMetalsQuickPickResult = { - _: MetalsQuickPickParams => RawMetalsQuickPickResult(cancelled = true) + (_: MetalsQuickPickParams) => RawMetalsQuickPickResult(cancelled = true) } private val refreshCount = new AtomicInteger diff --git a/tests/unit/src/main/scala/tests/TestingServer.scala b/tests/unit/src/main/scala/tests/TestingServer.scala index ed664d0c72f..b19af83ff34 100644 --- a/tests/unit/src/main/scala/tests/TestingServer.scala +++ b/tests/unit/src/main/scala/tests/TestingServer.scala @@ -1052,7 +1052,7 @@ final case class TestingServer( // or fails if it could nat be achieved withing [[maxRetries]] number of tries var retries = maxRetries val codeLenses = Promise[List[l.CodeLens]]() - val handler = { refreshCount: Int => + val handler = { (refreshCount: Int) => scribe.info(s"Refreshing model for $filename") if (refreshCount > 0) for { diff --git a/tests/unit/src/main/scala/tests/WorkspaceSymbolReferences.scala b/tests/unit/src/main/scala/tests/WorkspaceSymbolReferences.scala index c900bdf2c81..ec641e8c9b0 100644 --- a/tests/unit/src/main/scala/tests/WorkspaceSymbolReferences.scala +++ b/tests/unit/src/main/scala/tests/WorkspaceSymbolReferences.scala @@ -1,5 +1,7 @@ package tests +import scala.meta.internal.inputs.XtensionInputSyntaxStructure + import munit.internal.difflib.Diffs case class WorkspaceSymbolReferences( 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 73d6611f099..35278a10877 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 7832a3d9654..1a91b1d4b86 100644 --- a/tests/unit/src/test/scala/tests/BloopJavaHomeLspSuite.scala +++ b/tests/unit/src/test/scala/tests/BloopJavaHomeLspSuite.scala @@ -67,9 +67,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, @@ -104,9 +103,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 9b03c3b8c6e..af8314a30c8 100644 --- a/tests/unit/src/test/scala/tests/CodeLensLspSuite.scala +++ b/tests/unit/src/test/scala/tests/CodeLensLspSuite.scala @@ -69,7 +69,7 @@ class CodeLensLspSuite extends BaseCodeLensLspSuite("codeLenses") { |""".stripMargin ) - check("test-suite-object", library = Some("com.lihaoyi::utest:0.7.3"))( + check("test-suite-object", library = Some("com.lihaoyi::utest:0.8.1"))( """|package foo.bar |<><> |object Foo extends utest.TestSuite { diff --git a/tests/unit/src/test/scala/tests/CompletionLspSuite.scala b/tests/unit/src/test/scala/tests/CompletionLspSuite.scala index 5157f0fb8e0..75f1496e7a8 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/DebugDiscoverySuite.scala b/tests/unit/src/test/scala/tests/DebugDiscoverySuite.scala index 22a25d697be..165b712bd41 100644 --- a/tests/unit/src/test/scala/tests/DebugDiscoverySuite.scala +++ b/tests/unit/src/test/scala/tests/DebugDiscoverySuite.scala @@ -295,7 +295,7 @@ class DebugDiscoverySuite } test("invalid-env") { - val fakePath = workspace + "fake-path" + val fakePath = workspace.toString + "fake-path" for { _ <- initialize( 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 73767cae753..5b539772526 100644 --- a/tests/unit/src/test/scala/tests/DidFocusLspSuite.scala +++ b/tests/unit/src/test/scala/tests/DidFocusLspSuite.scala @@ -174,9 +174,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 @@ -211,9 +210,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 bf970069fa6..f247cd1572c 100644 --- a/tests/unit/src/test/scala/tests/HoverLspSuite.scala +++ b/tests/unit/src/test/scala/tests/HoverLspSuite.scala @@ -41,7 +41,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/JavaToplevelSuite.scala b/tests/unit/src/test/scala/tests/JavaToplevelSuite.scala index 2d27c36d6d5..9dd493a14ea 100644 --- a/tests/unit/src/test/scala/tests/JavaToplevelSuite.scala +++ b/tests/unit/src/test/scala/tests/JavaToplevelSuite.scala @@ -81,7 +81,7 @@ class JavaToplevelSuite extends BaseSuite { name: TestOptions, code: String, expected: String, - )(implicit loc: Location) { + )(implicit loc: Location) = { test(name) { val input = AbsolutePath(Files.createTempFile("mtags", ".java")) input.writeText(code) 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 dd2b7a43b11..f1dd273216a 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 @@ -894,7 +835,46 @@ class RenameLspSuite extends BaseRenameLspSuite(s"rename") { expectedError = true, ) - override protected def libraryDependencies: List[String] = - List("org.scalatest::scalatest:3.2.12", "io.circe::circe-generic:0.14.1") + 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), + ) } 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 e13dd6e0dcf..02251cb57b3 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 @@ -71,40 +72,40 @@ class TreeViewLspSuite extends BaseLspSuite("tree-view") { test("projects") { cleanWorkspace() for { - _ <- initialize(""" - |/metals.json - |{ - | "a": {}, - | "b": {} - |} - |/a/src/main/scala/a/Zero.scala - |class Zero { - | val a = 1 - |} - |/a/src/main/scala/a/First.scala - |package a - |class First { - | def a = 1 - | val b = 2 - |} - |object First - |/a/src/main/scala/a/Second.scala - |package a - |class Second { - | def a = 1 - | val b = 2 - | var c = 2 - |} - |object Second - |/b/src/main/scala/b/Third.scala - |package b - |class Third - |object Third - |/b/src/main/scala/b/Fourth.scala - |package b - |class Fourth - |object Fourth - |""".stripMargin) + _ <- initialize(s""" + |/metals.json + |{ + | "a": { "scalaVersion" : "${V.scala213}"}, + | "b": { "scalaVersion" : "${V.scala213}"} + |} + |/a/src/main/scala/a/Zero.scala + |class Zero { + | val a = 1 + |} + |/a/src/main/scala/a/First.scala + |package a + |class First { + | def a = 1 + | val b = 2 + |} + |object First + |/a/src/main/scala/a/Second.scala + |package a + |class Second { + | def a = 1 + | val b = 2 + | var c = 2 + |} + |object Second + |/b/src/main/scala/b/Third.scala + |package b + |class Third + |object Third + |/b/src/main/scala/b/Fourth.scala + |package b + |class Fourth + |object Fourth + |""".stripMargin) _ = assertNoDiff( client.workspaceTreeViewChanges, s"""|${TreeViewProvider.Project} @@ -191,18 +192,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 _ = { @@ -561,22 +563,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/ConvertPatternMatchLspSuite.scala b/tests/unit/src/test/scala/tests/codeactions/ConvertPatternMatchLspSuite.scala index 79dfa997957..4e1e85e4b71 100644 --- a/tests/unit/src/test/scala/tests/codeactions/ConvertPatternMatchLspSuite.scala +++ b/tests/unit/src/test/scala/tests/codeactions/ConvertPatternMatchLspSuite.scala @@ -9,7 +9,7 @@ class ConvertPatternMatchLspSuite "convertPatternMatch" ) { - val filterAction: CodeAction => Boolean = { act: CodeAction => + val filterAction: CodeAction => Boolean = { (act: CodeAction) => act.getTitle() == PatternMatchRefactor.convertPatternMatch } diff --git a/tests/unit/src/test/scala/tests/codeactions/ConvertToNamedArgumentsLspSuite.scala b/tests/unit/src/test/scala/tests/codeactions/ConvertToNamedArgumentsLspSuite.scala index b371dc684ff..073cad19e0b 100644 --- a/tests/unit/src/test/scala/tests/codeactions/ConvertToNamedArgumentsLspSuite.scala +++ b/tests/unit/src/test/scala/tests/codeactions/ConvertToNamedArgumentsLspSuite.scala @@ -9,7 +9,7 @@ class ConvertToNamedArgumentsLspSuite "convertToNamedArguments" ) { - val filterAction: CodeAction => Boolean = { act: CodeAction => + val filterAction: CodeAction => Boolean = { (act: CodeAction) => ConvertToNamedArguments.title(".*").r matches act.getTitle() } 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/codeactions/InsertInferredTypeLspSuite.scala b/tests/unit/src/test/scala/tests/codeactions/InsertInferredTypeLspSuite.scala index bcfdb7d276d..026bff9389c 100644 --- a/tests/unit/src/test/scala/tests/codeactions/InsertInferredTypeLspSuite.scala +++ b/tests/unit/src/test/scala/tests/codeactions/InsertInferredTypeLspSuite.scala @@ -9,7 +9,7 @@ class InsertInferredTypeLspSuite "insertInferredType" ) { - val filterAction: CodeAction => Boolean = { act: CodeAction => + val filterAction: CodeAction => Boolean = { (act: CodeAction) => act.getTitle() == InsertInferredType.insertType || act .getTitle() == InsertInferredType.insertTypeToPattern } diff --git a/tests/unit/src/test/scala/tests/debug/CompletionDapSuite.scala b/tests/unit/src/test/scala/tests/debug/CompletionDapSuite.scala index 8a3ed3bbf7e..c47596e74f2 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/formatting/OnTypeFormattingSuite.scala b/tests/unit/src/test/scala/tests/formatting/OnTypeFormattingSuite.scala index 25da27ee845..326ba6284d7 100644 --- a/tests/unit/src/test/scala/tests/formatting/OnTypeFormattingSuite.scala +++ b/tests/unit/src/test/scala/tests/formatting/OnTypeFormattingSuite.scala @@ -621,7 +621,7 @@ class OnTypeFormattingSuite extends BaseLspSuite("onTypeFormatting") { stripMarginEnabled: Boolean = true, additionalRequests: TestingServer => Future[Unit] = _ => Future.unit, )(implicit loc: Location): Unit = { - val quote = """\u0022""" + val quote = "\"" def unmangle(string: String): String = string.replaceAll("'", quote) diff --git a/tests/unit/src/test/scala/tests/rangeFormatting/MultilineStringRangeFormattingWhenPastingSuite.scala b/tests/unit/src/test/scala/tests/rangeFormatting/MultilineStringRangeFormattingWhenPastingSuite.scala index 60f4d5bc4a8..d2e72d470c0 100644 --- a/tests/unit/src/test/scala/tests/rangeFormatting/MultilineStringRangeFormattingWhenPastingSuite.scala +++ b/tests/unit/src/test/scala/tests/rangeFormatting/MultilineStringRangeFormattingWhenPastingSuite.scala @@ -345,7 +345,7 @@ class MultilineStringRangeFormattingWhenPastingSuite paste: String, expectedCase: String, )(implicit loc: Location): Unit = { - val tripleQuote = """\u0022\u0022\u0022""" + val tripleQuote = "\"\"\"" def unmangle(string: String): String = string.replaceAll("'''", tripleQuote) diff --git a/tests/unit/src/test/scala/tests/rangeFormatting/MultilineStringRangeFormattingWhenSelectingSuite.scala b/tests/unit/src/test/scala/tests/rangeFormatting/MultilineStringRangeFormattingWhenSelectingSuite.scala index ff2026994e4..a31fbcf2b7c 100644 --- a/tests/unit/src/test/scala/tests/rangeFormatting/MultilineStringRangeFormattingWhenSelectingSuite.scala +++ b/tests/unit/src/test/scala/tests/rangeFormatting/MultilineStringRangeFormattingWhenSelectingSuite.scala @@ -142,7 +142,7 @@ class MultilineStringRangeFormattingWhenSelectingSuite testCase: String, expectedCase: String, )(implicit loc: Location): Unit = { - val tripleQuote = """\u0022\u0022\u0022""" + val tripleQuote = "\"\"\"" def unmangle(string: String): String = string.replaceAll("'''", tripleQuote) diff --git a/tests/unit/src/test/scala/tests/scalafix/ScalafixProviderLspSuite.scala b/tests/unit/src/test/scala/tests/scalafix/ScalafixProviderLspSuite.scala index 8972333d773..84c0d637a32 100644 --- a/tests/unit/src/test/scala/tests/scalafix/ScalafixProviderLspSuite.scala +++ b/tests/unit/src/test/scala/tests/scalafix/ScalafixProviderLspSuite.scala @@ -117,8 +117,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 df1eb099e75..aab51e1dda3 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 ()