Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Oct 25, 2023
1 parent 0d1d839 commit 9201e89
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ final class DefinitionProvider(
fromCompilerOrSemanticdb.map { definition =>
if (definition.isEmpty && !definition.symbol.endsWith("/")) {
val isScala3 =
scalaVersionSelector.scalaVersionForPath(path).startsWith("3")
ScalaVersions.isScala3Version(
scalaVersionSelector.scalaVersionForPath(path)
)
scaladocDefinitionProvider
.definition(path, params, isScala3)
.orElse(fromSearch(path, params.getPosition(), token))
Expand Down
40 changes: 18 additions & 22 deletions tests/unit/src/test/scala/tests/DefinitionLspSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import scala.meta.internal.metals.InitializationOptions
import scala.meta.internal.metals.MetalsServerConfig
import scala.meta.internal.metals.StatisticsConfig

class DefinitionLspSuite extends BaseLspSuite("definition") {
class DefinitionLspSuite
extends BaseLspSuite("definition")
with ScriptsAssertions {

override protected def initializationOptions: Option[InitializationOptions] =
Some(TestingServer.TestDefault)
Expand Down Expand Up @@ -640,19 +642,6 @@ class DefinitionLspSuite extends BaseLspSuite("definition") {
}

test("scaladoc-definition-this") {
val testCase =
"""|package a
|
|object O {
| class A {
| /**
| * Calls [[this@@.g]]
| */
| def f: Int = g
| def g: Int = ???
| }
|}
|""".stripMargin
for {
_ <- initialize(
s"""
Expand All @@ -661,18 +650,25 @@ class DefinitionLspSuite extends BaseLspSuite("definition") {
| "a": { }
|}
|/a/src/main/scala/a/Main.scala
|${testCase.replace("@@", "")}
| package a
|
|object O {
| class A {
| /**
| * Calls [[this.g]]
| */
| def f: Int = g
| def g: Int = ???
| }
|}
|""".stripMargin
)
_ <- server.didOpen("a/src/main/scala/a/Main.scala")
locations <- server.definition(
_ = assertDefinitionAtLocation(
"a/src/main/scala/a/Main.scala",
testCase,
workspace,
"this@@.g",
"a/src/main/scala/a/Main.scala",
expectedLine = 8,
)
_ = assert(locations.length == 1)
_ = assert(locations.head.getUri().endsWith("a/Main.scala"))
_ = assertEquals(locations.head.getRange().getStart().getLine(), 8)
} yield ()
}

Expand Down

0 comments on commit 9201e89

Please sign in to comment.