Search in sources :

Example 1 with JSPrimitiveArrayType

use of com.intellij.lang.javascript.psi.types.primitives.JSPrimitiveArrayType in project intellij-plugins by JetBrains.

the class ActionScriptTypeEvaluator method addTypeFromElementResolveResult.

@Override
protected boolean addTypeFromElementResolveResult(PsiElement resolveResult, boolean hasSomeType) {
    if (resolveResult instanceof JSOffsetBasedImplicitElement && JavaScriptSupportLoader.isFlexMxmFile(resolveResult.getContainingFile())) {
        resolveResult = ((JSOffsetBasedImplicitElement) resolveResult).getElementAtOffset();
    }
    if (resolveResult instanceof XmlToken) {
        final XmlToken xmlToken = (XmlToken) resolveResult;
        final XmlAttribute xmlAttribute = PsiTreeUtil.getParentOfType(xmlToken, XmlAttribute.class);
        final XmlTag xmlTag = PsiTreeUtil.getParentOfType(xmlToken, XmlTag.class);
        if (xmlToken.getTokenType() == XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN && xmlAttribute != null && "id".equals(xmlAttribute.getName()) && xmlTag != null && isInsideRepeaterTag(xmlTag)) {
            final PsiElement arrayClass = ActionScriptClassResolver.findClassByQNameStatic(ARRAY_CLASS_NAME, xmlToken);
            if (arrayClass != null) {
                final String arrayType = new JSTagContextBuilder(resolveResult, null).typeName;
                JSTypeSource source = JSTypeSourceFactory.createTypeSource(resolveResult);
                JSType type;
                if (arrayType != null) {
                    JSType baseType = JSNamedType.createType(arrayType, source, JSContext.INSTANCE);
                    type = new JSArrayTypeImpl(baseType, source);
                } else {
                    type = new JSPrimitiveArrayType(source, JSTypeContext.INSTANCE);
                }
                addType(type, arrayClass);
            }
        } else {
            final XmlTag tag = PsiTreeUtil.getParentOfType(resolveResult, XmlTag.class, false);
            final JSClass clazz = JSResolveUtil.getClassFromTagNameInMxml(tag);
            if (clazz != null) {
                final String name = clazz.getQualifiedName();
                if (name != null) {
                    addType(name, clazz);
                }
            }
        }
        return hasSomeType;
    }
    return super.addTypeFromElementResolveResult(resolveResult, hasSomeType);
}
Also used : XmlAttribute(com.intellij.psi.xml.XmlAttribute) JSPrimitiveArrayType(com.intellij.lang.javascript.psi.types.primitives.JSPrimitiveArrayType) JSOffsetBasedImplicitElement(com.intellij.lang.javascript.psi.impl.JSOffsetBasedImplicitElement) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) PsiElement(com.intellij.psi.PsiElement) XmlToken(com.intellij.psi.xml.XmlToken) XmlTag(com.intellij.psi.xml.XmlTag)

Aggregations

JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)1 JSOffsetBasedImplicitElement (com.intellij.lang.javascript.psi.impl.JSOffsetBasedImplicitElement)1 JSPrimitiveArrayType (com.intellij.lang.javascript.psi.types.primitives.JSPrimitiveArrayType)1 PsiElement (com.intellij.psi.PsiElement)1 XmlAttribute (com.intellij.psi.xml.XmlAttribute)1 XmlTag (com.intellij.psi.xml.XmlTag)1 XmlToken (com.intellij.psi.xml.XmlToken)1