From 7a4e060c731fa54bb521fed1987d10b6a35c5fed Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Thu, 13 Oct 2011 17:35:22 +0400 Subject: [PATCH] Update copyright for HTML5 file should not insert comment before DOCTYPE because of IE thinking it is quirked file then --- plugins/copyright/copyright.iml | 1 + .../copyright/psi/UpdateXmlCopyrightsProvider.java | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/copyright/copyright.iml b/plugins/copyright/copyright.iml index 6f44fbc0fbdd..c9de25db777d 100644 --- a/plugins/copyright/copyright.iml +++ b/plugins/copyright/copyright.iml @@ -14,6 +14,7 @@ + diff --git a/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdateXmlCopyrightsProvider.java b/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdateXmlCopyrightsProvider.java index cf55cda0a117..19760dacd874 100644 --- a/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdateXmlCopyrightsProvider.java +++ b/plugins/copyright/src/com/maddyhome/idea/copyright/psi/UpdateXmlCopyrightsProvider.java @@ -22,6 +22,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; import com.intellij.psi.xml.*; +import com.intellij.xml.util.HtmlUtil; import com.maddyhome.idea.copyright.CopyrightProfile; import com.maddyhome.idea.copyright.options.LanguageOptions; import com.maddyhome.idea.copyright.options.XmlOptions; @@ -94,7 +95,7 @@ public class UpdateXmlCopyrightsProvider extends UpdateCopyrightsProvider { } int location = getLanguageOptions().getFileLocation(); - if (doctype != null) + if (doctype != null && !isHtml5DoctypeIEFix(doc)) { checkComments(first, doctype, location == XmlOptions.LOCATION_BEFORE_DOCTYPE); first = doctype; @@ -115,6 +116,13 @@ public class UpdateXmlCopyrightsProvider extends UpdateCopyrightsProvider { } } + private boolean isHtml5DoctypeIEFix(XmlDocument doc) { + if (HtmlUtil.isHtml5Document(doc)) { + return true; // IE goes quirks mode if comment before doc type so pardon the setting we will not handle you then + } + return false; + } + protected PsiElement getPreviousSibling(PsiElement element) { if (element == null) return null;