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

Add annotations to semanticdb #13818

Merged
merged 2 commits into from Oct 27, 2021
Merged

Conversation

tgodzik
Copy link
Contributor

@tgodzik tgodzik commented Oct 25, 2021

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

@tgodzik tgodzik force-pushed the add-annotations branch 3 times, most recently from 7246f49 to 7b7dbd0 Compare October 26, 2021 17:44
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?
@@ -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))
Copy link
Member

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]

Copy link
Contributor Author

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))
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed! Using tpe instead

@bishabosha bishabosha merged commit e1930d1 into scala:master Oct 27, 2021
@Kordyjan Kordyjan added this to the 3.1.2 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants