Get field for annotation
Hi there,
I'm currently working on an IntelliJ inspection that registers errors on certain annotations (placed at fields in a class). When this annotation is used on a field that has the wrong type, I mark the annotation as ' in error'. So far, this all works great.
However, I'm currently working on a quick-fix for my 'error'. The quick-fix should change the type of the field to the correct value. What I cannot find though is how to get a reference to this field when my problem description element is the PsiAnnotation which I marked.
Can someone tell me how I can get a reference to this field?
Thanks!
Martijn
Please sign in to leave a comment.
Hello Martijn,
PsiTreeUtil.getParentOfType(annotation, PsiField.class)
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
That's it! Works like a charm!
Thanks Dmitry!