// Path: src/org/emberjs/codeInsight/ComponentUtil.java
// public class ComponentUtil {
//     public static String getAttributeName(final String text) {
//         final String[] split = StringUtil.unquoteString(text).split("(?=[A-Z])");
//         for (int i = 0; i < split.length; i++) {
//             split[i] = StringUtil.decapitalize(split[i]);
//         }
//         return StringUtil.join(split, "-");
//     }
// 
//     public static String attributeToComponent(String name) {
//         final String[] words = name.split("-");
//         for (int i = 1; i < words.length; i++) {
//             words[i] = StringUtil.capitalize(words[i]);
//         }
//         return StringUtil.join(words);
//     }
// 
//     public static boolean processComponents(final Project project,
//                                                Processor<JSNamedElementProxy> processor) {
//         final Collection<String> docComponents = EmberIndexUtil.getAllKeys(EmberComponentDocIndex.INDEX_ID, project);
//         for (String componentName : docComponents) {
//             final JSNamedElementProxy component = getComponentProxy(project, componentName, EmberComponentDocIndex.INDEX_ID);
//             if (component != null) {
//                 if (!processor.process(component)) {
//                     return false;
//                 }
//             }
//         }
//         final Collection<String> components = EmberIndexUtil.getAllKeys(EmberComponentIndex.INDEX_ID, project);
//         for (String componentName : components) {
//             if (!docComponents.contains(componentName)) {
//                 final JSNamedElementProxy component = getComponentProxy(project, componentName, EmberComponentIndex.INDEX_ID);
//                 if (component != null) {
//                     if (!processor.process(component)) {
//                         return false;
//                     }
//                 }
//             }
//         }
//         return true;
//     }
// 
//     public static JSNamedElementProxy getComponentProxy(String componentName, Project project) {
//         final JSNamedElementProxy component = getComponentProxy(project, componentName, EmberComponentDocIndex.INDEX_ID);
//         return component == null ? getComponentProxy(project, componentName, EmberComponentIndex.INDEX_ID) : component;
//     }
// 
//     private static JSNamedElementProxy getComponentProxy(Project project, String componentName, final ID<String, Void> index) {
//         final JSNamedElementProxy component = EmberIndexUtil.resolve(project, index, componentName);
//         // TODO: do some stuff??
//         return null;
//     }
// 
//     @Nullable
//     public static JSNamedElementProxy getComponent(@Nullable PsiElement element) {
//         if (element instanceof JSNamedElementProxy) {
//             return getComponent(element, ((JSNamedElementProxy)element).getName());
//         }
//         if (element instanceof JSLiteralExpression && ((JSLiteralExpression)element).isQuotedLiteral()) {
//             return getComponent(element, StringUtil.unquoteString(element.getText()));
//         }
//         return null;
//     }
// 
//     private static JSNamedElementProxy getComponent(PsiElement element, final String name) {
//         final String componentName = getAttributeName(name);
//         final JSNamedElementProxy component = EmberIndexUtil.resolve(element.getProject(), EmberComponentIndex.INDEX_ID, componentName);
//         if (component != null && element.getTextRange().contains(component.getTextOffset())) {
//             return component;
//         }
//         return null;
//     }
// }


