use of com.intellij.openapi.project.DumbService in project android by JetBrains.
the class AndroidProjectComponent method createAlarmForAutogeneration.
private void createAlarmForAutogeneration() {
DumbService service = DumbService.getInstance(myProject);
final Alarm alarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, myDisposable);
alarm.addRequest(new Runnable() {
@Override
public void run() {
Map<AndroidFacet, Collection<AndroidAutogeneratorMode>> facetsToProcess = service.runReadActionInSmartMode(() -> checkGenerate());
if (facetsToProcess.size() > 0) {
generate(facetsToProcess);
}
if (!alarm.isDisposed()) {
alarm.addRequest(this, 2000);
}
}
}, 2000);
}
use of com.intellij.openapi.project.DumbService in project intellij-plugins by JetBrains.
the class ModuleInfoUtil method collectLocalStyle.
public static List<LocalStyleHolder> collectLocalStyle(final ModuleInfo moduleInfo, final String flexSdkVersion, final StringWriter stringWriter, final ProblemsHolder problemsHolder, ProjectComponentReferenceCounter projectComponentReferenceCounter, AssetCounter assetCounter) {
Project project = moduleInfo.getModule().getProject();
DumbService dumbService = DumbService.getInstance(project);
if (dumbService.isDumb()) {
dumbService.waitForSmartMode();
}
final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
if (psiDocumentManager.hasUncommitedDocuments()) {
final Semaphore semaphore = new Semaphore();
semaphore.down();
Application application = ApplicationManager.getApplication();
LogMessageUtil.LOG.assertTrue(!application.isReadAccessAllowed());
application.invokeLater(() -> psiDocumentManager.performWhenAllCommitted(() -> semaphore.up()));
semaphore.waitFor();
}
final AccessToken token = ReadAction.start();
try {
if (moduleInfo.isApp()) {
return collectApplicationLocalStyle(moduleInfo.getModule(), flexSdkVersion, problemsHolder, stringWriter, projectComponentReferenceCounter, assetCounter);
} else {
return collectLibraryLocalStyle(moduleInfo.getModule(), stringWriter, problemsHolder, projectComponentReferenceCounter, assetCounter);
}
} finally {
token.finish();
}
}
Aggregations