Update copyright for HTML5 file should not insert comment before DOCTYPE because of IE thinking it is quirked file then

This commit is contained in:
Maxim.Mossienko
2011-10-13 17:37:00 +04:00
parent d36bc95569
commit 7a4e060c73
2 changed files with 10 additions and 1 deletions
+1
View File
@@ -14,6 +14,7 @@
<orderEntry type="module" module-name="openapi" />
<orderEntry type="library" name="Velocity" level="project" />
<orderEntry type="library" name="commons-collections" level="project" />
<orderEntry type="module" module-name="xml" />
</component>
</module>
@@ -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;