Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Dec 18, 2024
1 parent 3b37f02 commit c40bbda
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ final class DefinitionProvider(
new ScaladocDefinitionProvider(buffers, trees, destinationProvider)

private def isAmmonnite(path: AbsolutePath): Boolean =
path.isAmmoniteScript && buildTargets.inverseSources(path).flatMap(buildTargets.targetData).exists(_.isAmmonite)
path.isAmmoniteScript && buildTargets
.inverseSources(path)
.flatMap(buildTargets.targetData)
.exists(_.isAmmonite)

def definition(
path: AbsolutePath,
Expand All @@ -90,17 +93,24 @@ final class DefinitionProvider(
): Future[DefinitionResult] =
for {
fromCompiler <-
if (path.isScalaFilename && !isAmmonnite(path)) compilers().definition(params, token)
if (path.isScalaFilename && !isAmmonnite(path))
compilers().definition(params, token)
else Future.successful(DefinitionResult.empty)
} yield {
if (!fromCompiler.isEmpty) {
val pathToDef = fromCompiler.locations.asScala.head.getUri.toAbsolutePath
fromCompiler.copy(semanticdb = semanticdbs().textDocument(pathToDef).documentIncludingStale)
val pathToDef =
fromCompiler.locations.asScala.head.getUri.toAbsolutePath
fromCompiler.copy(semanticdb =
semanticdbs().textDocument(pathToDef).documentIncludingStale
)
} else {
val reportBuilder =
new DefinitionProviderReportBuilder(path, params, fromCompiler)
val fromSemanticDB =
semanticdbs().textDocument(path).documentIncludingStale.map(definitionFromSnapshot(path, params, _))
semanticdbs()
.textDocument(path)
.documentIncludingStale
.map(definitionFromSnapshot(path, params, _))
fromSemanticDB.foreach(reportBuilder.withSemanticDBResult(_))
val result = fromSemanticDB match {
case Some(definition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,13 @@ final class RenameProvider(
}

private def findDefinitionRage(location: Location): Location = {
val adjustedPosition = for {
val adjustedPosition = for {
source <- location.getUri().toAbsolutePathSafe
tree <- trees.get(source)
pos <- location.getRange().getStart().toMeta(Input.VirtualFile(source.toString(), tree.text))
pos <- location
.getRange()
.getStart()
.toMeta(Input.VirtualFile(source.toString(), tree.text))
token <- tree.tokens.collectFirst {
case token: Ident if token.pos.contains(pos) => token
}
Expand Down

0 comments on commit c40bbda

Please sign in to comment.