Search in sources :

Example 1 with VirtualFileVisitor

use of com.intellij.openapi.vfs.VirtualFileVisitor in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoPerformanceTest method testParserAndStubs.

public void testParserAndStubs() {
    File go = new File(getTestDataPath(), "go");
    if (!go.exists()) {
        System.err.println("For performance tests you need to have a go sources (https://storage.googleapis.com/golang/go1.4.2.src.tar.gz) inside testData/" + getBasePath() + " directory");
        return;
    }
    PlatformTestUtil.startPerformanceTest(getTestName(true), (int) TimeUnit.MINUTES.toMillis(1), () -> {
        VirtualFile root = LocalFileSystem.getInstance().findFileByIoFile(go);
        assertNotNull(root);
        VfsUtilCore.visitChildrenRecursively(root, new VirtualFileVisitor() {

            @NotNull
            @Override
            public Result visitFileEx(@NotNull VirtualFile file) {
                if (file.isDirectory() && "testdata".equals(file.getName()))
                    return SKIP_CHILDREN;
                if (file.isDirectory() && "test".equals(file.getName()) && file.getParent().equals(root))
                    return SKIP_CHILDREN;
                if (file.getFileType() != GoFileType.INSTANCE)
                    return CONTINUE;
                try {
                    System.out.print(".");
                    buildStubTreeText(getProject(), file, FileUtil.loadFile(new File(file.getPath()), "UTF-8", true).trim(), true);
                } catch (IOException ignored) {
                }
                return CONTINUE;
            }
        });
    }).usesAllCPUCores().assertTiming();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) IOException(java.io.IOException) VirtualFileVisitor(com.intellij.openapi.vfs.VirtualFileVisitor) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with VirtualFileVisitor

use of com.intellij.openapi.vfs.VirtualFileVisitor in project intellij-elixir by KronicDeth.

the class MixProjectImportBuilder method findMixExs.

@NotNull
private List<VirtualFile> findMixExs(@NotNull final VirtualFile root, @NotNull final ProgressIndicator indicator) {
    // synchronous and recursive
    root.refresh(false, true);
    final List<VirtualFile> foundMixExs = new ArrayList<VirtualFile>();
    VfsUtilCore.visitChildrenRecursively(root, new VirtualFileVisitor() {

        @Override
        public boolean visitFile(@NotNull VirtualFile file) {
            indicator.checkCanceled();
            if (file.isDirectory()) {
                if (isBuildOrConfigOrDepsOrTestsDirectory(root.getPath(), file.getPath()))
                    return false;
                indicator.setText2(file.getPath());
            } else if (file.getName().equalsIgnoreCase("mix.exs")) {
                foundMixExs.add(file);
            }
            return true;
        }
    });
    return foundMixExs;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFileVisitor(com.intellij.openapi.vfs.VirtualFileVisitor) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with VirtualFileVisitor

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

the class SvnRecursiveStatusWalker method processRecursively.

private void processRecursively(@NotNull VirtualFile vFile, @NotNull Depth prevDepth) {
    if (Depth.EMPTY.equals(prevDepth))
        return;
    if (isIgnoredIdeaLevel(vFile)) {
        myReceiver.processIgnored(vFile);
        return;
    }
    Depth newDepth = Depth.INFINITY.equals(prevDepth) ? Depth.INFINITY : Depth.EMPTY;
    VirtualFileVisitor.Option[] options = newDepth.equals(Depth.EMPTY) ? ar(SKIP_ROOT, ONE_LEVEL_DEEP) : new VirtualFileVisitor.Option[0];
    visitChildrenRecursively(vFile, new VirtualFileVisitor(options) {

        @NotNull
        @Override
        public Result visitFileEx(@NotNull VirtualFile file) {
            if (isIgnoredIdeaLevel(file)) {
                myReceiver.processIgnored(file);
                return SKIP_CHILDREN;
            } else if (file.isDirectory() && file.findChild(SvnUtil.SVN_ADMIN_DIR_NAME) != null) {
                myQueue.add(createItem(VcsUtil.getFilePath(file), newDepth, true));
                return SKIP_CHILDREN;
            } else {
                myReceiver.processUnversioned(file);
                return CONTINUE;
            }
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFileVisitor(com.intellij.openapi.vfs.VirtualFileVisitor) NotNull(org.jetbrains.annotations.NotNull) Depth(org.jetbrains.idea.svn.api.Depth)

Example 4 with VirtualFileVisitor

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

the class PyPackageUtil method collectPackageNames.

private static void collectPackageNames(@NotNull final Project project, @NotNull final VirtualFile root, @NotNull final List<String> results) {
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
    VfsUtilCore.visitChildrenRecursively(root, new VirtualFileVisitor() {

        @Override
        public boolean visitFile(@NotNull VirtualFile file) {
            if (!fileIndex.isExcluded(file) && file.isDirectory() && file.findChild(PyNames.INIT_DOT_PY) != null) {
                results.add(VfsUtilCore.getRelativePath(file, root, '.'));
            }
            return true;
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) VirtualFileVisitor(com.intellij.openapi.vfs.VirtualFileVisitor)

Example 5 with VirtualFileVisitor

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

the class ConflictCreator method create.

public void create() throws PatchSyntaxException, IOException {
    // local changes, do not commit
    for (TreeConflictData.FileData data : myData.getLeftFiles()) {
        applyFileData(myMineDir, data);
    }
    final PatchReader reader = new PatchReader(myData.getTheirsPatch());
    final List<TextFilePatch> patches = reader.readTextPatches();
    final List<FilePatch> filePatchList = new ArrayList<>(patches);
    for (Iterator<FilePatch> iterator = filePatchList.iterator(); iterator.hasNext(); ) {
        final FilePatch patch = iterator.next();
        if (patch.isDeletedFile()) {
            myClientRunner.delete(myTheirsDir, patch.getBeforeName());
            iterator.remove();
        }
    }
    if (!filePatchList.isEmpty()) {
        PatchApplier<BinaryFilePatch> applier = new PatchApplier<>(myProject, myTheirsDir, filePatchList, (LocalChangeList) null, null, null);
        applier.setIgnoreContentRootsCheck();
        applier.execute();
        Assert.assertEquals(0, applier.getRemainingPatches().size());
    }
    TimeoutUtil.sleep(10);
    SvnVcs vcs = SvnVcs.getInstance(myProject);
    for (TextFilePatch patch : patches) {
        if (patch.isNewFile() || !Comparing.equal(patch.getAfterName(), patch.getBeforeName())) {
            final String afterName = patch.getAfterName();
            final String[] parts = afterName.split("/");
            String subPath = "";
            for (String part : parts) {
                final String path = subPath + part;
                Info info = vcs.getInfo(new File(myTheirsDir.getPath(), path));
                if (info == null || info.getURL() == null) {
                    myClientRunner.add(myTheirsDir, path);
                }
                subPath += part + "/";
            }
            if (!patch.isNewFile()) {
                myClientRunner.delete(myTheirsDir, patch.getBeforeName());
            }
        }
    }
    VfsUtilCore.visitChildrenRecursively(myTheirsDir, new VirtualFileVisitor() {

        @NotNull
        @Override
        public Result visitFileEx(@NotNull VirtualFile file) {
            if (!myTheirsDir.equals(file) && file.isDirectory() && file.getChildren().length == 0) {
                try {
                    myClientRunner.delete(myTheirsDir, file.getPath());
                } catch (IOException e) {
                    throw new VisitorException(e);
                }
            }
            return file.isDirectory() && SvnUtil.isAdminDirectory(file) ? SKIP_CHILDREN : CONTINUE;
        }
    }, IOException.class);
    // this will commit all patch changes
    myClientRunner.checkin(myTheirsDir);
    // this will create the conflict
    myClientRunner.update(myMineDir);
    myClientRunner.update(myTheirsDir);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Info(org.jetbrains.idea.svn.info.Info) VirtualFileVisitor(com.intellij.openapi.vfs.VirtualFileVisitor) NotNull(org.jetbrains.annotations.NotNull) PatchApplier(com.intellij.openapi.diff.impl.patch.formove.PatchApplier) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)23 VirtualFileVisitor (com.intellij.openapi.vfs.VirtualFileVisitor)23 NotNull (org.jetbrains.annotations.NotNull)12 FileTypeManager (com.intellij.openapi.fileTypes.FileTypeManager)4 File (java.io.File)4 FileType (com.intellij.openapi.fileTypes.FileType)3 IOException (java.io.IOException)3 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)2 ArrayList (java.util.ArrayList)2 Nullable (org.jetbrains.annotations.Nullable)2 Result (com.intellij.openapi.application.Result)1 PatchApplier (com.intellij.openapi.diff.impl.patch.formove.PatchApplier)1 FileTypeRegistry (com.intellij.openapi.fileTypes.FileTypeRegistry)1 Module (com.intellij.openapi.module.Module)1 ModuleImpl (com.intellij.openapi.module.impl.ModuleImpl)1 Project (com.intellij.openapi.project.Project)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 SdkModificator (com.intellij.openapi.projectRoots.SdkModificator)1 ContentIterator (com.intellij.openapi.roots.ContentIterator)1 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)1