Processing control-click in JSP

We use a set of JSP tags from our app server vendor (ATG). One of the tags we use (everywhere) is used instead of the include directive (e.g. <dsp:include page="/other/page.jsp"/>).

I'd like to write a plugin that would allow me to control-click on the page attribute and jump to the page.

Any pointers?

Thanks

Todd

0
5 comments

The simplest (but probably not the best) way to do this is registering com.intellij.psi.impl.source.resolve.reference.impl.providers.WebPathReferenceProvider for your tags.

for example:

registerTags("page", DTDS, new WebPathReferenceProvider(), "include");

where DTDS is String array of all namespaces of custom tags, you want provide with references (ctrl+mouseclick,...) and method registerTags() looks like following one (it's the same as in StrutsAssistant plugin)

protected void registerTags(String attrib, String[] dtds, PsiReferenceProvider provider, String... tags) {
NamespaceFilter nf = new NamespaceFilter(dtds);
TextFilter tf = new TextFilter(tags);
AndFilter af = new AndFilter(nf, new ClassFilter(XmlTag.class), tf);
ParentElementFilter pef = new ParentElementFilter(af, 2);
registry.registerXmlAttributeValueReferenceProvider(new String[]{attrib}, new ScopeFilter(pef), provider);
}

Or have a look at com.intellij.struts.dom.converters.StrutsPagesReferenceProvider in StrutsAssistant plugin (latest versions).

Josef

0

Thanks Josef, that gives me something to work with. I'll explore that later today.

0

The simplest (but probably not the best) way to do this is registering com.intellij.psi.impl.source.resolve.reference.impl.providers.WebPathReferenceProvider for your tags.

for example:

registerTags("page", DTDS, new WebPathReferenceProvider(), "include");
...

Is WebPathReferenceProvider available in the OpenAPI? I cannot locate it.

Thanks!!

Todd

0

never mind. Found it in idea.jar

Plugin is now working!

Thanks!

Todd

0

I'm really sorry for not responding, I didn't have much time to watch this forum.
And I'm glad it helped you. Josef

0

Please sign in to leave a comment.