How do you override, extend, or enhance the functionality of an existing language plugin?

My goal is ultimately to add dynamic GotoDeclaration functionality to a certain kind of URL in certain tags (in a JSP file).

My original approach was to override the GoToDeclarationAction (extend the default, and add interception of the case I'm interested in). After browsing around the source code a bit, I discovered an easy way of using a GotoDeclaration Extension to get the same thing done.

I Implemented the extension and it seems to be functioning for the most part (it works fine when there is a single option, but fails when there are multiple options).

The extension fails in the GotoDeclarationAction on the call: TargetElementUtilBase.findReference(editor, offset)

This call ends up retuning null because there is no existing PsiReference associated with the PsiElement (the URL that the user is trying to find the declaration for).

For some reason this doesn't seem to cause problems in the case of a single declaration being returned from the GotoDeclaration extension, but when multiple are returned, the action seems to require this reference. (I'd argue that this is actually a bug and I'm fairly sure that the only reason the referenece is needed is to ultimately find the text of the PsiElement which seems to be easily done with a PsiElement object rather than a PsiReference object)

Long story short.. I'm currently of the opinion that the best solution is to extend the JSP language support so that these special URLs are initilized with references from the beginning (as they are indeed references).

If anyone has any comments on my thoughts so far, I would be very grateful.. I have only just started tinkering with plugin development and I'm still somewhat lost.

Please sign in to leave a comment.