Enrich "implement method" action
Hi all,
for one of our main platforms we've developed a custom framework that uses annotations. For this framework we created an intellij idea plugin to support our developers and help them focus on subject-specific tasks. Our issue now is that everytime we are creating an interface and annotating this, these annotations are automatically inserted in the implementation after using the built-in "implement methods" action.
Is there a way to hook into this action or being notified after the method stubs are generated in implementation, so that our plugin can clean unnecessary annotations after generation? Or maybe there is even a way to not take our custom annotations in the "implement methods" action at all!?
Regards
Please sign in to leave a comment.
Hi Jonas,
please check com.intellij.codeInsight.generation.OverrideImplementsAnnotationsHandler
Anna
Hi Anna,
thanks for your response. The interface looks very promising. How do I enable/ register my own implementation? Service Locator? Plugin.xml?
Jonas
//EDIT
Solution is to register the implementation in plugin.xml, e.g.:
Maybe this information is helpful to other developers.
Hi Anna,
two questions regarding the extension point you've mentioned:
Thank you
Jonas
1. EJB-Facet should not influence custom extension, at least if it doesn't depend on ejb.
2. getAnnotations should return all annotations for which the extension would work. Iff overridden method is annotated, then #annotationsToRemove will be called
Anna
1. I agree with you that it shouldn't, but after debugging intellij idea code I can definitely say that there are side effects (in OverrideImplementUtil.overrideOrImplementMethod there is a difference in populating "results" when implementor is the ejb specific one and class with method is an ejb)
2. That was my first assumption. But all I can see is that the method is additionally annotated with the annotations I return in #getAnnotations. If I return new String[0] no additional are set and the parameter annotations are removed as expected (only when EJB facet is disabled)
1. I assume due to com.intellij.javaee.ejb.EjbMethodImplementor. So the common extension do not work as EJB implementation knows better. I am not sure what is the correct behaviour here.
2. If parent is annotated with annotation and current is not, then current would be annotated and all contradicting annotations would be removed. That's about annotations on method/return type, not parameters
Thank you for the provided information. As the current implementation doesn't help us I have to come back to the question in my first post - are there any mechanisms where I can hook into right after the implement method action has been called?