com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl Java Examples
The following examples show how to use
com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TYPO3ExtensionUtil.java From idea-php-typo3-plugin with MIT License | 6 votes |
/** * Traverses the given directories and returns the first valid * extension definition that's applicable. * * @param directories List of directories to analyze */ public static TYPO3ExtensionDefinition findContainingExtension(PsiDirectory[] directories) { for (PsiDirectory directory : directories) { VirtualDirectoryImpl virtualFile = (VirtualDirectoryImpl) directory.getVirtualFile(); while (!isExtensionRootDirectory(virtualFile)) { if (virtualFile.getParent() == null) { return null; } virtualFile = virtualFile.getParent(); } TYPO3ExtensionDefinition extensionDefinition = ExtensionDefinitionFactory.fromDirectory(virtualFile); if (extensionDefinition != null) { return extensionDefinition; } } return null; }
Example #2
Source File: LocalFileSystemRefreshWorker.java From consulo with Apache License 2.0 | 6 votes |
private void processFile(@Nonnull NewVirtualFile file, @Nonnull RefreshContext refreshContext) { if (!VfsEventGenerationHelper.checkDirty(file) || isCancelled(file, refreshContext)) { return; } if (file.isDirectory()) { boolean fullSync = ((VirtualDirectoryImpl)file).allChildrenLoaded(); if (fullSync) { fullDirRefresh((VirtualDirectoryImpl)file, refreshContext); } else { partialDirRefresh((VirtualDirectoryImpl)file, refreshContext); } } else { refreshFile(file, refreshContext); } if (isCancelled(file, refreshContext)) { return; } if (myIsRecursive || !file.isDirectory()) { file.markClean(); } }
Example #3
Source File: TYPO3ExtensionUtil.java From idea-php-typo3-plugin with MIT License | 5 votes |
/** * Determines if a directory is the top-most directory of an extension. * It does so by searching the "ext_emconf.php" * * @param virtualFile Directory to scan * @return true if the current directory is a root directory. */ private static boolean isExtensionRootDirectory(VirtualDirectoryImpl virtualFile) { VirtualFile[] immediateChildren = virtualFile.getChildren(); for (VirtualFile file : immediateChildren) { if (file.getName().equals("ext_emconf.php")) { return true; } } return false; }
Example #4
Source File: ExtensionDefinitionFactory.java From idea-php-typo3-plugin with MIT License | 5 votes |
public static TYPO3ExtensionDefinition fromDirectory(VirtualDirectoryImpl virtualDirectory) { TYPO3ExtensionDefinition extensionDefinition = null; // try finding composer manifest VirtualFileSystemEntry composerManifest = virtualDirectory.findChild("composer.json"); if (composerManifest != null) { try { extensionDefinition = fromComposerManifest(composerManifest); } catch (IOException e) { e.printStackTrace(); } } return extensionDefinition; }
Example #5
Source File: FileUtils.java From vue-for-idea with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static List<String> getAllFilesInDirectory(VirtualFile directory, String target, String replacement) { List<String> files = new ArrayList<String>(); VirtualFile[] children = directory.getChildren(); for (VirtualFile child : children) { if (child instanceof VirtualDirectoryImpl) { files.addAll(getAllFilesInDirectory(child, target, replacement)); } else if (child instanceof VirtualFileImpl) { files.add(child.getPath().replace(target, replacement)); } } return files; }
Example #6
Source File: FileUtils.java From WebStormRequireJsPlugin with MIT License | 5 votes |
public static List<String> getAllFilesInDirectory(VirtualFile directory, String target, String replacement) { List<String> files = new ArrayList<String>(); VirtualFile[] children = directory.getChildren(); for (VirtualFile child : children) { if (child instanceof VirtualDirectoryImpl) { files.addAll(getAllFilesInDirectory(child, target, replacement)); } else if (child instanceof VirtualFileImpl) { files.add(child.getPath().replace(target, replacement)); } } return files; }
Example #7
Source File: PlatformTestCase.java From consulo with Apache License 2.0 | 5 votes |
private static void addSubTree(VirtualFile root, Set<VirtualFile> to) { if (root instanceof VirtualDirectoryImpl) { for (VirtualFile child : ((VirtualDirectoryImpl)root).getCachedChildren()) { if (child instanceof VirtualDirectoryImpl) { to.add(child); addSubTree(child, to); } } } }
Example #8
Source File: LocalFileSystemTest.java From consulo with Apache License 2.0 | 5 votes |
public void testFileCaseChange() throws Exception { if (SystemInfo.isFileSystemCaseSensitive) { System.err.println("Ignored: case-insensitive FS required"); return; } File top = createTempDirectory(false); File file = IoTestUtil.createTestFile(top, "file.txt", "test"); File intermediate = new File(top, "_intermediate_"); VirtualFile topDir = myFS.refreshAndFindFileByIoFile(top); assertNotNull(topDir); VirtualFile sourceFile = myFS.refreshAndFindFileByIoFile(file); assertNotNull(sourceFile); String newName = StringUtil.capitalize(file.getName()); FileUtil.rename(file, intermediate); FileUtil.rename(intermediate, new File(top, newName)); topDir.refresh(false, true); assertFalse(((VirtualDirectoryImpl)topDir).allChildrenLoaded()); assertTrue(sourceFile.isValid()); assertEquals(newName, sourceFile.getName()); topDir.getChildren(); newName = newName.toLowerCase(Locale.ENGLISH); FileUtil.rename(file, intermediate); FileUtil.rename(intermediate, new File(top, newName)); topDir.refresh(false, true); assertTrue(((VirtualDirectoryImpl)topDir).allChildrenLoaded()); assertTrue(sourceFile.isValid()); assertEquals(newName, sourceFile.getName()); }
Example #9
Source File: RefreshWorker.java From consulo with Apache License 2.0 | 5 votes |
private void queueDirectory(NewVirtualFile root) { if (root instanceof VirtualDirectoryImpl) { myRefreshQueue.addLast(root); } else { LOG.error("not a directory: " + root + " (" + root.getClass()); } }
Example #10
Source File: RefreshWorker.java From consulo with Apache License 2.0 | 5 votes |
private void processQueue(@Nonnull NewVirtualFileSystem fs, @Nonnull PersistentFS persistence) throws RefreshCancelledException { TObjectHashingStrategy<String> strategy = FilePathHashingStrategy.create(fs.isCaseSensitive()); next: while (!myRefreshQueue.isEmpty()) { VirtualDirectoryImpl dir = (VirtualDirectoryImpl)myRefreshQueue.pullFirst(); boolean fullSync = dir.allChildrenLoaded(), succeeded; do { myHelper.beginTransaction(); try { succeeded = fullSync ? fullDirRefresh(fs, persistence, strategy, dir) : partialDirRefresh(fs, persistence, strategy, dir); } catch (InvalidVirtualFileAccessException e) { myHelper.endTransaction(false); continue next; } myHelper.endTransaction(succeeded); if (!succeeded && LOG.isTraceEnabled()) LOG.trace("retry: " + dir); } while (!succeeded); if (myIsRecursive) { dir.markClean(); } } }
Example #11
Source File: LocalFileSystemRefreshWorker.java From consulo with Apache License 2.0 | 5 votes |
private void fullDirRefresh(@Nonnull VirtualDirectoryImpl dir, @Nonnull RefreshContext refreshContext) { while (true) { // obtaining directory snapshot Pair<String[], VirtualFile[]> result = getDirectorySnapshot(refreshContext.persistence, dir); if (result == null) return; String[] persistedNames = result.getFirst(); VirtualFile[] children = result.getSecond(); RefreshingFileVisitor refreshingFileVisitor = new RefreshingFileVisitor(dir, refreshContext, null, Arrays.asList(children)); refreshingFileVisitor.visit(dir); if (myCancelled) { addAllEventsFrom(refreshingFileVisitor); break; } // generating events unless a directory was changed in between boolean hasEvents = ReadAction.compute(() -> { if (ApplicationManager.getApplication().isDisposed()) { return true; } if (!Arrays.equals(persistedNames, refreshContext.persistence.list(dir)) || !Arrays.equals(children, dir.getChildren())) { if (LOG.isDebugEnabled()) LOG.debug("retry: " + dir); return false; } addAllEventsFrom(refreshingFileVisitor); return true; }); if (hasEvents) { break; } } }
Example #12
Source File: LocalFileSystemRefreshWorker.java From consulo with Apache License 2.0 | 5 votes |
private void partialDirRefresh(@Nonnull VirtualDirectoryImpl dir, @Nonnull RefreshContext refreshContext) { while (true) { // obtaining directory snapshot Pair<List<VirtualFile>, List<String>> result = ReadAction.compute(() -> pair(dir.getCachedChildren(), dir.getSuspiciousNames())); List<VirtualFile> cached = result.getFirst(); List<String> wanted = result.getSecond(); if (cached.isEmpty() && wanted.isEmpty()) return; RefreshingFileVisitor refreshingFileVisitor = new RefreshingFileVisitor(dir, refreshContext, wanted, cached); refreshingFileVisitor.visit(dir); if (myCancelled) { addAllEventsFrom(refreshingFileVisitor); break; } // generating events unless a directory was changed in between boolean hasEvents = ReadAction.compute(() -> { if (!cached.equals(dir.getCachedChildren()) || !wanted.equals(dir.getSuspiciousNames())) { if (LOG.isDebugEnabled()) LOG.debug("retry: " + dir); return false; } addAllEventsFrom(refreshingFileVisitor); return true; }); if (hasEvents) { break; } } }
Example #13
Source File: RefreshWorker.java From consulo with Apache License 2.0 | 4 votes |
private boolean isDirectoryChanged(@Nonnull PersistentFS persistence, @Nonnull VirtualDirectoryImpl dir, @Nonnull String[] persistedNames, @Nonnull VirtualFile[] children) { return ReadAction.compute(() -> { checkCancelled(dir); return !Arrays.equals(persistedNames, persistence.list(dir)) || !Arrays.equals(children, dir.getChildren()); }); }
Example #14
Source File: RefreshWorker.java From consulo with Apache License 2.0 | 4 votes |
private boolean isDirectoryChanged(@Nonnull VirtualDirectoryImpl dir, @Nonnull List<VirtualFile> cached, @Nonnull List<String> wanted) { return ReadAction.compute(() -> { checkCancelled(dir); return !cached.equals(dir.getCachedChildren()) || !wanted.equals(dir.getSuspiciousNames()); }); }
Example #15
Source File: LocalFileSystemRefreshWorker.java From consulo with Apache License 2.0 | 4 votes |
static Pair<String[], VirtualFile[]> getDirectorySnapshot(@Nonnull PersistentFS persistence, @Nonnull VirtualDirectoryImpl dir) { return ReadAction.compute(() -> ApplicationManager.getApplication().isDisposed() ? null : pair(persistence.list(dir), dir.getChildren())); }