From 352fa3711eee6d8fcc31769809acf70e1c7e3d8c Mon Sep 17 00:00:00 2001 From: Katarzyna Marek Date: Tue, 21 Nov 2023 21:21:22 +0100 Subject: [PATCH] fixes after merge --- metals-bench/src/main/scala/bench/MetalsBench.scala | 10 +++++++++- .../implementation/ImplementationProvider.scala | 6 ++---- .../scala/meta/internal/mtags/SymbolIndexBucket.scala | 7 ++++--- .../main/scala/tests/DelegatingGlobalSymbolIndex.scala | 6 +++--- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/metals-bench/src/main/scala/bench/MetalsBench.scala b/metals-bench/src/main/scala/bench/MetalsBench.scala index 2726ab262a8..5715745a5de 100644 --- a/metals-bench/src/main/scala/bench/MetalsBench.scala +++ b/metals-bench/src/main/scala/bench/MetalsBench.scala @@ -102,7 +102,15 @@ class MetalsBench { @Benchmark @BenchmarkMode(Array(Mode.SingleShotTime)) def typeHierarchyIndex(): Unit = { - scalaDependencySources.inputs.foreach { Mtags.indexWithOverrides(_) } + scalaDependencySources.inputs.foreach { input => + implicit val rc: ReportContext = EmptyReportContext + new ScalaToplevelMtags( + input, + includeInnerClasses = true, + includeMembers = false, + dialects.Scala213, + ).index() + } } @Benchmark 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 7c86ab3ae6d..2adf1e3cb84 100644 --- a/metals/src/main/scala/scala/meta/internal/implementation/ImplementationProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/implementation/ImplementationProvider.scala @@ -10,7 +10,6 @@ import scala.concurrent.ExecutionContext import scala.concurrent.Future import scala.util.control.NonFatal -import scala.meta.inputs.Input import scala.meta.internal.io.FileIO import scala.meta.internal.metals.Buffers import scala.meta.internal.metals.BuildTargets @@ -417,9 +416,8 @@ final class ImplementationProvider( private def semanticdbForJarFile(fileSource: AbsolutePath) = { val dialect = ScalaVersions.dialectForDependencyJar(fileSource.filename) - val text = FileIO.slurp(fileSource, StandardCharsets.UTF_8) - val input = Input.VirtualFile(fileSource.toURI.toString(), text) - val textDocument = Mtags.index(input, dialect) + FileIO.slurp(fileSource, StandardCharsets.UTF_8) + val textDocument = Mtags.index(fileSource, dialect) textDocument } diff --git a/mtags/src/main/scala/scala/meta/internal/mtags/SymbolIndexBucket.scala b/mtags/src/main/scala/scala/meta/internal/mtags/SymbolIndexBucket.scala index 70fe1d5c191..7a122356e6b 100644 --- a/mtags/src/main/scala/scala/meta/internal/mtags/SymbolIndexBucket.scala +++ b/mtags/src/main/scala/scala/meta/internal/mtags/SymbolIndexBucket.scala @@ -93,10 +93,11 @@ class SymbolIndexBucket( } def addSourceFile( - source: AbsolutePath, - sourceDirectory: Option[AbsolutePath], + source: AbsolutePath, + sourceDirectory: Option[AbsolutePath] ): Option[IndexingResult] = { - val IndexingResult(path, topLevels, overrides) = indexSource(source, dialect, sourceDirectory) + val IndexingResult(path, topLevels, overrides) = + indexSource(source, dialect, sourceDirectory) topLevels.foreach { symbol => val acc = toplevels.getOrElse(symbol, Set.empty) toplevels(symbol) = acc + source diff --git a/tests/mtest/src/main/scala/tests/DelegatingGlobalSymbolIndex.scala b/tests/mtest/src/main/scala/tests/DelegatingGlobalSymbolIndex.scala index 383a276f29b..782503ac6ce 100644 --- a/tests/mtest/src/main/scala/tests/DelegatingGlobalSymbolIndex.scala +++ b/tests/mtest/src/main/scala/tests/DelegatingGlobalSymbolIndex.scala @@ -25,19 +25,19 @@ class DelegatingGlobalSymbolIndex( def addSourceFile( file: AbsolutePath, sourceDirectory: Option[AbsolutePath], - dialect: Dialect, + dialect: Dialect ): Option[mtags.IndexingResult] = { underlying.addSourceFile(file, sourceDirectory, dialect) } def addSourceJar( jar: AbsolutePath, - dialect: Dialect, + dialect: Dialect ): List[mtags.IndexingResult] = { underlying.addSourceJar(jar, dialect) } def addSourceDirectory( dir: AbsolutePath, - dialect: Dialect, + dialect: Dialect ): List[mtags.IndexingResult] = { underlying.addSourceDirectory(dir, dialect) }