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

Fix various java annotation parsing issues #146

Merged
merged 1 commit into from
Nov 11, 2020

Conversation

yigit
Copy link
Collaborator

@yigit yigit commented Nov 6, 2020

This commit fixes multiple issues in annotation parsing for java code

  1. When getting annotation names, it was always using the index instead
    of the name. I changed it to default to name and only use index if
    name is not provided.

  2. Array values in annotations were repoted as a list of pairs instead
    of 1 key and multiple values, fixed.

  3. When the annotation value is a type, it was not returning a KSType
    but instead returning a PsiType, fixed.

  4. When the annotation value is another annotation, it was not returning
    a KSAnnotation, fixed.

  5. For expressions resolving to literals, it was returning the PsiLiteral
    instead of the value of it.

  6. TypeReferences (relevant in enum values) were not being resolved.

Updated/added tests for all cases above.

The enum fix for java source is not great right now because seems like
evaluator does not resolve it, hence I implemented a manual resolution that
is very similar to the implementation in KSAnnotationImpl.

@yigit
Copy link
Collaborator Author

yigit commented Nov 7, 2020

this probably needs a followup for descriptor implementation but i'll do that after #140 is merged.

This commit fixes multiple issues in annotation parsing for java code

1) When getting annotation names, it was always using the index instead
of the name. I changed it to default to name and only use index if
name is not provided.

2) Array values in annotations were repoted as a list of pairs instead
of 1 key and multiple values, fixed.

3) When the annotation value is a type, it was not returning a KSType
but instead returning a PsiType, fixed.

4) When the annotation value is another annotation, it was not returning
a KSAnnotation, fixed.

5) For expressions resolving to literals, it was returning the PsiLiteral
instead of the value of it.

6) TypeReferences (relevant in enum values) were not being resolved.

Updated/added tests for all cases above.

The enum fix for java source is not great right now because seems like
evaluator does not resolve it, hence I implemented a manual resolution that
is very similar to the implementation in KSAnnotationImpl.
@yigit yigit force-pushed the java-annotation-parser-improvements branch from 2e59f94 to 9728df7 Compare November 7, 2020 03:09
@ting-yuan ting-yuan self-requested a review November 10, 2020 21:24
@ting-yuan ting-yuan self-assigned this Nov 10, 2020
@ting-yuan ting-yuan requested review from neetopia and removed request for ting-yuan November 10, 2020 22:02
@ting-yuan ting-yuan assigned neetopia and unassigned ting-yuan Nov 10, 2020
Copy link
Contributor

@neetopia neetopia left a comment

Choose a reason for hiding this comment

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

Overall looks good except for 1 minor comment.

@neetopia neetopia merged commit 489dbfb into google:master Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants