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();
}
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;
}
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;
}
}
});
}
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;
}
});
}
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);
}
Aggregations