use of com.intellij.codeInsight.daemon.Validator in project intellij-community by JetBrains.
the class XmlHighlightVisitor method checkTagByDescriptor.
private void checkTagByDescriptor(final XmlTag tag) {
String name = tag.getName();
XmlElementDescriptor elementDescriptor;
final PsiElement parent = tag.getParent();
if (parent instanceof XmlTag) {
XmlTag parentTag = (XmlTag) parent;
elementDescriptor = XmlUtil.getDescriptorFromContext(tag);
final XmlElementDescriptor parentDescriptor = parentTag.getDescriptor();
if (parentDescriptor != null && elementDescriptor == null && shouldBeValidated(tag)) {
if (tag instanceof HtmlTag) {
//if (inspection != null /*&& isAdditionallyDeclared(inspection.getAdditionalEntries(XmlEntitiesInspection.UNKNOWN_TAG), name)*/) {
return;
//}
}
addElementsForTag(tag, XmlErrorMessages.message("element.is.not.allowed.here", name), getTagProblemInfoType(tag));
return;
}
if (elementDescriptor instanceof AnyXmlElementDescriptor || elementDescriptor == null) {
elementDescriptor = tag.getDescriptor();
}
if (elementDescriptor == null)
return;
} else {
//root tag
elementDescriptor = tag.getDescriptor();
if (elementDescriptor == null) {
addElementsForTag(tag, XmlErrorMessages.message("element.must.be.declared", name), HighlightInfoType.WRONG_REF);
return;
}
}
if (elementDescriptor instanceof Validator) {
//noinspection unchecked
((Validator<XmlTag>) elementDescriptor).validate(tag, this);
}
}
use of com.intellij.codeInsight.daemon.Validator in project intellij-community by JetBrains.
the class XMLExternalAnnotator method collectInformation.
@Nullable
@Override
public MyHost collectInformation(@NotNull PsiFile file) {
if (!(file instanceof XmlFile))
return null;
final XmlDocument document = ((XmlFile) file).getDocument();
if (document == null)
return null;
XmlTag rootTag = document.getRootTag();
XmlNSDescriptor nsDescriptor = rootTag == null ? null : rootTag.getNSDescriptor(rootTag.getNamespace(), false);
if (nsDescriptor instanceof Validator) {
//noinspection unchecked
MyHost host = new MyHost();
((Validator<XmlDocument>) nsDescriptor).validate(document, host);
return host;
}
return null;
}
Aggregations