use of com.intellij.openapi.vfs.VirtualFileVisitor in project intellij-community by JetBrains.
the class ModuleChunkSourcePath method addExcludePatterns.
private static void addExcludePatterns(Module module, final VirtualFile root, VirtualFile dir, final CompositeGenerator generator, final boolean parentIncluded) {
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor() {
@Override
public boolean visitFile(@NotNull VirtualFile dir) {
if (!dir.isDirectory() || fileTypeManager.isFileIgnored(dir)) {
// ignored files are handled by global 'ignored' pattern set
return false;
}
final boolean isIncluded = moduleRootManager.getFileIndex().isInContent(dir);
if (isIncluded != parentIncluded) {
final String relativePath = VfsUtilCore.getRelativePath(dir, root, '/');
if (isIncluded) {
generator.add(new Include(relativePath + "/**"));
} else {
if (!isExcludedByDefault(dir.getName())) {
generator.add(new Exclude(relativePath + "/**"));
}
}
}
return true;
}
});
}
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 LightProjectDescriptor method registerSourceRoot.
protected void registerSourceRoot(Project project, VirtualFile srcRoot) {
IndexableFileSet indexableFileSet = new IndexableFileSet() {
@Override
public boolean isInSet(@NotNull VirtualFile file) {
return file.getFileSystem() == srcRoot.getFileSystem() && project.isOpen();
}
@Override
public void iterateIndexableFilesIn(@NotNull VirtualFile file, @NotNull ContentIterator iterator) {
VfsUtilCore.visitChildrenRecursively(file, new VirtualFileVisitor() {
@Override
public boolean visitFile(@NotNull VirtualFile file) {
iterator.processFile(file);
return true;
}
});
}
};
FileBasedIndex.getInstance().registerIndexableSet(indexableFileSet, null);
Disposer.register(project, () -> FileBasedIndex.getInstance().removeIndexableSet(indexableFileSet));
}
use of com.intellij.openapi.vfs.VirtualFileVisitor in project intellij-community by JetBrains.
the class BytecodeAnalysisIntegrationTest method setUpExternalUpAnnotations.
private void setUpExternalUpAnnotations() {
String annotationsPath = PathManagerEx.getTestDataPath() + "/codeInspection/bytecodeAnalysis/annotations";
VirtualFile annotationsDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(annotationsPath);
assertNotNull(annotationsDir);
ModuleRootModificationUtil.updateModel(myModule, new AsynchConsumer<ModifiableRootModel>() {
@Override
public void finished() {
}
@Override
public void consume(ModifiableRootModel modifiableRootModel) {
LibraryTable libraryTable = modifiableRootModel.getModuleLibraryTable();
Library[] libs = libraryTable.getLibraries();
for (Library library : libs) {
Library.ModifiableModel libraryModel = library.getModifiableModel();
libraryModel.addRoot(annotationsDir, AnnotationOrderRootType.getInstance());
libraryModel.commit();
}
Sdk sdk = modifiableRootModel.getSdk();
if (sdk != null) {
Sdk clone;
try {
clone = (Sdk) sdk.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
SdkModificator sdkModificator = clone.getSdkModificator();
sdkModificator.addRoot(annotationsDir, AnnotationOrderRootType.getInstance());
sdkModificator.commitChanges();
modifiableRootModel.setSdk(clone);
}
}
});
VfsUtilCore.visitChildrenRecursively(annotationsDir, new VirtualFileVisitor() {
});
annotationsDir.refresh(false, true);
}
use of com.intellij.openapi.vfs.VirtualFileVisitor in project intellij-community by JetBrains.
the class AnalysisScope method initFilesSet.
protected void initFilesSet() {
if (myType == FILE) {
myFilesSet = new HashSet<>(1);
myFilesSet.add(((PsiFileSystemItem) myElement).getVirtualFile());
} else if (myType == DIRECTORY || myType == PROJECT || myType == MODULES || myType == MODULE || myType == CUSTOM) {
myFilesSet = new THashSet<>();
accept(createFileSearcher(), false);
} else if (myType == VIRTUAL_FILES) {
myFilesSet = new THashSet<>();
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
for (Iterator<VirtualFile> iterator = myVFiles.iterator(); iterator.hasNext(); ) {
final VirtualFile vFile = iterator.next();
VfsUtilCore.visitChildrenRecursively(vFile, new VirtualFileVisitor() {
@NotNull
@Override
public Result visitFileEx(@NotNull VirtualFile file) {
boolean ignored = fileIndex.isExcluded(file);
if (!ignored && !file.isDirectory()) {
myFilesSet.add(file);
}
return ignored ? SKIP_CHILDREN : CONTINUE;
}
});
if (vFile.isDirectory()) {
iterator.remove();
}
}
}
}
Aggregations