Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Dec 18, 2024
1 parent c40bbda commit 73fde6a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import scala.util.Try

import scala.meta.inputs.Input
import scala.meta.inputs.Position.Range
import scala.meta.internal.metals.LoggerReportContext.unsanitized
import scala.meta.internal.metals.MetalsEnrichments._
import scala.meta.internal.mtags.GlobalSymbolIndex
import scala.meta.internal.mtags.Mtags
Expand Down Expand Up @@ -61,7 +60,6 @@ final class DefinitionProvider(
scalaVersionSelector: ScalaVersionSelector,
saveDefFileToDisk: Boolean,
sourceMapper: SourceMapper,
warnings: () => Warnings,
)(implicit ec: ExecutionContext, rc: ReportContext) {

private val fallback = new FallbackDefinitionProvider(trees, index)
Expand Down Expand Up @@ -132,7 +130,7 @@ final class DefinitionProvider(
)
.getOrElse(fromCompiler)
}
reportBuilder.build().foreach(unsanitized.create(_))
reportBuilder.build().foreach(rc.unsanitized.create(_))
result
}
}
Expand Down Expand Up @@ -592,12 +590,19 @@ class DefinitionProviderReportBuilder(
|""".stripMargin,
s"empty definition using pc, found symbol in pc: ${compilerDefn.querySymbol}",
path = Some(path.toURI),
id = Some(
if (compilerDefn.querySymbol != "") compilerDefn.querySymbol
else
s"${path.toURI}:${params.getPosition().getLine()}:${params.getPosition().getCharacter()}"
id = querySymbol.orElse(
Some(s"${path.toURI}:${params.getPosition().getLine()}")
),
error = error,
)
}

private def querySymbol: Option[String] =
compilerDefn.querySymbol match {
case "" =>
semanticDBDefn
.map(_.querySymbol)
.orElse(fallbackDefn.map(_.querySymbol))
case q => Some(q)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package scala.meta.internal.metals

import scala.util.control.NonFatal

import scala.meta.Term
import scala.meta.Type
import scala.meta._
Expand Down Expand Up @@ -175,7 +177,7 @@ class FallbackDefinitionProvider(

defResult.flatten
} catch {
case e: Exception =>
case NonFatal(e) =>
reportBuilder.withError(e)
None
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ abstract class MetalsLspService(
scalaVersionSelector,
saveDefFileToDisk = !clientConfig.isVirtualDocumentSupported(),
sourceMapper,
() => warnings,
)

val stacktraceAnalyzer: StacktraceAnalyzer = new StacktraceAnalyzer(
Expand Down

0 comments on commit 73fde6a

Please sign in to comment.