Search in sources :

Example 1 with JSFileImpl

use of com.intellij.lang.javascript.psi.impl.JSFileImpl in project WebStormRequireJsPlugin by Fedott.

the class RequirejsProjectComponent method parseRequirejsConfig.

//    private Date lastParse;
public boolean parseRequirejsConfig() {
    VirtualFile mainJsVirtualFile = findPathInWebDir(settings.configFilePath);
    if (null == mainJsVirtualFile) {
        this.showErrorConfigNotification("Config file not found. File " + settings.publicPath + '/' + settings.configFilePath + " not found in project");
        LOG.debug("Config not found");
        return false;
    } else {
        PsiFile mainJs = PsiManager.getInstance(project).findFile(mainJsVirtualFile);
        if (mainJs instanceof JSFileImpl || mainJs instanceof XmlFileImpl) {
            Map<String, VirtualFile> allConfigPaths;
            packageConfig.clear();
            requireMap.clear();
            requirePaths.clear();
            if (((PsiFileImpl) mainJs).getTreeElement() == null) {
                parseMainJsFile(((PsiFileImpl) mainJs).calcTreeElement());
            } else {
                parseMainJsFile(((PsiFileImpl) mainJs).getTreeElement());
            }
        } else {
            this.showErrorConfigNotification("Config file wrong format");
            LOG.debug("Config file wrong format");
            return false;
        }
    }
    return true;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) XmlFileImpl(com.intellij.psi.impl.source.xml.XmlFileImpl) JSFileImpl(com.intellij.lang.javascript.psi.impl.JSFileImpl)

Example 2 with JSFileImpl

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

the class FlexTreeStructureProvider method modify.

@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
    List<AbstractTreeNode> result = new ArrayList<>();
    if (parent instanceof SwfQualifiedNamedElementNode || parent instanceof FlexFileNode) {
        if (((ProjectViewNode) parent).getSettings().isShowMembers()) {
            JSQualifiedNamedElement parentElement = getElement(parent);
            if (parentElement != null) {
                JSStructureViewElement structureViewElement = parentElement instanceof XmlBackedJSClassImpl ? new FlexStructureViewElement(((XmlBackedJSClassImpl) parentElement), (XmlFile) parentElement.getContainingFile(), false) : new JSStructureViewElement(parentElement, false, true);
                StructureViewTreeElement[] structureViewChildren = structureViewElement.getChildren();
                for (final StructureViewTreeElement structureViewChild : structureViewChildren) {
                    if (structureViewChild instanceof JSStructureViewElement) {
                        PsiElement childElement = ((JSStructureViewElement) structureViewChild).getValue();
                        result.add(new FlexClassMemberNode((JSElement) childElement, ((ProjectViewNode) parent).getSettings()));
                    } else {
                        result.add(new UnknownNode(parentElement.getProject(), structureViewChild, ((ProjectViewNode) parent).getSettings()));
                    }
                }
            }
        }
    } else {
        for (final AbstractTreeNode child : children) {
            Object o = child.getValue();
            if (o instanceof JSFileImpl && !(o instanceof PsiCompiledFile) && DialectDetector.isActionScript((PsiFile) o) || o instanceof XmlFile && JavaScriptSupportLoader.isFlexMxmFile((PsiFile) o)) {
                result.add(new FlexFileNode((PsiFile) o, ((ProjectViewNode) parent).getSettings()));
                continue;
            }
            result.add(child);
        }
    }
    return result;
}
Also used : XmlBackedJSClassImpl(com.intellij.lang.javascript.flex.XmlBackedJSClassImpl) XmlFile(com.intellij.psi.xml.XmlFile) ArrayList(java.util.ArrayList) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) JSQualifiedNamedElement(com.intellij.lang.javascript.psi.ecmal4.JSQualifiedNamedElement) JSStructureViewElement(com.intellij.lang.javascript.structureView.JSStructureViewElement) FlexStructureViewElement(com.intellij.lang.javascript.flex.presentation.FlexStructureViewProvider.FlexStructureViewElement) JSFileImpl(com.intellij.lang.javascript.psi.impl.JSFileImpl) ProjectViewNode(com.intellij.ide.projectView.ProjectViewNode) PsiCompiledFile(com.intellij.psi.PsiCompiledFile) JSElement(com.intellij.lang.javascript.psi.JSElement) StructureViewTreeElement(com.intellij.ide.structureView.StructureViewTreeElement) PsiFile(com.intellij.psi.PsiFile) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with JSFileImpl

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

