Documentation or explanation of PsiAugmentProvider?

Other than the source code of CE, are there any other resources to help me learn more about the concept driving the PsiAugmentProvider extension point?

The reason I ask, I'm trying to augment annotated fields and types with new methods. For example, the annotation @Getter on a PsiField will add a getter method to the class. But in practice it looks like when I'm typing in the editor and I finish adding the annotation the PsiAugmentProvider is only called for ...getAugments(..., PsiField.class).  It looks like the logic assumes a change to the modifier list of a field would only ever need to augment new fields into the class.

Also i'm looking for any documentation on how and when the editor reparses the Psi tree.  It looks to be doing multiple passes in practice as well.

0
4 comments
Avatar
Permanently deleted user

jaXzin wrote:

It looks like the logic assumes a change to the modifier list of a field would only ever need to augment new fields into the class.


So assuming I'm right about the above point, I went down the path of writing my own PsiTreeChangeListener and listening for the events of someone adding or removing the new PsiAnnotation I'm interested it.  I've got it working for the most part, but now the problem is that the new methods I've added are also written to the file. I'm using something like:

writeLater(new Runnable() {      public void run() {          psiClass.add(setter);      } });



where writeLater is just a utility method to use invokeLater() and runWriteAction().

Is it possible to add non-physical elements within a physical PsiClass?
0
Avatar
Permanently deleted user

bump, is there any feedback on this ?
This is blocking a lombok plugin to be written (http://groups.google.com/group/project-lombok/msg/285dbd915ce7395a)
which is blocking me from using idea

0

Would be glad to help.

To answer original questions:

  • no other resources, sorry (PsiAugmentProvider is used for AspectJ support but this code isn't open)
  • to add a getters based on field annotations the provider should be implemented somewhat like this: only respond to requests where parameter "element" is of type PsiClass and "type" equals to PsiMethod.class; find all fields in a given  "element" for which a getter should be added; and return a PsiMethod implementation for each such field (for Lombok I think LightMethod instances should be used, see PsiClassImpl code for example)
0
Avatar
Permanently deleted user

thanks! hopefully that can get the ball rolling again.

0

Please sign in to leave a comment.