Search in sources :

Example 21 with JarFileSystem

use of com.intellij.openapi.vfs.JarFileSystem in project intellij-community by JetBrains.

the class IdeaJdk method appendIdeaLibrary.

private static void appendIdeaLibrary(final String libDirPath, final ArrayList<VirtualFile> result, @NonNls final String... forbidden) {
    Arrays.sort(forbidden);
    final String path = libDirPath + File.separator + LIB_DIR_NAME;
    final JarFileSystem jfs = JarFileSystem.getInstance();
    final File lib = new File(path);
    if (lib.isDirectory()) {
        File[] jars = lib.listFiles();
        if (jars != null) {
            for (File jar : jars) {
                @NonNls String name = jar.getName();
                if (jar.isFile() && Arrays.binarySearch(forbidden, name) < 0 && (name.endsWith(".jar") || name.endsWith(".zip"))) {
                    VirtualFile file = jfs.findFileByPath(jar.getPath() + JarFileSystem.JAR_SEPARATOR);
                    LOG.assertTrue(file != null, jar.getPath() + " not found");
                    result.add(file);
                }
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) NonNls(org.jetbrains.annotations.NonNls) JarFileSystem(com.intellij.openapi.vfs.JarFileSystem) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Example 22 with JarFileSystem

use of com.intellij.openapi.vfs.JarFileSystem in project intellij-community by JetBrains.

the class PyTreeStructureProvider method hideSkeletons.

@NotNull
private static Collection<AbstractTreeNode> hideSkeletons(@NotNull Collection<AbstractTreeNode> children) {
    List<AbstractTreeNode> newChildren = new ArrayList<>();
    for (AbstractTreeNode child : children) {
        if (child instanceof PsiDirectoryNode) {
            PsiDirectory directory = ((PsiDirectoryNode) child).getValue();
            if (directory == null) {
                continue;
            }
            VirtualFile dir = directory.getVirtualFile();
            if (dir.equals(PyUserSkeletonsUtil.getUserSkeletonsDirectory())) {
                continue;
            }
            if (dir.getFileSystem() instanceof JarFileSystem) {
                dir = ((JarFileSystem) dir.getFileSystem()).getLocalVirtualFileFor(dir);
            }
            if (dir == null) {
                continue;
            }
            if (PyTypeShed.INSTANCE.isInside(dir)) {
                continue;
            }
            VirtualFile dirParent = dir.getParent();
            if (dirParent != null && dirParent.getName().equals(PythonSdkType.SKELETON_DIR_NAME)) {
                continue;
            }
            if (dirParent != null && dirParent.getName().equals(PythonSdkType.REMOTE_SOURCES_DIR_NAME)) {
                continue;
            }
            if (dirParent != null) {
                VirtualFile grandParent = dirParent.getParent();
                if (grandParent != null && grandParent.getName().equals(PythonSdkType.REMOTE_SOURCES_DIR_NAME)) {
                    continue;
                }
            }
        }
        newChildren.add(child);
    }
    return newChildren;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) JarFileSystem(com.intellij.openapi.vfs.JarFileSystem) PsiDirectory(com.intellij.psi.PsiDirectory) ArrayList(java.util.ArrayList) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) PsiDirectoryNode(com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode) NotNull(org.jetbrains.annotations.NotNull)

Example 23 with JarFileSystem

use of com.intellij.openapi.vfs.JarFileSystem in project intellij-plugins by JetBrains.

the class StrutsVersionDetector method getStrutsJarRoot.

@Nullable
private static VirtualFile getStrutsJarRoot(final Module module) {
    final GlobalSearchScope scope = GlobalSearchScope.moduleRuntimeScope(module, false);
    final JavaPsiFacade psiManager = JavaPsiFacade.getInstance(module.getProject());
    final VirtualFile virtualFile = getStrutsClass(scope, psiManager);
    if (virtualFile == null || !(virtualFile.getFileSystem() instanceof JarFileSystem)) {
        return null;
    }
    final VirtualFile jarFile = JarFileSystem.getInstance().getLocalVirtualFileFor(virtualFile);
    if (jarFile == null) {
        return null;
    }
    return JarFileSystem.getInstance().getJarRootForLocalFile(jarFile);
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) VirtualFile(com.intellij.openapi.vfs.VirtualFile) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) JarFileSystem(com.intellij.openapi.vfs.JarFileSystem) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

JarFileSystem (com.intellij.openapi.vfs.JarFileSystem)23 VirtualFile (com.intellij.openapi.vfs.VirtualFile)23 Nullable (org.jetbrains.annotations.Nullable)7 Module (com.intellij.openapi.module.Module)6 Project (com.intellij.openapi.project.Project)5 File (java.io.File)4 NonNls (org.jetbrains.annotations.NonNls)4 NotNull (org.jetbrains.annotations.NotNull)4 ArrayList (java.util.ArrayList)3 FileElement (com.intellij.openapi.fileChooser.FileElement)2 RootFileElement (com.intellij.openapi.fileChooser.ex.RootFileElement)2 VirtualFileSystem (com.intellij.openapi.vfs.VirtualFileSystem)2 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)2 ZipFile (java.util.zip.ZipFile)2 ArchiveFileType (com.intellij.ide.highlighter.ArchiveFileType)1 PsiDirectoryNode (com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode)1 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 ParamValue (com.intellij.javaee.model.xml.ParamValue)1 Filter (com.intellij.javaee.model.xml.web.Filter)1 WebApp (com.intellij.javaee.model.xml.web.WebApp)1