use of com.intellij.struts2.dom.struts.model.StrutsModel in project intellij-plugins by JetBrains.
the class ActionReferenceProvider method getReferencesByElement.
@NotNull
public PsiReference[] getReferencesByElement(@NotNull final PsiElement psiElement, @NotNull final ProcessingContext context) {
final StrutsManager strutsManager = StrutsManager.getInstance(psiElement.getProject());
final StrutsModel strutsModel = strutsManager.getCombinedModel(psiElement);
if (strutsModel == null) {
return PsiReference.EMPTY_ARRAY;
}
final XmlAttributeValue xmlAttributeValue = (XmlAttributeValue) psiElement;
final String path = xmlAttributeValue.getValue();
// resolve to <action>
final String actionName = TaglibUtil.trimActionPath(path);
final String namespace = getNamespace(xmlAttributeValue);
final List<Action> actions = strutsModel.findActionsByName(actionName, namespace);
final Action action = actions.isEmpty() ? null : actions.get(0);
final int bangIndex = path.indexOf(TaglibUtil.BANG_SYMBOL);
if (bangIndex == -1) {
return new PsiReference[] { new ActionReference(xmlAttributeValue, action, namespace, strutsModel) };
}
return new PsiReference[] { new ActionReference(xmlAttributeValue, action, namespace, strutsModel), new ActionMethodReference(xmlAttributeValue, action, bangIndex) };
}
Aggregations