
main.dotty.tools.pc.completions.FilenameCompletions.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scala3-presentation-compiler_3 Show documentation
Show all versions of scala3-presentation-compiler_3 Show documentation
scala3-presentation-compiler-bootstrapped
package dotty.tools.pc
package completions
import dotty.tools.dotc.ast.tpd.TypeDef
import dotty.tools.dotc.core.Contexts.Context
import dotty.tools.dotc.core.Flags
import dotty.tools.pc.utils.InteractiveEnrichments.*
object FilenameCompletions:
def contribute(
filename: String,
td: TypeDef
)(using ctx: Context): List[CompletionValue] =
val owner = td.symbol.owner
lazy val scope =
owner.info.decls.filter(sym => sym.isType && sym.sourcePos.exists)
if owner.is(Flags.Package) && !scope.exists(sym =>
sym.name.decoded == filename && (sym.is(Flags.ModuleClass) == td.symbol
.is(Flags.ModuleClass))
)
then
List(
CompletionValue.keyword(
s"${td.symbol.showKind} ${filename}",
filename
)
)
else Nil
end contribute
end FilenameCompletions
© 2015 - 2025 Weber Informatics LLC | Privacy Policy