use of com.intellij.openapi.vfs.LocalFileSystem in project intellij-community by JetBrains.
the class JrtFileSystemImpl method checkSubscription.
private void checkSubscription() {
if (mySubscribed.getAndSet(true))
return;
Application app = ApplicationManager.getApplication();
app.getMessageBus().connect(app).subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
Set<VirtualFile> toRefresh = null;
for (VFileEvent event : events) {
if (event.getFileSystem() instanceof LocalFileSystem && event instanceof VFileContentChangeEvent) {
VirtualFile file = event.getFile();
if (file != null && "release".equals(file.getName())) {
String homePath = file.getParent().getPath();
ArchiveHandler handler = myHandlers.remove(homePath);
if (handler != null) {
handler.dispose();
VirtualFile root = findFileByPath(composeRootPath(homePath));
if (root != null) {
((NewVirtualFile) root).markDirtyRecursively();
if (toRefresh == null)
toRefresh = ContainerUtil.newHashSet();
toRefresh.add(root);
}
}
}
}
}
if (toRefresh != null) {
boolean async = !ApplicationManager.getApplication().isUnitTestMode();
RefreshQueue.getInstance().refresh(async, true, null, toRefresh);
}
}
});
}
use of com.intellij.openapi.vfs.LocalFileSystem in project intellij-community by JetBrains.
the class PsiDirectoryNode method contains.
@Override
public boolean contains(@NotNull VirtualFile file) {
final PsiDirectory value = getValue();
if (value == null) {
return false;
}
VirtualFile directory = value.getVirtualFile();
if (directory.getFileSystem() instanceof LocalFileSystem) {
file = PathUtil.getLocalFile(file);
}
if (!VfsUtilCore.isAncestor(directory, file, false)) {
return false;
}
final Project project = value.getProject();
PsiFileSystemItemFilter filter = getFilter();
if (filter != null) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile != null && !filter.shouldShow(psiFile))
return false;
PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(file);
if (psiDirectory != null && !filter.shouldShow(psiDirectory))
return false;
}
if (Registry.is("ide.hide.excluded.files")) {
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
return !fileIndex.isExcluded(file);
} else {
return !FileTypeRegistry.getInstance().isFileIgnored(file);
}
}
use of com.intellij.openapi.vfs.LocalFileSystem in project intellij-plugins by JetBrains.
the class FlexCompilationManager method refreshAndFindFileInWriteAction.
static VirtualFile refreshAndFindFileInWriteAction(final String outputFilePath, final String... possibleBaseDirs) {
final LocalFileSystem localFileSystem = LocalFileSystem.getInstance();
final Ref<VirtualFile> outputFileRef = new Ref<>();
final Application app = ApplicationManager.getApplication();
app.invokeAndWait(() -> outputFileRef.set(app.runWriteAction(new NullableComputable<VirtualFile>() {
public VirtualFile compute() {
VirtualFile outputFile = localFileSystem.refreshAndFindFileByPath(outputFilePath);
//}
if (outputFile == null) {
for (final String baseDir : possibleBaseDirs) {
outputFile = localFileSystem.refreshAndFindFileByPath(baseDir + "/" + outputFilePath);
if (outputFile != null) {
break;
}
}
}
if (outputFile == null)
return null;
// it's important because this file has just been created
outputFile.refresh(false, false);
return outputFile;
}
})));
return outputFileRef.get();
}
use of com.intellij.openapi.vfs.LocalFileSystem in project android by JetBrains.
the class AndroidJniFolderNode method getDirectories.
@NotNull
@Override
public PsiDirectory[] getDirectories() {
Collection<File> sourceFolders = getModel().getSelectedVariant().getSourceFolders();
List<PsiDirectory> psiDirectories = Lists.newArrayListWithExpectedSize(sourceFolders.size());
LocalFileSystem fileSystem = LocalFileSystem.getInstance();
assert myProject != null;
PsiManager psiManager = PsiManager.getInstance(myProject);
for (File folder : sourceFolders) {
VirtualFile virtualFile = fileSystem.findFileByIoFile(folder);
if (virtualFile != null) {
PsiDirectory dir = psiManager.findDirectory(virtualFile);
if (dir != null) {
psiDirectories.add(dir);
}
}
}
return psiDirectories.toArray(new PsiDirectory[psiDirectories.size()]);
}
use of com.intellij.openapi.vfs.LocalFileSystem in project android by JetBrains.
the class NativeAndroidLibraryNode method convertToVirtualFiles.
@NotNull
private static List<VirtualFile> convertToVirtualFiles(@NotNull Collection<File> files) {
List<VirtualFile> result = Lists.newArrayListWithCapacity(files.size());
LocalFileSystem fileSystem = LocalFileSystem.getInstance();
for (File file : files) {
VirtualFile virtualFile = fileSystem.findFileByIoFile(file);
if (virtualFile != null) {
result.add(virtualFile);
}
}
return result;
}
Aggregations