diff options
author | René Purrio | 2018-01-05 12:16:02 +0000 |
---|---|---|
committer | René Purrio | 2018-01-05 13:31:46 +0000 |
commit | 94aad1c5bfc2d862c62a0f5fe245e84a798504e8 (patch) | |
tree | 7adebe06ce252db56da7fa4435842b9ec9f012c7 | |
parent | 40fef335d8d498da87bcfa0f1898d1b62428c0ce (diff) | |
download | eclipse.platform.debug-94aad1c5bfc2d862c62a0f5fe245e84a798504e8.tar.gz eclipse.platform.debug-94aad1c5bfc2d862c62a0f5fe245e84a798504e8.tar.xz eclipse.platform.debug-94aad1c5bfc2d862c62a0f5fe245e84a798504e8.zip |
Bug 529427 - [sonar] Resolve "instanceof will always return true"I20180107-2000I20180106-1500I20180105-2000
Change-Id: I6b251df47346eaf3aa5e68c7073081f94704314b
Signed-off-by: René Purrio <rpurrio@itemis.de>
4 files changed, 17 insertions, 23 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionAction.java index bf50966bd..0266b07de 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionAction.java @@ -29,14 +29,13 @@ import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewSite; import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; /** * Generic abstract class for the actions associated to the java watch * expressions. */ public abstract class WatchExpressionAction implements IViewActionDelegate { - IWorkbenchPart fPart = null; + IViewPart fPart = null; private static IWatchExpression[] EMPTY_EXPRESSION_ARRAY = new IWatchExpression[0]; @@ -110,8 +109,8 @@ public abstract class WatchExpressionAction implements IViewActionDelegate { * @param message the message to display */ protected void showErrorMessage(String message) { - if (fPart instanceof IViewPart) { - IViewSite viewSite = ((IViewPart) fPart).getViewSite(); + if (fPart != null) { + IViewSite viewSite = fPart.getViewSite(); IStatusLineManager manager = viewSite.getActionBars().getStatusLineManager(); manager.setErrorMessage(message); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java index 50cff0042..9f497e2aa 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java @@ -299,12 +299,12 @@ public class RunDebugPropertiesPage extends PropertyPage { * @return resource */ protected IResource getResource() { - Object element = getElement(); + IAdaptable element = getElement(); IResource resource = null; if (element instanceof IResource) { resource = (IResource) element; - } else if (element instanceof IAdaptable) { - resource = ((IAdaptable)element).getAdapter(IResource.class); + } else if (element != null) { + resource = element.getAdapter(IResource.class); } return resource; } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/TreeViewerDropDown.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/TreeViewerDropDown.java index a0b978763..98fdaebfa 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/TreeViewerDropDown.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/TreeViewerDropDown.java @@ -143,22 +143,21 @@ public abstract class TreeViewerDropDown { @Override public void mouseMove(MouseEvent e) { if (tree.equals(e.getSource())) { - Object o= tree.getItem(new Point(e.x, e.y)); - if (fLastItem == null ^ o == null) { - tree.setCursor(o == null ? null : tree.getDisplay() + TreeItem currentItem = tree.getItem(new Point(e.x, e.y)); + if (fLastItem == null ^ currentItem == null) { + tree.setCursor(currentItem == null ? null : tree.getDisplay() .getSystemCursor(SWT.CURSOR_HAND)); } - if (o instanceof TreeItem) { - TreeItem currentItem= (TreeItem) o; - if (!o.equals(fLastItem)) { - fLastItem= (TreeItem) o; + if (currentItem != null) { + if (!currentItem.equals(fLastItem)) { + fLastItem = currentItem; tree.setSelection(new TreeItem[] { fLastItem }); } else if (System.currentTimeMillis() > (fLastScrollTime + MOUSE_MOVE_SCROLL_DELAY)) { if (e.y < tree.getItemHeight() / 4) { // Scroll up if (currentItem.getParentItem() == null) { - int index= tree.indexOf((TreeItem) o); + int index = tree.indexOf(currentItem); if (index < 1) { return; } @@ -177,7 +176,7 @@ public abstract class TreeViewerDropDown { } else if (e.y > tree.getBounds().height - tree.getItemHeight() / 4) { // Scroll down if (currentItem.getParentItem() == null) { - int index= tree.indexOf((TreeItem) o); + int index = tree.indexOf(currentItem); if (index >= tree.getItemCount() - 1) { return; } @@ -195,7 +194,7 @@ public abstract class TreeViewerDropDown { } } } - } else if (o == null) { + } else { fLastItem = null; } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDropAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDropAdapter.java index 564b2b35f..a7460f9df 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDropAdapter.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDropAdapter.java @@ -60,9 +60,7 @@ public class BreakpointsDropAdapter extends ViewerDropAdapter { } else if (fView != null) { ISelection selection = LocalSelectionTransfer.getTransfer().getSelection(); if (fPath != null && selection instanceof ITreeSelection) { - if (selection instanceof ITreeSelection) { - return fView.performDrop(fPath, (ITreeSelection) LocalSelectionTransfer.getTransfer().getSelection()); - } + return fView.performDrop(fPath, (ITreeSelection) selection); } } return false; @@ -99,9 +97,7 @@ public class BreakpointsDropAdapter extends ViewerDropAdapter { } else { ISelection selection = LocalSelectionTransfer.getTransfer().getSelection(); if (fPath != null && selection instanceof ITreeSelection) { - if (selection instanceof ITreeSelection) { - return fView.canDrop(fPath, (ITreeSelection) LocalSelectionTransfer.getTransfer().getSelection()); - } + return fView.canDrop(fPath, (ITreeSelection) LocalSelectionTransfer.getTransfer().getSelection()); } } return false; |