use of com.intellij.openapi.progress.EmptyProgressIndicator in project intellij-community by JetBrains.
the class BackgroundTaskUtil method executeAndTryWait.
@NotNull
@CalledInAwt
public static ProgressIndicator executeAndTryWait(@NotNull Function<ProgressIndicator, /*@NotNull*/
Runnable> backgroundTask, @Nullable Runnable onSlowAction, long waitMillis, boolean forceEDT) {
ModalityState modality = ModalityState.current();
if (forceEDT) {
ProgressIndicator indicator = new EmptyProgressIndicator(modality);
try {
Runnable callback = backgroundTask.fun(indicator);
finish(callback, indicator);
} catch (ProcessCanceledException ignore) {
} catch (Throwable t) {
LOG.error(t);
}
return indicator;
} else {
Pair<Runnable, ProgressIndicator> pair = computeInBackgroundAndTryWait(backgroundTask, (callback, indicator) -> {
ApplicationManager.getApplication().invokeLater(() -> {
finish(callback, indicator);
}, modality);
}, modality, waitMillis);
Runnable callback = pair.first;
ProgressIndicator indicator = pair.second;
if (callback != null) {
finish(callback, indicator);
} else {
if (onSlowAction != null)
onSlowAction.run();
}
return indicator;
}
}
use of com.intellij.openapi.progress.EmptyProgressIndicator in project intellij-community by JetBrains.
the class ParsingTestCase method ensureCorrectReparse.
public static void ensureCorrectReparse(@NotNull final PsiFile file) {
final String psiToStringDefault = DebugUtil.psiToString(file, false, false);
final String fileText = file.getText();
final DiffLog diffLog = new BlockSupportImpl(file.getProject()).reparseRange(file, file.getNode(), TextRange.allOf(fileText), fileText, new EmptyProgressIndicator(), fileText);
diffLog.performActualPsiChange(file);
TestCase.assertEquals(psiToStringDefault, DebugUtil.psiToString(file, false, false));
}
use of com.intellij.openapi.progress.EmptyProgressIndicator in project intellij-community by JetBrains.
the class JobUtilTest method testTasksRunEvenWhenReadActionIsHardToGet_Performance.
public void testTasksRunEvenWhenReadActionIsHardToGet_Performance() throws ExecutionException, InterruptedException {
AtomicInteger processorCalled = new AtomicInteger();
final Processor<String> processor = s -> {
busySleep(1);
processorCalled.incrementAndGet();
return true;
};
for (int i = 0; i < 10; /*0*/
i++) {
System.out.println("i = " + i);
processorCalled.set(0);
final ProgressIndicator indicator = new EmptyProgressIndicator();
int N = 10000;
Future<?> future = ApplicationManager.getApplication().executeOnPooledThread(() -> {
JobLauncher.getInstance().invokeConcurrentlyUnderProgress(Collections.nCopies(N, ""), indicator, true, false, processor);
assertFalse(indicator.isCanceled());
});
for (int k = 0; k < 10000; k++) {
ApplicationManager.getApplication().runWriteAction(() -> {
busySleep(1);
});
}
future.get();
assertEquals(N, processorCalled.get());
}
}
use of com.intellij.openapi.progress.EmptyProgressIndicator in project intellij-community by JetBrains.
the class HgUpdateTest method updateThroughPlugin.
private List<VcsException> updateThroughPlugin() throws VcsException {
HgRegularUpdater updater = new HgRegularUpdater(myProject, projectRepoVirtualFile, new HgUpdateConfigurationSettings());
UpdatedFiles updatedFiles = UpdatedFiles.create();
EmptyProgressIndicator indicator = new EmptyProgressIndicator();
ArrayList<VcsException> nonFatalWarnings = new ArrayList<>();
updater.update(updatedFiles, indicator, nonFatalWarnings);
return nonFatalWarnings;
}
use of com.intellij.openapi.progress.EmptyProgressIndicator in project intellij-community by JetBrains.
the class PatternEditorContextMembersProvider method calcDevPatternClassNames.
private static Set<String> calcDevPatternClassNames(@NotNull final Project project) {
final List<String> roots = ContainerUtil.createLockFreeCopyOnWriteList();
JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project);
PsiClass beanClass = psiFacade.findClass(PatternClassBean.class.getName(), GlobalSearchScope.allScope(project));
if (beanClass != null) {
GlobalSearchScope scope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), StdFileTypes.XML);
final TextOccurenceProcessor occurenceProcessor = new TextOccurenceProcessor() {
@Override
public boolean execute(@NotNull PsiElement element, int offsetInElement) {
XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
String className = tag == null ? null : tag.getAttributeValue("className");
if (StringUtil.isNotEmpty(className) && tag.getLocalName().endsWith("patternClass")) {
roots.add(className);
}
return true;
}
};
final StringSearcher searcher = new StringSearcher("patternClass", true, true);
CacheManager.SERVICE.getInstance(beanClass.getProject()).processFilesWithWord(psiFile -> {
LowLevelSearchUtil.processElementsContainingWordInElement(occurenceProcessor, psiFile, searcher, true, new EmptyProgressIndicator());
return true;
}, searcher.getPattern(), UsageSearchContext.IN_FOREIGN_LANGUAGES, scope, searcher.isCaseSensitive());
}
return ContainerUtil.newHashSet(roots);
}
Aggregations