com.intellij.openapi.project.DumbModeTask Java Examples

The following examples show how to use com.intellij.openapi.project.DumbModeTask. 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: ORProjectRootListener.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
private ORProjectRootListener(@NotNull Project project) {
    project.getMessageBus().
            connect(project).
            subscribe(PROJECT_ROOTS, new ModuleRootListener() {
                @Override
                public void rootsChanged(@NotNull ModuleRootEvent event) {
                    DumbService.getInstance(project).queueTask(new DumbModeTask() {
                        @Override
                        public void performInDumbMode(@NotNull ProgressIndicator indicator) {
                            if (!project.isDisposed()) {
                                indicator.setText("Updating resource repository roots");
                                // should be done per module
                                //ModuleManager moduleManager = ModuleManager.getInstance(project);
                                //for (Module module : moduleManager.getModules()) {
                                //    moduleRootsOrDependenciesChanged(module);
                                //}
                                Sdk projectSdk = ProjectRootManager.getInstance(project).getProjectSdk();
                                if (projectSdk != null && projectSdk.getSdkType() instanceof OCamlSdkType) {
                                    OCamlSdkType.reindexSourceRoots(projectSdk);
                                }
                            }
                        }
                    });
                }
            });
}
 
Example #2
Source File: ToggleDumbModeAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(final AnActionEvent e) {
  if (myDumb) {
    myDumb = false;
  }
  else {
    myDumb = true;
    final Project project = e.getData(CommonDataKeys.PROJECT);
    if (project == null) return;

    DumbServiceImpl.getInstance(project).queueTask(new DumbModeTask() {
      @Override
      public void performInDumbMode(@Nonnull ProgressIndicator indicator) {
        while (myDumb) {
          indicator.checkCanceled();
          TimeoutUtil.sleep(100);
        }
      }
    });
  }
}
 
Example #3
Source File: ProjectRootManagerComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void doUpdateOnRefresh() {
  if (ApplicationManager.getApplication().isUnitTestMode() && (!myStartupActivityPerformed || myProject.isDisposed())) {
    return; // in test mode suppress addition to a queue unless project is properly initialized
  }
  if (myProject.isDefault()) {
    return;
  }

  if (myDoLogCachesUpdate) LOG.debug("refresh");
  DumbServiceImpl dumbService = DumbServiceImpl.getInstance(myProject);
  DumbModeTask task = FileBasedIndexProjectHandler.createChangedFilesIndexingTask(myProject);
  if (task != null) {
    dumbService.queueTask(task);
  }
}
 
Example #4
Source File: MockDumbService.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void queueTask(@Nonnull DumbModeTask task) {
  task.performInDumbMode(new EmptyProgressIndicator());
  Disposer.dispose(task);
}
 
Example #5
Source File: MockDumbService.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void cancelTask(@Nonnull DumbModeTask task) {
}