the class FlexIconProvider method getIcon.

@Override
public Icon getIcon(@NotNull PsiElement element, int flags) {
    int transformedFlags = ElementBase.transformFlags(element, flags);
    Icon icon = null;
    if (element instanceof XmlFile) {
        if (JavaScriptSupportLoader.isFlexMxmFile((PsiFile) element)) {
            final JSClass jsClass = XmlBackedJSClassFactory.getXmlBackedClass((XmlFile) element);
            if (jsClass != null) {
                icon = jsClass.getIcon(flags);
            }
        }
    } else if (element instanceof JSFileImpl) {
        final JSNamedElement mainDeclaredElement = ActionScriptResolveUtil.findMainDeclaredElement((JSFileImpl) element);
        if (mainDeclaredElement != null) {
            icon = mainDeclaredElement.getIcon(transformedFlags);
        }
    }
    if (icon != null) {
        final PsiFile psiFile = element.getContainingFile();
        final VirtualFile vFile = psiFile == null ? null : psiFile.getVirtualFile();
        CompilerManager compilerManager = CompilerManager.getInstance(element.getProject());
        if (vFile != null && compilerManager != null && compilerManager.isExcludedFromCompilation(vFile)) {
            icon = new LayeredIcon(icon, PlatformIcons.EXCLUDED_FROM_COMPILE_ICON);
        }
    }
    return icon;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LayeredIcon(com.intellij.ui.LayeredIcon) XmlFile(com.intellij.psi.xml.XmlFile) CompilerManager(com.intellij.openapi.compiler.CompilerManager) JSNamedElement(com.intellij.lang.javascript.psi.JSNamedElement) PsiFile(com.intellij.psi.PsiFile) LayeredIcon(com.intellij.ui.LayeredIcon) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) JSFileImpl(com.intellij.lang.javascript.psi.impl.JSFileImpl)

Aggregations

JSFileImpl (com.intellij.lang.javascript.psi.impl.JSFileImpl)3 PsiFile (com.intellij.psi.PsiFile)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 XmlFile (com.intellij.psi.xml.XmlFile)2 ProjectViewNode (com.intellij.ide.projectView.ProjectViewNode)1 StructureViewTreeElement (com.intellij.ide.structureView.StructureViewTreeElement)1 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 XmlBackedJSClassImpl (com.intellij.lang.javascript.flex.XmlBackedJSClassImpl)1 FlexStructureViewElement (com.intellij.lang.javascript.flex.presentation.FlexStructureViewProvider.FlexStructureViewElement)1 JSElement (com.intellij.lang.javascript.psi.JSElement)1 JSNamedElement (com.intellij.lang.javascript.psi.JSNamedElement)1 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)1 JSQualifiedNamedElement (com.intellij.lang.javascript.psi.ecmal4.JSQualifiedNamedElement)1 JSStructureViewElement (com.intellij.lang.javascript.structureView.JSStructureViewElement)1 CompilerManager (com.intellij.openapi.compiler.CompilerManager)1 PsiCompiledFile (com.intellij.psi.PsiCompiledFile)1 PsiElement (com.intellij.psi.PsiElement)1 XmlFileImpl (com.intellij.psi.impl.source.xml.XmlFileImpl)1 LayeredIcon (com.intellij.ui.LayeredIcon)1 ArrayList (java.util.ArrayList)1