
main.dotty.tools.pc.PcDocumentHighlightProvider.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scala3-presentation-compiler_3 Show documentation
Show all versions of scala3-presentation-compiler_3 Show documentation
scala3-presentation-compiler-bootstrapped
package dotty.tools.pc
import scala.meta.pc.OffsetParams
import dotty.tools.dotc.ast.tpd.*
import dotty.tools.dotc.core.Symbols.*
import dotty.tools.dotc.interactive.InteractiveDriver
import dotty.tools.dotc.util.SourcePosition
import dotty.tools.pc.utils.InteractiveEnrichments.*
import org.eclipse.lsp4j.DocumentHighlight
import org.eclipse.lsp4j.DocumentHighlightKind
final class PcDocumentHighlightProvider(
driver: InteractiveDriver,
params: OffsetParams
) extends WithSymbolSearchCollector[DocumentHighlight](driver, params):
def collect(
parent: Option[Tree]
)(
tree: Tree | EndMarker,
toAdjust: SourcePosition,
sym: Option[Symbol]
): DocumentHighlight =
val (pos, _) = toAdjust.adjust(text)
tree match
case _: NamedDefTree =>
DocumentHighlight(pos.toLsp, DocumentHighlightKind.Write)
case _ => DocumentHighlight(pos.toLsp, DocumentHighlightKind.Read)
def highlights: List[DocumentHighlight] =
result().distinctBy(_.getRange())
end PcDocumentHighlightProvider
© 2015 - 2025 Weber Informatics LLC | Privacy Policy