Skip to content

Improve semantic information for types compiled by dotty #2049

Open
@bjaglin

Description

@bjaglin

The SymbolTable required by core for finding information that is not available in SemanticDB is injected by cli using a helper from reflect, which is currently backed by scalameta's internal semanticdb-scalac-core which was written for Scala 2 class files.

def info(sym: Symbol): Option[SymbolInformation] = {
if (sym.isNone) {
None
} else if (sym.isLocal) {
locals.get(sym.value).map(new SymbolInformation(_)(this))
} else {
val fromGlobalSymtab =
symtab.info(sym.value).map(new SymbolInformation(_)(this))
def fromTextDocument(): Option[SymbolInformation] =
textDocument.symbols
.find(_.symbol == sym.value)
.map(new SymbolInformation(_)(this))
fromTextDocument().orElse(fromGlobalSymtab)
}
}

def configuredSymtab: Configured[SymbolTable] = {
Try(
ClasspathOps.newSymbolTable(
classpath = validatedClasspath,
out = out
)
) match {
case Success(symtab) =>
Configured.ok(symtab)
case Failure(e) =>
ConfError.message(s"Unable to load symbol table: ${e.getMessage}").notOk
}
}

def newSymbolTable(
classpath: Classpath,
parallel: Boolean = false,
out: PrintStream = System.out
): SymbolTable = {
GlobalSymbolTable(classpath, includeJdk = true)
}

We need to migrate to https://github.com/scalacenter/tasty-query or equivalent to provide exhaustive information about types compiled by dotty. While doing that, we should drop the need to using Scalameta internal structures as a contract between core & cli.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions