use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.
the class JpsLibraryDelegate method isValid.
@Override
public boolean isValid(@NotNull String url, @NotNull OrderRootType rootType) {
final VirtualFilePointerContainer container = myRoots.get(rootType);
if (container == null)
return false;
final VirtualFilePointer fp = container.findByUrl(url);
return fp != null && fp.isValid();
}
use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.
the class JpsLibraryDelegate method getFiles.
@NotNull
@Override
public VirtualFile[] getFiles(@NotNull OrderRootType rootType) {
final VirtualFilePointerContainer container = myRoots.get(rootType);
if (container == null)
return VirtualFile.EMPTY_ARRAY;
final List<VirtualFile> expanded = new ArrayList<>();
for (JpsLibraryRoot root : myJpsLibrary.getRoots(getJpsRootType(rootType))) {
final VirtualFilePointer pointer = container.findByUrl(root.getUrl());
if (pointer == null)
continue;
VirtualFile file = pointer.getFile();
if (file == null)
continue;
if (file.isDirectory() && root.getInclusionOptions() != JpsLibraryRoot.InclusionOptions.ROOT_ITSELF) {
LibraryImpl.collectJarFiles(file, expanded, root.getInclusionOptions() == JpsLibraryRoot.InclusionOptions.ARCHIVES_UNDER_ROOT_RECURSIVELY);
continue;
}
expanded.add(file);
}
return VfsUtilCore.toVirtualFileArray(expanded);
}
use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.
the class LibraryImpl method getInvalidRootUrls.
@Override
public List<String> getInvalidRootUrls(OrderRootType type) {
if (myDisposed)
return Collections.emptyList();
final List<VirtualFilePointer> pointers = myRoots.get(type).getList();
List<String> invalidPaths = null;
for (VirtualFilePointer pointer : pointers) {
if (!pointer.isValid()) {
if (invalidPaths == null) {
invalidPaths = new SmartList<>();
}
invalidPaths.add(pointer.getUrl());
}
}
return ContainerUtil.notNullize(invalidPaths);
}
use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.
the class FileOrDirectoryTreeNode method setUserObject.
@Override
public void setUserObject(final Object userObject) {
final Object oldObject = getUserObject();
try {
super.setUserObject(userObject);
} finally {
if (oldObject instanceof VirtualFilePointer) {
VirtualFilePointer pointer = (VirtualFilePointer) oldObject;
Disposer.dispose((Disposable) pointer);
}
}
}
use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-community by JetBrains.
the class VirtualFilePointerManagerImpl method after.
@Override
public void after(@NotNull final List<? extends VFileEvent> events) {
incModificationCount();
for (FilePointerPartNode node : myNodesToUpdateUrl) {
synchronized (this) {
String urlBefore = node.myFileAndUrl.second;
Pair<VirtualFile, String> after = node.update();
assert after != null : "can't invalidate inside modification";
String urlAfter = after.second;
if (URL_COMPARATOR.compare(urlBefore, urlAfter) != 0 || !urlAfter.endsWith(node.part)) {
List<VirtualFilePointerImpl> myPointers = new SmartList<>();
node.addAllPointersTo(myPointers);
// url has changed, reinsert
int useCount = node.useCount;
FilePointerPartNode root = node.remove();
FilePointerPartNode newNode = root.findPointerOrCreate(VfsUtilCore.urlToPath(urlAfter), 0, after, myPointers.size());
VirtualFilePointer existingPointer = newNode.getAnyPointer();
if (existingPointer != null) {
// merge two pointers
for (FilePointerPartNode n = newNode; n != null; n = n.parent) {
n.pointersUnder += myPointers.size();
}
}
newNode.addAllPointersTo(myPointers);
VirtualFilePointerImpl[] newMyPointers = myPointers.toArray(new VirtualFilePointerImpl[myPointers.size()]);
newNode.associate(newMyPointers, after);
newNode.incrementUsageCount(useCount);
}
}
}
VirtualFilePointer[] pointersToFireArray = toPointers(myNodesToFire);
for (VirtualFilePointer pointer : pointersToFireArray) {
((VirtualFilePointerImpl) pointer).myNode.update();
}
for (EventDescriptor event : myEvents) {
event.fireAfter();
}
if (pointersToFireArray.length != 0) {
myBus.syncPublisher(VirtualFilePointerListener.TOPIC).validityChanged(pointersToFireArray);
}
myNodesToUpdateUrl = Collections.emptyList();
myEvents = Collections.emptyList();
myNodesToFire = Collections.emptyList();
assertConsistency();
}
Aggregations