use of com.intellij.util.xml.DomElement in project intellij-plugins by JetBrains.
the class AllowedMethodsConverter method getActionElement.
/**
* Gets the enclosing <code>action</code>-element for the current context.
*
* @param context Current context.
* @return Action-element.
*/
@NotNull
private static Action getActionElement(final ConvertContext context) {
final DomElement domElement = context.getInvocationElement();
final Action action = domElement.getParentOfType(Action.class, false);
assert action != null : "not triggered within <action> for " + domElement.getXmlElement();
return action;
}
use of com.intellij.util.xml.DomElement in project intellij-plugins by JetBrains.
the class ExceptionMappingResultResolveConverter method getVariants.
@NotNull
public Collection<? extends HasResultType> getVariants(final ConvertContext context) {
final DomElement invocationElement = context.getInvocationElement();
final Action action = invocationElement.getParentOfType(Action.class, true);
if (action == null) {
return Collections.emptySet();
}
final List<HasResultType> variants = new ArrayList<>();
// Action-local first
variants.addAll(action.getResults());
final StrutsPackage strutsPackage = action.getStrutsPackage();
final GlobalResults globalResults = strutsPackage.getGlobalResults();
variants.addAll(globalResults.getResults());
return variants;
}
use of com.intellij.util.xml.DomElement in project intellij-plugins by JetBrains.
the class StrutsResultContributor method getNamespace.
/**
* Gets the current namespace for the given element.
*
* @param psiElement Current element.
* @return {@code null} on XML errors or if {@link #matchesResultType(String)} returns {@code false}.
*/
@Nullable
protected final String getNamespace(@NotNull final PsiElement psiElement) {
final DomElement resultElement = DomUtil.getDomElement(psiElement);
if (resultElement == null) {
// XML syntax error
return null;
}
assert resultElement instanceof HasResultType : "not instance of HasResultType: " + resultElement + ", text: " + psiElement.getText();
final ResultType effectiveResultType = ((HasResultType) resultElement).getEffectiveResultType();
if (effectiveResultType == null) {
return null;
}
final String resultType = effectiveResultType.getName().getStringValue();
if (resultType == null || !matchesResultType(resultType)) {
return null;
}
final StrutsPackage strutsPackage = resultElement.getParentOfType(StrutsPackage.class, true);
if (strutsPackage == null) {
// XML syntax error
return null;
}
return strutsPackage.searchNamespace();
}
use of com.intellij.util.xml.DomElement in project intellij-plugins by JetBrains.
the class ParamNameConverterImpl method createReferences.
@NotNull
public PsiReference[] createReferences(final GenericDomValue<List<BeanProperty>> listGenericDomValue, final PsiElement psiElement, final ConvertContext convertContext) {
final DomElement paramsElement = findEnclosingTag(convertContext);
if (paramsElement == null) {
return PsiReference.EMPTY_ARRAY;
}
for (ParamNameCustomConverter customConverter : Extensions.getExtensions(EP_NAME)) {
final PsiReference[] customReferences = customConverter.getCustomReferences((XmlAttributeValue) psiElement, paramsElement);
if (customReferences.length > 0) {
return customReferences;
}
}
final PsiClass rootPsiClass = findBeanPropertyClass(paramsElement);
return new BeanPropertyPathReferenceSet(psiElement, rootPsiClass, false).getPsiReferences();
}
use of com.intellij.util.xml.DomElement in project intellij-plugins by JetBrains.
the class DomElementListCellRenderer method getElementText.
public String getElementText(final XmlTag element) {
final DomElement domElement = getDomElement(element);
if (domElement == null) {
return element.getName();
}
final String elementName = domElement.getPresentation().getElementName();
return elementName == null ? unknownElementText : elementName;
}
Aggregations