Search in sources :

Example 1 with JSField

use of com.intellij.lang.javascript.psi.JSField in project intellij-plugins by JetBrains.

the class AngularBindingDescriptor method createOneTimeBinding.

@Nullable
private static AngularBindingDescriptor createOneTimeBinding(Pair<PsiElement, String> dom) {
    PsiElement element = dom.first;
    if (element instanceof JSImplicitElement) {
        String type = ((JSImplicitElement) element).getTypeString();
        if (type != null && (type.endsWith("String") || type.endsWith("Object"))) {
            return new AngularBindingDescriptor(element, dom.second);
        }
    }
    final JSType type = expandStringLiteralTypes(element instanceof JSFunction ? ((JSFunction) element).getReturnType() : element instanceof JSField ? ((JSField) element).getType() : null);
    return type != null && type.isDirectlyAssignableType(STRING_TYPE, null) ? new AngularBindingDescriptor(element, dom.second) : null;
}
Also used : JSType(com.intellij.lang.javascript.psi.JSType) JSFunction(com.intellij.lang.javascript.psi.JSFunction) JSField(com.intellij.lang.javascript.psi.JSField) JSImplicitElement(com.intellij.lang.javascript.psi.stubs.JSImplicitElement) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with JSField

use of com.intellij.lang.javascript.psi.JSField in project intellij-plugins by JetBrains.

the class NodeClassInfo method fillMapsForClass.

private static void fillMapsForClass(final JSClass jsClass, final Map<String, Icon> staticFields, final Map<String, Icon> staticProperties, final Map<String, Icon> fields, final Map<String, Icon> properties) {
    for (final JSField variable : jsClass.getFields()) {
        final JSAttributeList varAttributes = variable.getAttributeList();
        if (varAttributes != null && varAttributes.hasModifier(JSAttributeList.ModifierType.STATIC)) {
            staticFields.put(variable.getName(), variable.getIcon(Iconable.ICON_FLAG_VISIBILITY));
        } else {
            fields.put(variable.getName(), variable.getIcon(Iconable.ICON_FLAG_VISIBILITY));
        }
    }
    for (final JSFunction function : jsClass.getFunctions()) {
        if (function.getKind() == JSFunction.FunctionKind.GETTER && function.getName() != null) {
            final JSAttributeList functionAttributes = function.getAttributeList();
            if (functionAttributes != null && functionAttributes.hasModifier(JSAttributeList.ModifierType.STATIC)) {
                staticProperties.put(function.getName(), function.getIcon(Iconable.ICON_FLAG_VISIBILITY));
            } else {
                properties.put(function.getName(), function.getIcon(Iconable.ICON_FLAG_VISIBILITY));
            }
        }
    }
    if (jsClass instanceof MxmlJSClass) {
        final PsiFile file = jsClass.getContainingFile();
        final XmlFile xmlFile = file instanceof XmlFile ? (XmlFile) file : null;
        final XmlTag rootTag = xmlFile == null ? null : xmlFile.getRootTag();
        if (rootTag != null) {
            processSubtagsRecursively(rootTag, tag -> {
                final String id = tag.getAttributeValue("id");
                if (id != null) {
                    fields.put(id, tag.getIcon(Iconable.ICON_FLAG_VISIBILITY));
                }
                return !MxmlJSClass.isTagThatAllowsAnyXmlContent(tag);
            });
        }
    }
}
Also used : JSAttributeList(com.intellij.lang.javascript.psi.ecmal4.JSAttributeList) XmlFile(com.intellij.psi.xml.XmlFile) JSFunction(com.intellij.lang.javascript.psi.JSFunction) JSField(com.intellij.lang.javascript.psi.JSField) PsiFile(com.intellij.psi.PsiFile) MxmlJSClass(com.intellij.javascript.flex.mxml.MxmlJSClass) XmlTag(com.intellij.psi.xml.XmlTag)

Aggregations

JSField (com.intellij.lang.javascript.psi.JSField)2 JSFunction (com.intellij.lang.javascript.psi.JSFunction)2 MxmlJSClass (com.intellij.javascript.flex.mxml.MxmlJSClass)1 JSType (com.intellij.lang.javascript.psi.JSType)1 JSAttributeList (com.intellij.lang.javascript.psi.ecmal4.JSAttributeList)1 JSImplicitElement (com.intellij.lang.javascript.psi.stubs.JSImplicitElement)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1 XmlFile (com.intellij.psi.xml.XmlFile)1 XmlTag (com.intellij.psi.xml.XmlTag)1 Nullable (org.jetbrains.annotations.Nullable)1