use of com.intellij.codeInsight.daemon.IdeValidationHost in project intellij-plugins by JetBrains.
the class MxmlLanguageTagsUtil method addErrorMessage.
private static void addErrorMessage(final XmlElement element, final String message, final Validator.ValidationHost host, @NotNull IntentionAction... intentionActions) {
PsiElement target = element;
PsiElement secondaryTarget = null;
if (element instanceof XmlAttributeValue) {
final ASTNode node = element.getNode();
final ASTNode value = node == null ? null : XmlChildRole.ATTRIBUTE_VALUE_VALUE_FINDER.findChild(node);
if (value instanceof PsiElement) {
target = (PsiElement) value;
}
} else if (element instanceof XmlAttributeImpl) {
target = ((XmlAttributeImpl) element).getNameElement();
} else if (element instanceof XmlTag) {
target = XmlTagUtil.getStartTagNameElement((XmlTag) element);
secondaryTarget = XmlTagUtil.getEndTagNameElement((XmlTag) element);
}
if (host instanceof IdeValidationHost) {
if (target != null) {
((IdeValidationHost) host).addMessageWithFixes(target, message, Validator.ValidationHost.ErrorType.ERROR, intentionActions);
}
if (secondaryTarget != null) {
((IdeValidationHost) host).addMessageWithFixes(secondaryTarget, message, Validator.ValidationHost.ErrorType.ERROR, intentionActions);
}
} else {
if (target != null) {
host.addMessage(target, message, Validator.ValidationHost.ErrorType.ERROR);
}
if (secondaryTarget != null) {
host.addMessage(secondaryTarget, message, Validator.ValidationHost.ErrorType.ERROR);
}
}
}
Aggregations