import com.intellij.html.impl.RelaxedHtmlFromSchemaElementDescriptor;
import com.intellij.lang.javascript.index.JSNamedElementProxy;
import com.intellij.openapi.util.Condition;
import com.intellij.psi.PsiElement;
import com.intellij.psi.impl.source.xml.XmlDocumentImpl;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xml.XmlAttributeDescriptor;
import com.intellij.xml.XmlElementDescriptor;
import com.intellij.xml.XmlElementsGroup;
import com.intellij.xml.XmlNSDescriptor;
import com.intellij.xml.impl.schema.AnyXmlAttributeDescriptor;
import org.emberjs.codeInsight.ComponentUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
    public String getDefaultName() {
        return myName;
    }

    @Override
    public XmlElementDescriptor[] getElementsDescriptors(XmlTag context) {
        XmlDocumentImpl xmlDocument = PsiTreeUtil.getParentOfType(context, XmlDocumentImpl.class);
        if (xmlDocument == null) return EMPTY_ARRAY;
        return xmlDocument.getRootTagNSDescriptor().getRootElementsDescriptors(xmlDocument);
    }

    @Override
    public XmlElementDescriptor getElementDescriptor(XmlTag childTag, XmlTag contextTag) {
        XmlTag parent = contextTag.getParentTag();
        if (parent == null) return null;
        final XmlNSDescriptor descriptor = parent.getNSDescriptor(childTag.getNamespace(), true);
        return descriptor == null ? null : descriptor.getElementDescriptor(childTag);
    }

    @Override
    public XmlAttributeDescriptor[] getAttributesDescriptors(@Nullable XmlTag context) {
        final String string = getDeclaration().getIndexItem().getTypeString();
        final String attributes = string.split(";", -1)[3];
        final String[] split = attributes.split(",");
        final XmlAttributeDescriptor[] result;
        if (split.length == 1 && split[0].isEmpty()) {
            result = XmlAttributeDescriptor.EMPTY;
        } else {
            result = new XmlAttributeDescriptor[split.length];
            for (int i = 0; i < split.length; i++) {
// Path: src/org/emberjs/codeInsight/ComponentUtil.java
// public class ComponentUtil {
//     public static String getAttributeName(final String text) {
//         final String[] split = StringUtil.unquoteString(text).split("(?=[A-Z])");
//         for (int i = 0; i < split.length; i++) {
//             split[i] = StringUtil.decapitalize(split[i]);
//         }
//         return StringUtil.join(split, "-");
//     }
// 
//     public static String attributeToComponent(String name) {
//         final String[] words = name.split("-");
//         for (int i = 1; i < words.length; i++) {
//             words[i] = StringUtil.capitalize(words[i]);
//         }
//         return StringUtil.join(words);
//     }
// 
//     public static boolean processComponents(final Project project,
//                                                Processor<JSNamedElementProxy> processor) {
//         final Collection<String> docComponents = EmberIndexUtil.getAllKeys(EmberComponentDocIndex.INDEX_ID, project);
//         for (String componentName : docComponents) {
//             final JSNamedElementProxy component = getComponentProxy(project, componentName, EmberComponentDocIndex.INDEX_ID);
//             if (component != null) {
//                 if (!processor.process(component)) {
//                     return false;
//                 }
//             }
//         }
//         final Collection<String> components = EmberIndexUtil.getAllKeys(EmberComponentIndex.INDEX_ID, project);
//         for (String componentName : components) {
//             if (!docComponents.contains(componentName)) {
//                 final JSNamedElementProxy component = getComponentProxy(project, componentName, EmberComponentIndex.INDEX_ID);
//                 if (component != null) {
//                     if (!processor.process(component)) {
//                         return false;
//                     }
//                 }
//             }
//         }
//         return true;
//     }
// 
//     public static JSNamedElementProxy getComponentProxy(String componentName, Project project) {
//         final JSNamedElementProxy component = getComponentProxy(project, componentName, EmberComponentDocIndex.INDEX_ID);
//         return component == null ? getComponentProxy(project, componentName, EmberComponentIndex.INDEX_ID) : component;
//     }
// 
//     private static JSNamedElementProxy getComponentProxy(Project project, String componentName, final ID<String, Void> index) {
//         final JSNamedElementProxy component = EmberIndexUtil.resolve(project, index, componentName);
//         // TODO: do some stuff??
//         return null;
//     }
// 
//     @Nullable
//     public static JSNamedElementProxy getComponent(@Nullable PsiElement element) {
//         if (element instanceof JSNamedElementProxy) {
//             return getComponent(element, ((JSNamedElementProxy)element).getName());
//         }
//         if (element instanceof JSLiteralExpression && ((JSLiteralExpression)element).isQuotedLiteral()) {
//             return getComponent(element, StringUtil.unquoteString(element.getText()));
//         }
//         return null;
//     }
// 
//     private static JSNamedElementProxy getComponent(PsiElement element, final String name) {
//         final String componentName = getAttributeName(name);
//         final JSNamedElementProxy component = EmberIndexUtil.resolve(element.getProject(), EmberComponentIndex.INDEX_ID, componentName);
//         if (component != null && element.getTextRange().contains(component.getTextOffset())) {
//             return component;
//         }
//         return null;
//     }
// }


// Path: src/org/emberjs/codeInsight/tags/EmberJSTagDescriptor.java
import com.intellij.html.impl.RelaxedHtmlFromSchemaElementDescriptor;
import com.intellij.lang.javascript.index.JSNamedElementProxy;
import com.intellij.openapi.util.Condition;
import com.intellij.psi.PsiElement;
import com.intellij.psi.impl.source.xml.XmlDocumentImpl;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.ArrayUtil;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.xml.XmlAttributeDescriptor;
import com.intellij.xml.XmlElementDescriptor;
import com.intellij.xml.XmlElementsGroup;
import com.intellij.xml.XmlNSDescriptor;
import com.intellij.xml.impl.schema.AnyXmlAttributeDescriptor;
import org.emberjs.codeInsight.ComponentUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;

    public String getDefaultName() {
        return myName;
    }

    @Override
    public XmlElementDescriptor[] getElementsDescriptors(XmlTag context) {
        XmlDocumentImpl xmlDocument = PsiTreeUtil.getParentOfType(context, XmlDocumentImpl.class);
        if (xmlDocument == null) return EMPTY_ARRAY;
        return xmlDocument.getRootTagNSDescriptor().getRootElementsDescriptors(xmlDocument);
    }

    @Override
    public XmlElementDescriptor getElementDescriptor(XmlTag childTag, XmlTag contextTag) {
        XmlTag parent = contextTag.getParentTag();
        if (parent == null) return null;
        final XmlNSDescriptor descriptor = parent.getNSDescriptor(childTag.getNamespace(), true);
        return descriptor == null ? null : descriptor.getElementDescriptor(childTag);
    }

    @Override
    public XmlAttributeDescriptor[] getAttributesDescriptors(@Nullable XmlTag context) {
        final String string = getDeclaration().getIndexItem().getTypeString();
        final String attributes = string.split(";", -1)[3];
        final String[] split = attributes.split(",");
        final XmlAttributeDescriptor[] result;
        if (split.length == 1 && split[0].isEmpty()) {
            result = XmlAttributeDescriptor.EMPTY;
        } else {
            result = new XmlAttributeDescriptor[split.length];
            for (int i = 0; i < split.length; i++) {
                result[i] = new AnyXmlAttributeDescriptor(ComponentUtil.getAttributeName(split[i]));