Search in sources :

Example 1 with XmlBackedJSClass

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

the class ActionScriptCreateConstructorFix method createIfApplicable.

@Nullable
public static ActionScriptCreateConstructorFix createIfApplicable(final JSCallExpression node) {
    final JSClass clazz;
    final JSReferenceExpression reference;
    if (node instanceof JSNewExpression) {
        JSExpression methodExpression = node.getMethodExpression();
        if (!(methodExpression instanceof JSReferenceExpression)) {
            return null;
        }
        PsiElement resolved = ((JSReferenceExpression) methodExpression).resolve();
        if (!(resolved instanceof JSClass) || resolved instanceof XmlBackedJSClass || ((JSClass) resolved).isInterface()) {
            return null;
        }
        clazz = (JSClass) resolved;
        reference = (JSReferenceExpression) methodExpression;
    } else {
        JSExpression methodExpression = node.getMethodExpression();
        if (!(methodExpression instanceof JSSuperExpression)) {
            return null;
        }
        JSClass containingClass = JSResolveUtil.getClassOfContext(node);
        if (containingClass == null) {
            return null;
        }
        clazz = containingClass.getSuperClasses()[0];
        if (clazz.isInterface()) {
            return null;
        }
        reference = (JSReferenceExpression) clazz.findNameIdentifier().getPsi();
    }
    return new ActionScriptCreateConstructorFix(clazz, reference, node);
}
Also used : XmlBackedJSClass(com.intellij.lang.javascript.psi.ecmal4.XmlBackedJSClass) JSSuperExpression(com.intellij.lang.javascript.psi.ecmal4.JSSuperExpression) XmlBackedJSClass(com.intellij.lang.javascript.psi.ecmal4.XmlBackedJSClass) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with XmlBackedJSClass

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

the class FlashUmlElementManager method findInDataContext.

public PsiElement findInDataContext(DataContext context) {
    PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(context);
    if (isAcceptableAsNode(element)) {
        return element;
    }
    // if caret stands on a member or whitespace, show diagram for the enclosing class
    final Editor editor = LangDataKeys.EDITOR.getData(context);
    if (editor != null) {
        final PsiFile file = CommonDataKeys.PSI_FILE.getData(context);
        if (file != null) {
            PsiElement elementAtOffset = file.findElementAt(editor.getCaretModel().getOffset());
            final PsiNamedElement enclosing = PsiTreeUtil.getParentOfType(elementAtOffset, JSClass.class, JSFile.class, XmlFile.class);
            if (enclosing instanceof JSClass) {
                element = enclosing;
            } else if (enclosing instanceof JSFile) {
                final XmlBackedJSClass clazz = JSResolveUtil.getXmlBackedClass((JSFile) enclosing);
                if (clazz != null) {
                    return clazz;
                }
                JSElement qualified = JSPsiImplUtils.findQualifiedElement((JSFile) enclosing);
                if (qualified instanceof JSClass) {
                    return qualified;
                }
            }
            if (enclosing instanceof XmlFile && JavaScriptSupportLoader.isFlexMxmFile((PsiFile) enclosing)) {
                return XmlBackedJSClassFactory.getXmlBackedClass((XmlFile) enclosing);
            }
        }
    }
    // handle PsiPackage (invoked when 'View as packages' mode is selected)
    Project project = CommonDataKeys.PROJECT.getData(context);
    if (project != null) {
        VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
        if (file != null) {
            PsiDirectory directory = PsiManager.getInstance(project).findDirectory(file);
            if (directory != null && isAcceptableAsNode(directory)) {
                return directory;
            }
        }
    }
    return element;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XmlBackedJSClass(com.intellij.lang.javascript.psi.ecmal4.XmlBackedJSClass) Project(com.intellij.openapi.project.Project) XmlFile(com.intellij.psi.xml.XmlFile) Editor(com.intellij.openapi.editor.Editor) XmlBackedJSClass(com.intellij.lang.javascript.psi.ecmal4.XmlBackedJSClass) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass)

Example 3 with XmlBackedJSClass

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

the class MxmlJSClassProvider method getChildInlineComponents.

public static Collection<XmlBackedJSClass> getChildInlineComponents(XmlTag rootTag, final boolean recursive) {
    final XmlTag[] directChildren = ourChildComponentsTagsCache.get(CHILD_INLINE_COMPONENTS_TAGS_KEY, rootTag, null).getValue();
    Collection<XmlTag> allChildren;
    if (recursive) {
        allChildren = new ArrayList<>();
        collectComponentsTagRecursively(directChildren, allChildren);
    } else {
        allChildren = Arrays.asList(directChildren);
    }
    Collection<XmlBackedJSClass> result = new ArrayList<>(allChildren.size());
    for (XmlTag tag : allChildren) {
        result.add(XmlBackedJSClassFactory.getInstance().getXmlBackedClass(tag));
    }
    return result;
}
Also used : XmlBackedJSClass(com.intellij.lang.javascript.psi.ecmal4.XmlBackedJSClass) ArrayList(java.util.ArrayList) XmlTag(com.intellij.psi.xml.XmlTag)

Example 4 with XmlBackedJSClass

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

the class XmlBackedClassLineMarkerProvider method collectSlowLineMarkers.

public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) {
    for (PsiElement element : elements) {
        ProgressManager.checkCanceled();
        if (element instanceof XmlTag && element.getParent() instanceof XmlDocument && element.getContainingFile() != null && JavaScriptSupportLoader.isFlexMxmFile(element.getContainingFile())) {
            final XmlBackedJSClass clazz = XmlBackedJSClassFactory.getInstance().getXmlBackedClass((XmlTag) element);
            Query<JSClass> classQuery = JSClassSearch.searchClassInheritors(clazz, true);
            XmlToken nameElement = XmlTagUtil.getStartTagNameElement((XmlTag) element);
            if (classQuery.findFirst() != null && nameElement != null) {
                result.add(new LineMarkerInfo<>(clazz, nameElement.getTextRange(), AllIcons.Gutter.OverridenMethod, Pass.LINE_MARKERS, JavaScriptLineMarkerProvider.ourClassInheritorsTooltipProvider, JavaScriptLineMarkerProvider.ourClassInheritorsNavHandler, GutterIconRenderer.Alignment.RIGHT));
            }
        }
    }
}
Also used : XmlBackedJSClass(com.intellij.lang.javascript.psi.ecmal4.XmlBackedJSClass) XmlDocument(com.intellij.psi.xml.XmlDocument) XmlBackedJSClass(com.intellij.lang.javascript.psi.ecmal4.XmlBackedJSClass) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) PsiElement(com.intellij.psi.PsiElement) XmlTag(com.intellij.psi.xml.XmlTag) XmlToken(com.intellij.psi.xml.XmlToken)

Aggregations

XmlBackedJSClass (com.intellij.lang.javascript.psi.ecmal4.XmlBackedJSClass)4 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)3 PsiElement (com.intellij.psi.PsiElement)2 XmlTag (com.intellij.psi.xml.XmlTag)2 JSSuperExpression (com.intellij.lang.javascript.psi.ecmal4.JSSuperExpression)1 Editor (com.intellij.openapi.editor.Editor)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 XmlDocument (com.intellij.psi.xml.XmlDocument)1 XmlFile (com.intellij.psi.xml.XmlFile)1 XmlToken (com.intellij.psi.xml.XmlToken)1 ArrayList (java.util.ArrayList)1 Nullable (org.jetbrains.annotations.Nullable)1