-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Create infrastructure for SemanticDB #5193
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
Create infrastructure for SemanticDB #5193
Conversation
I plan to refactor common logic with the decompiler later on. |
import dotty.tools.dotc.core.Phases.Phase | ||
import dotty.tools.dotc.tastyreflect.TastyImpl | ||
|
||
class TASTyConsumer extends Phase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tasty not TASTy
override def setup(args0: Array[String], rootCtx: Context): (List[String], Context) = { | ||
var args = args0.filter(a => a != "-gen-semantic-db") | ||
if (!args.contains("-from-tasty")) args = "-from-tasty" +: args | ||
if (args.contains("-d")) args = "-color:never" +: args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy pasted from the decompiler. Will remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be in a separate project from the compiler since it may need to use scala libraries for serializing semanticdb.
What about a compiler plugin instead? |
A subproject in the dotty repo is better for rapid development (if something needs to be fixed in tasty reflect while working on the emitter) but eventually it should be in a separate repo yes (and it shouldn't need to be a compiler plugin since it shouldn't have to use internal compiler APIs) |
b3a94b1
to
941f95d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Please ping me if you have any questions. It's possible to generate pure Java bindings for semanticdb, I haven't tried it myself but there are instructions here https://github.com/thesamet/sbt-protoc#installation
project/Build.scala
Outdated
@@ -677,6 +677,7 @@ object Build { | |||
val dottyCompiler = jars("dotty-compiler") | |||
val args0: List[String] = spaceDelimited("<arg>").parsed.toList | |||
val decompile = args0.contains("-decompile") | |||
val consumeTasty = args0.contains("-gen-semantic-db") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'd write -gen-semanticdb
and in in camel case it would be GenSemanticdb
(or SemanticdbGen
, ..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I should remove this flag.
tests/run-with-compiler/tasty-consumer/Test.scala shows an example of how to consume tasty files.
941f95d
to
d90e8c3
Compare
b52292e
to
7ba35b6
Compare
@smarter can we merge this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it can be changed later but I'm not a fan of having something called "TastyConsumer" and something called "ConsumeTasty" at the same time, it's ugly.
I agree with the names. They are horrible. Any suggestions? |
no idea |
I will ask around to see if someone has a good idea |
No description provided.