Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use uri from params in pc for location #6692

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading