Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlena Laskavaia2014-11-28 15:30:48 -0500
committerElena Laskavaia2014-12-02 19:38:08 -0500
commit0f49ec201507feaf2e1d21bbd4db1c9fa07ea62f (patch)
tree28d49354e7d81cc9d0c852624aaa55dda58dbc3c /codan/org.eclipse.cdt.codan.ui
parent8667f5a5aee85c8a663f2c0773f9bcf021e91a1c (diff)
downloadorg.eclipse.cdt-0f49ec201507feaf2e1d21bbd4db1c9fa07ea62f.tar.gz
org.eclipse.cdt-0f49ec201507feaf2e1d21bbd4db1c9fa07ea62f.tar.xz
org.eclipse.cdt-0f49ec201507feaf2e1d21bbd4db1c9fa07ea62f.zip
Avoid ClassCastException in Codan Run job
Occasionally Run Code Analysis actions get text selection instead of structured selection so it is failing and logging CCE. Avoid this by non accepting other selections. Change-Id: Ia3583755547e5251a057290e506184656ebf2d5a Signed-off-by: Alena Laskavaia <elaskavaia.cdt@gmail.com> Reviewed-on: https://git.eclipse.org/r/37306 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Diffstat (limited to 'codan/org.eclipse.cdt.codan.ui')
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java53
1 files changed, 27 insertions, 26 deletions
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java
index e3a124d400..d132b45b34 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/actions/RunCodeAnalysis.java
@@ -38,35 +38,36 @@ public class RunCodeAnalysis implements IObjectActionDelegate {
@Override
public void run(IAction action) {
- Job job = new Job(CodanUIMessages.Job_TitleRunningAnalysis) {
- @SuppressWarnings("unchecked")
- @Override
- protected IStatus run(final IProgressMonitor monitor) {
- IStructuredSelection ss = (IStructuredSelection) sel;
- int count = ss.size();
- monitor.beginTask(getName(), count * 100);
- if (monitor.isCanceled())
- return Status.CANCEL_STATUS;
- for (Iterator iterator = ss.iterator(); iterator.hasNext();) {
- Object o = iterator.next();
- if (o instanceof IAdaptable) {
- o = ((IAdaptable) o).getAdapter(IResource.class);
- }
- if (o instanceof IResource) {
- IResource res = (IResource) o;
- SubProgressMonitor subMon = new SubProgressMonitor(monitor, 100);
- CodanRuntime.getInstance().getBuilder().processResource(res, subMon, CheckerLaunchMode.RUN_ON_DEMAND);
- if (subMon.isCanceled())
- return Status.CANCEL_STATUS;
- }
+ if (sel instanceof IStructuredSelection) {
+ final IStructuredSelection ss = (IStructuredSelection) sel;
+ Job job = new Job(CodanUIMessages.Job_TitleRunningAnalysis) {
+ @Override
+ protected IStatus run(final IProgressMonitor monitor) {
+ int count = ss.size();
+ monitor.beginTask(getName(), count * 100);
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
+ for (Iterator iterator = ss.iterator(); iterator.hasNext();) {
+ Object o = iterator.next();
+ if (o instanceof IAdaptable) {
+ o = ((IAdaptable) o).getAdapter(IResource.class);
+ }
+ if (o instanceof IResource) {
+ IResource res = (IResource) o;
+ SubProgressMonitor subMon = new SubProgressMonitor(monitor, 100);
+ CodanRuntime.getInstance().getBuilder().processResource(res, subMon, CheckerLaunchMode.RUN_ON_DEMAND);
+ if (subMon.isCanceled())
+ return Status.CANCEL_STATUS;
+ }
+ if (monitor.isCanceled())
+ return Status.CANCEL_STATUS;
+ }
+ return Status.OK_STATUS;
}
- return Status.OK_STATUS;
- }
- };
- job.setUser(true);
- job.schedule();
+ };
+ job.setUser(true);
+ job.schedule();
+ }
}
@Override

Back to the top