Java 类com.intellij.openapi.vfs.InvalidVirtualFileAccessException 实例源码

项目:IntelliJATS    文件:ATSFile.java   
public ATSFile(@NotNull FileViewProvider viewProvider) {
    super(viewProvider, ATSLanguage.INSTANCE);

    String extension = "";
    int i = this.getName().lastIndexOf('.');
    if (i > 0) {
        extension = this.getName().substring(i + 1);
    }
    if (extension.equals("dats")) {
        myFileTypeInstance = ATSFileTypeDynamic.INSTANCE;
    } else if (extension.equals("sats")) {
        myFileTypeInstance = ATSFileTypeStatic.INSTANCE;
    } else if (extension.equals("hats")) {
        myFileTypeInstance = ATSFileTypeInclude.INSTANCE;
    } else {
        // This is probably not exactly what we need:
        throw new InvalidVirtualFileAccessException(this.getName());
    }
}
项目:intellij-ce-playground    文件:IndexingStamp.java   
@NotNull
public static List<ID<?,?>> getNontrivialFileIndexedStates(int fileId) {
  if (fileId != INVALID_FILE_ID) {
    Lock readLock = getStripedLock(fileId).readLock();
    readLock.lock();
    try {
      Timestamps stamp = createOrGetTimeStamp(fileId);
      if (stamp != null && stamp.myIndexStamps != null && !stamp.myIndexStamps.isEmpty()) {
        final SmartList<ID<?, ?>> retained = new SmartList<ID<?, ?>>();
        stamp.myIndexStamps.forEach(new TObjectProcedure<ID<?, ?>>() {
          @Override
          public boolean execute(ID<?, ?> object) {
            retained.add(object);
            return true;
          }
        });
        return retained;
      }
    }
    catch (InvalidVirtualFileAccessException ignored /*ok to ignore it here*/) {
    }
    finally {
      readLock.unlock();
    }
  }
  return Collections.emptyList();
}
项目:tools-idea    文件:IndexingStamp.java   
public static void update(final VirtualFile file, final ID<?, ?> indexName, final long indexCreationStamp) {
  synchronized (getStripedLock(file)) {
    try {
      Timestamps stamp = createOrGetTimeStamp(file);
      if (stamp != null) stamp.set(indexName, indexCreationStamp);
    }
    catch (InvalidVirtualFileAccessException ignored /*ok to ignore it here*/) {
    }
  }
}
项目:consulo    文件:IndexingStamp.java   
@Nonnull
public static List<ID<?,?>> getNontrivialFileIndexedStates(int fileId) {
  if (fileId != INVALID_FILE_ID) {
    Lock readLock = getStripedLock(fileId).readLock();
    readLock.lock();
    try {
      Timestamps stamp = createOrGetTimeStamp(fileId);
      if (stamp != null && stamp.myIndexStamps != null && !stamp.myIndexStamps.isEmpty()) {
        final SmartList<ID<?, ?>> retained = new SmartList<ID<?, ?>>();
        stamp.myIndexStamps.forEach(new TObjectProcedure<ID<?, ?>>() {
          @Override
          public boolean execute(ID<?, ?> object) {
            retained.add(object);
            return true;
          }
        });
        return retained;
      }
    }
    catch (InvalidVirtualFileAccessException ignored /*ok to ignore it here*/) {
    }
    finally {
      readLock.unlock();
    }
  }
  return Collections.emptyList();
}
项目:intellij-ce-playground    文件:FileContentQueue.java   
@SuppressWarnings("InstanceofCatchParameter")
private boolean doLoadContent(@NotNull FileContent content, @NotNull final ProgressIndicator indicator) throws InterruptedException {
  final long contentLength = content.getLength();

  boolean counterUpdated = false;
  try {
    synchronized (myProceedWithLoadingLock) {
      while (myLoadedBytesInQueue > MAX_SIZE_OF_BYTES_IN_QUEUE) {
        indicator.checkCanceled();
        myProceedWithLoadingLock.wait(300);
      }
      myLoadedBytesInQueue += contentLength;
      counterUpdated = true;
    }

    content.getBytes(); // Reads the content bytes and caches them.

    return true;
  }
  catch (Throwable e) {
    if (counterUpdated) {
      synchronized (myProceedWithLoadingLock) {
        myLoadedBytesInQueue -= contentLength;   // revert size counter
      }
    }

    if (e instanceof ProcessCanceledException) {
      throw (ProcessCanceledException)e;
    }
    else if (e instanceof InterruptedException) {
      throw (InterruptedException)e;
    }
    else if (e instanceof IOException || e instanceof InvalidVirtualFileAccessException) {
      LOG.info(e);
    }
    else if (ApplicationManager.getApplication().isUnitTestMode()) {
      //noinspection CallToPrintStackTrace
      e.printStackTrace();
    }
    else {
      LOG.error(e);
    }

    return false;
  }
}
项目:intellij-ce-playground    文件:VfsData.java   
private static InvalidVirtualFileAccessException reportDeadFileAccess(VirtualFileSystemEntry file) {
  return new InvalidVirtualFileAccessException("Accessing dead virtual file: " + file.getUrl());
}
项目:tools-idea    文件:FileContentQueue.java   
@SuppressWarnings("InstanceofCatchParameter")
private boolean doLoadContent(final FileContent content, @NotNull final ProgressIndicator indicator) throws InterruptedException {
  final long contentLength = content.getLength();

  boolean counterUpdated = false;
  try {
    synchronized (myProceedWithLoadingLock) {
      while (myLoadedBytesInQueue > MAX_SIZE_OF_BYTES_IN_QUEUE) {
        indicator.checkCanceled();
        myProceedWithLoadingLock.wait(300);
      }
      myLoadedBytesInQueue += contentLength;
      counterUpdated = true;
    }

    content.getBytes(); // Reads the content bytes and caches them.

    return true;
  }
  catch (Throwable e) {
    if (counterUpdated) {
      synchronized (myProceedWithLoadingLock) {
        myLoadedBytesInQueue -= contentLength;   // revert size counter
      }
    }

    if (e instanceof ProcessCanceledException) {
      throw (ProcessCanceledException)e;
    }
    else if (e instanceof InterruptedException) {
      throw (InterruptedException)e;
    }
    else if (e instanceof IOException || e instanceof InvalidVirtualFileAccessException) {
      LOG.info(e);
    }
    else if (ApplicationManager.getApplication().isUnitTestMode()) {
      //noinspection CallToPrintStackTrace
      e.printStackTrace();
    }
    else {
      LOG.error(e);
    }

    return false;
  }
}
项目:consulo    文件:FileContentQueue.java   
@SuppressWarnings("InstanceofCatchParameter")
private boolean doLoadContent(@Nonnull FileContent content, @Nonnull final ProgressIndicator indicator) throws InterruptedException {
  final long contentLength = content.getLength();

  boolean counterUpdated = false;
  try {
    synchronized (myProceedWithLoadingLock) {
      while (myLoadedBytesInQueue > MAX_SIZE_OF_BYTES_IN_QUEUE) {
        indicator.checkCanceled();
        myProceedWithLoadingLock.wait(300);
      }
      myLoadedBytesInQueue += contentLength;
      counterUpdated = true;
    }

    content.getBytes(); // Reads the content bytes and caches them.

    return true;
  }
  catch (Throwable e) {
    if (counterUpdated) {
      synchronized (myProceedWithLoadingLock) {
        myLoadedBytesInQueue -= contentLength;   // revert size counter
      }
    }

    if (e instanceof ProcessCanceledException) {
      throw (ProcessCanceledException)e;
    }
    else if (e instanceof InterruptedException) {
      throw (InterruptedException)e;
    }
    else if (e instanceof IOException || e instanceof InvalidVirtualFileAccessException) {
      LOG.info(e);
    }
    else if (ApplicationManager.getApplication().isUnitTestMode()) {
      //noinspection CallToPrintStackTrace
      e.printStackTrace();
    }
    else {
      LOG.error(e);
    }

    return false;
  }
}
项目:consulo    文件:VirtualDirectoryImpl.java   
@Nullable // null if there can't be a child with this name, NULL_VIRTUAL_FILE if cached as absent, the file if found
private VirtualFileSystemEntry doFindChild(@Nonnull String name,
                                           boolean ensureCanonicalName,
                                           @Nonnull NewVirtualFileSystem delegate,
                                           boolean ignoreCase) {
  if (name.isEmpty()) {
    return null;
  }
  if (!isValid()) {
    throw new InvalidVirtualFileAccessException(this);
  }

  VirtualFileSystemEntry found = doFindChildInArray(name, ignoreCase);
  if (found != null) return found;

  if (allChildrenLoaded()) {
    return NULL_VIRTUAL_FILE;
  }

  if (ensureCanonicalName) {
    name = UriUtil.trimTrailingSlashes(UriUtil.trimLeadingSlashes(FileUtilRt.toSystemIndependentName(name)));
    if (name.indexOf('/') != -1) return null; // name must not contain slashes in the middle
    VirtualFile fake = new FakeVirtualFile(this, name);
    name = delegate.getCanonicallyCasedName(fake);
    if (name.isEmpty()) return null;
  }

  VirtualFileSystemEntry child;
  synchronized (myData) {
    // maybe another doFindChild() sneaked in the middle
    if (myData.isAdoptedName(name)) return NULL_VIRTUAL_FILE;

    int[] array = myData.myChildrenIds;
    int indexInReal = findIndex(array, name, ignoreCase);
    // double check
    if (indexInReal >= 0) {
      return VfsData.getFileById(array[indexInReal], this);
    }
    if (allChildrenLoaded()) {
      return null;
    }

    // do not extract getId outside the synchronized block since it will cause a concurrency problem.
    int id = ourPersistence.getId(this, name, delegate);
    if (id <= 0) {
      myData.addAdoptedName(name, !ignoreCase);
      return null;
    }
    child = createChild(FileNameCache.storeName(name), id, delegate);

    int[] after = myData.myChildrenIds;
    if (after != array)  {
      // in tests when we call assertAccessInTests it can load a huge number of files which lead to children modification
      // so fall back to slow path
      addChild(child);
    }
    else {
      insertChildAt(child, indexInReal);
      assertConsistency(!delegate.isCaseSensitive(), name);
    }
  }

  if (!child.isDirectory()) {
    // access check should only be called when child is actually added to the parent, otherwise it may break VirtualFilePointers validity
    //noinspection TestOnlyProblems
    VfsRootAccess.assertAccessInTests(child, getFileSystem());
  }

  return child;
}
项目:consulo    文件:VfsData.java   
private static InvalidVirtualFileAccessException reportDeadFileAccess(VirtualFileSystemEntry file) {
  return new InvalidVirtualFileAccessException("Accessing dead virtual file: " + file.getUrl());
}