Skip to content

Commit

Permalink
fix: use uri from params in pc for location
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Aug 22, 2024
1 parent a10784f commit 9ba2829
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ final class DefinitionProvider(
.definition(path, params, isScala3)
.orElse(fallback.search(path, params.getPosition(), isScala3))
.getOrElse(definition)
} else {
definition
}
} else definition
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ object MtagsEnrichments extends ScalametaCommonEnrichments:
def focusAt(point: Int): SourcePosition =
pos.withSpan(pos.span.withPoint(point).focus)

def toLocation: Option[l.Location] =
for
uri <- InteractiveDriver.toUriOption(pos.source)
range <- if pos.exists then Some(pos.toLsp) else None
yield new l.Location(uri.toString, range)

def encloses(other: SourcePosition): Boolean =
pos.start <= other.start && pos.end >= other.end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ class PcDefinitionProvider(
defs.headOption match
case Some(srcTree) =>
val pos = srcTree.namePos
pos.toLocation match
case None => DefinitionResultImpl.empty
case Some(loc) =>
DefinitionResultImpl(
SemanticdbSymbols.symbolName(sym),
List(loc).asJava,
)
if pos.exists then
val loc = new Location(params.uri().toString(), pos.toLsp)
DefinitionResultImpl(
SemanticdbSymbols.symbolName(sym),
List(loc).asJava,
)
else DefinitionResultImpl.empty
case None =>
alternative(sym) match
case Some(alt) => findDefsForSymbol(alt)
Expand Down

0 comments on commit 9ba2829

Please sign in to comment.