All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.intellij.xml.HtmlXmlExtension Maven / Gradle / Ivy

Go to download

A packaging of the IntelliJ Community Edition xml-psi-impl library. This is release number 1 of trunk branch 142.

The newest version!
package com.intellij.xml;

import com.intellij.ide.highlighter.HtmlFileType;
import com.intellij.psi.PsiFile;
import com.intellij.psi.xml.XmlDocument;
import com.intellij.xml.util.HtmlUtil;
import org.jetbrains.annotations.Nullable;

/**
 * @author Dmitry Avdeev
 *         Date: 24.10.13
 */
public class HtmlXmlExtension extends DefaultXmlExtension {

  @Override
  public boolean isAvailable(PsiFile file) {
    return file.getFileType() == HtmlFileType.INSTANCE;
  }

  @Nullable
  @Override
  public String[][] getNamespacesFromDocument(XmlDocument parent, boolean declarationsExist) {
    String[][] namespaces = super.getNamespacesFromDocument(parent, false);
    if (namespaces == null || !HtmlUtil.isHtml5Document(parent)) return namespaces;

    for (String[] namespace : namespaces) {
      if ("xlink".equals(namespace[0])) return namespaces;
    }

    String[][] newNamespaces = new String[namespaces.length + 1][2];
    System.arraycopy(namespaces, 0, newNamespaces, 0, namespaces.length);
    newNamespaces[namespaces.length] = new String[] {"xlink", "http://www.w3.org/1999/xlink"};
    return newNamespaces;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy