Search in sources :

Example 16 with JSAttributeList

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

the class FlashUmlEdgeCreationPolicy method acceptSource.

public boolean acceptSource(@NotNull final DiagramNode<Object> source) {
    if (!(source.getIdentifyingElement() instanceof JSClass))
        return false;
    final JSClass clazz = (JSClass) source.getIdentifyingElement();
    JSAttributeList attributeList = clazz.getAttributeList();
    if (attributeList != null && attributeList.hasModifier(JSAttributeList.ModifierType.FINAL))
        return false;
    if (JSProjectUtil.isInLibrary(clazz))
        return false;
    return true;
}
Also used : JSAttributeList(com.intellij.lang.javascript.psi.ecmal4.JSAttributeList) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass)

Example 17 with JSAttributeList

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

the class FlashUmlVisibilityManager method getVisibilityLevel.

public VisibilityLevel getVisibilityLevel(Object element) {
    if (element instanceof JSAttributeListOwner) {
        JSAttributeList attributeList = ((JSAttributeListOwner) element).getAttributeList();
        JSAttributeList.AccessType accessType = attributeList != null ? attributeList.getAccessType() : JSUtils.getImplicitAccessType((PsiElement) element);
        return predefinedLevels.get(ArrayUtil.indexOf(JSVisibilityUtil.ACCESS_TYPES, accessType));
    }
    return null;
}
Also used : JSAttributeList(com.intellij.lang.javascript.psi.ecmal4.JSAttributeList) JSAttributeListOwner(com.intellij.lang.javascript.psi.ecmal4.JSAttributeListOwner) PsiElement(com.intellij.psi.PsiElement)

Example 18 with JSAttributeList

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

the class CreateJSSubclassIntention method isAvailable.

public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) {
    final PsiFile psiFile = element.getContainingFile();
    if (!(psiFile instanceof JSFile) || InjectedLanguageManager.getInstance(project).getInjectionHost(psiFile) != null || !psiFile.getLanguage().isKindOf(JavaScriptSupportLoader.ECMA_SCRIPT_L4)) {
        return false;
    }
    final JSClass jsClass = PsiTreeUtil.getParentOfType(element, JSClass.class);
    if (jsClass == null || !(jsClass.getParent() instanceof JSPackageStatement)) {
        return false;
    }
    if (!jsClass.isInterface()) {
        final JSAttributeList attributeList = jsClass.getAttributeList();
        if (attributeList != null && attributeList.hasModifier(JSAttributeList.ModifierType.FINAL)) {
            return false;
        }
    }
    final TextRange declarationRange = getClassDeclarationTextRange(jsClass);
    final int offset = editor.getCaretModel().getOffset();
    if (offset < declarationRange.getStartOffset() || offset > declarationRange.getEndOffset()) {
        // not the same as TextRange.contains()
        return false;
    }
    setText(getTitle(jsClass));
    return true;
}
Also used : JSAttributeList(com.intellij.lang.javascript.psi.ecmal4.JSAttributeList) JSPackageStatement(com.intellij.lang.javascript.psi.ecmal4.JSPackageStatement) PsiFile(com.intellij.psi.PsiFile) TextRange(com.intellij.openapi.util.TextRange) JSFile(com.intellij.lang.javascript.psi.JSFile) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass)

Example 19 with JSAttributeList

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

the class CreateJSSubclassIntention method getClassDeclarationTextRange.

public static TextRange getClassDeclarationTextRange(final JSClass jsClass) {
    int start = jsClass.getTextRange().getStartOffset();
    final JSAttributeList attributeList = jsClass.getAttributeList();
    if (attributeList != null) {
        final PsiElement accessTypeElement = attributeList.findAccessTypeElement();
        if (accessTypeElement != null) {
            start = accessTypeElement.getTextRange().getStartOffset();
        } else {
            final ASTNode node = jsClass.getNode();
            final ASTNode classKeyWordNode = node == null ? null : node.findChildByType(JSTokenTypes.CLASS_KEYWORD);
            if (classKeyWordNode != null) {
                start = classKeyWordNode.getTextRange().getStartOffset();
            }
        }
    }
    int end = start;
    JSReferenceList jsReferenceList = jsClass.getImplementsList();
    if (jsReferenceList == null) {
        jsReferenceList = jsClass.getExtendsList();
    }
    if (jsReferenceList != null) {
        end = jsReferenceList.getTextRange().getEndOffset();
    } else {
        final PsiElement nameIdentifier = jsClass.getNameIdentifier();
        if (nameIdentifier != null) {
            end = nameIdentifier.getTextRange().getEndOffset();
        }
    }
    return new TextRange(start, end);
}
Also used : JSAttributeList(com.intellij.lang.javascript.psi.ecmal4.JSAttributeList) ASTNode(com.intellij.lang.ASTNode) TextRange(com.intellij.openapi.util.TextRange) JSReferenceList(com.intellij.lang.javascript.psi.ecmal4.JSReferenceList) PsiElement(com.intellij.psi.PsiElement)

Example 20 with JSAttributeList

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

the class FlexMxmlNSDescriptor method isLegalRootElementDescriptor.

private static boolean isLegalRootElementDescriptor(@NotNull final XmlElementDescriptor _descriptor) {
    if (_descriptor instanceof ClassBackedElementDescriptor) {
        final ClassBackedElementDescriptor descriptor = (ClassBackedElementDescriptor) _descriptor;
        final PsiElement element = descriptor.getDeclaration();
        if (element instanceof JSClass) {
            final JSAttributeList attributeList = ((JSClass) element).getAttributeList();
            if (attributeList != null && attributeList.hasModifier(JSAttributeList.ModifierType.FINAL)) {
                return false;
            }
        }
        if (JavaScriptSupportLoader.isLanguageNamespace(descriptor.context.namespace)) {
            final String tagName = _descriptor.getName();
            return !descriptor.isPredefined() && !ArrayUtil.contains(tagName, ILLEGAL_LANGUAGE_ROOT_TAGS);
        }
    }
    return true;
}
Also used : JSAttributeList(com.intellij.lang.javascript.psi.ecmal4.JSAttributeList) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) MxmlJSClass(com.intellij.javascript.flex.mxml.MxmlJSClass) PsiElement(com.intellij.psi.PsiElement)

Aggregations

JSAttributeList (com.intellij.lang.javascript.psi.ecmal4.JSAttributeList)22 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)13 PsiElement (com.intellij.psi.PsiElement)12 JSFunction (com.intellij.lang.javascript.psi.JSFunction)5 JSAttributeListOwner (com.intellij.lang.javascript.psi.ecmal4.JSAttributeListOwner)5 NotNull (org.jetbrains.annotations.NotNull)5 JSAttribute (com.intellij.lang.javascript.psi.ecmal4.JSAttribute)4 JSAttributeNameValuePair (com.intellij.lang.javascript.psi.ecmal4.JSAttributeNameValuePair)4 MxmlJSClass (com.intellij.javascript.flex.mxml.MxmlJSClass)3 JSFile (com.intellij.lang.javascript.psi.JSFile)3 XmlFile (com.intellij.psi.xml.XmlFile)3 XmlTag (com.intellij.psi.xml.XmlTag)3 THashMap (gnu.trove.THashMap)3 ASTNode (com.intellij.lang.ASTNode)2 XmlBackedJSClassImpl (com.intellij.lang.javascript.flex.XmlBackedJSClassImpl)2 JSReferenceExpression (com.intellij.lang.javascript.psi.JSReferenceExpression)2 JSPackageStatement (com.intellij.lang.javascript.psi.ecmal4.JSPackageStatement)2 Module (com.intellij.openapi.module.Module)2 TextRange (com.intellij.openapi.util.TextRange)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2