Skip to content

Commit

Permalink
fix: don't show incorrect docs for inner methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Jan 13, 2025
1 parent cdf4dcd commit 08c5918
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package scala.meta.internal.mtags

import java.util.Optional

import scala.annotation.tailrec
import scala.util.control.NonFatal

Expand Down Expand Up @@ -28,6 +30,7 @@ import dotty.tools.dotc.core.Types.Type
import dotty.tools.dotc.core.Types.TypeBounds
import dotty.tools.dotc.interactive.Interactive
import dotty.tools.dotc.interactive.InteractiveDriver
import dotty.tools.dotc.transform.SymUtils.isLocal
import dotty.tools.dotc.util.SourcePosition
import dotty.tools.dotc.util.Spans
import dotty.tools.dotc.util.Spans.Span
Expand Down Expand Up @@ -248,12 +251,14 @@ object MtagsEnrichments extends ScalametaCommonEnrichments:
symbol.maybeOwner.companion,
).filter(_ != NoSymbol) ++ symbol.allOverriddenSymbols
else symbol.allOverriddenSymbols

val documentation = search.documentation(
sym,
() => parentSymbols.map(toSemanticdbSymbol).toList.asJava,
contentType
)
val documentation =
if symbol.isLocal then Optional.empty
else
search.documentation(
sym,
() => parentSymbols.map(toSemanticdbSymbol).toList.asJava,
contentType
)
if documentation.isPresent then Some(documentation.get())
else None
end symbolDocumentation
Expand Down
14 changes: 14 additions & 0 deletions tests/cross/src/test/scala/tests/hover/HoverDocSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -527,4 +527,18 @@ class HoverDocSuite extends BaseHoverSuite {
|""".stripMargin
)
)

check(
"i7093",
"""|object O {
| /** Ooopsie daisy */
| val computeLogicOwners: Unit = {
| /** This is a comment */
| <<def logi@@cOwners = ???>>
| ???
| }
|}
|""".stripMargin,
"""def logicOwners: Nothing""".hover.stripMargin
)
}

0 comments on commit 08c5918

Please sign in to comment.