use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.
the class VirtualFilePointerTest method testMoveSrcDirUnderNewRootShouldGenerateRootsChanged.
public void testMoveSrcDirUnderNewRootShouldGenerateRootsChanged() throws Exception {
File tempDirectory = createTempDirectory();
final File moveTarget = new File(tempDirectory, "moveTarget");
assertTrue(moveTarget.mkdir());
final File dirToMove = new File(tempDirectory, "dirToMove");
assertTrue(dirToMove.mkdir());
final LoggingListener listener = new LoggingListener();
final VirtualFilePointer dirToMovePointer = createPointerByFile(dirToMove, listener);
assertTrue(dirToMovePointer.isValid());
ApplicationManager.getApplication().runWriteAction(() -> {
final VirtualFile virtualFile = getVirtualFile(dirToMove);
assertTrue(virtualFile.isValid());
final VirtualFile target = getVirtualFile(moveTarget);
assertTrue(target.isValid());
try {
virtualFile.move(null, target);
} catch (IOException e) {
fail();
}
});
assertTrue(dirToMovePointer.isValid());
assertEquals("[before:true, after:true]", listener.getLog().toString());
}
use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.
the class FileAssociationsManagerImpl method addAssociation.
public void addAssociation(PsiFile file, VirtualFile assoc) {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
LOG.warn("No VirtualFile for " + file.getName());
return;
}
for (VirtualFilePointer pointer : myAssociations.keySet()) {
if (pointer.getUrl().equals(virtualFile.getUrl())) {
VirtualFilePointerContainer container = myAssociations.get(pointer);
if (container == null) {
container = myFilePointerManager.createContainer(myProject);
myAssociations.put(pointer, container);
}
if (container.findByUrl(assoc.getUrl()) == null) {
container.add(assoc);
touch();
}
return;
}
}
final VirtualFilePointerContainer container = myFilePointerManager.createContainer(myProject);
container.add(assoc);
myAssociations.put(myFilePointerManager.create(virtualFile, myProject, null), container);
touch();
}
use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.
the class FileAssociationsManagerImpl method clear.
private void clear() {
final Set<VirtualFilePointer> virtualFilePointers = myAssociations.keySet();
for (VirtualFilePointer pointer : virtualFilePointers) {
myAssociations.get(pointer).killAll();
}
myAssociations.clear();
}
use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.
the class FileAssociationsManagerImpl method removeAssociation.
public void removeAssociation(PsiFile file, PsiFile assoc) {
final VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null)
return;
if (assoc.getVirtualFile() == null)
return;
for (VirtualFilePointer pointer : myAssociations.keySet()) {
if (pointer.getUrl().equals(virtualFile.getUrl())) {
VirtualFilePointerContainer container = myAssociations.get(pointer);
if (container != null) {
//noinspection ConstantConditions
final VirtualFilePointer p = container.findByUrl(assoc.getVirtualFile().getUrl());
if (p != null) {
container.remove(p);
if (container.size() == 0) {
myAssociations.remove(pointer);
}
touch();
}
}
return;
}
}
}
use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.
the class FileAssociationsManagerImpl method copy.
private static HashMap<VirtualFilePointer, VirtualFilePointerContainer> copy(FileAssociationsManagerImpl other) {
final HashMap<VirtualFilePointer, VirtualFilePointerContainer> hashMap = new LinkedHashMap<>();
final Set<VirtualFilePointer> virtualFilePointers = other.myAssociations.keySet();
for (VirtualFilePointer pointer : virtualFilePointers) {
final VirtualFilePointerContainer container = other.myFilePointerManager.createContainer(other.myProject);
container.addAll(other.myAssociations.get(pointer));
hashMap.put(other.myFilePointerManager.duplicate(pointer, other.myProject, null), container);
}
return hashMap;
}
Aggregations