* @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) {
return null; // XML syntax error
}
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) {
return null; // XML syntax error
}
return strutsPackage.searchNamespace();