use of com.intellij.openapi.progress.EmptyProgressIndicator in project intellij-community by JetBrains.
the class MockDumbService method queueTask.
@Override
public void queueTask(@NotNull DumbModeTask task) {
task.performInDumbMode(new EmptyProgressIndicator());
Disposer.dispose(task);
}
use of com.intellij.openapi.progress.EmptyProgressIndicator in project intellij-community by JetBrains.
the class InspectionEngine method runInspectionOnFile.
@NotNull
public static List<ProblemDescriptor> runInspectionOnFile(@NotNull final PsiFile file, @NotNull InspectionToolWrapper toolWrapper, @NotNull final GlobalInspectionContext inspectionContext) {
final InspectionManager inspectionManager = InspectionManager.getInstance(file.getProject());
toolWrapper.initialize(inspectionContext);
RefManagerImpl refManager = (RefManagerImpl) inspectionContext.getRefManager();
refManager.inspectionReadActionStarted();
try {
if (toolWrapper instanceof LocalInspectionToolWrapper) {
return inspect(Collections.singletonList((LocalInspectionToolWrapper) toolWrapper), file, inspectionManager, new EmptyProgressIndicator());
}
if (toolWrapper instanceof GlobalInspectionToolWrapper) {
final GlobalInspectionTool globalTool = ((GlobalInspectionToolWrapper) toolWrapper).getTool();
final List<ProblemDescriptor> descriptors = new ArrayList<>();
if (globalTool instanceof GlobalSimpleInspectionTool) {
GlobalSimpleInspectionTool simpleTool = (GlobalSimpleInspectionTool) globalTool;
ProblemsHolder problemsHolder = new ProblemsHolder(inspectionManager, file, false);
ProblemDescriptionsProcessor collectProcessor = new ProblemDescriptionsProcessor() {
@Nullable
@Override
public CommonProblemDescriptor[] getDescriptions(@NotNull RefEntity refEntity) {
return descriptors.toArray(new CommonProblemDescriptor[descriptors.size()]);
}
@Override
public void ignoreElement(@NotNull RefEntity refEntity) {
throw new RuntimeException();
}
@Override
public void addProblemElement(@Nullable RefEntity refEntity, @NotNull CommonProblemDescriptor... commonProblemDescriptors) {
if (!(refEntity instanceof RefElement))
return;
PsiElement element = ((RefElement) refEntity).getElement();
convertToProblemDescriptors(element, commonProblemDescriptors, descriptors);
}
@Override
public RefEntity getElement(@NotNull CommonProblemDescriptor descriptor) {
throw new RuntimeException();
}
};
simpleTool.checkFile(file, inspectionManager, problemsHolder, inspectionContext, collectProcessor);
return descriptors;
}
RefElement fileRef = refManager.getReference(file);
final AnalysisScope scope = new AnalysisScope(file);
assert fileRef != null;
fileRef.accept(new RefVisitor() {
@Override
public void visitElement(@NotNull RefEntity elem) {
CommonProblemDescriptor[] elemDescriptors = globalTool.checkElement(elem, scope, inspectionManager, inspectionContext);
if (elemDescriptors != null) {
convertToProblemDescriptors(file, elemDescriptors, descriptors);
}
for (RefEntity child : elem.getChildren()) {
child.accept(this);
}
}
});
return descriptors;
}
} finally {
refManager.inspectionReadActionFinished();
toolWrapper.cleanup(file.getProject());
inspectionContext.cleanup();
}
return Collections.emptyList();
}
use of com.intellij.openapi.progress.EmptyProgressIndicator in project intellij-community by JetBrains.
the class DirDiffTableModel method reloadModel.
public void reloadModel(final boolean userForcedRefresh) {
myUpdating.set(true);
myTable.getEmptyText().setText(StatusText.DEFAULT_EMPTY_TEXT);
final JBLoadingPanel loadingPanel = getLoadingPanel();
loadingPanel.startLoading();
final ModalityState modalityState = ModalityState.current();
ApplicationManager.getApplication().executeOnPooledThread(() -> {
EmptyProgressIndicator indicator = new EmptyProgressIndicator(modalityState);
ProgressManager.getInstance().executeProcessUnderProgress(() -> {
try {
if (myDisposed)
return;
myUpdater = new Updater(loadingPanel, 100);
myUpdater.start();
text.set("Loading...");
myTree = new DTree(null, "", true);
mySrc.refresh(userForcedRefresh);
myTrg.refresh(userForcedRefresh);
scan(mySrc, myTree, true);
scan(myTrg, myTree, false);
} catch (final IOException e) {
LOG.warn(e);
reportException(VcsBundle.message("refresh.failed.message", StringUtil.decapitalize(e.getLocalizedMessage())));
} finally {
if (myTree != null) {
myTree.setSource(mySrc);
myTree.setTarget(myTrg);
myTree.update(mySettings);
applySettings();
}
}
}, indicator);
});
}
use of com.intellij.openapi.progress.EmptyProgressIndicator in project intellij-community by JetBrains.
the class JobUtilTest method testProcessorReturningFalseDoesNotCrashTheOtherThread.
public void testProcessorReturningFalseDoesNotCrashTheOtherThread() {
final AtomicInteger delay = new AtomicInteger(0);
final Runnable checkCanceled = ProgressManager::checkCanceled;
Processor<String> processor = s -> {
busySleep(delay.incrementAndGet() % 10 + 10, checkCanceled);
return delay.get() % 100 != 0;
};
for (int i = 0; i < 100; i++) {
ProgressIndicator indicator = new EmptyProgressIndicator();
boolean result = JobLauncher.getInstance().invokeConcurrentlyUnderProgress(Collections.nCopies(10000, ""), indicator, false, false, processor);
assertFalse(indicator.isCanceled());
assertFalse(result);
}
}
use of com.intellij.openapi.progress.EmptyProgressIndicator in project intellij-community by JetBrains.
the class ModuleManagerImpl method loadModules.
protected void loadModules(@NotNull ModuleModelImpl moduleModel) {
myFailedModulePaths.clear();
if (myModulePathsToLoad == null || myModulePathsToLoad.isEmpty()) {
return;
}
myFailedModulePaths.addAll(myModulePathsToLoad);
ProgressIndicator globalIndicator = ProgressIndicatorProvider.getGlobalProgressIndicator();
ProgressIndicator progressIndicator = myProject.isDefault() || globalIndicator == null ? new EmptyProgressIndicator() : globalIndicator;
progressIndicator.setText("Loading modules...");
progressIndicator.setText2("");
List<Module> modulesWithUnknownTypes = new SmartList<>();
List<ModuleLoadingErrorDescription> errors = Collections.synchronizedList(new ArrayList<>());
ModuleGroupInterner groupInterner = new ModuleGroupInterner();
ExecutorService service = AppExecutorUtil.createBoundedApplicationPoolExecutor("modules loader", JobSchedulerImpl.CORES_COUNT);
List<Pair<Future<Module>, ModulePath>> tasks = new ArrayList<>();
Set<String> paths = new THashSet<>();
boolean parallel = Registry.is("parallel.modules.loading");
for (ModulePath modulePath : myModulePathsToLoad) {
if (progressIndicator.isCanceled()) {
break;
}
try {
String path = modulePath.getPath();
if (!paths.add(path))
continue;
if (!parallel) {
tasks.add(Pair.create(null, modulePath));
continue;
}
ThrowableComputable<Module, IOException> computable = moduleModel.loadModuleInternal(path);
Future<Module> future = service.submit(() -> {
progressIndicator.setFraction(progressIndicator.getFraction() + myProgressStep);
try {
return computable.compute();
} catch (IOException e) {
reportError(errors, modulePath, e);
} catch (Exception e) {
LOG.error(e);
}
return null;
});
tasks.add(Pair.create(future, modulePath));
} catch (IOException e) {
reportError(errors, modulePath, e);
}
}
for (Pair<Future<Module>, ModulePath> task : tasks) {
if (progressIndicator.isCanceled()) {
break;
}
try {
Module module;
if (parallel) {
module = task.first.get();
} else {
module = moduleModel.loadModuleInternal(task.second.getPath()).compute();
progressIndicator.setFraction(progressIndicator.getFraction() + myProgressStep);
}
if (module == null)
continue;
if (isUnknownModuleType(module)) {
modulesWithUnknownTypes.add(module);
}
ModulePath modulePath = task.second;
final String groupPathString = modulePath.getGroup();
if (groupPathString != null) {
// model should be updated too
groupInterner.setModuleGroupPath(moduleModel, module, groupPathString.split(MODULE_GROUP_SEPARATOR));
}
myFailedModulePaths.remove(modulePath);
} catch (IOException e) {
reportError(errors, task.second, e);
} catch (Exception e) {
LOG.error(e);
}
}
service.shutdown();
progressIndicator.checkCanceled();
Application app = ApplicationManager.getApplication();
if (app.isInternal() || app.isEAP() || ApplicationInfo.getInstance().getBuild().isSnapshot()) {
Map<String, Module> track = new THashMap<>();
for (Module module : moduleModel.getModules()) {
for (String url : ModuleRootManager.getInstance(module).getContentRootUrls()) {
Module oldModule = track.put(url, module);
if (oldModule != null) {
//Map<String, VirtualFilePointer> track1 = ContentEntryImpl.track;
//VirtualFilePointer pointer = track1.get(url);
LOG.error("duplicated content url: " + url);
}
}
}
}
onModuleLoadErrors(moduleModel, errors);
showUnknownModuleTypeNotification(modulesWithUnknownTypes);
}
Aggregations