Java Code Examples for com.intellij.openapi.vfs.pointers.VirtualFilePointer#isValid()

The following examples show how to use com.intellij.openapi.vfs.pointers.VirtualFilePointer#isValid() . 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: LibraryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<String> getInvalidRootUrls(@Nonnull OrderRootType type) {
  if (myDisposed) return Collections.emptyList();

  VirtualFilePointerContainer container = myRoots.get(type);
  final List<VirtualFilePointer> pointers = container == null ? Collections.emptyList() : container.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);
}
 
Example 2
Source File: FileTreeNode.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean acceptFilter(Pair<PackageSetBase, NamedScopesHolder> filter, boolean showOnlyFilteredItems) {
  try {
    VirtualFilePointer filePointer = getFilePointer();
    if (!filePointer.isValid()) {
      return false;
    }
    VirtualFile file = filePointer.getFile();
    if (file != null && file.isValid() && filter.first.contains(file, filter.second)) {
      applyFilter(true);
      return true;
    }
  }
  catch (Throwable e) {
    // TODO: catch and ignore exceptions: see to FilePatternPackageSet
    // sometimes for new file DirectoryFileIndex.getContentRootForFile() return random path
  }
  return false;
}
 
Example 3
Source File: UpdateInfoTree.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void step() {
  myNext = null;
  while (myEnum.hasMoreElements()) {
    final Object o = myEnum.nextElement();
    if (o instanceof FileTreeNode) {
      final FileTreeNode treeNode = (FileTreeNode)o;
      VirtualFilePointer filePointer = treeNode.getFilePointer();
      if (!filePointer.isValid()) continue;

      myNext = getFilePath(filePointer);
      myStatus = FileStatus.MODIFIED;

      final GroupTreeNode parent = findParentGroupTreeNode(treeNode.getParent());
      if (parent != null) {
        final String id = parent.getFileGroupId();
        if (FileGroup.CREATED_ID.equals(id)) {
          myStatus = FileStatus.ADDED;
        }
        else if (FileGroup.REMOVED_FROM_REPOSITORY_ID.equals(id)) {
          myStatus = FileStatus.DELETED;
        }
      }
      break;
    }
  }
}
 
Example 4
Source File: LibraryImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isValid(@Nonnull final String url, @Nonnull final OrderRootType rootType) {
  final VirtualFilePointerContainer container = myRoots.get(rootType);
  final VirtualFilePointer fp = container == null ? null : container.findByUrl(url);
  return fp != null && fp.isValid();
}