Java 类com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl 实例源码

项目:intellij-ce-playground    文件:PlatformTestCase.java   
public static void cleanupApplicationCaches(Project project) {
  if (project != null && !project.isDisposed()) {
    UndoManagerImpl globalInstance = (UndoManagerImpl)UndoManager.getGlobalInstance();
    if (globalInstance != null) {
      globalInstance.dropHistoryInTests();
    }
    ((UndoManagerImpl)UndoManager.getInstance(project)).dropHistoryInTests();

    ((PsiManagerImpl)PsiManager.getInstance(project)).cleanupForNextTest();
  }

  ProjectManagerImpl projectManager = (ProjectManagerImpl)ProjectManager.getInstance();
  if (projectManager.isDefaultProjectInitialized()) {
    Project defaultProject = projectManager.getDefaultProject();
    ((PsiManagerImpl)PsiManager.getInstance(defaultProject)).cleanupForNextTest();
  }

  LocalFileSystemImpl localFileSystem = (LocalFileSystemImpl)LocalFileSystem.getInstance();
  if (localFileSystem != null) {
    localFileSystem.cleanupForNextTest();
  }

}
项目:intellij-ce-playground    文件:ProjectManagerImpl.java   
private static void waitForFileWatcher(@NotNull ProgressIndicator indicator) {
  LocalFileSystem fs = LocalFileSystem.getInstance();
  if (!(fs instanceof LocalFileSystemImpl)) return;

  final FileWatcher watcher = ((LocalFileSystemImpl)fs).getFileWatcher();
  if (!watcher.isOperational() || !watcher.isSettingRoots()) return;

  LOG.info("FW/roots waiting started");
  indicator.setIndeterminate(true);
  indicator.setText(ProjectBundle.message("project.load.waiting.watcher"));
  if (indicator instanceof ProgressWindow) {
    ((ProgressWindow)indicator).setCancelButtonText(CommonBundle.message("button.skip"));
  }
  while (watcher.isSettingRoots() && !indicator.isCanceled()) {
    TimeoutUtil.sleep(10);
  }
  LOG.info("FW/roots waiting finished");
}
项目:tools-idea    文件:PlatformTestCase.java   
public static void cleanupApplicationCaches(Project project) {
  if (project != null && !project.isDisposed()) {
    UndoManagerImpl globalInstance = (UndoManagerImpl)UndoManager.getGlobalInstance();
    if (globalInstance != null) {
      globalInstance.dropHistoryInTests();
    }
    ((UndoManagerImpl)UndoManager.getInstance(project)).dropHistoryInTests();

    ((PsiManagerEx)PsiManager.getInstance(project)).getFileManager().cleanupForNextTest();
  }

  LocalFileSystemImpl localFileSystem = (LocalFileSystemImpl)LocalFileSystem.getInstance();
  if (localFileSystem != null) {
    localFileSystem.cleanupForNextTest();
  }

  LocalHistoryImpl.getInstanceImpl().cleanupForNextTest();

  PatchedWeakReference.clearAll();
}
项目:tools-idea    文件:ProjectManagerImpl.java   
private void waitForFileWatcher(@NotNull Project project) {
  LocalFileSystem fs = LocalFileSystem.getInstance();
  if (!(fs instanceof LocalFileSystemImpl)) return;

  final FileWatcher watcher = ((LocalFileSystemImpl)fs).getFileWatcher();
  if (!watcher.isOperational() || !watcher.isSettingRoots()) return;

  LOG.info("FW/roots waiting started");
  Task.Modal task = new Task.Modal(project, ProjectBundle.message("project.load.progress"), true) {
    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      indicator.setIndeterminate(true);
      indicator.setText(ProjectBundle.message("project.load.waiting.watcher"));
      if (indicator instanceof ProgressWindow) {
        ((ProgressWindow)indicator).setCancelButtonText(CommonBundle.message("button.skip"));
      }
      while (watcher.isSettingRoots() && !indicator.isCanceled()) {
        TimeoutUtil.sleep(10);
      }
      LOG.info("FW/roots waiting finished");
    }
  };
  myProgressManager.run(task);
}
项目:consulo    文件:PlatformTestCase.java   
public static void cleanupApplicationCaches(Project project) {
  if (project != null && !project.isDisposed()) {
    UndoManagerImpl globalInstance = (UndoManagerImpl)UndoManager.getGlobalInstance();
    if (globalInstance != null) {
      globalInstance.dropHistoryInTests();
    }
    ((UndoManagerImpl)UndoManager.getInstance(project)).dropHistoryInTests();

    ((PsiManagerEx)PsiManager.getInstance(project)).getFileManager().cleanupForNextTest();
  }

  LocalFileSystemImpl localFileSystem = (LocalFileSystemImpl)LocalFileSystem.getInstance();
  if (localFileSystem != null) {
    localFileSystem.cleanupForNextTest();
  }

  LocalHistory.getInstance().cleanupForNextTest();
}
项目:manifold-ij    文件:IjResource.java   
public VirtualFile resolveVirtualFile()
{
  if( _virtualFile == null )
  {
    //try re-resolve virtual file if it null
    _virtualFile = LocalFileSystemImpl.getInstance().findFileByPath( _path );
    if( _virtualFile == null && _path.contains( ".jar!" ) )
    {
      _virtualFile = JarFileSystemImpl.getInstance().findFileByPath( _path );
    }
  }
  return _virtualFile;
}
项目:manifold-ij    文件:IjFileSystem.java   
IDirectory getIDirectory( String pathString )
{
  VirtualFile file = LocalFileSystemImpl.getInstance().findFileByPath( pathString );
  if( file != null && pathString.endsWith( ".jar" ) )
  {
    file = JarFileSystem.getInstance().getJarRootForLocalFile( file );
    if( file == null )
    {
      throw new RuntimeException( "Cannot load Jar file for: " + pathString );
    }
    return new IjJarDirectory( this, file );
  }
  return file != null ? new IjDirectory( this, file ) : new IjDirectory( this, pathString );
}
项目:manifold-ij    文件:IjFileSystem.java   
IFile getIFile( String pathString )
{
  VirtualFile file = LocalFileSystemImpl.getInstance().findFileByPath( pathString );
  if( file == null && pathString.contains( ".jar!" ) )
  {
    file = JarFileSystemImpl.getInstance().findFileByPath( pathString );
  }
  return file != null ? new IjFile( this, file ) : new IjFile( this, pathString );
}
项目:intellij-ce-playground    文件:StartupManagerImpl.java   
private void checkProjectRoots() {
  LocalFileSystem fs = LocalFileSystem.getInstance();
  if (!(fs instanceof LocalFileSystemImpl)) return;
  FileWatcher watcher = ((LocalFileSystemImpl)fs).getFileWatcher();
  if (!watcher.isOperational()) return;
  List<String> manualWatchRoots = watcher.getManualWatchRoots();
  if (manualWatchRoots.isEmpty()) return;
  VirtualFile[] roots = ProjectRootManager.getInstance(myProject).getContentRoots();
  if (roots.length == 0) return;

  List<String> nonWatched = new SmartList<String>();
  for (VirtualFile root : roots) {
    if (!(root.getFileSystem() instanceof LocalFileSystem)) continue;
    String rootPath = root.getPath();
    for (String manualWatchRoot : manualWatchRoots) {
      if (FileUtil.isAncestor(manualWatchRoot, rootPath, false)) {
        nonWatched.add(rootPath);
      }
    }
  }

  if (!nonWatched.isEmpty()) {
    String message = ApplicationBundle.message("watcher.non.watchable.project");
    watcher.notifyOnFailure(message, null);
    LOG.info("unwatched roots: " + nonWatched);
    LOG.info("manual watches: " + manualWatchRoots);
  }
}
项目:tools-idea    文件:StartupManagerImpl.java   
private void checkProjectRoots() {
  LocalFileSystem fs = LocalFileSystem.getInstance();
  if (!(fs instanceof LocalFileSystemImpl)) return;
  FileWatcher watcher = ((LocalFileSystemImpl)fs).getFileWatcher();
  if (!watcher.isOperational()) return;
  List<String> manualWatchRoots = watcher.getManualWatchRoots();
  if (manualWatchRoots.isEmpty()) return;
  VirtualFile[] roots = ProjectRootManager.getInstance(myProject).getContentRoots();
  if (roots.length == 0) return;

  List<String> nonWatched = new SmartList<String>();
  for (VirtualFile root : roots) {
    if (!(root.getFileSystem() instanceof LocalFileSystem)) continue;
    String rootPath = root.getPath();
    for (String manualWatchRoot : manualWatchRoots) {
      if (FileUtil.isAncestor(manualWatchRoot, rootPath, false)) {
        nonWatched.add(rootPath);
      }
    }
  }

  if (!nonWatched.isEmpty()) {
    String message = ApplicationBundle.message("watcher.non.watchable.project");
    watcher.notifyOnFailure(message, null);
    LOG.info("unwatched roots: " + nonWatched);
    LOG.info("manual watches: " + manualWatchRoots);
  }
}
项目:tools-idea    文件:FileWatcherTest.java   
@Override
protected void setUp() throws Exception {
  LOG.debug("================== setting up " + getName() + " ==================");

  super.setUp();

  myFileSystem = LocalFileSystem.getInstance();
  assertNotNull(myFileSystem);

  myWatcher = ((LocalFileSystemImpl)myFileSystem).getFileWatcher();
  assertNotNull(myWatcher);
  assertFalse(myWatcher.isOperational());
  myWatcher.startup(myNotifier);
  assertTrue(myWatcher.isOperational());

  myAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, getProject());
  myTimeout = NATIVE_PROCESS_DELAY;

  myConnection = ApplicationManager.getApplication().getMessageBus().connect();
  myConnection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
    @Override
    public void after(@NotNull List<? extends VFileEvent> events) {
      synchronized (myEvents) {
        myEvents.addAll(events);
      }
    }
  });

  ((LocalFileSystemImpl)myFileSystem).cleanupForNextTest();

  LOG = FileWatcher.getLog();
  LOG.debug("================== setting up " + getName() + " ==================");
}
项目:consulo    文件:StartupManagerImpl.java   
private void checkProjectRoots() {
  VirtualFile[] roots = ProjectRootManager.getInstance(myProject).getContentRoots();
  if (roots.length == 0) return;
  LocalFileSystem fs = LocalFileSystem.getInstance();
  if (!(fs instanceof LocalFileSystemImpl)) return;
  FileWatcher watcher = ((LocalFileSystemImpl)fs).getFileWatcher();
  if (!watcher.isOperational()) return;

  PooledThreadExecutor.INSTANCE.submit(() -> {
    LOG.debug("FW/roots waiting started");
    while (true) {
      if (myProject.isDisposed()) return;
      if (!watcher.isSettingRoots()) break;
      TimeoutUtil.sleep(10);
    }
    LOG.debug("FW/roots waiting finished");

    Collection<String> manualWatchRoots = watcher.getManualWatchRoots();
    if (!manualWatchRoots.isEmpty()) {
      List<String> nonWatched = new SmartList<>();
      for (VirtualFile root : roots) {
        if (!(root.getFileSystem() instanceof LocalFileSystem)) continue;
        String rootPath = root.getPath();
        for (String manualWatchRoot : manualWatchRoots) {
          if (FileUtil.isAncestor(manualWatchRoot, rootPath, false)) {
            nonWatched.add(rootPath);
          }
        }
      }
      if (!nonWatched.isEmpty()) {
        String message = ApplicationBundle.message("watcher.non.watchable.project");
        watcher.notifyOnFailure(message, null);
        LOG.info("unwatched roots: " + nonWatched);
        LOG.info("manual watches: " + manualWatchRoots);
      }
    }
  });
}
项目:manifold-ij    文件:IjResource.java   
@Override
public boolean isJavaFile()
{
  return _virtualFile.getFileSystem() instanceof LocalFileSystemImpl;
}
项目:intellij-ce-playground    文件:RefreshSessionImpl.java   
public void scan() {
  List<VirtualFile> workQueue = myWorkQueue;
  myWorkQueue = new ArrayList<VirtualFile>();
  boolean haveEventsToFire = myFinishRunnable != null || !myEvents.isEmpty();

  if (!workQueue.isEmpty()) {
    final LocalFileSystem fileSystem = LocalFileSystem.getInstance();
    final FileWatcher watcher;
    if (fileSystem instanceof LocalFileSystemImpl) {
      LocalFileSystemImpl fs = (LocalFileSystemImpl)fileSystem;
      fs.markSuspiciousFilesDirty(workQueue);
      watcher = fs.getFileWatcher();
    }
    else {
      watcher = null;
    }

    long t = 0;
    if (LOG.isDebugEnabled()) {
      LOG.debug("scanning " + workQueue);
      t = System.currentTimeMillis();
    }

    for (VirtualFile file : workQueue) {
      if (myCancelled) break;

      NewVirtualFile nvf = (NewVirtualFile)file;
      if (!myIsRecursive && (!myIsAsync || (watcher != null && !watcher.isWatched(nvf)))) {
        // we're unable to definitely refresh synchronously by means of file watcher.
        nvf.markDirty();
      }

      RefreshWorker worker = myWorker = new RefreshWorker(nvf, myIsRecursive);
      worker.scan();
      List<VFileEvent> events = worker.getEvents();
      if (myEvents.addAll(events)) {
        haveEventsToFire = true;
      }
    }

    if (t != 0) {
      t = System.currentTimeMillis() - t;
      LOG.debug((myCancelled ? "cancelled, " : "done, ") + t + " ms, events " + myEvents);
    }
  }

  myWorker = null;
  iHaveEventsToFire = haveEventsToFire;
}
项目:tools-idea    文件:RefreshSessionImpl.java   
public void scan() {
  List<VirtualFile> workQueue = myWorkQueue;
  myWorkQueue = new ArrayList<VirtualFile>();
  boolean haveEventsToFire = myFinishRunnable != null || !myEvents.isEmpty();

  if (!workQueue.isEmpty()) {
    LocalFileSystemImpl fs = (LocalFileSystemImpl)LocalFileSystem.getInstance();
    fs.markSuspiciousFilesDirty(workQueue);
    FileWatcher watcher = fs.getFileWatcher();

    long t = 0;
    if (LOG.isDebugEnabled()) {
      LOG.debug("scanning " + workQueue);
      t = System.currentTimeMillis();
    }

    for (VirtualFile file : workQueue) {
      if (myCancelled) break;

      NewVirtualFile nvf = (NewVirtualFile)file;
      if (!myIsRecursive && (!myIsAsync || !watcher.isWatched(nvf))) {
        // we're unable to definitely refresh synchronously by means of file watcher.
        nvf.markDirty();
      }

      RefreshWorker worker = myWorker = new RefreshWorker(nvf, myIsRecursive);
      worker.scan();
      List<VFileEvent> events = worker.getEvents();
      if (myEvents.addAll(events)) {
        haveEventsToFire = true;
      }
    }

    if (t != 0) {
      t = System.currentTimeMillis() - t;
      LOG.debug((myCancelled ? "cancelled, " : "done, ") + t + " ms, events " + myEvents);
    }
  }

  myWorker = null;
  iHaveEventsToFire = haveEventsToFire;
}
项目:consulo    文件:RefreshSessionImpl.java   
public void scan() {
  List<VirtualFile> workQueue = myWorkQueue;
  myWorkQueue = new ArrayList<>();
  boolean haveEventsToFire = myFinishRunnable != null || !myEvents.isEmpty();

  if (!workQueue.isEmpty()) {
    LocalFileSystem fs = LocalFileSystem.getInstance();
    if (fs instanceof LocalFileSystemImpl) {
      ((LocalFileSystemImpl)fs).markSuspiciousFilesDirty(workQueue);
    }

    long t = 0;
    if (LOG.isTraceEnabled()) {
      LOG.trace("scanning " + workQueue);
      t = System.currentTimeMillis();
    }

    int count = 0;
    refresh: do {
      if (LOG.isTraceEnabled()) LOG.trace("try=" + count);

      for (VirtualFile file : workQueue) {
        if (myCancelled) break refresh;

        NewVirtualFile nvf = (NewVirtualFile)file;
        if (!myIsRecursive && !myIsAsync) {
          nvf.markDirty();  // always scan when non-recursive AND synchronous - needed e.g. when refreshing project files on open
        }

        RefreshWorker worker = new RefreshWorker(nvf, myIsRecursive);
        myWorker = worker;
        worker.scan();
        haveEventsToFire |= myEvents.addAll(worker.getEvents());
      }

      count++;
      if (LOG.isTraceEnabled()) LOG.trace("events=" + myEvents.size());
    }
    while (!myCancelled && myIsRecursive && count < 3 && workQueue.stream().anyMatch(f -> ((NewVirtualFile)f).isDirty()));

    if (t != 0) {
      t = System.currentTimeMillis() - t;
      LOG.trace((myCancelled ? "cancelled, " : "done, ") + t + " ms, events " + myEvents);
    }
  }

  myWorker = null;
  myHaveEventsToFire = haveEventsToFire;
}