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
Add annotations to semanticdb #13818
Conversation
compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala
Outdated
Show resolved
Hide resolved
7246f49
to
7b7dbd0
Compare
Previously, it was not possible to find if a given method was for example annotated with @main, which will be useful for run/debug code lenses. Now, they should be correctly saved. The only issue seems to be `@specialized` which is currently producing empty type, anone knows what is going on?
7b7dbd0
to
c4bcba4
Compare
@@ -95,6 +95,10 @@ object Scala3: | |||
val kind = s.symbolKind(symkinds) | |||
val sname = sym.symbolName | |||
val signature = s.info.toSemanticSig(s) | |||
val symbolAnnotations = s.annotations.collect{ | |||
case annot if annot.symbol != defn.BodyAnnot && annot.symbol != defn.ChildAnnot => | |||
Annotation(annot.symbol.typeRef.toSemanticType(annot.symbol)) |
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.
what if the annotation has type parameters? like @throws[java.io.IOException]
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.
Ach, that didn't work. I added a test case and switched how we get the type in the last commit.
@@ -97,7 +97,7 @@ object Scala3: | |||
val signature = s.info.toSemanticSig(s) | |||
val symbolAnnotations = s.annotations.collect{ | |||
case annot if annot.symbol != defn.BodyAnnot && annot.symbol != defn.ChildAnnot => | |||
Annotation(annot.symbol.typeRef.toSemanticType(annot.symbol)) | |||
Annotation(annot.tree.typeOpt.toSemanticType(annot.symbol)) |
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.
if the tree has NoType
then should we skip adding an annotation? Although as .tree
is a tpd.Tree
you should be able to call .tpe
instead of .typeOpt
without any issue
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.
Fixed! Using tpe
instead
e1eeec3
to
8fa8c36
Compare
Previously, it was not possible to find if a given method was for example annotated with @main, which will be useful for run/debug code lenses. Now, they should be correctly saved.
The only issue seems to be
@specialized
which is currently producing empty type, anone knows what is going on?CC @tanishiking