use of com.intellij.analysis.PerformAnalysisInBackgroundOption in project intellij-community by JetBrains.
the class DependenciesHandlerBase method analyze.
public void analyze() {
final List<DependenciesBuilder> builders = new ArrayList<>();
final Task task;
if (canStartInBackground()) {
task = new Task.Backgroundable(myProject, getProgressTitle(), true, new PerformAnalysisInBackgroundOption(myProject)) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
perform(builders);
}
@Override
public void onSuccess() {
DependenciesHandlerBase.this.onSuccess(builders);
}
};
} else {
task = new Task.Modal(myProject, getProgressTitle(), true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
perform(builders);
}
@Override
public void onSuccess() {
DependenciesHandlerBase.this.onSuccess(builders);
}
};
}
ProgressManager.getInstance().run(task);
}
use of com.intellij.analysis.PerformAnalysisInBackgroundOption in project intellij-community by JetBrains.
the class ViewOfflineResultsAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent event) {
final Project project = event.getData(CommonDataKeys.PROJECT);
LOG.assertTrue(project != null);
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false) {
@Override
public Icon getIcon(VirtualFile file) {
if (file.isDirectory()) {
if (file.findChild(InspectionApplication.DESCRIPTIONS + "." + StdFileTypes.XML.getDefaultExtension()) != null) {
return AllIcons.Nodes.InspectionResults;
}
}
return super.getIcon(file);
}
};
descriptor.setTitle("Select Path");
descriptor.setDescription("Select directory which contains exported inspections results");
final VirtualFile virtualFile = FileChooser.chooseFile(descriptor, project, null);
if (virtualFile == null || !virtualFile.isDirectory())
return;
final Map<String, Map<String, Set<OfflineProblemDescriptor>>> resMap = new HashMap<>();
final String[] profileName = new String[1];
ProgressManager.getInstance().run(new Task.Backgroundable(project, InspectionsBundle.message("parsing.inspections.dump.progress.title"), true, new PerformAnalysisInBackgroundOption(project)) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
final VirtualFile[] files = virtualFile.getChildren();
try {
for (final VirtualFile inspectionFile : files) {
if (inspectionFile.isDirectory())
continue;
final String shortName = inspectionFile.getNameWithoutExtension();
final String extension = inspectionFile.getExtension();
if (shortName.equals(InspectionApplication.DESCRIPTIONS)) {
profileName[0] = ReadAction.compute(() -> OfflineViewParseUtil.parseProfileName(LoadTextUtil.loadText(inspectionFile).toString()));
} else if (XML_EXTENSION.equals(extension)) {
resMap.put(shortName, ReadAction.compute(() -> OfflineViewParseUtil.parse(LoadTextUtil.loadText(inspectionFile).toString())));
}
}
} catch (final Exception e) {
//all parse exceptions
ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage(e.getMessage(), InspectionsBundle.message("offline.view.parse.exception.title")));
//cancel process
throw new ProcessCanceledException();
}
}
@Override
public void onSuccess() {
ApplicationManager.getApplication().invokeLater(() -> {
final String name = profileName[0];
showOfflineView(project, name, resMap, InspectionsBundle.message("offline.view.title") + " (" + (name != null ? name : InspectionsBundle.message("offline.view.editor.settings.title")) + ")");
});
}
});
}
use of com.intellij.analysis.PerformAnalysisInBackgroundOption in project intellij-community by JetBrains.
the class CyclicDependenciesHandler method analyze.
public void analyze() {
final CyclicDependenciesBuilder builder = new CyclicDependenciesBuilder(myProject, myScope);
final Runnable process = () -> builder.analyze();
final Runnable successRunnable = () -> SwingUtilities.invokeLater(() -> {
CyclicDependenciesPanel panel = new CyclicDependenciesPanel(myProject, builder);
Content content = ContentFactory.SERVICE.getInstance().createContent(panel, AnalysisScopeBundle.message("action.analyzing.cyclic.dependencies.in.scope", builder.getScope().getDisplayName()), false);
content.setDisposer(panel);
panel.setContent(content);
DependenciesToolWindow.getInstance(myProject).addContent(content);
});
ProgressManager.getInstance().runProcessWithProgressAsynchronously(myProject, AnalysisScopeBundle.message("package.dependencies.progress.title"), process, successRunnable, null, new PerformAnalysisInBackgroundOption(myProject));
}
Aggregations