Java 类com.intellij.openapi.util.LowMemoryWatcher 实例源码

项目:intellij-ce-playground    文件:FileManagerImpl.java   
public FileManagerImpl(PsiManagerImpl manager, FileDocumentManager fileDocumentManager, FileIndexFacade fileIndex) {
  myManager = manager;
  myFileIndex = fileIndex;
  myConnection = manager.getProject().getMessageBus().connect();

  myFileDocumentManager = fileDocumentManager;

  myConnection.subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
    @Override
    public void enteredDumbMode() {
      updateAllViewProviders();
    }

    @Override
    public void exitDumbMode() {
      updateAllViewProviders();
    }
  });
  Disposer.register(manager.getProject(), this);
  LowMemoryWatcher.register(new Runnable() {
    @Override
    public void run() {
      processQueue();
    }
  }, this);
}
项目:consulo    文件:FileManagerImpl.java   
public FileManagerImpl(PsiManagerImpl manager, FileDocumentManager fileDocumentManager, FileIndexFacade fileIndex) {
  myManager = manager;
  myFileIndex = fileIndex;
  myConnection = manager.getProject().getMessageBus().connect();

  myFileDocumentManager = fileDocumentManager;

  Disposer.register(manager.getProject(), this);
  LowMemoryWatcher.register(this::processQueue, this);

  myConnection.subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
    @Override
    public void enteredDumbMode() {
      processFileTypesChanged();
    }

    @Override
    public void exitDumbMode() {
      processFileTypesChanged();
    }
  });
}
项目:consulo    文件:SemServiceImpl.java   
public SemServiceImpl(Project project, PsiManager psiManager) {
  myProject = project;
  final MessageBusConnection connection = project.getMessageBus().connect();
  connection.subscribe(PsiModificationTracker.TOPIC, new PsiModificationTracker.Listener() {
    @Override
    public void modificationCountChanged() {
      if (!isInsideAtomicChange()) {
        clearCache();
      }
    }
  });

  ((PsiManagerEx)psiManager).registerRunnableToRunOnChange(() -> {
    if (!isInsideAtomicChange()) {
      clearCache();
    }
  });


  LowMemoryWatcher.register(() -> {
    if (myCreatingSem.get() == 0) {
      clearCache();
    }
    //System.out.println("SemService cache flushed");
  }, project);
}
项目:consulo-java    文件:NonClasspathClassFinder.java   
public NonClasspathClassFinder(@NotNull Project project, @NotNull String... fileExtensions)
{
    myProject = project;
    myPackageManager = PsiPackageManager.getInstance(myProject);
    myManager = PsiManager.getInstance(myProject);
    myFileExtensions = ArrayUtil.append(fileExtensions, "class");
    final MessageBusConnection connection = project.getMessageBus().connect(project);
    connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener()
    {
        @Override
        public void after(@NotNull List<? extends VFileEvent> events)
        {
            clearCache();
        }
    });
    LowMemoryWatcher.register(this::clearCache, project);
}
项目:intellij-ce-playground    文件:BaseExternalAnnotationsManager.java   
public BaseExternalAnnotationsManager(@NotNull PsiManager psiManager) {
  myPsiManager = psiManager;
  LowMemoryWatcher.register(new Runnable() {
    @Override
    public void run() {
      dropCache();
    }
  }, psiManager.getProject());
}
项目:intellij-ce-playground    文件:SemServiceImpl.java   
public SemServiceImpl(Project project, PsiManager psiManager) {
  myProject = project;
  final MessageBusConnection connection = project.getMessageBus().connect();
  connection.subscribe(PsiModificationTracker.TOPIC, new PsiModificationTracker.Listener() {
    @Override
    public void modificationCountChanged() {
      if (!isInsideAtomicChange()) {
        clearCache();
      }
    }
  });

  ((PsiManagerEx)psiManager).registerRunnableToRunOnChange(new Runnable() {
    @Override
    public void run() {
      if (!isInsideAtomicChange()) {
        clearCache();
      }
    }
  });


  LowMemoryWatcher.register(new Runnable() {
    @Override
    public void run() {
      if (myCreatingSem.get() == 0) {
        clearCache();
      }
      //System.out.println("SemService cache flushed");
    }
  }, project);
}
项目:consulo    文件:IconDeferrerImpl.java   
public IconDeferrerImpl(MessageBus bus) {
  final MessageBusConnection connection = bus.connect();
  connection.subscribe(PsiModificationTracker.TOPIC, this::clear);
  connection.subscribe(ProjectLifecycleListener.TOPIC, new ProjectLifecycleListener() {
    @Override
    public void afterProjectClosed(@Nonnull Project project) {
      clear();
    }
  });
  LowMemoryWatcher.register(this::clear, connection);
}
项目:consulo-java    文件:BaseExternalAnnotationsManager.java   
public BaseExternalAnnotationsManager(@NotNull PsiManager psiManager)
{
    myPsiManager = psiManager;
    LowMemoryWatcher.register(new Runnable()
    {
        @Override
        public void run()
        {
            dropCache();
        }
    }, psiManager.getProject());
}
项目:consulo    文件:SmartPointerManagerImpl.java   
public SmartPointerManagerImpl(Project project) {
  myProject = project;
  myPsiDocManager = (PsiDocumentManagerBase)PsiDocumentManager.getInstance(myProject);
  LowMemoryWatcher.register(() -> processQueue(), project);
}
项目:consulo    文件:AstPathPsiMap.java   
MyReferenceQueue(Project project) {
  LowMemoryWatcher.register(() -> cleanupStaleReferences(), project);
}