Reference Provider for JSP Paths


Hi, I need a Reference Provider for Paths to JSP or other files in a Web
Application, I want to add auto completion in the next case

public Resolution myEvent()
{
//some funny logic
return new RedirectResolution("/foo/bar/myJSP.jsp");
}

I already Write the ElementFilter but I need A Reference Provider to register
in the ReferenceRegistry

I need to wreite a ReferenceProvider by myself????

Or Already exist A ReferenceProvider for that? (like the references in html,
or JSP in a ]]> tag)


Many Thanks for your answer


6 comments
Comment actions Permalink

Take a look at Struts Assistant sources, you'll find plenty of examples in there.

0
Comment actions Permalink

Hello Yann,

I already look this plugin, but is Overkill for my purpouse, they have references
to Struts Actions and construct a very complicated Model for do that.

Take a look at Struts Assistant sources, you'll find plenty of
examples in there.



0
Comment actions Permalink

For this I am using IDEA's "native" WebPathReferenceProvider, works pretty well. The path in references is absolute according webapp's root.

0
Comment actions Permalink

Hello Josef,

WebPathReferenceProvider have 3 constructors,

WebPathReferenceProvider();
WebPathReferenceProvider(boolean);
WebPathReferenceProvider(boolean,boolean,boolean);

you use???

BTW

you have a litle piece of code with an example

Thanks

For this I am using IDEA's "native" WebPathReferenceProvider, works
pretty well. The path in references is absolute according webapp's
root.



0
Comment actions Permalink

Hi Mario, perhaps I wrote it wrong way, I extended WebPathReferenceProvider for some more functionality (tests wether ithe provider is enabled etc.)

I only use the constructor without parameters, which is for "classic" paths (/WEB-INF/jsp/somePage.jsp) and works fine. Unfortunatelly I don't know what the other two are for. (maybe switching abolute/context relative paths, I didn't tried)
My code isn't impressive, I just override constructors and add a test. Here it is:

public class CustomWebPathReferenceProvider extends WebPathReferenceProvider {

@NotNull
public PsiReference[] getReferencesByElement(PsiElement psiElement) {
if (isEnabled(psiElement)) {
return super.getReferencesByElement(psiElement);
}
return PsiReference.EMPTY_ARRAY;
}

public WrappedWebPathReferenceProvider() {
super();
}

public WrappedWebPathReferenceProvider(boolean b) {
super(b);
}

public WrappedWebPathReferenceProvider(boolean b, boolean b1, boolean b2) {
super(b, b1, b2);
}

protected boolean isEnabled(PsiElement element) {
Module module = ModuleUtil.findModuleForPsiElement(element);
if (module != null) {
JspServletFacet facet = JspServletFacet.getInstance(module);
if (facet != null) {
JspServletFacetConfiguration config = facet.getConfiguration();
return config.isMappingSupportEnabled();
}
}
return false;
}
}

0
Comment actions Permalink

Hello Josef,

Well woks fine.... inside a JSP, sadly I needed inside a Class.....

Hi Mario, perhaps I wrote it wrong way, I extended
WebPathReferenceProvider for some more functionality (tests wether
ithe provider is enabled etc.)

I only use the constructor without parameters, which is for "classic"
paths (/WEB-INF/jsp/somePage.jsp) and works fine. Unfortunatelly I
don't know what the other two are for. (maybe switching
abolute/context relative paths, I didn't tried)

My code isn't impressive, I just override constructors and add a test.
Here it is:

public class CustomWebPathReferenceProvider extends
WebPathReferenceProvider {

@NotNull
public PsiReference[] getReferencesByElement(PsiElement psiElement)
{
if (isEnabled(psiElement)) {
return super.getReferencesByElement(psiElement);
}
return PsiReference.EMPTY_ARRAY;
}
public WrappedWebPathReferenceProvider() {
super();
}
public WrappedWebPathReferenceProvider(boolean b) {
super(b);
}
public WrappedWebPathReferenceProvider(boolean b, boolean b1,
boolean b2) {
super(b, b1, b2);
}
protected boolean isEnabled(PsiElement element) {
Module module = ModuleUtil.findModuleForPsiElement(element);
if (module != null) {
JspServletFacet facet = JspServletFacet.getInstance(module);
if (facet != null) {
JspServletFacetConfiguration config =
facet.getConfiguration();
return config.isMappingSupportEnabled();
}
}
return false;
}
}



0

Please sign in to leave a comment.