From 061b258d8bab296ef104bbec356c7af33437b48e Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Thu, 22 Jul 2010 19:17:54 +0400 Subject: [PATCH] IDEA-56656 IDEA does not highlight not well-formed XML: comment before XML declaration --- .../src/messages/XmlErrorMessages.properties | 1 + .../impl/analysis/XmlHighlightVisitor.java | 24 +++++++++++++++++++ .../xml/XmlProcessingInstructionImpl.java | 2 +- .../com/intellij/psi/XmlElementVisitor.java | 4 ++++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/platform/platform-resources-en/src/messages/XmlErrorMessages.properties b/platform/platform-resources-en/src/messages/XmlErrorMessages.properties index af35e58f9cee..4ab6cd49b655 100644 --- a/platform/platform-resources-en/src/messages/XmlErrorMessages.properties +++ b/platform/platform-resources-en/src/messages/XmlErrorMessages.properties @@ -74,3 +74,4 @@ xml.parsing.closing.tag.name.missing=Closing tag name missing xml.parsing.closing.tag.is.not.done=Closing tag is not done attribute.should.be.preceded.with.space=There should be a space between attribute and previous attribute cdata.end.should.not.appear.in.content.unless.to.mark.end.of.cdata.section=Character sequence ']]>' must not appear in content unless used to mark the end of a CDATA section +xml.declaration.should.precede.all.document.content=Xml declaration should precede all document content diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java index 97c49723b40e..d7e24d4f9219 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java @@ -167,6 +167,30 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV bindMessageToAstNode(childByRole, warning, 0, messageLength, localizedMessage, quickFixActions); } + + @Override + public void visitXmlProcessingInstruction(XmlProcessingInstruction processingInstruction) { + super .visitXmlProcessingInstruction(processingInstruction); + PsiElement parent = processingInstruction.getParent(); + + if (parent instanceof XmlProlog && processingInstruction.getText().startsWith("