();
- @NonNls private static final String[] BLOCK_TAGS = { "p", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "ol", "dir", "menu", "pre",
- "dl", "div", "center", "noscript", "noframes", "blockquote", "form", "isindex", "hr", "table", "fieldset", "address",
- // nonexplicitly specified
- "map",
- // flow elements
- "body", "object", "applet", "ins", "del", "dd", "li", "button", "th", "td", "iframe","comment","nobr"
+ @NonNls private static final String[] BLOCK_TAGS = {"p", "h1", "h2", "h3", "h4", "h5", "h6", "ul", "ol", "dir", "menu", "pre",
+ "dl", "div", "center", "noscript", "noframes", "blockquote", "form", "isindex", "hr", "table", "fieldset", "address",
+ // nonexplicitly specified
+ "map",
+ // flow elements
+ "body", "object", "applet", "ins", "del", "dd", "li", "button", "th", "td", "iframe", "comment", "nobr"
};
// flow elements are block or inline, so they shuld not close for example
- @NonNls private static final String[] POSSIBLY_INLINE_TAGS = { "object", "applet", "ins", "del", "button", "nobr" };
+ @NonNls private static final String[] POSSIBLY_INLINE_TAGS = {"object", "applet", "ins", "del", "button", "nobr"};
private static final Set BLOCK_TAGS_MAP = new THashSet();
- @NonNls private static final String[] INLINE_ELEMENTS_CONTAINER = { "p", "h1", "h2", "h3", "h4", "h5", "h6", "pre", "dt" };
+ @NonNls private static final String[] INLINE_ELEMENTS_CONTAINER = {"p", "h1", "h2", "h3", "h4", "h5", "h6", "pre", "dt"};
private static final Set INLINE_ELEMENTS_CONTAINER_MAP = new THashSet();
- @NonNls private static final String[] EMPTY_ATTRS = { "nowrap", "compact", "disabled", "readonly", "selected", "multiple", "nohref", "ismap", "declare", "noshade", "checked" };
+ @NonNls private static final String[] EMPTY_ATTRS =
+ {"nowrap", "compact", "disabled", "readonly", "selected", "multiple", "nohref", "ismap", "declare", "noshade", "checked"};
private static final Set EMPTY_ATTRS_MAP = new THashSet();
private static final Set POSSIBLY_INLINE_TAGS_MAP = new THashSet();
@@ -146,8 +158,8 @@ public class HtmlUtil {
public static boolean isSingleHtmlTag(String tagName) {
return EMPTY_TAGS_MAP.contains(tagName.toLowerCase());
-
}
+
public static boolean isSingleHtmlTagL(String tagName) {
return EMPTY_TAGS_MAP.contains(tagName);
}
@@ -193,7 +205,7 @@ public class HtmlUtil {
if (name != null && isOptionalEndForHtmlTag(name)) {
PsiElement parent = element.getParent();
- if (parent!=null) {
+ if (parent != null) {
// we need grand parent since completion already uses parent's descriptor
parent = parent.getParent();
}
@@ -201,7 +213,7 @@ public class HtmlUtil {
if (parent instanceof HtmlTag) {
final XmlElementDescriptor parentDescriptor = ((HtmlTag)parent).getDescriptor();
- if (parentDescriptor!=descriptor && parentDescriptor!=null) {
+ if (parentDescriptor != descriptor && parentDescriptor != null) {
for (final XmlElementDescriptor elementsDescriptor : parentDescriptor.getElementsDescriptors((XmlTag)parent)) {
if (isHtmlBlockTag(elementsDescriptor.getName())) {
variants.add(elementsDescriptor);
@@ -232,11 +244,11 @@ public class HtmlUtil {
String entitiesString = getEntitiesString(context, XmlEntitiesInspection.UNKNOWN_ATTRIBUTE);
if (entitiesString == null) return XmlAttributeDescriptor.EMPTY;
- StringTokenizer tokenizer = new StringTokenizer(entitiesString,",");
+ StringTokenizer tokenizer = new StringTokenizer(entitiesString, ",");
XmlAttributeDescriptor[] descriptors = new XmlAttributeDescriptor[tokenizer.countTokens()];
int index = 0;
- while(tokenizer.hasMoreElements()) {
+ while (tokenizer.hasMoreElements()) {
final String customName = tokenizer.nextToken();
if (customName.length() == 0) continue;
@@ -262,11 +274,11 @@ public class HtmlUtil {
XmlElementDescriptor[] descriptors = new XmlElementDescriptor[tokenizer.countTokens()];
int index = 0;
- while(tokenizer.hasMoreElements()) {
+ while (tokenizer.hasMoreElements()) {
final String tagName = tokenizer.nextToken();
if (tagName.length() == 0) continue;
- descriptors[index++] = new XmlElementDescriptorImpl(context instanceof XmlTag ? (XmlTag)context:null) {
+ descriptors[index++] = new XmlElementDescriptorImpl(context instanceof XmlTag ? (XmlTag)context : null) {
public String getName(PsiElement context) {
return tagName;
}
@@ -291,19 +303,21 @@ public class HtmlUtil {
final InspectionProfile profile = InspectionProjectProfileManager.getInstance(context.getProject()).getInspectionProfile();
- switch(type) {
+ switch (type) {
case XmlEntitiesInspection.UNKNOWN_TAG:
- LocalInspectionToolWrapper wrapper = (LocalInspectionToolWrapper) profile.getInspectionTool(HtmlUnknownTagInspection.TAG_SHORT_NAME,
- containingFile);
- HtmlUnknownTagInspection unknownTagInspection = wrapper != null ? (HtmlUnknownTagInspection) wrapper.getTool() : null;
+ LocalInspectionToolWrapper wrapper = (LocalInspectionToolWrapper)profile.getInspectionTool(HtmlUnknownTagInspection.TAG_SHORT_NAME,
+ containingFile);
+ HtmlUnknownTagInspection unknownTagInspection = wrapper != null ? (HtmlUnknownTagInspection)wrapper.getTool() : null;
if (unknownTagInspection != null) {
return unknownTagInspection.getAdditionalEntries();
}
break;
case XmlEntitiesInspection.UNKNOWN_ATTRIBUTE:
- LocalInspectionToolWrapper wrapper1 = (LocalInspectionToolWrapper) profile.getInspectionTool(HtmlUnknownAttributeInspection.ATTRIBUTE_SHORT_NAME,
- containingFile);
- HtmlUnknownAttributeInspection unknownAttributeInspection = wrapper1 != null ? (HtmlUnknownAttributeInspection) wrapper1.getTool() : null;
+ LocalInspectionToolWrapper wrapper1 =
+ (LocalInspectionToolWrapper)profile.getInspectionTool(HtmlUnknownAttributeInspection.ATTRIBUTE_SHORT_NAME,
+ containingFile);
+ HtmlUnknownAttributeInspection unknownAttributeInspection =
+ wrapper1 != null ? (HtmlUnknownAttributeInspection)wrapper1.getTool() : null;
if (unknownAttributeInspection != null) {
return unknownAttributeInspection.getAdditionalEntries();
}
@@ -314,8 +328,8 @@ public class HtmlUtil {
}
public static XmlAttributeDescriptor[] appendHtmlSpecificAttributeCompletions(final XmlTag declarationTag,
- XmlAttributeDescriptor[] descriptors,
- final XmlAttributeImpl context) {
+ XmlAttributeDescriptor[] descriptors,
+ final XmlAttributeImpl context) {
if (declarationTag instanceof HtmlTag) {
descriptors = ArrayUtil.mergeArrays(
descriptors,
@@ -355,7 +369,7 @@ public class HtmlUtil {
}
final PsiFile htmlFile = doc.getContainingFile();
-
+
final String htmlFileFullName;
if (htmlFile != null) {
final VirtualFile vFile = htmlFile.getVirtualFile();
@@ -372,7 +386,8 @@ public class HtmlUtil {
if (doctype == null) {
LOG.debug("DOCTYPE for " + htmlFileFullName + " is null");
- return Html5SchemaProvider.HTML5_SCHEMA_LOCATION.equals(ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(doc.getProject()));
+ return Html5SchemaProvider.HTML5_SCHEMA_LOCATION
+ .equals(ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(doc.getProject()));
}
final boolean html5Doctype = isHtml5Doctype(doctype);
@@ -412,7 +427,7 @@ public class HtmlUtil {
}
public static void processLinks(@NotNull final XmlFile xhtmlFile,
- @NotNull Processor tagProcessor) {
+ @NotNull Processor tagProcessor) {
final XmlDocument doc = getRealXmlDocument(xhtmlFile.getDocument());
if (doc == null) return;
@@ -421,7 +436,8 @@ public class HtmlUtil {
if (LINK.equalsIgnoreCase(rootTag.getName())) {
tagProcessor.process(rootTag);
- } else {
+ }
+ else {
findLinkStylesheets(rootTag, tagProcessor);
}
}
@@ -448,7 +464,7 @@ public class HtmlUtil {
if (injectedDocument != null) {
final XmlTag rootTag = injectedDocument.getRootTag();
if (rootTag != null) {
- for(PsiElement element = rootTag; element != null; element = element.getNextSibling()) {
+ for (PsiElement element = rootTag; element != null; element = element.getNextSibling()) {
if (element instanceof XmlTag) {
final XmlTag tag = (XmlTag)element;
String tagName = tag.getLocalName();
@@ -488,6 +504,7 @@ public class HtmlUtil {
private static class TerminateException extends RuntimeException {
private static final TerminateException INSTANCE = new TerminateException();
}
+
public static Charset detectCharsetFromMetaHttpEquiv(@NotNull String content) {
final Ref charsetNameRef = new Ref();
try {
@@ -495,7 +512,10 @@ public class HtmlUtil {
@NonNls final Set inTag = new THashSet();
boolean metHttpEquiv = false;
- public void doctype(@Nullable final CharSequence publicId, @Nullable final CharSequence systemId, final int startOffset, final int endOffset) {
+ public void doctype(@Nullable final CharSequence publicId,
+ @Nullable final CharSequence systemId,
+ final int startOffset,
+ final int endOffset) {
}
public ProcessingOrder startTag(final CharSequence localName, final String namespace, final int startoffset, final int endoffset,
@@ -531,6 +551,7 @@ public class HtmlUtil {
}
private String contentAttributeValue;
+
public void attribute(final CharSequence localName, final CharSequence v, final int startoffset, final int endoffset) {
@NonNls final String name = localName.toString().toLowerCase();
if (inTag.contains("meta")) {
@@ -555,7 +576,7 @@ public class HtmlUtil {
});
}
catch (TerminateException e) {
- //ignore
+ //ignore
}
catch (Exception e) {
// some weird things can happen, like unbalanaced tree