diff --git a/presentation-compiler/src/main/dotty/tools/pc/AutoImportsProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/AutoImportsProvider.scala index 0a6178eae106..97ec396abcf1 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/AutoImportsProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/AutoImportsProvider.scala @@ -4,7 +4,7 @@ import java.nio.file.Paths import scala.collection.mutable import scala.jdk.CollectionConverters.* -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import scala.meta.internal.pc.AutoImportsResultImpl import scala.meta.pc.* diff --git a/presentation-compiler/src/main/dotty/tools/pc/CompilerSearchVisitor.scala b/presentation-compiler/src/main/dotty/tools/pc/CompilerSearchVisitor.scala index d282d7c8a8f3..f2e17415138a 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/CompilerSearchVisitor.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/CompilerSearchVisitor.scala @@ -4,7 +4,7 @@ import java.util.logging.Level import java.util.logging.Logger import scala.meta.internal.metals.Report -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import scala.meta.pc.* import scala.util.control.NonFatal @@ -35,7 +35,7 @@ class CompilerSearchVisitor( false case NonFatal(e) => reports.incognito.create( - Report( + () => Report( "is_public", s"""Symbol: $sym""".stripMargin, e diff --git a/presentation-compiler/src/main/dotty/tools/pc/ExtractMethodProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/ExtractMethodProvider.scala index 00cde67873d5..bd44878aa11a 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/ExtractMethodProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/ExtractMethodProvider.scala @@ -2,7 +2,7 @@ package dotty.tools.pc import java.nio.file.Paths -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import scala.meta.internal.pc.ExtractMethodUtils import scala.meta.pc.OffsetParams import scala.meta.pc.RangeParams diff --git a/presentation-compiler/src/main/dotty/tools/pc/HoverProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/HoverProvider.scala index d86b3d2eb2c4..c55a8a0210be 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/HoverProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/HoverProvider.scala @@ -3,7 +3,7 @@ package dotty.tools.pc import java.util as ju import scala.meta.internal.metals.Report -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import scala.meta.internal.pc.ScalaHover import scala.meta.pc.ContentType import scala.meta.pc.HoverSignature @@ -88,7 +88,7 @@ object HoverProvider: s"$uri::$posId" ) end report - reportContext.unsanitized.create(report, ifVerbose = true) + reportContext.unsanitized.create(() => report, /*ifVerbose =*/ true) ju.Optional.empty().nn else val skipCheckOnName = diff --git a/presentation-compiler/src/main/dotty/tools/pc/InferExpectedType.scala b/presentation-compiler/src/main/dotty/tools/pc/InferExpectedType.scala index 075167f3f5c1..b90a43146ed4 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/InferExpectedType.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/InferExpectedType.scala @@ -21,7 +21,7 @@ import dotty.tools.pc.printer.ShortenedTypePrinter import dotty.tools.pc.printer.ShortenedTypePrinter.IncludeDefaultParam import dotty.tools.pc.utils.InteractiveEnrichments.* -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import scala.meta.pc.OffsetParams import scala.meta.pc.SymbolSearch diff --git a/presentation-compiler/src/main/dotty/tools/pc/InferredTypeProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/InferredTypeProvider.scala index 887d404570c0..d019368c7ed6 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/InferredTypeProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/InferredTypeProvider.scala @@ -3,7 +3,7 @@ package dotty.tools.pc import java.nio.file.Paths import scala.annotation.tailrec -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import scala.meta.pc.OffsetParams import scala.meta.pc.PresentationCompilerConfig import scala.meta.pc.SymbolSearch diff --git a/presentation-compiler/src/main/dotty/tools/pc/PcInlayHintsProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/PcInlayHintsProvider.scala index 0734468754c0..c8847dc5b478 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/PcInlayHintsProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/PcInlayHintsProvider.scala @@ -5,7 +5,7 @@ import java.nio.file.Paths import scala.annotation.tailrec -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import dotty.tools.pc.utils.InteractiveEnrichments.* import dotty.tools.pc.printer.ShortenedTypePrinter import scala.meta.internal.pc.InlayHints diff --git a/presentation-compiler/src/main/dotty/tools/pc/Scala3CompilerAccess.scala b/presentation-compiler/src/main/dotty/tools/pc/Scala3CompilerAccess.scala index 1443fbcf37cc..f6fc48e5ae67 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/Scala3CompilerAccess.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/Scala3CompilerAccess.scala @@ -3,7 +3,7 @@ package dotty.tools.pc import java.util.concurrent.ScheduledExecutorService import scala.concurrent.ExecutionContextExecutor -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import scala.meta.internal.pc.CompilerAccess import scala.meta.pc.PresentationCompilerConfig diff --git a/presentation-compiler/src/main/dotty/tools/pc/ScalaPresentationCompiler.scala b/presentation-compiler/src/main/dotty/tools/pc/ScalaPresentationCompiler.scala index 81bad6a2976d..2f218687296f 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/ScalaPresentationCompiler.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/ScalaPresentationCompiler.scala @@ -15,11 +15,10 @@ import scala.jdk.CollectionConverters._ import scala.language.unsafeNulls import scala.meta.internal.metals.CompilerVirtualFileParams import scala.meta.internal.metals.EmptyCancelToken -import scala.meta.internal.metals.EmptyReportContext +import scala.meta.pc.reports.EmptyReportContext import scala.meta.internal.metals.PcQueryContext -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import scala.meta.internal.metals.ReportLevel -import scala.meta.internal.metals.StdReportContext import scala.meta.internal.mtags.CommonMtagsEnrichments.* import scala.meta.internal.pc.CompilerAccess import scala.meta.internal.pc.DefinitionResultImpl @@ -54,8 +53,11 @@ case class ScalaPresentationCompiler( folderPath: Option[Path] = None, reportsLevel: ReportLevel = ReportLevel.Info, completionItemPriority: CompletionItemPriority = (_: String) => 0, + reportContext: ReportContext = EmptyReportContext() ) extends PresentationCompiler: + given ReportContext = reportContext + override def supportedCodeActions(): ju.List[String] = List( CodeActionId.ConvertToNamedArguments, CodeActionId.ImplementAbstractMembers, @@ -72,10 +74,6 @@ case class ScalaPresentationCompiler( private val forbiddenOptions = Set("-print-lines", "-print-tasty") private val forbiddenDoubleOptions = Set.empty[String] - given ReportContext = - folderPath - .map(StdReportContext(_, _ => buildTargetName, reportsLevel)) - .getOrElse(EmptyReportContext) override def codeAction[T]( params: OffsetParams, @@ -513,6 +511,9 @@ case class ScalaPresentationCompiler( def withSearch(search: SymbolSearch): PresentationCompiler = copy(search = search) + override def withReportContext(reportContext: ReportContext): PresentationCompiler = + copy(reportContext = reportContext) + def withWorkspace(workspace: Path): PresentationCompiler = copy(folderPath = Some(workspace)) diff --git a/presentation-compiler/src/main/dotty/tools/pc/SignatureHelpProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/SignatureHelpProvider.scala index 5f925ea80ee7..423ca5d8db89 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/SignatureHelpProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/SignatureHelpProvider.scala @@ -13,7 +13,7 @@ import dotty.tools.pc.utils.InteractiveEnrichments.* import org.eclipse.lsp4j as l import scala.jdk.CollectionConverters.* -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import scala.meta.pc.OffsetParams import scala.meta.pc.SymbolDocumentation import scala.meta.pc.SymbolSearch diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteFileCompletions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteFileCompletions.scala index a903aa5dea19..7c25f8a69174 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteFileCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/AmmoniteFileCompletions.scala @@ -63,7 +63,7 @@ object AmmoniteFileCompletions: ) def matches(file: Path): Boolean = - (Files.isDirectory(file) || file.toAbsolutePath().toString.isAmmoniteScript) && + (Files.isDirectory(file) || file.toAbsolutePath().toString.isScalaScript) && query.exists(q => CompletionFuzzy.matches(q.nn, file.getFileName().toString)) (split, workspace) match diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionProvider.scala index ef9f77eb58fc..f1645f76cf97 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/CompletionProvider.scala @@ -4,7 +4,7 @@ package completions import java.nio.file.Path import scala.jdk.CollectionConverters._ -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import scala.meta.pc.OffsetParams import scala.meta.pc.PresentationCompilerConfig import scala.meta.pc.SymbolSearch diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala index 4b2e76807895..6e79f5a293e5 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala @@ -5,7 +5,7 @@ import java.nio.file.Path import java.nio.file.Paths import scala.collection.mutable -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import scala.meta.internal.mtags.CoursierComplete import scala.meta.internal.pc.{IdentifierComparator, MemberOrdering, CompletionFuzzy} import scala.meta.pc.* diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/InterpolatorCompletions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/InterpolatorCompletions.scala index da46e5167834..9cceff7310c6 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/InterpolatorCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/InterpolatorCompletions.scala @@ -1,7 +1,7 @@ package dotty.tools.pc.completions import scala.collection.mutable.ListBuffer -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import scala.meta.internal.pc.CompletionFuzzy import scala.meta.internal.pc.InterpolationSplice import scala.meta.pc.PresentationCompilerConfig diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/MatchCaseCompletions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/MatchCaseCompletions.scala index 185f3f87f42e..2e89b4e5bb99 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/MatchCaseCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/MatchCaseCompletions.scala @@ -6,7 +6,7 @@ import java.net.URI import scala.collection.mutable import scala.collection.mutable.ListBuffer import scala.jdk.CollectionConverters._ -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import scala.meta.internal.pc.CompletionFuzzy import scala.meta.pc.PresentationCompilerConfig import scala.meta.pc.SymbolSearch diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/OverrideCompletions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/OverrideCompletions.scala index 8123bc8fa216..807f959a2406 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/OverrideCompletions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/OverrideCompletions.scala @@ -4,7 +4,7 @@ package completions import java.util as ju import scala.jdk.CollectionConverters._ -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import scala.meta.pc.OffsetParams import scala.meta.pc.PresentationCompilerConfig import scala.meta.pc.PresentationCompilerConfig.OverrideDefFormat diff --git a/presentation-compiler/src/main/dotty/tools/pc/printer/ShortenedTypePrinter.scala b/presentation-compiler/src/main/dotty/tools/pc/printer/ShortenedTypePrinter.scala index dd390fb09ace..99a32e42d8a4 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/printer/ShortenedTypePrinter.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/printer/ShortenedTypePrinter.scala @@ -2,7 +2,7 @@ package dotty.tools.pc.printer import scala.collection.mutable import scala.meta.internal.jdk.CollectionConverters.* -import scala.meta.internal.metals.ReportContext +import scala.meta.pc.reports.ReportContext import scala.meta.internal.mtags.KeywordWrapper import scala.meta.pc.SymbolDocumentation import scala.meta.pc.SymbolSearch diff --git a/presentation-compiler/test/dotty/tools/pc/base/BaseInlayHintsSuite.scala b/presentation-compiler/test/dotty/tools/pc/base/BaseInlayHintsSuite.scala index 7d29e6c4dda9..32c6ad26c6a5 100644 --- a/presentation-compiler/test/dotty/tools/pc/base/BaseInlayHintsSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/base/BaseInlayHintsSuite.scala @@ -30,12 +30,14 @@ class BaseInlayHintsSuite extends BasePCSuite { withPkg.length() ) val pcParams = CompilerInlayHintsParams( - rangeParams, - true, - true, - true, - true, - hintsInPatternMatch + rangeParams = rangeParams, + inferredTypes = true, + typeParameters = true, + implicitParameters = true, + byNameParameters = true, + implicitConversions = true, + namedParameters = true, + hintsInPatternMatch = hintsInPatternMatch ) val inlayHints = presentationCompiler diff --git a/presentation-compiler/test/dotty/tools/pc/tests/CompilerCachingSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/CompilerCachingSuite.scala index b2d837e2ff50..1327c8dab91e 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/CompilerCachingSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/CompilerCachingSuite.scala @@ -8,9 +8,9 @@ import org.junit.{Before, Test} import scala.language.unsafeNulls import scala.meta.internal.metals.CompilerOffsetParams import scala.meta.internal.metals.EmptyCancelToken -import scala.meta.internal.metals.EmptyReportContext import scala.meta.internal.metals.PcQueryContext import scala.meta.pc.OffsetParams +import scala.meta.pc.reports.EmptyReportContext import scala.concurrent.Future import scala.concurrent.Await import scala.meta.pc.VirtualFileParams @@ -42,7 +42,7 @@ class CompilerCachingSuite extends BasePCSuite: }(emptyQueryContext).get(timeout.length, timeout.unit) case _ => throw IllegalStateException("Presentation compiler should always be of type of ScalaPresentationCompiler") - private def emptyQueryContext = PcQueryContext(None, () => "")(using EmptyReportContext) + private def emptyQueryContext = PcQueryContext(None, () => "")(using EmptyReportContext()) @Before def beforeEach: Unit = diff --git a/project/Build.scala b/project/Build.scala index 6339b26243e3..7934bf2bdcbf 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1498,7 +1498,7 @@ object Build { BuildInfoPlugin.buildInfoDefaultSettings lazy val presentationCompilerSettings = { - val mtagsVersion = "1.5.1" + val mtagsVersion = "1.5.3" Seq( libraryDependencies ++= Seq( "org.lz4" % "lz4-java" % "1.8.0",