Skip to content

Commit

Permalink
bugfix: add moduleClass imported symbols in IndexedContext
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Sep 29, 2023
1 parent 95e42a9 commit f024cf8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import scala.meta.internal.pc.IndexedContext.Result

import dotty.tools.dotc.core.Contexts.*
import dotty.tools.dotc.core.Flags.*
import dotty.tools.dotc.core.NameOps.moduleClassName
import dotty.tools.dotc.core.Names.*
import dotty.tools.dotc.core.Symbols.*
import dotty.tools.dotc.core.Types.*
Expand Down Expand Up @@ -172,7 +173,11 @@ object IndexedContext:
initial ++ fromPackageObjects

def fromImport(site: Type, name: Name)(using Context): List[Symbol] =
List(site.member(name.toTypeName), site.member(name.toTermName))
List(
site.member(name.toTypeName),
site.member(name.toTermName),
site.member(name.moduleClassName),
)
.flatMap(_.alternatives)
.map(_.symbol)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,30 @@ class Scala3CodeActionLspSuite
),
)

checkEdit(
"alias-rename",
s"""|/metals.json
|{"a":
| { "scalaVersion" : "$scalaVersion",
| "libraryDependencies": [
| "org.typelevel::cats-parse:0.3.7"
| ]
| }
|}
|/${toPath("A.scala")}
|import cats.parse.{Parser => P}
|def <<read>>(txt: String) = {
| P.string("a").parseAll(txt)
|}
|""".stripMargin,
InsertInferredType.insertType,
"""|import cats.parse.{Parser => P}
|def read(txt: String): Either[P.Error, Unit] = {
| P.string("a").parseAll(txt)
|}
|""".stripMargin,
)

check(
"issue",
"""|object Main {
Expand Down

0 comments on commit f024cf8

Please sign in to comment.