Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve semantic information for types compiled by dotty #2049

Open
bjaglin opened this issue Aug 24, 2024 · 3 comments
Open

Improve semantic information for types compiled by dotty #2049

bjaglin opened this issue Aug 24, 2024 · 3 comments

Comments

@bjaglin
Copy link
Collaborator

bjaglin commented Aug 24, 2024

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.

@bjaglin bjaglin changed the title Improve semantic information for classpath types compiled by dotty Improve semantic information for types compiled by dotty Aug 24, 2024
@tgodzik
Copy link
Contributor

tgodzik commented Aug 25, 2024

An alternative is to use info method that we added to the presentation compiler. It provides a similar interface as semanticdb.

@bjaglin
Copy link
Collaborator Author

bjaglin commented Aug 25, 2024

Interesting! Do you know what's the PC overhead? In terms of start up time (I guess in Metals it's warm no it does not matter much) and RAM footprint?

@tgodzik
Copy link
Contributor

tgodzik commented Aug 26, 2024

The overhead shouldn't be too big, but it's hard to say. It's basically the addition of the compiler, which would already be added when I manage to finish the inferred type PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants