diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CompositeDebugImageDescriptor.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CompositeDebugImageDescriptor.java index 1d350a77beb..e24228a22ee 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CompositeDebugImageDescriptor.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CompositeDebugImageDescriptor.java @@ -61,10 +61,9 @@ protected Point getSize() { */ @Override public boolean equals(Object object) { - if (!(object instanceof CompositeDebugImageDescriptor)){ + if (!(object instanceof CompositeDebugImageDescriptor other)){ return false; } - CompositeDebugImageDescriptor other= (CompositeDebugImageDescriptor)object; return (getBaseImage().equals(other.getBaseImage()) && getFlags() == other.getFlags()); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java index 199b5c897f0..2f37d982c10 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java @@ -1099,7 +1099,7 @@ public static void launchInForeground(final ILaunchConfiguration configuration, * Build & launch (98) */ final SubMonitor subMonitor = SubMonitor.convert(monitor, MessageFormat - .format(DebugUIMessages.DebugUIPlugin_25, new Object[] { configuration.getName() }), 100); + .format(DebugUIMessages.DebugUIPlugin_25, configuration.getName()), 100); try { jobManager.join(ResourcesPlugin.FAMILY_MANUAL_BUILD, subMonitor.split(1)); jobManager.join(ResourcesPlugin.FAMILY_AUTO_BUILD, subMonitor.split(1)); @@ -1127,7 +1127,7 @@ public static void launchInForeground(final ILaunchConfiguration configuration, * Setup progress monitor - Build & launch (1) */ final SubMonitor subMonitor = SubMonitor.convert(monitor, MessageFormat - .format(DebugUIMessages.DebugUIPlugin_25, new Object[] { configuration.getName() }), 1); + .format(DebugUIMessages.DebugUIPlugin_25, configuration.getName()), 1); try { buildAndLaunch(configuration, mode, subMonitor); } catch (CoreException e) { @@ -1151,8 +1151,7 @@ private static void handleInvocationTargetException(InvocationTargetException e, if (targetException instanceof CoreException) { t = targetException; } - if (t instanceof CoreException) { - CoreException ce = (CoreException)t; + if (t instanceof CoreException ce) { IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(ce.getStatus()); if (handler != null) { ILaunchGroup group = DebugUITools.getLaunchGroup(configuration, mode); @@ -1207,7 +1206,7 @@ public static void launchInBackground(final ILaunchConfiguration configuration, } } final boolean waitInJob = wait; - Job job = new Job(MessageFormat.format(DebugUIMessages.DebugUIPlugin_25, new Object[] {configuration.getName()})) { + Job job = new Job(MessageFormat.format(DebugUIMessages.DebugUIPlugin_25, configuration.getName())) { @Override public IStatus run(final IProgressMonitor monitor) { /* Setup progress monitor @@ -1280,7 +1279,7 @@ public void done(IJobChangeEvent event) { job.setPriority(Job.INTERACTIVE); job.setProperty(IProgressConstants2.SHOW_IN_TASKBAR_ICON_PROPERTY, Boolean.TRUE); - job.setName(MessageFormat.format(DebugUIMessages.DebugUIPlugin_25, new Object[] {configuration.getName()})); + job.setName(MessageFormat.format(DebugUIMessages.DebugUIPlugin_25, configuration.getName())); if (wait) { progressService.showInDialog(getShell(), job); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DefaultLabelProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DefaultLabelProvider.java index 2c8eca778fe..5f19b538df5 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DefaultLabelProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DefaultLabelProvider.java @@ -132,8 +132,7 @@ public String getImageKey(Object element) { return IDebugUIConstants.IMG_OBJS_STACKFRAME; } return IDebugUIConstants.IMG_OBJS_STACKFRAME_RUNNING; - } else if (element instanceof IThread) { - IThread thread = (IThread)element; + } else if (element instanceof IThread thread) { if (thread.isSuspended()) { return IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED; } else if (thread.isTerminated()) { @@ -141,8 +140,7 @@ public String getImageKey(Object element) { } else { return IDebugUIConstants.IMG_OBJS_THREAD_RUNNING; } - } else if (element instanceof IDebugTarget) { - IDebugTarget target= (IDebugTarget) element; + } else if (element instanceof IDebugTarget target) { if (target.isTerminated() || target.isDisconnected()) { return IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_TERMINATED; } else if (target.isSuspended()) { @@ -163,9 +161,8 @@ public String getImageKey(Object element) { return IDebugUIConstants.IMG_OBJS_OS_PROCESS_TERMINATED; } return IDebugUIConstants.IMG_OBJS_OS_PROCESS; - } else if (element instanceof ILaunch) { + } else if (element instanceof ILaunch launch) { // determine the image from the launch config type - ILaunch launch= (ILaunch)element; ILaunchConfiguration configuration = launch.getLaunchConfiguration(); if (configuration != null) { try { @@ -237,8 +234,7 @@ public String getText(Object element) { label.append(((ILaunchConfiguration)element).getName()); } else if (element instanceof ILaunchConfigurationType) { label.append(((ILaunchConfigurationType)element).getName()); - } else if(element instanceof ILaunchDelegate) { - ILaunchDelegate delegate = (ILaunchDelegate) element; + } else if(element instanceof ILaunchDelegate delegate) { String name = delegate.getName(); if(name == null) { name = delegate.getContributorName(); @@ -255,10 +251,9 @@ public String getText(Object element) { if (element instanceof ITerminate) { if (((ITerminate) element).isTerminated()) { String terminatedMessage= null; - if (element instanceof IProcess) { - IProcess process = (IProcess)element; + if (element instanceof IProcess process) { int exit = process.getExitValue(); - terminatedMessage = MessageFormat.format(DebugUIMessages.DefaultLabelProvider_16, new Object[] { Integer.toString(exit) }); + terminatedMessage = MessageFormat.format(DebugUIMessages.DefaultLabelProvider_16, Integer.toString(exit)); } else { terminatedMessage= DebugUIMessages.DefaultLabelProvider_1; } @@ -290,7 +285,7 @@ private String getBreakpointText(IBreakpoint breakpoint) { if (breakpoint instanceof ILineBreakpoint) { try { int lineNumber = ((ILineBreakpoint)breakpoint).getLineNumber(); - label.append(MessageFormat.format(DebugUIMessages.DefaultLabelProvider_17, new Object[] { Integer.toString(lineNumber) })); + label.append(MessageFormat.format(DebugUIMessages.DefaultLabelProvider_17, Integer.toString(lineNumber))); } catch (CoreException e) { } } @@ -437,8 +432,7 @@ protected String getBreakpointImageKey(IBreakpoint breakpoint) { if (breakpoint != null && breakpoint.getMarker().exists()) { try { boolean enabled = breakpoint.isEnabled(); - if (breakpoint instanceof IWatchpoint) { - IWatchpoint watchpoint = (IWatchpoint) breakpoint; + if (breakpoint instanceof IWatchpoint watchpoint) { if (watchpoint.isAccess()) { if (watchpoint.isModification()) { //access and modification diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java index 4f5ea54f4fa..d01c2ea417c 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java @@ -231,11 +231,9 @@ public boolean isLabelProperty(Object element, String property) { */ protected IDebugModelPresentation getConfiguredPresentation(Object element) { String id= null; - if (element instanceof IDebugElement) { - IDebugElement de= (IDebugElement) element; + if (element instanceof IDebugElement de) { id= de.getModelIdentifier(); - } else if (element instanceof IMarker) { - IMarker m= (IMarker) element; + } else if (element instanceof IMarker m) { IBreakpoint bp = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(m); if (bp != null) { id= bp.getModelIdentifier(); @@ -320,8 +318,7 @@ protected HashMap getLabelProviders() { @Override public Color getForeground(Object element) { IDebugModelPresentation presentation = getConfiguredPresentation(element); - if (presentation instanceof IColorProvider) { - IColorProvider colorProvider = (IColorProvider) presentation; + if (presentation instanceof IColorProvider colorProvider) { return colorProvider.getForeground(element); } return null; @@ -330,8 +327,7 @@ public Color getForeground(Object element) { @Override public Color getBackground(Object element) { IDebugModelPresentation presentation = getConfiguredPresentation(element); - if (presentation instanceof IColorProvider) { - IColorProvider colorProvider = (IColorProvider) presentation; + if (presentation instanceof IColorProvider colorProvider) { return colorProvider.getBackground(element); } return null; @@ -340,8 +336,7 @@ public Color getBackground(Object element) { @Override public Font getFont(Object element) { IDebugModelPresentation presentation = getConfiguredPresentation(element); - if (presentation instanceof IFontProvider) { - IFontProvider fontProvider = (IFontProvider) presentation; + if (presentation instanceof IFontProvider fontProvider) { return fontProvider.getFont(element); } return null; @@ -354,9 +349,8 @@ public Annotation getInstructionPointerAnnotation(IEditorPart editorPart, IStack String id = null; Image image = null; String text = null; - if (presentation instanceof IInstructionPointerPresentation) { + if (presentation instanceof IInstructionPointerPresentation pointerPresentation) { // first check if an annotaion object is provided - IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation; annotation = pointerPresentation.getInstructionPointerAnnotation(editorPart, frame); if (annotation == null) { // next check for a marker annotation specification extension diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerContext.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerContext.java index 326f3997d33..7d309d70607 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerContext.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerContext.java @@ -54,8 +54,7 @@ public InstructionPointerContext(IDebugTarget target, IThread thread, ITextEdito @Override public boolean equals(Object other) { - if (other instanceof InstructionPointerContext) { - InstructionPointerContext otherContext = (InstructionPointerContext) other; + if (other instanceof InstructionPointerContext otherContext) { if (getAnnotation().equals(otherContext.getAnnotation())){ return getEditor().equals(otherContext.getEditor()); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java index 34057779124..87432082703 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java @@ -396,8 +396,7 @@ public Map getAttributes() { @Override public Color getForeground(Object element) { IDebugModelPresentation presentation = getPresentation(); - if (presentation instanceof IColorProvider) { - IColorProvider colorProvider = (IColorProvider) presentation; + if (presentation instanceof IColorProvider colorProvider) { return colorProvider.getForeground(element); } return null; @@ -406,8 +405,7 @@ public Color getForeground(Object element) { @Override public Color getBackground(Object element) { IDebugModelPresentation presentation = getPresentation(); - if (presentation instanceof IColorProvider) { - IColorProvider colorProvider = (IColorProvider) presentation; + if (presentation instanceof IColorProvider colorProvider) { return colorProvider.getBackground(element); } return null; @@ -416,8 +414,7 @@ public Color getBackground(Object element) { @Override public Font getFont(Object element) { IDebugModelPresentation presentation = getPresentation(); - if (presentation instanceof IFontProvider) { - IFontProvider fontProvider = (IFontProvider) presentation; + if (presentation instanceof IFontProvider fontProvider) { return fontProvider.getFont(element); } return null; @@ -426,8 +423,7 @@ public Font getFont(Object element) { @Override public Annotation getInstructionPointerAnnotation(IEditorPart editorPart, IStackFrame frame) { IDebugModelPresentation presentation = getPresentation(); - if (presentation instanceof IInstructionPointerPresentation) { - IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation; + if (presentation instanceof IInstructionPointerPresentation pointerPresentation) { return pointerPresentation.getInstructionPointerAnnotation(editorPart, frame); } return null; @@ -436,8 +432,7 @@ public Annotation getInstructionPointerAnnotation(IEditorPart editorPart, IStack @Override public String getInstructionPointerAnnotationType(IEditorPart editorPart, IStackFrame frame) { IDebugModelPresentation presentation = getPresentation(); - if (presentation instanceof IInstructionPointerPresentation) { - IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation; + if (presentation instanceof IInstructionPointerPresentation pointerPresentation) { return pointerPresentation.getInstructionPointerAnnotationType(editorPart, frame); } return null; @@ -446,8 +441,7 @@ public String getInstructionPointerAnnotationType(IEditorPart editorPart, IStack @Override public Image getInstructionPointerImage(IEditorPart editorPart, IStackFrame frame) { IDebugModelPresentation presentation = getPresentation(); - if (presentation instanceof IInstructionPointerPresentation) { - IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation; + if (presentation instanceof IInstructionPointerPresentation pointerPresentation) { return pointerPresentation.getInstructionPointerImage(editorPart, frame); } return null; @@ -456,8 +450,7 @@ public Image getInstructionPointerImage(IEditorPart editorPart, IStackFrame fram @Override public String getInstructionPointerText(IEditorPart editorPart, IStackFrame frame) { IDebugModelPresentation presentation = getPresentation(); - if (presentation instanceof IInstructionPointerPresentation) { - IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation; + if (presentation instanceof IInstructionPointerPresentation pointerPresentation) { return pointerPresentation.getInstructionPointerText(editorPart, frame); } return null; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ResourceExtender.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ResourceExtender.java index 05835c151bf..dafe59865f7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ResourceExtender.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ResourceExtender.java @@ -119,10 +119,9 @@ private boolean matchesContentType(IContentType type, String typeId) { * @return whether or not the given resource has the given content type */ private boolean matchesContentType(IResource resource, String contentType) { - if (resource == null || !(resource instanceof IFile) || !resource.exists()) { + if (resource == null || !(resource instanceof IFile file) || !resource.exists()) { return false; } - IFile file = (IFile) resource; IContentDescription description; try { description = file.getContentDescription(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractSelectionActionDelegate.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractSelectionActionDelegate.java index f4bd0ff2f8d..432be243b5c 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractSelectionActionDelegate.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractSelectionActionDelegate.java @@ -74,8 +74,7 @@ public void dispose() { @Override public void selectionChanged(IAction action, ISelection s) { - if (s instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) s; + if (s instanceof IStructuredSelection ss) { action.setEnabled(getEnableStateForSelection(ss)); setSelection(ss); } else { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AddToFavoritesAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AddToFavoritesAction.java index 48afd124c46..beafb6fdef2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AddToFavoritesAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AddToFavoritesAction.java @@ -88,7 +88,7 @@ protected boolean updateSelection(IStructuredSelection selection) { setGroup(group); setLaunchConfiguration(configuration); setMode(launch.getLaunchMode()); - setText(MessageFormat.format(ActionMessages.AddToFavoritesAction_1, new Object[] { DebugUIPlugin.removeAccelerators(getGroup().getLabel()) })); + setText(MessageFormat.format(ActionMessages.AddToFavoritesAction_1, DebugUIPlugin.removeAccelerators(getGroup().getLabel()))); } } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/EditLaunchConfigurationAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/EditLaunchConfigurationAction.java index 52f26e44bf1..646b44861be 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/EditLaunchConfigurationAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/EditLaunchConfigurationAction.java @@ -95,7 +95,7 @@ protected boolean updateSelection(IStructuredSelection selection) { setLaunchConfiguration(configuration); setMode(launch.getLaunchMode()); setIsTerminated(launch.isTerminated()); - setText(MessageFormat.format(ActionMessages.EditLaunchConfigurationAction_1, new Object[] { configuration.getName() })); + setText(MessageFormat.format(ActionMessages.EditLaunchConfigurationAction_1, configuration.getName())); ImageDescriptor descriptor = null; try { descriptor = DebugPluginImages.getImageDescriptor(configuration.getType().getIdentifier()); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchConfigurationAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchConfigurationAction.java index f277a065940..d312ca42636 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchConfigurationAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/LaunchConfigurationAction.java @@ -43,8 +43,7 @@ public class LaunchConfigurationAction extends Action { * @param image the image for the action */ public LaunchConfigurationAction(ILaunchConfiguration config, String mode, String text, ImageDescriptor image, int accelerator) { - super(MessageFormat.format(ActionMessages.LaunchConfigurationAction_0, new Object[] { - Integer.toString(accelerator), text }), image); + super(MessageFormat.format(ActionMessages.LaunchConfigurationAction_0, Integer.toString(accelerator), text), image); fConfig = config; fMode = mode; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetAction.java index 88ee2a48d0e..a418d3cbba7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetAction.java @@ -133,8 +133,7 @@ public void run(IAction action) { @Override public void selectionChanged(IAction action, ISelection selection) { // if the active part did not provide an adapter, see if the selection does - if (fTargetAdapter == null && selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; + if (fTargetAdapter == null && selection instanceof IStructuredSelection ss) { if (!ss.isEmpty()) { Object object = ss.getFirstElement(); if (object instanceof IAdaptable) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetRunToLineAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetRunToLineAction.java index 382a4032054..17868cec57d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetRunToLineAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetRunToLineAction.java @@ -42,8 +42,7 @@ class DebugContextListener implements IDebugContextListener { protected void contextActivated(ISelection selection) { fTargetElement = null; - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection ss) { if (ss.size() == 1) { fTargetElement = (ISuspendResume) DebugPlugin.getAdapter(ss.getFirstElement(), ISuspendResume.class); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java index 87c876fc8f1..02edeb789ea 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ToggleBreakpointsTargetManager.java @@ -301,8 +301,7 @@ public String getDefaultToggleTarget(IWorkbenchPart part, ISelection selection) private static class ToggleBreakpointsTargetAdapterFactory implements IToggleBreakpointsTargetFactory { private Object getSelectionElement(ISelection selection) { - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection)selection; + if (selection instanceof IStructuredSelection ss) { return ss.getFirstElement(); } return null; @@ -735,8 +734,7 @@ public IBreakpoint getBeakpointFromEditor(ITextEditor editor, IVerticalRulerInfo Iterator iterator = annotationModel.getAnnotationIterator(); while (iterator.hasNext()) { Annotation annot = iterator.next(); - if (annot instanceof SimpleMarkerAnnotation) { - SimpleMarkerAnnotation markerAnnotation = (SimpleMarkerAnnotation) annot; + if (annot instanceof SimpleMarkerAnnotation markerAnnotation) { IMarker marker = markerAnnotation.getMarker(); try { if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/CopyBreakpointsActionDelegate.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/CopyBreakpointsActionDelegate.java index 975edde5ad2..5ba76e469da 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/CopyBreakpointsActionDelegate.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/CopyBreakpointsActionDelegate.java @@ -51,8 +51,7 @@ public void run(IAction action) { IAction pasteAction = ((AbstractDebugView)getView()).getAction(IDebugView.PASTE_ACTION); // update the enablement of the paste action // workaround since the clipboard does not suppot callbacks - if (pasteAction instanceof PasteBreakpointsAction) { - PasteBreakpointsAction pba = (PasteBreakpointsAction) pasteAction; + if (pasteAction instanceof PasteBreakpointsAction pba) { if (pba.getStructuredSelection() != null) { pba.selectionChanged(pba.getStructuredSelection()); } @@ -80,12 +79,11 @@ public void breakpointsRemoved(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) // remove deleted breakpoints from drag/drop clipboard if (fStamp == LocalSelectionTransfer.getTransfer().getSelectionSetTime()) { ISelection selection = LocalSelectionTransfer.getTransfer().getSelection(); - if (selection instanceof IStructuredSelection) { + if (selection instanceof IStructuredSelection ss) { Set removed = new HashSet<>(); Collections.addAll(removed, breakpoints); boolean modified = false; List remain = new ArrayList<>(); - IStructuredSelection ss = (IStructuredSelection) selection; Iterator iterator = ss.iterator(); while (iterator.hasNext()) { Object bp = iterator.next(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/EditBreakpointGroupAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/EditBreakpointGroupAction.java index f85c6bd4784..674b6fbff1a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/EditBreakpointGroupAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/EditBreakpointGroupAction.java @@ -46,13 +46,10 @@ public void run(IAction action) { @Override public void selectionChanged(IAction action, ISelection sel) { fSet = null; - if (sel instanceof IStructuredSelection) { - IStructuredSelection selection= (IStructuredSelection) sel; - + if (sel instanceof IStructuredSelection selection) { if (selection.size() == 1) { Object element = selection.getFirstElement(); - if (element instanceof IBreakpointContainer) { - IBreakpointContainer container = (IBreakpointContainer)element; + if (element instanceof IBreakpointContainer container) { IAdaptable category = container.getCategory(); if (category instanceof WorkingSetCategory) { IWorkingSet set = ((WorkingSetCategory)category).getWorkingSet(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/PasteBreakpointsAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/PasteBreakpointsAction.java index 9a3c0ad82c3..ce3944595ed 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/PasteBreakpointsAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/PasteBreakpointsAction.java @@ -79,8 +79,7 @@ public void run() { protected boolean updateSelection(IStructuredSelection selection) { // can't paste into "Others" (only move) Object target = getTarget(); - if (target instanceof IBreakpointContainer) { - IBreakpointContainer container = (IBreakpointContainer) target; + if (target instanceof IBreakpointContainer container) { if (container.getCategory() instanceof OtherBreakpointCategory) { return false; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/RemoveFromWorkingSetAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/RemoveFromWorkingSetAction.java index e47864aeff1..cc7fd7d2082 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/RemoveFromWorkingSetAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/RemoveFromWorkingSetAction.java @@ -65,9 +65,7 @@ protected static class BreakpointSetElement { */ protected BreakpointSetElement[] getRemovableBreakpoints(IStructuredSelection selection) { List res = new ArrayList<>(); - if (selection instanceof ITreeSelection) { - ITreeSelection tSel = (ITreeSelection)selection; - + if (selection instanceof ITreeSelection tSel) { for (TreePath path : tSel.getPaths()) { // We can remove Breakpoints from their working set if any of their parents is a non "Other" breakpoint working set IBreakpoint breakpoint = (IBreakpoint)DebugPlugin.getAdapter(path.getLastSegment(), IBreakpoint.class); @@ -77,9 +75,7 @@ protected BreakpointSetElement[] getRemovableBreakpoints(IStructuredSelection se for (int j = 0; j < parents.getSegmentCount(); j++) { Object parent = parents.getSegment(j); - if (parent instanceof IBreakpointContainer) { - IBreakpointContainer container = (IBreakpointContainer)parent; - + if (parent instanceof IBreakpointContainer container) { // Test if this is a working set container. if (container.getCategory() instanceof WorkingSetCategory) { // Test if this container allows to remove this breakpoint. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/SetDefaultBreakpointGroupAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/SetDefaultBreakpointGroupAction.java index 344700d6644..f56b826d879 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/SetDefaultBreakpointGroupAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/SetDefaultBreakpointGroupAction.java @@ -31,7 +31,7 @@ public void run(IAction action) { sbwsd.setTitle(BreakpointGroupMessages.SetDefaultBreakpointGroupAction_0); IWorkingSet workingSet = BreakpointSetOrganizer.getDefaultWorkingSet(); if (workingSet != null){ - sbwsd.setInitialSelections(new Object[]{workingSet}); + sbwsd.setInitialSelections(workingSet); } if(sbwsd.open() == Window.OK) { BreakpointSetOrganizer.setDefaultWorkingSet((IWorkingSet) sbwsd.getResult()[0]); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/ToggleDefaultGroupAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/ToggleDefaultGroupAction.java index 4d406d6b3bc..56bec9da759 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/ToggleDefaultGroupAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/ToggleDefaultGroupAction.java @@ -42,12 +42,10 @@ public void run(IAction action) { @Override public void selectionChanged(IAction action, ISelection sel) { fSelectedSet = null; - if (sel instanceof IStructuredSelection) { - IStructuredSelection selection = (IStructuredSelection) sel; + if (sel instanceof IStructuredSelection selection) { if (selection.size() == 1) { Object firstElement = selection.getFirstElement(); - if (firstElement instanceof IBreakpointContainer) { - IBreakpointContainer container = (IBreakpointContainer) firstElement; + if (firstElement instanceof IBreakpointContainer container) { if (container.getCategory() instanceof WorkingSetCategory) { WorkingSetCategory category = (WorkingSetCategory)container.getCategory(); if (IDebugUIConstants.BREAKPOINT_WORKINGSET_ID.equals(category.getWorkingSet().getId())) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointSortBy/SortBreakpointsAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointSortBy/SortBreakpointsAction.java index d7bbbf5c524..0d98aabd140 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointSortBy/SortBreakpointsAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointSortBy/SortBreakpointsAction.java @@ -32,7 +32,7 @@ public class SortBreakpointsAction extends Action { /** * Creates a new action which will sort breakpoints in the given breakpoint - * view + * view */ public SortBreakpointsAction(BreakpointsView view, String name, int sortingBy) { super(name, IAction.AS_RADIO_BUTTON); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/EnableBreakpointsAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/EnableBreakpointsAction.java index 2e08f73c357..e37f1079b70 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/EnableBreakpointsAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/EnableBreakpointsAction.java @@ -141,11 +141,9 @@ protected IStructuredSelection getSelection() { @Override public void selectionChanged(IAction action, ISelection selection) { setAction(action); - if (!(selection instanceof IStructuredSelection)) { + if (!(selection instanceof IStructuredSelection sel)) { return; } - IStructuredSelection sel= (IStructuredSelection)selection; - Iterator itr = sel.iterator(); boolean allEnabled= true; boolean allDisabled= true; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ModifyWatchpointAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ModifyWatchpointAction.java index 096fde49680..8db1dd4a166 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ModifyWatchpointAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ModifyWatchpointAction.java @@ -71,8 +71,7 @@ public void selectionChanged(IAction action, ISelection selection) { Iterator iterator = fWatchpoints.iterator(); while (iterator.hasNext()) { Object next = iterator.next(); - if (next instanceof IWatchpoint) { - IWatchpoint watchpoint = (IWatchpoint) next; + if (next instanceof IWatchpoint watchpoint) { action.setChecked(isChecked(watchpoint)); if (!isEnabled(watchpoint)) { action.setEnabled(false); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/RemoveBreakpointAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/RemoveBreakpointAction.java index 4cac57e9382..a7086c04cc3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/RemoveBreakpointAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/RemoveBreakpointAction.java @@ -83,9 +83,8 @@ public void run(IAction action) { IBreakpoint breakpoint = (IBreakpoint)DebugPlugin.getAdapter(next, IBreakpoint.class); if (breakpoint != null) { breakpointsToDelete.add(breakpoint); - } else if (next instanceof IBreakpointContainer) { + } else if (next instanceof IBreakpointContainer bpc) { //the the container is a workingset, ask if they want to delete it as well - IBreakpointContainer bpc = (IBreakpointContainer) next; if(bpc.getCategory() instanceof WorkingSetCategory) { IWorkingSet set = ((WorkingSetCategory)bpc.getCategory()).getWorkingSet(); if(!prompted) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/RetargetToggleBreakpointAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/RetargetToggleBreakpointAction.java index 666260fe7d1..139d6ceaa4b 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/RetargetToggleBreakpointAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/RetargetToggleBreakpointAction.java @@ -29,8 +29,7 @@ public class RetargetToggleBreakpointAction extends RetargetBreakpointAction { @Override protected void performAction(Object target, ISelection selection, IWorkbenchPart part) throws CoreException { - if (target instanceof IToggleBreakpointsTargetExtension) { - IToggleBreakpointsTargetExtension ext = (IToggleBreakpointsTargetExtension) target; + if (target instanceof IToggleBreakpointsTargetExtension ext) { ext.toggleBreakpoints(part, selection); } else { ((IToggleBreakpointsTarget)target).toggleLineBreakpoints(part, selection); @@ -39,8 +38,7 @@ protected void performAction(Object target, ISelection selection, IWorkbenchPart @Override protected boolean canPerformAction(Object target, ISelection selection, IWorkbenchPart part) { - if (target instanceof IToggleBreakpointsTargetExtension) { - IToggleBreakpointsTargetExtension ext = (IToggleBreakpointsTargetExtension) target; + if (target instanceof IToggleBreakpointsTargetExtension ext) { return ext.canToggleBreakpoints(part, selection); } else { return ((IToggleBreakpointsTarget)target).canToggleLineBreakpoints(part, selection); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ShowSupportedBreakpointsAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ShowSupportedBreakpointsAction.java index e61fab2e1f8..8fa65d53cbb 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ShowSupportedBreakpointsAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ShowSupportedBreakpointsAction.java @@ -129,8 +129,7 @@ public void dispose() { */ @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss= (IStructuredSelection)selection; + if (selection instanceof IStructuredSelection ss) { List debugTargets= getDebugTargets(ss); if (!isChecked()) { fDebugTargets= debugTargets; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ToggleBreakpointObjectActionDelegate.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ToggleBreakpointObjectActionDelegate.java index f3b5d2822cc..f352f8dc1f5 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ToggleBreakpointObjectActionDelegate.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/ToggleBreakpointObjectActionDelegate.java @@ -70,8 +70,7 @@ public void run(IAction action) { @Override public void selectionChanged(IAction action, ISelection selection) { boolean enabled = false; - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection ss) { this.fSelection = ss; // selectionChagned() can sometimes be called before setActivePart(). // Guard here against that possibility. diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EnableWatchExpressionAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EnableWatchExpressionAction.java index 50f5475c526..1271598737d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EnableWatchExpressionAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/EnableWatchExpressionAction.java @@ -52,8 +52,7 @@ public void run(IAction action) { fireWatchExpressionChanged(expression); } } - } else if (fSelection instanceof IWatchExpression) { - IWatchExpression expression= ((IWatchExpression) fSelection); + } else if (fSelection instanceof IWatchExpression expression) { expression.setEnabled(fEnable); fireWatchExpressionChanged(expression); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionDialog.java index bfd465f6658..695c96550e7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionDialog.java @@ -162,7 +162,7 @@ public void documentChanged(DocumentEvent event) { fCheckBox.setFont(font); String tipText = MessageFormat.format(ActionMessages.WatchExpressionDialog_5, - new Object[] { getCtrlReturnText() }); + getCtrlReturnText()); fTip= new Label(container, SWT.LEFT); fTip.setText(tipText); fTip.setFont(font); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionFactoryTester.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionFactoryTester.java index 13e1428e827..9cf41476c94 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionFactoryTester.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchExpressionFactoryTester.java @@ -35,12 +35,10 @@ public class WatchExpressionFactoryTester extends PropertyTester { @Override public boolean test(Object element, String property, Object[] args, Object expectedValue) { if (CAN_CREATE_WATCH_EXPRESSION_PROPERTY.equals(property)){ - if (element instanceof IVariable) { - IVariable variable = (IVariable)element; + if (element instanceof IVariable variable) { if (DebugPlugin.getDefault().getExpressionManager().hasWatchExpressionDelegate(variable.getModelIdentifier())) { IWatchExpressionFactoryAdapter factory = WatchHandler.getFactory(variable); - if (factory instanceof IWatchExpressionFactoryAdapterExtension) { - IWatchExpressionFactoryAdapterExtension ext = (IWatchExpressionFactoryAdapterExtension) factory; + if (factory instanceof IWatchExpressionFactoryAdapterExtension ext) { return ext.canCreateWatchExpression(variable); } return true; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchHandler.java index a667e8d8e03..a45587081a2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/WatchHandler.java @@ -77,8 +77,7 @@ private void showExpressionsView() { private void createExpression(Object element) { String expressionString; try { - if (element instanceof IVariable) { - IVariable variable = (IVariable)element; + if (element instanceof IVariable variable) { IWatchExpressionFactoryAdapter factory = getFactory(variable); expressionString = variable.getName(); if (factory != null) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ChangeVariableValueAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ChangeVariableValueAction.java index 52ce275efe7..8094f270a09 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ChangeVariableValueAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ChangeVariableValueAction.java @@ -124,7 +124,7 @@ protected void doDefaultEdit(Shell shell) { DebugUIPlugin.errorDialog(shell, ActionMessages.ChangeVariableValue_errorDialogTitle,ActionMessages.ChangeVariableValue_errorDialogMessage, exception); // return; } - ChangeVariableValueInputDialog inputDialog = new ChangeVariableValueInputDialog(shell, ActionMessages.ChangeVariableValue_1, MessageFormat.format(ActionMessages.ChangeVariableValue_2, new Object[] { name }), value, input -> { + ChangeVariableValueInputDialog inputDialog = new ChangeVariableValueInputDialog(shell, ActionMessages.ChangeVariableValue_1, MessageFormat.format(ActionMessages.ChangeVariableValue_2, name), value, input -> { try { if (fVariable.verifyValue(input)) { return null; // null means valid @@ -158,9 +158,8 @@ protected void update(IStructuredSelection sel) { Iterator iter = sel.iterator(); if (iter.hasNext()) { Object object= iter.next(); - if (object instanceof IValueModification) { + if (object instanceof IValueModification varMod) { isApplicable = true; - IValueModification varMod= (IValueModification)object; if (!varMod.supportsValueModification()) { setEnabled(false); return; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ShowTypesAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ShowTypesAction.java index 4c269c102e0..ed4a9344130 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ShowTypesAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/ShowTypesAction.java @@ -68,8 +68,7 @@ private void valueChanged(boolean on) { if (debugLabelProvider != null) { Boolean typesStatus = on ? Boolean.TRUE : Boolean.FALSE; debugLabelProvider.setAttribute(IDebugModelPresentation.DISPLAY_VARIABLE_TYPE_NAMES, typesStatus); - if (viewer instanceof TreeModelViewer) { - TreeModelViewer treeViewer = (TreeModelViewer) viewer; + if (viewer instanceof TreeModelViewer treeViewer) { treeViewer.getPresentationContext().setProperty(IDebugModelPresentation.DISPLAY_VARIABLE_TYPE_NAMES, typesStatus); } BusyIndicator.showWhile(viewer.getControl().getDisplay(), () -> viewer.refresh()); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneAssignValueAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneAssignValueAction.java index b65ef14b744..ff1e8220859 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneAssignValueAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/variables/details/DetailPaneAssignValueAction.java @@ -80,8 +80,7 @@ public static void assignValue(Shell shell, IVariable variable, String newValueE variable.setValue(newValueExpression); } else { if (shell != null) { - DebugUIPlugin.errorDialog(shell, ActionMessages.DetailPaneAssignValueAction_2, MessageFormat.format(ActionMessages.DetailPaneAssignValueAction_3, new Object[] { - newValueExpression, variable.getName() }), new StatusInfo(IStatus.ERROR, ActionMessages.DetailPaneAssignValueAction_4)); // + DebugUIPlugin.errorDialog(shell, ActionMessages.DetailPaneAssignValueAction_2, MessageFormat.format(ActionMessages.DetailPaneAssignValueAction_3, newValueExpression, variable.getName()), new StatusInfo(IStatus.ERROR, ActionMessages.DetailPaneAssignValueAction_4)); // } } } catch (DebugException e) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/breakpoints/provisional/OtherBreakpointCategory.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/breakpoints/provisional/OtherBreakpointCategory.java index f39ae03f4f0..ccf67a43e7f 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/breakpoints/provisional/OtherBreakpointCategory.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/breakpoints/provisional/OtherBreakpointCategory.java @@ -80,8 +80,7 @@ public Object getParent(Object o) { @Override public boolean equals(Object obj) { - if (obj instanceof OtherBreakpointCategory) { - OtherBreakpointCategory category = (OtherBreakpointCategory) obj; + if (obj instanceof OtherBreakpointCategory category) { return fOrganizer.equals(category.fOrganizer); } return false; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRelaunchAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRelaunchAction.java index 99016622e29..b4846cd26d3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRelaunchAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRelaunchAction.java @@ -59,8 +59,7 @@ public void postExecute(IRequest request, final Object[] targets) { protected ISelection getContext() { // Convert action context to contain only launch objects (bug 356651). ISelection context = super.getContext(); - if (context instanceof IStructuredSelection && !context.isEmpty()) { - IStructuredSelection ss = (IStructuredSelection)context; + if (context instanceof IStructuredSelection ss && !context.isEmpty()) { Set launches = new HashSet<>(ss.size()); for (Iterator itr = ss.iterator(); itr.hasNext();) { ILaunch launch = DebugUIPlugin.getLaunch(itr.next()); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java index cf62aaf6097..496bb1c76bb 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/commands/actions/TerminateAndRemoveAction.java @@ -156,8 +156,7 @@ public void runWithEvent(Event event) { } else { sel = getDebugContextService().getActiveContext(); } - if (sel instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) sel; + if (sel instanceof IStructuredSelection ss) { postExecute(new Request(), ss.toArray()); } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java index 857371bd44e..cd28a36ee30 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/ContextRunner.java @@ -204,7 +204,7 @@ else if(esize < 1) { else { String msg = ContextMessages.ContextRunner_7; if(!resource.isAccessible()) { - msg = MessageFormat.format(ContextMessages.ContextRunner_13, new Object[] { resource.getName() }); + msg = MessageFormat.format(ContextMessages.ContextRunner_13, resource.getName()); } MessageDialog.openInformation(DebugUIPlugin.getShell(), ContextMessages.ContextRunner_0, msg); } @@ -289,9 +289,7 @@ private boolean validateMode(ILaunchConfiguration configuration, String mode) { } else { String label = launchMode.getLabel(); String modeLabel = DebugUIPlugin.removeAccelerators(label); - MessageDialog.openInformation(DebugUIPlugin.getShell(), MessageFormat.format(ContextMessages.ContextRunner_1, new Object[] { modeLabel }), MessageFormat.format(ContextMessages.ContextRunner_3, new Object[] { - configuration.getName(), - modeLabel.toLowerCase() })); + MessageDialog.openInformation(DebugUIPlugin.getShell(), MessageFormat.format(ContextMessages.ContextRunner_1, modeLabel), MessageFormat.format(ContextMessages.ContextRunner_3, configuration.getName(), modeLabel.toLowerCase())); } return false; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java index a4dd5e0b163..9c239151a53 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contextlaunching/LaunchingResourceManager.java @@ -299,7 +299,7 @@ private String appendLaunched(ILaunchConfiguration config) { } } if(launched) { - return MessageFormat.format(ContextMessages.LaunchingResourceManager_0, new Object[] { config.getName() }); + return MessageFormat.format(ContextMessages.LaunchingResourceManager_0, config.getName()); } return config.getName(); } @@ -374,7 +374,7 @@ else if(shouldLaunchLast() || resource == null) { return resource.getName(); } else { - return MessageFormat.format(ContextMessages.LaunchingResourceManager_1, new Object[] { sc.get(0).getLabel() }); + return MessageFormat.format(ContextMessages.LaunchingResourceManager_1, sc.get(0).getLabel()); } } else { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugModelContextBindingManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugModelContextBindingManager.java index 4d2108fe135..207f9be3b84 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugModelContextBindingManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/DebugModelContextBindingManager.java @@ -181,8 +181,7 @@ private void loadDebugModelActivityExtensions() { public void debugContextChanged(DebugContextEvent event) { if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) { ISelection selection = event.getContext(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection ss) { Iterator iterator = ss.iterator(); while (iterator.hasNext()) { activated(iterator.next()); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/LaunchSuspendTrigger.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/LaunchSuspendTrigger.java index db1f5f900d0..64c388982ec 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/LaunchSuspendTrigger.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/LaunchSuspendTrigger.java @@ -79,8 +79,7 @@ public void handleDebugEvents(DebugEvent[] events) { if (event.getKind() == DebugEvent.SUSPEND && !event.isEvaluation() && event.getDetail() != DebugEvent.STEP_END) { // Don't switch perspective for evaluations or stepping Object source = event.getSource(); - if (source instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) source; + if (source instanceof IAdaptable adaptable) { ILaunch launch = adaptable.getAdapter(ILaunch.class); if (fLaunch.equals(launch)) { // only notify for this launch diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultVariableCellModifier.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultVariableCellModifier.java index cbd58352a6a..763fd3f8e41 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultVariableCellModifier.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/DefaultVariableCellModifier.java @@ -39,8 +39,7 @@ public boolean canModify(Object element, String property) { @Override public Object getValue(Object element, String property) { if (IDebugUIConstants.COLUMN_ID_VARIABLE_VALUE.equals(property)) { - if (element instanceof IVariable) { - IVariable variable = (IVariable) element; + if (element instanceof IVariable variable) { try { return DefaultLabelProvider.escapeSpecialChars(variable.getValue().getValueString()); } catch (DebugException e) { @@ -56,11 +55,10 @@ public void modify(Object element, String property, Object value) { Object oldValue = getValue(element, property); if (!value.equals(oldValue)) { if (IDebugUIConstants.COLUMN_ID_VARIABLE_VALUE.equals(property)) { - if (element instanceof IVariable) { + if (element instanceof IVariable variable) { if (value instanceof String) { // The value column displays special characters escaped, so encode the string with any special characters escaped properly String valueExpression = DefaultLabelProvider.encodeEsacpedChars((String)value); - IVariable variable = (IVariable) element; DetailPaneAssignValueAction.assignValue(DebugUIPlugin.getShell(), variable, valueExpression); } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryBlockContentAdapter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryBlockContentAdapter.java index 6a838b4e307..a6d2a62ea0d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryBlockContentAdapter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryBlockContentAdapter.java @@ -46,11 +46,10 @@ protected Object[] getChildren(Object parent, IPresentationContext context) thro return new Object[0]; } - if (!(context instanceof MemoryViewPresentationContext)) { + if (!(context instanceof MemoryViewPresentationContext memoryViewContext)) { return new Object[0]; } - MemoryViewPresentationContext memoryViewContext = (MemoryViewPresentationContext) context; IMemoryRendering rendering = memoryViewContext.getRendering(); if (!(rendering instanceof AbstractAsyncTableRendering)) { @@ -380,11 +379,10 @@ public Object[] getMemoryToFitTable(BigInteger startAddress, long numberOfLines, private Object[] organizeLines(long numberOfLines, MemoryByte[] memoryBuffer, BigInteger address, boolean manageDelta, MemoryViewPresentationContext context) { ArrayList lineCache = new ArrayList<>(); IMemoryRendering rendering = context.getRendering(); - if (!(rendering instanceof AbstractAsyncTableRendering)) { + if (!(rendering instanceof AbstractAsyncTableRendering tableRendering)) { return lineCache.toArray(); } - AbstractAsyncTableRendering tableRendering = (AbstractAsyncTableRendering) rendering; int addressableUnit = tableRendering.getBytesPerLine() / tableRendering.getAddressableSize(); for (int i = 0; i < numberOfLines; i++) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryBlockLabelAdapter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryBlockLabelAdapter.java index 1a8b5d2f6c8..b7ecbbf2932 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryBlockLabelAdapter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryBlockLabelAdapter.java @@ -26,8 +26,9 @@ public class MemoryBlockLabelAdapter extends AsynchronousDebugLabelAdapter { @Override protected ImageDescriptor[] getImageDescriptors(Object element, IPresentationContext context) throws CoreException { - if (element instanceof IMemoryBlock) + if (element instanceof IMemoryBlock) { return new ImageDescriptor[]{DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_OBJS_VARIABLE)}; + } return new ImageDescriptor[0]; } @@ -54,8 +55,9 @@ private String getLabel(IMemoryBlock memoryBlock) { @Override protected String[] getLabels(Object element, IPresentationContext context) throws CoreException { - if (element instanceof IMemoryBlock) + if (element instanceof IMemoryBlock) { return new String[]{getLabel((IMemoryBlock)element)}; + } return super.getLabels(element, context); } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryRetrievalContentAdapter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryRetrievalContentAdapter.java index 04170272246..5ab6e5c0f46 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryRetrievalContentAdapter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemoryRetrievalContentAdapter.java @@ -43,8 +43,9 @@ protected boolean hasChildren(Object element, IPresentationContext context) thro { if (element instanceof IMemoryBlockRetrieval) { - if (((IMemoryBlockRetrieval)element).supportsStorageRetrieval()) + if (((IMemoryBlockRetrieval)element).supportsStorageRetrieval()) { return DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks((IMemoryBlockRetrieval)element).length > 0; + } } } return false; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemorySegmentLabelAdapter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemorySegmentLabelAdapter.java index 91d9c2bbc98..e1a9be6f13c 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemorySegmentLabelAdapter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/MemorySegmentLabelAdapter.java @@ -49,9 +49,8 @@ public class MemorySegmentLabelAdapter extends AsynchronousLabelAdapter { protected String[] getLabels(Object element, IPresentationContext context) throws CoreException { - if (context instanceof MemoryViewPresentationContext) + if (context instanceof MemoryViewPresentationContext tableRenderingContext) { - MemoryViewPresentationContext tableRenderingContext = (MemoryViewPresentationContext)context; if (tableRenderingContext.getRendering() != null && tableRenderingContext.getRendering() instanceof AbstractAsyncTableRendering) { AbstractAsyncTableRendering tableRendering = (AbstractAsyncTableRendering)tableRenderingContext.getRendering(); @@ -86,8 +85,9 @@ private String getColumnText(Object element, int columnIndex, AbstractAsyncTable if (presentation != null) { String rowLabel = presentation.getRowLabel(tableRendering.getMemoryBlock(), ((MemorySegment)element).getAddress()); - if (rowLabel != null) + if (rowLabel != null) { return rowLabel; + } } columnLabel = ((MemorySegment)element).getAddress().toString(16).toUpperCase(); @@ -112,11 +112,11 @@ else if (columnIndex > (tableRendering.getBytesPerLine()/tableRendering.getBytes } else { - if (element instanceof MemorySegment) + if (element instanceof MemorySegment segment) { - MemorySegment segment = (MemorySegment)element; - if (segment.getBytes().length != tableRendering.getBytesPerLine()) + if (segment.getBytes().length != tableRendering.getBytesPerLine()) { return IInternalDebugCoreConstants.EMPTY_STRING; + } } ILabelProvider labelProvider = tableRendering.getAdapter(ILabelProvider.class); @@ -125,8 +125,9 @@ else if (columnIndex > (tableRendering.getBytesPerLine()/tableRendering.getBytes MemoryRenderingElement renderingElement = getMemoryRenderingElement(element, columnIndex, tableRendering); if (renderingElement != null) { String label = labelProvider.getText(renderingElement); - if (label != null) + if (label != null) { return label; + } } } @@ -143,9 +144,8 @@ else if (columnIndex > (tableRendering.getBytesPerLine()/tableRendering.getBytes @Override protected ImageDescriptor[] getImageDescriptors(Object element, IPresentationContext context) throws CoreException { - if (context instanceof MemoryViewPresentationContext) + if (context instanceof MemoryViewPresentationContext tableRenderingContext) { - MemoryViewPresentationContext tableRenderingContext = (MemoryViewPresentationContext)context; if (tableRenderingContext.getRendering() != null && tableRenderingContext.getRendering() instanceof AbstractAsyncTableRendering) { AbstractAsyncTableRendering tableRendering = (AbstractAsyncTableRendering)tableRenderingContext.getRendering(); @@ -167,14 +167,15 @@ protected ImageDescriptor[] getImageDescriptors(Object element, private ImageDescriptor getColumnImageDescriptor(Object element, int columnIndex, AbstractAsyncTableRendering tableRendering) { - if (columnIndex == 0) + if (columnIndex == 0) { return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_OBJECT_MEMORY); + } - if (element instanceof MemorySegment) + if (element instanceof MemorySegment segment) { - MemorySegment segment = (MemorySegment)element; - if (segment.getBytes().length != tableRendering.getBytesPerLine()) + if (segment.getBytes().length != tableRendering.getBytesPerLine()) { return null; + } ILabelProvider labelProvider = tableRendering.getAdapter(ILabelProvider.class); if (labelProvider != null && columnIndex > 0) @@ -206,8 +207,9 @@ private ImageDescriptor getColumnImageDescriptor(Object element, int columnIndex if (allKnown) { // mark changed elements with changed icon - if (!unchanged) + if (!unchanged) { return DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_OBJECT_MEMORY_CHANGED); + } } } @@ -217,9 +219,8 @@ private ImageDescriptor getColumnImageDescriptor(Object element, int columnIndex @Override protected FontData[] getFontDatas(Object element, IPresentationContext context) throws CoreException { - if (context instanceof MemoryViewPresentationContext) + if (context instanceof MemoryViewPresentationContext tableRenderingContext) { - MemoryViewPresentationContext tableRenderingContext = (MemoryViewPresentationContext)context; if (tableRenderingContext.getRendering() != null && tableRenderingContext.getRendering() instanceof AbstractAsyncTableRendering) { AbstractAsyncTableRendering tableRendering = (AbstractAsyncTableRendering)tableRenderingContext.getRendering(); @@ -240,11 +241,11 @@ protected FontData[] getFontDatas(Object element, private FontData getColumnFontData(Object element, int columnIndex, AbstractAsyncTableRendering tableRendering) { - if (element instanceof MemorySegment) + if (element instanceof MemorySegment segment) { - MemorySegment segment = (MemorySegment)element; - if (segment.getBytes().length != tableRendering.getBytesPerLine()) + if (segment.getBytes().length != tableRendering.getBytesPerLine()) { return null; + } IFontProvider fontProvider = tableRendering.getAdapter(IFontProvider.class); if (fontProvider != null && columnIndex > 0) @@ -252,8 +253,9 @@ private FontData getColumnFontData(Object element, int columnIndex, AbstractAsyn MemoryRenderingElement renderingElement = getMemoryRenderingElement(element, columnIndex, tableRendering); if (renderingElement != null) { Font font = fontProvider.getFont(renderingElement); - if (font != null) + if (font != null) { return font.getFontData()[0]; + } } } } @@ -264,9 +266,8 @@ private FontData getColumnFontData(Object element, int columnIndex, AbstractAsyn protected RGB[] getForegrounds(Object element, IPresentationContext context) throws CoreException { - if (context instanceof MemoryViewPresentationContext) + if (context instanceof MemoryViewPresentationContext tableRenderingContext) { - MemoryViewPresentationContext tableRenderingContext = (MemoryViewPresentationContext)context; if (tableRenderingContext.getRendering() != null && tableRenderingContext.getRendering() instanceof AbstractAsyncTableRendering) { AbstractAsyncTableRendering tableRendering = (AbstractAsyncTableRendering)tableRenderingContext.getRendering(); @@ -290,14 +291,15 @@ protected RGB[] getForegrounds(Object element, IPresentationContext context) private RGB getColumnBackground(Object element, int columnIndex, AbstractAsyncTableRendering tableRendering) { - if (columnIndex == 0) + if (columnIndex == 0) { return null; + } - if (element instanceof MemorySegment) + if (element instanceof MemorySegment segment) { - MemorySegment segment = (MemorySegment)element; - if (segment.getBytes().length != tableRendering.getBytesPerLine()) + if (segment.getBytes().length != tableRendering.getBytesPerLine()) { return null; + } IColorProvider colorProvider = tableRendering.getAdapter(IColorProvider.class); if (colorProvider != null && columnIndex > 0) @@ -305,8 +307,9 @@ private RGB getColumnBackground(Object element, int columnIndex, AbstractAsyncTa MemoryRenderingElement renderingElement = getMemoryRenderingElement(element, columnIndex, tableRendering); if (renderingElement != null) { Color color = colorProvider.getBackground(renderingElement); - if (color != null) + if (color != null) { return color.getRGB(); + } } } } @@ -315,14 +318,15 @@ private RGB getColumnBackground(Object element, int columnIndex, AbstractAsyncTa private RGB getColumnForeground(Object element, int columnIndex, AbstractAsyncTableRendering tableRendering) { - if (columnIndex == 0) + if (columnIndex == 0) { return null; + } - if (element instanceof MemorySegment) + if (element instanceof MemorySegment segment) { - MemorySegment segment = (MemorySegment)element; - if (segment.getBytes().length != tableRendering.getBytesPerLine()) + if (segment.getBytes().length != tableRendering.getBytesPerLine()) { return null; + } IColorProvider colorProvider = tableRendering.getAdapter(IColorProvider.class); if (colorProvider != null && columnIndex > 0) @@ -330,8 +334,9 @@ private RGB getColumnForeground(Object element, int columnIndex, AbstractAsyncTa MemoryRenderingElement renderingElement = getMemoryRenderingElement(element, columnIndex, tableRendering); if (renderingElement != null) { Color color = colorProvider.getForeground(renderingElement); - if (color != null) + if (color != null) { return color.getRGB(); + } } } @@ -351,8 +356,9 @@ private RGB getColumnForeground(Object element, int columnIndex, AbstractAsyncTa if (allKnown) { // mark changed elements in changed color - if (!unchanged) + if (!unchanged) { return DebugUIPlugin.getPreferenceColor(IDebugUIConstants.PREF_CHANGED_DEBUG_ELEMENT_COLOR).getRGB(); + } return DebugUIPlugin.getPreferenceColor(IDebugUIConstants.PREF_MEMORY_HISTORY_KNOWN_COLOR).getRGB(); } @@ -367,9 +373,8 @@ private RGB getColumnForeground(Object element, int columnIndex, AbstractAsyncTa protected RGB[] getBackgrounds(Object element, IPresentationContext context) throws CoreException { - if (context instanceof MemoryViewPresentationContext) + if (context instanceof MemoryViewPresentationContext tableRenderingContext) { - MemoryViewPresentationContext tableRenderingContext = (MemoryViewPresentationContext)context; if (tableRenderingContext.getRendering() != null && tableRenderingContext.getRendering() instanceof AbstractAsyncTableRendering) { AbstractAsyncTableRendering tableRendering = (AbstractAsyncTableRendering)tableRenderingContext.getRendering(); @@ -400,8 +405,7 @@ protected RGB[] getBackgrounds(Object element, IPresentationContext context) * @return memory rendering element or null */ private MemoryRenderingElement getMemoryRenderingElement(Object element, int columnIndex, AbstractBaseTableRendering rendering) { - if (element instanceof MemorySegment) { - MemorySegment line = (MemorySegment) element; + if (element instanceof MemorySegment line) { BigInteger address = line.getAddress(); int offset = (columnIndex - 1) * rendering.getBytesPerColumn(); if (offset < rendering.getBytesPerLine() && (offset + rendering.getBytesPerColumn()) <= rendering.getBytesPerLine()) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/WatchExpressionCellModifier.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/WatchExpressionCellModifier.java index 5fc0d00314d..dd365290cb1 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/WatchExpressionCellModifier.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/WatchExpressionCellModifier.java @@ -48,13 +48,12 @@ public void modify(Object element, String property, Object value) { Object oldValue = getValue(element, property); if (!value.equals(oldValue)) { if (IDebugUIConstants.COLUMN_ID_VARIABLE_NAME.equals(property)) { - if (element instanceof IWatchExpression) { + if (element instanceof IWatchExpression expression) { if (value instanceof String) { // The value column displays special characters // escaped, so encode the string with any special // characters escaped properly String expressionText = DefaultLabelProvider.encodeEsacpedChars((String)value); - IWatchExpression expression = (IWatchExpression) element; // Bug 345974 see ExpressionManagerContentProvider.AddNewExpressionElement.modify does not allow an empty string if (expressionText.trim().length() > 0) { expression.setExpressionText(expressionText); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/CommonTabLite.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/CommonTabLite.java index 0b55a79ff37..37d2a62403d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/CommonTabLite.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/CommonTabLite.java @@ -235,8 +235,7 @@ private void handleSharedLocationButtonSelected() { dialog.setDialogBoundsSettings(getDialogBoundsSettings(), Dialog.DIALOG_PERSISTSIZE); dialog.open(); Object[] results = dialog.getResult(); - if ((results != null) && (results.length > 0) && (results[0] instanceof IPath)) { - IPath path = (IPath)results[0]; + if ((results != null) && (results.length > 0) && (results[0] instanceof IPath path)) { String containerName = path.toOSString(); fSharedLocationText.setText(containerName); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupElementLaunchedHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupElementLaunchedHandler.java index 16b71766f91..78d6d64ca85 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupElementLaunchedHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupElementLaunchedHandler.java @@ -29,9 +29,7 @@ public class GroupElementLaunchedHandler implements IStatusHandler { @Override public Object handleStatus(IStatus status, Object source) throws CoreException { - if (source instanceof ILaunch[]) { - ILaunch[] launches = (ILaunch[]) source; - + if (source instanceof ILaunch[] launches) { // Now we need to override the history to make multi-launch // appear last, if we don't do it last launch would be our // child's launch which is not correct for repeating the diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationSelectionDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationSelectionDialog.java index 0ff1d19cf49..456a80be9a5 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationSelectionDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationSelectionDialog.java @@ -95,8 +95,7 @@ public GroupLaunchConfigurationSelectionDialog(Shell shell, String initMode, boo @Override public boolean select(Viewer viewer, Object parentElement, Object element) { try { - if (element instanceof ILaunchConfigurationType) { - ILaunchConfigurationType type = (ILaunchConfigurationType) element; + if (element instanceof ILaunchConfigurationType type) { if (type.equals(groupType)) { // we're hiding ourselves. if we're the only group, // don't show the type. @@ -104,8 +103,7 @@ public boolean select(Viewer viewer, Object parentElement, Object element) { } return getLaunchManager().getLaunchConfigurations(type, ILaunchConfiguration.CONFIGURATION).length > 0; - } else if (element instanceof ILaunchConfiguration) { - ILaunchConfiguration c = (ILaunchConfiguration) element; + } else if (element instanceof ILaunchConfiguration c) { if (c.getName().equals(self.getName()) && c.getType().equals(groupType)) { return false; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationTabGroup.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationTabGroup.java index bb4b3d1546b..2db23a126d7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationTabGroup.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/GroupLaunchConfigurationTabGroup.java @@ -120,11 +120,10 @@ public boolean hasChildren(Object element) { static class LabelProvider extends BaseLabelProvider implements ITableLabelProvider { @Override public Image getColumnImage(Object element, int columnIndex) { - if (!(element instanceof GroupLaunchElement)) { + if (!(element instanceof GroupLaunchElement el)) { return null; } if (columnIndex == 0) { - GroupLaunchElement el = (GroupLaunchElement) element; if (el.data == null || !isValidLaunchReference(el.data)) { Image errorImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); return errorImage; @@ -143,11 +142,9 @@ public Image getColumnImage(Object element, int columnIndex) { @Override public String getColumnText(Object element, int columnIndex) { - if (!(element instanceof GroupLaunchElement)) { + if (!(element instanceof GroupLaunchElement el)) { return null; } - GroupLaunchElement el = (GroupLaunchElement) element; - // launch name if (columnIndex == 0) { try { @@ -172,7 +169,7 @@ public String getColumnText(Object element, int columnIndex) { return action.getDescription(); case DELAY: final Object actionParam = el.actionParam; - return NLS.bind(DebugUIMessages.GroupLaunchConfigurationTabGroup_13, actionParam instanceof Integer ? Integer.toString((Integer) actionParam) : "?"); //$NON-NLS-1$ + return NLS.bind(DebugUIMessages.GroupLaunchConfigurationTabGroup_13, actionParam instanceof Integer i ? Integer.toString(i) : "?"); //$NON-NLS-1$ case OUTPUT_REGEXP: return NLS.bind(DebugUIMessages.GroupLaunchConfigurationTabGroup_0, el.actionParam); default: diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/UnsupportedModeHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/UnsupportedModeHandler.java index 10d1161af1c..4116c1696a2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/UnsupportedModeHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/groups/UnsupportedModeHandler.java @@ -32,8 +32,7 @@ public class UnsupportedModeHandler implements IStatusHandler { @Override public Object handleStatus(IStatus status, Object source) throws CoreException { - if (source instanceof String[]) { - final String[] data = (String[]) source; + if (source instanceof final String[] data) { PlatformUI.getWorkbench().getDisplay() .asyncExec(() -> MessageDialog.openError( DebugUIPlugin.getShellForModalDialog(), diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/hover/DebugTextHover.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/hover/DebugTextHover.java index fa850a7935d..be2191a05a5 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/hover/DebugTextHover.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/hover/DebugTextHover.java @@ -58,8 +58,7 @@ public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { return null; } Object object = getHoverInfo2(textViewer, hoverRegion); - if (object instanceof IVariable) { - IVariable var = (IVariable) object; + if (object instanceof IVariable var) { return getVariableText(var); } return null; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/hover/ExpressionInformationControlCreator.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/hover/ExpressionInformationControlCreator.java index c1f5fd97bf2..13aafa321c5 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/hover/ExpressionInformationControlCreator.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/hover/ExpressionInformationControlCreator.java @@ -282,8 +282,7 @@ protected void createContent(Composite parent) { fDetailPaneComposite = SWTFactory.createComposite(fSashForm, 1, 1, GridData.FILL_BOTH); Layout layout = fDetailPaneComposite.getLayout(); - if (layout instanceof GridLayout) { - GridLayout gl = (GridLayout) layout; + if (layout instanceof GridLayout gl) { gl.marginHeight = 0; gl.marginWidth = 0; } @@ -362,7 +361,7 @@ protected void initSashWeights(){ if (tree > 0) { int details = getIntSetting(settings, SASH_WEIGHT_DETAILS); if (details > 0) { - fSashForm.setWeights(new int[]{tree, details}); + fSashForm.setWeights(tree, details); } } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/BreakpointsPathDecorator.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/BreakpointsPathDecorator.java index 3799f9468d5..944cc4dd3be 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/BreakpointsPathDecorator.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/BreakpointsPathDecorator.java @@ -31,8 +31,7 @@ public Image decorateImage(Image image, Object element) { @Override public String decorateText(String text, Object element) { - if (element instanceof IBreakpoint) { - IBreakpoint breakpoint = (IBreakpoint) element; + if (element instanceof IBreakpoint breakpoint) { IMarker marker = breakpoint.getMarker(); if (marker == null) { return null; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java index b94b96794d2..a596dcb07e8 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/EmbeddedBreakpointsViewer.java @@ -139,7 +139,7 @@ private void createControl(Composite parent, Object input, IStructuredSelection * Performs the initialization of the viewer from a selection */ private void initViewerState() { - fViewer.setGrayedElements(new Object[] {}); + fViewer.setGrayedElements(); fViewer.setCheckedElements(new Object[] {}); ArrayList list = new ArrayList<>(); for (Object item : fSelection.toArray()) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardExportBreakpointsPage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardExportBreakpointsPage.java index 2769fb481e9..a02d5c50913 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardExportBreakpointsPage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardExportBreakpointsPage.java @@ -117,7 +117,7 @@ private void handleSelectAllPressed() { BreakpointsViewer viewer = fTView.getViewer(); viewer.getTree().selectAll(); viewer.setCheckedElements(viewer.getStructuredSelection().toArray()); - viewer.setGrayedElements(new Object[] {}); + viewer.setGrayedElements(); viewer.getTree().deselectAll(); setPageComplete(detectPageComplete()); } @@ -128,7 +128,7 @@ private void handleSelectAllPressed() { private void handleDeselectAllPressed() { BreakpointsViewer viewer = fTView.getViewer(); viewer.setCheckedElements(new Object[] {}); - viewer.setGrayedElements(new Object[] {}); + viewer.setGrayedElements(); setPageComplete(detectPageComplete()); } @@ -292,7 +292,7 @@ else if(!path.getFileExtension().equals(IImportExportConstants.EXTENSION)) { } saveWidgetState(); if(path.toFile().exists() && !fOverwriteExistingFilesCheckbox.getSelection()) { - if (!MessageDialog.openQuestion(null, ImportExportMessages.WizardBreakpointsPage_12, MessageFormat.format(ImportExportMessages.ImportExportOperations_0, new Object[] { path.toPortableString() }))) { + if (!MessageDialog.openQuestion(null, ImportExportMessages.WizardBreakpointsPage_12, MessageFormat.format(ImportExportMessages.ImportExportOperations_0, path.toPortableString()))) { return false; } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsPage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsPage.java index 873e6a7cdcd..a7b4f33eed0 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsPage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsPage.java @@ -129,7 +129,7 @@ private boolean detectPageComplete() { } File file = new File(fileName); if (!file.exists() || file.isDirectory()) { - setMessage(MessageFormat.format(ImportExportMessages.WizardImportBreakpointsPage_1, new Object[] { fileName }), ERROR); + setMessage(MessageFormat.format(ImportExportMessages.WizardImportBreakpointsPage_1, fileName), ERROR); return false; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsSelectionPage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsSelectionPage.java index a817aea8fdb..70a90b25436 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsSelectionPage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/breakpoints/WizardImportBreakpointsSelectionPage.java @@ -154,7 +154,7 @@ private void handleSelectAllPressed() { BreakpointsViewer viewer = fTView.getViewer(); viewer.getTree().selectAll(); viewer.setCheckedElements(viewer.getStructuredSelection().toArray()); - viewer.setGrayedElements(new Object[] {}); + viewer.setGrayedElements(); viewer.getTree().deselectAll(); setErrorMessage(null); setPageComplete(true); @@ -166,7 +166,7 @@ private void handleSelectAllPressed() { private void handleDeselectAllPressed() { BreakpointsViewer viewer = fTView.getViewer(); viewer.setCheckedElements(new Object[] {}); - viewer.setGrayedElements(new Object[] {}); + viewer.setGrayedElements(); setErrorMessage(ImportExportMessages.WizardImportBreakpointsSelectionPage_1); setPageComplete(false); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java index d743c8fa40b..49854e787f2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ExportLaunchConfigurationsWizardPage.java @@ -360,14 +360,14 @@ public IStatus runInUIThread(IProgressMonitor monitor) { if (errors == null) { errors = new ArrayList<>(configs.length); } - errors.add(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), MessageFormat.format(WizardMessages.ExportLaunchConfigurationsWizardPage_19, new Object[] { launchConfig.getName() }), null)); + errors.add(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), MessageFormat.format(WizardMessages.ExportLaunchConfigurationsWizardPage_19, launchConfig.getName()), null)); } else { newfile = new File(destpath.append(file.getName()).toOSString()); if(newfile.exists() && !overwrite) { if(nowall) { continue; } - dialog = new MessageDialog(DebugUIPlugin.getShell(), WizardMessages.ExportLaunchConfigurationsWizardPage_11, null, MessageFormat.format(WizardMessages.ExportLaunchConfigurationsWizardPage_12, new Object[] { file.getName() }), MessageDialog.QUESTION, new String[] { + dialog = new MessageDialog(DebugUIPlugin.getShell(), WizardMessages.ExportLaunchConfigurationsWizardPage_11, null, MessageFormat.format(WizardMessages.ExportLaunchConfigurationsWizardPage_12, file.getName()), MessageDialog.QUESTION, new String[] { WizardMessages.ExportLaunchConfigurationsWizardPage_13, WizardMessages.ExportLaunchConfigurationsWizardPage_14, WizardMessages.ExportLaunchConfigurationsWizardPage_15, diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizardPage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizardPage.java index e234c9b5007..cf277470542 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizardPage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/importexport/launchconfigurations/ImportLaunchConfigurationsWizardPage.java @@ -180,7 +180,7 @@ public boolean finish() { dialog = new MessageDialog(DebugUIPlugin.getShell(), WizardMessages.ExportLaunchConfigurationsWizardPage_11, null, - MessageFormat.format(WizardMessages.ExportLaunchConfigurationsWizardPage_12, new Object[] { config.getName() }), + MessageFormat.format(WizardMessages.ExportLaunchConfigurationsWizardPage_12, config.getName()), MessageDialog.QUESTION, new String[] {WizardMessages.ExportLaunchConfigurationsWizardPage_13, WizardMessages.ExportLaunchConfigurationsWizardPage_14, WizardMessages.ExportLaunchConfigurationsWizardPage_15, WizardMessages.ExportLaunchConfigurationsWizardPage_16, WizardMessages.ExportLaunchConfigurationsWizardPage_17}, 0); int ret = dialog.open(); switch(ret) { @@ -308,8 +308,7 @@ protected ITreeContentProvider getFileProvider() { return new WorkbenchContentProvider() { @Override public Object[] getChildren(Object o) { - if (o instanceof DebugFileSystemElement) { - DebugFileSystemElement element = (DebugFileSystemElement) o; + if (o instanceof DebugFileSystemElement element) { return element.getFiles().getChildren(element); } return new Object[0]; @@ -322,8 +321,7 @@ protected ITreeContentProvider getFolderProvider() { return new WorkbenchContentProvider() { @Override public Object[] getChildren(Object o) { - if (o instanceof DebugFileSystemElement) { - DebugFileSystemElement element = (DebugFileSystemElement) o; + if (o instanceof DebugFileSystemElement element) { return element.getFolders().getChildren(); } return new Object[0]; @@ -331,8 +329,7 @@ public Object[] getChildren(Object o) { @Override public boolean hasChildren(Object o) { - if (o instanceof DebugFileSystemElement) { - DebugFileSystemElement element = (DebugFileSystemElement) o; + if (o instanceof DebugFileSystemElement element) { if (element.isPopulated()) { return getChildren(element).length > 0; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CompileErrorProjectPromptStatusHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CompileErrorProjectPromptStatusHandler.java index f2249ec4042..4033f600cb2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CompileErrorProjectPromptStatusHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CompileErrorProjectPromptStatusHandler.java @@ -65,12 +65,12 @@ public Object handleStatus(IStatus status, Object source) throws CoreException { } String projectMessage = null; if(projects.size() > 20) { - projectMessage = MessageFormat.format(LaunchConfigurationsMessages.CompileErrorProjectPromptStatusHandler_0, new Object[]{projectList.toString()}); + projectMessage = MessageFormat.format(LaunchConfigurationsMessages.CompileErrorProjectPromptStatusHandler_0, projectList.toString()); } else{ projectMessage = projectList.toString(); } String title = LaunchConfigurationsMessages.CompileErrorPromptStatusHandler_0; - String message = MessageFormat.format(LaunchConfigurationsMessages.CompileErrorPromptStatusHandler_2, new Object[] { projectMessage }); + String message = MessageFormat.format(LaunchConfigurationsMessages.CompileErrorPromptStatusHandler_2, projectMessage); IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore(); String pref = store.getString(IInternalDebugUIConstants.PREF_CONTINUE_WITH_COMPILE_ERROR); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CompileErrorPromptStatusHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CompileErrorPromptStatusHandler.java index 0b8e1a174f0..62594c606c2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CompileErrorPromptStatusHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CompileErrorPromptStatusHandler.java @@ -31,8 +31,7 @@ public class CompileErrorPromptStatusHandler implements IStatusHandler { @Override public Object handleStatus(IStatus status, Object source) throws CoreException { - if (source instanceof ILaunchConfiguration) { - ILaunchConfiguration config = (ILaunchConfiguration)source; + if (source instanceof ILaunchConfiguration config) { if (DebugUITools.isPrivate(config)) { return Boolean.TRUE; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationAction.java index 773612fc071..c6195ea7095 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationAction.java @@ -59,8 +59,7 @@ protected void performAction() { if(object != null) { ILaunchConfigurationType type= null; // Construct a new config of the selected type - if (object instanceof ILaunchConfiguration) { - ILaunchConfiguration config= (ILaunchConfiguration) object; + if (object instanceof ILaunchConfiguration config) { try { type = config.getType(); } catch (CoreException e) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationPrototypeAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationPrototypeAction.java index 75b35c68e51..022655c062b 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationPrototypeAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/CreateLaunchConfigurationPrototypeAction.java @@ -61,8 +61,7 @@ protected void performAction() { if (object != null) { ILaunchConfigurationType type = null; // Construct a new configuration prototype of the selected type - if (object instanceof ILaunchConfiguration) { - ILaunchConfiguration config = (ILaunchConfiguration) object; + if (object instanceof ILaunchConfiguration config) { try { type = config.getType(); } catch (CoreException e) { @@ -103,8 +102,7 @@ protected boolean updateSelection(IStructuredSelection selection) { if (object != null) { ILaunchConfigurationType type = null; // Construct a new configuration prototype of the selected type - if (object instanceof ILaunchConfiguration) { - ILaunchConfiguration config = (ILaunchConfiguration) object; + if (object instanceof ILaunchConfiguration config) { try { type = config.getType(); } catch (CoreException e) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DebugModePromptStatusHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DebugModePromptStatusHandler.java index 3c98f5dcff6..2049b22ae88 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DebugModePromptStatusHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DebugModePromptStatusHandler.java @@ -31,8 +31,7 @@ public class DebugModePromptStatusHandler implements IStatusHandler { @Override public Object handleStatus(IStatus status, Object source) throws CoreException { - if (source instanceof ILaunchConfiguration) { - ILaunchConfiguration config = (ILaunchConfiguration)source; + if (source instanceof ILaunchConfiguration config) { if (DebugUITools.isPrivate(config)) { return Boolean.FALSE; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DuplicateLaunchDelegatesStatusHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DuplicateLaunchDelegatesStatusHandler.java index 9729e2f4fef..701c2354232 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DuplicateLaunchDelegatesStatusHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/DuplicateLaunchDelegatesStatusHandler.java @@ -41,8 +41,7 @@ public class DuplicateLaunchDelegatesStatusHandler implements IStatusHandler { */ @Override public Object handleStatus(IStatus status, Object source) throws CoreException { - if(source instanceof Object[]) { - Object[] infos = (Object[]) source; + if(source instanceof Object[] infos) { if(infos.length == 2) { ILaunchConfiguration config = (ILaunchConfiguration) infos[0]; String mode = (String) infos[1]; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/EnvironmentVariable.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/EnvironmentVariable.java index 52c7784f3a3..29caad0468f 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/EnvironmentVariable.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/EnvironmentVariable.java @@ -78,8 +78,7 @@ public String toString() { @Override public boolean equals(Object obj) { boolean equal = false; - if (obj instanceof EnvironmentVariable) { - EnvironmentVariable var = (EnvironmentVariable)obj; + if (obj instanceof EnvironmentVariable var) { equal = var.getName().equals(name); } return equal; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/FavoritesDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/FavoritesDialog.java index 54246765853..f0e07f82662 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/FavoritesDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/FavoritesDialog.java @@ -226,7 +226,7 @@ protected TableViewer getFavoritesTable() { @Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); - getShell().setText(MessageFormat.format(LaunchConfigurationsMessages.FavoritesDialog_1, new Object[] { getModeLabel() })); + getShell().setText(MessageFormat.format(LaunchConfigurationsMessages.FavoritesDialog_1, getModeLabel())); createFavoritesArea(composite); handleFavoriteSelectionChanged(); return composite; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationComparator.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationComparator.java index f064ec2af7b..0fe10048956 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationComparator.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationComparator.java @@ -44,8 +44,7 @@ public class LaunchConfigurationComparator extends WorkbenchViewerComparator { @Override public int category(Object element) { Map map = getCategories(); - if (element instanceof ILaunchConfiguration) { - ILaunchConfiguration configuration = (ILaunchConfiguration) element; + if (element instanceof ILaunchConfiguration configuration) { try { Integer i = map.get(configuration.getType()); if (i != null) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationFilteredTree.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationFilteredTree.java index 56208ef1617..47fe7b94b67 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationFilteredTree.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationFilteredTree.java @@ -185,8 +185,7 @@ else if(text.equals(getInitialText())) { public String computeContextId() { try { ISelection selection = getViewer().getSelection(); - if (!selection.isEmpty() && selection instanceof IStructuredSelection ) { - IStructuredSelection structuredSelection = (IStructuredSelection) selection; + if (!selection.isEmpty() && selection instanceof IStructuredSelection structuredSelection ) { Object firstSelected = structuredSelection.getFirstElement(); ILaunchConfigurationType configType = null; if (firstSelected instanceof ILaunchConfigurationType) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java index 76aa9964c98..377f3edeb43 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationManager.java @@ -936,8 +936,7 @@ public ILaunchConfiguration getMRUConfiguration(List confi * @since 3.3 */ public ILaunchConfiguration isSharedConfig(Object receiver) { - if(receiver instanceof IFile) { - IFile file = (IFile) receiver; + if(receiver instanceof IFile file) { String ext = file.getFileExtension(); if(ext == null) { return null; @@ -949,8 +948,7 @@ public ILaunchConfiguration isSharedConfig(Object receiver) { } } } - else if(receiver instanceof IFileEditorInput) { - IFileEditorInput input = (IFileEditorInput) receiver; + else if(receiver instanceof IFileEditorInput input) { return isSharedConfig(input.getFile()); } else if(receiver instanceof IEditorPart) { @@ -1188,7 +1186,7 @@ public void saving(ISaveContext context) throws CoreException { /** * Sets the given launch to be the most recent launch in the launch * history (for applicable histories). - * + * * @param launch the launch to prepend to its associated histories * @since 3.3 */ diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPropertiesDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPropertiesDialog.java index 9a0b49eb647..2d095338330 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPropertiesDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPropertiesDialog.java @@ -92,8 +92,7 @@ protected void initializeBounds() { @Override protected void initializeContent() { ILaunchConfiguration launchConfiguration = getLaunchConfiguration(); - if (shouldSetDefaultsOnOpen() && launchConfiguration instanceof ILaunchConfigurationWorkingCopy) { - ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) launchConfiguration; + if (shouldSetDefaultsOnOpen() && launchConfiguration instanceof ILaunchConfigurationWorkingCopy wc) { doSetDefaults(wc); } getTabViewer().setInput(launchConfiguration); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabImageDescriptor.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabImageDescriptor.java index 4e987d8810c..de2199b1a83 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabImageDescriptor.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabImageDescriptor.java @@ -61,11 +61,10 @@ protected Point getSize() { */ @Override public boolean equals(Object object) { - if (!(object instanceof LaunchConfigurationTabImageDescriptor)){ + if (!(object instanceof LaunchConfigurationTabImageDescriptor other)){ return false; } - LaunchConfigurationTabImageDescriptor other= (LaunchConfigurationTabImageDescriptor)object; return (getBaseImage().equals(other.getBaseImage()) && getFlags() == other.getFlags()); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTreeContentProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTreeContentProvider.java index c09d469bfe8..63c8a71f6e0 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTreeContentProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTreeContentProvider.java @@ -85,9 +85,8 @@ public Object[] getChildren(Object parentElement) { if (((ILaunchConfiguration) parentElement).isPrototype()) { return ((ILaunchConfiguration) parentElement).getPrototypeChildren().toArray(); } - } else if (parentElement instanceof ILaunchConfigurationType) { + } else if (parentElement instanceof ILaunchConfigurationType type) { List configs = new ArrayList<>(); - ILaunchConfigurationType type = (ILaunchConfigurationType) parentElement; ILaunchConfiguration[] launchConfigurations = getLaunchManager().getLaunchConfigurations(type, ILaunchConfiguration.CONFIGURATION); for (ILaunchConfiguration launchConfig : launchConfigurations) { if (launchConfig.getPrototype() == null) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java index 31414eeb4f8..3e3d1270ad1 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationView.java @@ -456,9 +456,7 @@ public Viewer getViewer() { */ public void updateFilterLabel() { LaunchConfigurationViewer viewer = (LaunchConfigurationViewer) getViewer(); - fFilteredNotice.setText(MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationView_0, new Object[] { - Integer.toString(viewer.getNonFilteredChildCount()), - Integer.toString(viewer.getTotalChildCount()) })); + fFilteredNotice.setText(MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationView_0, Integer.toString(viewer.getNonFilteredChildCount()), Integer.toString(viewer.getTotalChildCount()))); } /** diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java index 5735e0ba9d6..e0a97b6c1f3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsDialog.java @@ -927,7 +927,7 @@ public Object getSelectedPage() { protected String getShellTitle() { String title = null; if(getLaunchGroup() != null) { - title = MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationsDialog_configurations, new Object[] { DebugUIPlugin.removeAccelerators(getLaunchGroup().getLabel()) }); + title = MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationsDialog_configurations, DebugUIPlugin.removeAccelerators(getLaunchGroup().getLabel())); } if (title == null) { title = LaunchConfigurationsMessages.LaunchConfigurationDialog_Launch_Configurations_18; @@ -1121,7 +1121,7 @@ protected void initializeBounds() { w1 = DEFAULT_SASH_WEIGHTS[0]; w2 = DEFAULT_SASH_WEIGHTS[1]; } - fSashForm.setWeights(new int[] {w1, w2}); + fSashForm.setWeights(w1, w2); } super.initializeBounds(); } @@ -1165,8 +1165,7 @@ protected void initializeContent() { if(fSetDefaultOnOpen) { try { Object o = fInitialSelection.getFirstElement(); - if(o instanceof ILaunchConfigurationWorkingCopy) { - ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) o; + if(o instanceof ILaunchConfigurationWorkingCopy wc) { doSetDefaults(wc); setInitialSelection(new StructuredSelection(wc.doSave())); } @@ -1549,7 +1548,7 @@ protected void setTabViewer(LaunchConfigurationTabGroupViewer viewer) { * IDialogConstants. */ private int showDiscardChangesDialog() { - StringBuilder buffer = new StringBuilder(MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationDialog_The_configuration___35, new Object[] { fTabViewer.getWorkingCopy().getName() })); + StringBuilder buffer = new StringBuilder(MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationDialog_The_configuration___35, fTabViewer.getWorkingCopy().getName())); buffer.append(fTabViewer.getErrorMesssage()); buffer.append(LaunchConfigurationsMessages.LaunchConfigurationDialog_Do_you_wish_to_discard_changes_37); MessageDialog dialog = new MessageDialog(getShell(), @@ -1587,7 +1586,7 @@ private int showDiscardChangesDialog() { * IDialogConstants. */ private int showSaveChangesDialog() { - String message = MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationDialog_The_configuration___29, new Object[] { fTabViewer.getWorkingCopy().getName() }); + String message = MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationDialog_The_configuration___29, fTabViewer.getWorkingCopy().getName()); MessageDialog dialog = new MessageDialog(getShell(), LaunchConfigurationsMessages.LaunchConfigurationFilteredTree_save_changes, null, diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchDelegateNotAvailableHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchDelegateNotAvailableHandler.java index aa527d9e62e..29d89561959 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchDelegateNotAvailableHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchDelegateNotAvailableHandler.java @@ -36,8 +36,7 @@ public class LaunchDelegateNotAvailableHandler implements IStatusHandler { */ @Override public Object handleStatus(IStatus status, Object source) throws CoreException { - if(source instanceof Object[]) { - Object[] infos = (Object[]) source; + if(source instanceof Object[] infos) { if(infos.length == 2) { final ILaunchConfiguration config = (ILaunchConfiguration) infos[0]; final String mode = (String) infos[1]; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutSelectionDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutSelectionDialog.java index 314f2b7e73f..0488c7f09b0 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutSelectionDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchShortcutSelectionDialog.java @@ -63,7 +63,7 @@ public LaunchShortcutSelectionDialog(List shortcuts, IR if (lmode != null) { fModeName = DebugUIPlugin.removeAccelerators(lmode.getLabel()); } - setTitle(MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_0, new Object[] { fModeName })); + setTitle(MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_0, fModeName)); } @Override @@ -107,11 +107,10 @@ protected Object getViewerInput() { @Override protected String getViewerLabel() { if(fResource == null) { - return MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_4, new Object[] { fModeName.toLowerCase() }); + return MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_4, fModeName.toLowerCase()); } else { - return MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_1, new Object[] { - fModeName.toLowerCase(), fResource.getName() }); + return MessageFormat.format(LaunchConfigurationsMessages.LaunchShortcutSelectionDialog_1, fModeName.toLowerCase(), fResource.getName()); } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java index 1ddc66881c1..af3b554c893 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java @@ -133,8 +133,7 @@ public boolean equals(Object object) { } catch (CoreException e) {return false;} } - else if(object instanceof PerspectiveContext) { - PerspectiveContext context = (PerspectiveContext) object; + else if(object instanceof PerspectiveContext context) { type = context.getLaunchConfigurationType(); delegate = context.getLaunchDelegate(); } @@ -385,7 +384,7 @@ protected void switchToPerspective(IWorkbenchWindow window, String id) { } catch (WorkbenchException e) { DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), LaunchConfigurationsMessages.PerspectiveManager_Error_1, - MessageFormat.format(LaunchConfigurationsMessages.PerspectiveManager_Unable_to_switch_to_perspective___0__2, new Object[] { id }), + MessageFormat.format(LaunchConfigurationsMessages.PerspectiveManager_Unable_to_switch_to_perspective___0__2, id), e); } } @@ -420,7 +419,7 @@ protected void sync(Runnable r) { protected void switchFailed(final Throwable t, final String launchName) { sync(() -> DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), LaunchConfigurationsMessages.PerspectiveManager_Error_1, - MessageFormat.format(LaunchConfigurationsMessages.PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4, new Object[] { launchName }), + MessageFormat.format(LaunchConfigurationsMessages.PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4, launchName), t)); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SaveScopeResourcesHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SaveScopeResourcesHandler.java index 0207a786143..567a608a2a1 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SaveScopeResourcesHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SaveScopeResourcesHandler.java @@ -162,8 +162,7 @@ public Object handleStatus(IStatus status, Object source) throws CoreException { // retrieve config and projects ILaunchConfiguration config = null; IProject[] projects = null; - if (source instanceof Object[]) { - Object[] objects = (Object[]) source; + if (source instanceof Object[] objects) { if (objects.length == 2) { config = (ILaunchConfiguration) objects[0]; projects = (IProject[]) objects[1]; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectFavoritesDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectFavoritesDialog.java index 03666269bfa..7d30df67c06 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectFavoritesDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/SelectFavoritesDialog.java @@ -80,7 +80,7 @@ public SelectFavoritesDialog(Shell parentShell, LaunchHistory history, List> configPathMap = new HashMap<>(); for (Object element : elements) { - if (element instanceof ILaunchConfiguration) { - ILaunchConfiguration config = (ILaunchConfiguration) element; - + if (element instanceof ILaunchConfiguration config) { String path = toLaunchFileLocation(config); if (!configPathMap.containsKey(path)) { configPathMap.put(path, new ArrayList<>()); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/WorkingSetsFilter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/WorkingSetsFilter.java index 9e2234c09a9..8998cc511b3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/WorkingSetsFilter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/WorkingSetsFilter.java @@ -41,8 +41,7 @@ public boolean select(Viewer viewer, Object parentElement, Object element) { if(element instanceof ILaunchConfigurationType) { return true; } - if(element instanceof ILaunchConfiguration) { - ILaunchConfiguration config = (ILaunchConfiguration)element; + if(element instanceof ILaunchConfiguration config) { try { IResource[] resources = config.getMappedResources(); if(resources == null) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java index ab281b9ebcd..e38ebe469a8 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/memory/provisional/AbstractAsyncTableRendering.java @@ -351,8 +351,7 @@ public boolean contains(ISchedulingRule rule) { @Override public boolean isConflicting(ISchedulingRule rule) { - if (rule instanceof SerialByObjectRule) { - SerialByObjectRule rRule = (SerialByObjectRule) rule; + if (rule instanceof SerialByObjectRule rRule) { return fObject == rRule.fObject; } return false; @@ -1017,8 +1016,7 @@ public void propertyChange(PropertyChangeEvent event) { return; } - if (evtSrc instanceof IMemoryRendering) { - IMemoryRendering rendering = (IMemoryRendering) evtSrc; + if (evtSrc instanceof IMemoryRendering rendering) { IMemoryBlock memoryBlock = rendering.getMemoryBlock(); // do not handle event from renderings displaying other memory @@ -1590,8 +1588,7 @@ private boolean isAtTopLimit() { if (model != null) { Object key = model.getKey(0); - if (key instanceof BigInteger) { - BigInteger startBufferAddress = (BigInteger) key; + if (key instanceof BigInteger startBufferAddress) { startBufferAddress = MemoryViewUtil.alignToBoundary(startBufferAddress, getAddressableUnitPerLine()); if (startAddress.compareTo(startBufferAddress) == 0) { @@ -1610,8 +1607,7 @@ private boolean isAtBottomLimit() { if (model != null) { int numElements = model.getElements().length; Object key = model.getKey(numElements - 1); - if (key instanceof BigInteger) { - BigInteger endBufferAddress = (BigInteger) key; + if (key instanceof BigInteger endBufferAddress) { endBufferAddress = MemoryViewUtil.alignToBoundary(endBufferAddress, getAddressableUnitPerLine()); if (endAddress.compareTo(endBufferAddress) == 0) { @@ -1996,11 +1992,10 @@ public MemoryByte[] getSelectedAsBytes() { return new MemoryByte[0]; } - if (!(element instanceof MemorySegment)) { + if (!(element instanceof MemorySegment line)) { return new MemoryByte[0]; } - MemorySegment line = (MemorySegment) element; int offset = (col - 1) * (getAddressableUnitPerColumn() * getAddressableSize()); // make a copy of the bytes to ensure that data cannot be changed @@ -2818,9 +2813,7 @@ protected void toolTipAboutToShow(Control toolTipControl, TableItem item, int co Object address = fTableViewer.getKey(fTableViewer.getTable().indexOf(item), col); if (address != null && address instanceof BigInteger) { Object data = item.getData(); - if (data instanceof MemorySegment) { - MemorySegment line = (MemorySegment) data; - + if (data instanceof MemorySegment line) { if (col > 0) { int start = (col - 1) * getBytesPerColumn(); int end = start + getBytesPerColumn(); @@ -3052,7 +3045,7 @@ private void showGoToAddressComposite() { double tableWeight = (tableHeight / canvasHeight) * 100; double textWeight = (height / canvasHeight) * 100; - fSashForm.setWeights(new int[] { (int) tableWeight, (int) textWeight }); + fSashForm.setWeights((int) tableWeight, (int) textWeight); fSashForm.setMaximizedControl(null); fGoToAddressComposite.getExpressionWidget().setFocus(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointContainerLabelProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointContainerLabelProvider.java index f3f2530ddb0..7006154f194 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointContainerLabelProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointContainerLabelProvider.java @@ -50,8 +50,7 @@ protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentation @Override public boolean getChecked(TreePath path, IPresentationContext presentationContext) throws CoreException { Object lastSegment = path.getLastSegment(); - if (lastSegment instanceof IBreakpointContainer) { - IBreakpointContainer container = (IBreakpointContainer) lastSegment; + if (lastSegment instanceof IBreakpointContainer container) { for (IBreakpoint breakpoint : container.getBreakpoints()) { if (breakpoint.isEnabled()) { return true; @@ -67,9 +66,7 @@ public boolean getChecked(TreePath path, IPresentationContext presentationContex @Override public boolean getGrayed(TreePath path, IPresentationContext presentationContext) throws CoreException { Object lastSegment = path.getLastSegment(); - if (lastSegment instanceof IBreakpointContainer) { - IBreakpointContainer container = (IBreakpointContainer) lastSegment; - + if (lastSegment instanceof IBreakpointContainer container) { // Return true, gray if some breakpoints are enabled and some are disabled. // return false if all breakpoints are either disabled or all are enabled. boolean hasEnabled = false; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointContainerMementoProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointContainerMementoProvider.java index e51601ef465..e79ebdef007 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointContainerMementoProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointContainerMementoProvider.java @@ -29,8 +29,7 @@ public class BreakpointContainerMementoProvider extends DebugElementMementoProvi @Override protected String getElementName(Object element, IPresentationContext context) throws CoreException { - if (element instanceof IBreakpointContainer) { - IBreakpointContainer container = (IBreakpointContainer) element; + if (element instanceof IBreakpointContainer container) { IAdaptable category = container.getCategory(); if (category != null) { IWorkbenchAdapter adapter = category.getAdapter(IWorkbenchAdapter.class); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointManagerContentProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointManagerContentProvider.java index 8eedb18d409..e127d59a9ee 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointManagerContentProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointManagerContentProvider.java @@ -441,8 +441,7 @@ private boolean buildTrackSelectionDelta(ModelDelta delta, BreakpointContainer c delta.setChildCount(children.length); for (int i = 0; i < children.length; i++) { ModelDelta childDelta = delta.addNode(children[i], i, IModelDelta.NO_CHANGE); - if (children[i] instanceof BreakpointContainer) { - BreakpointContainer childContainer = (BreakpointContainer)children[i]; + if (children[i] instanceof BreakpointContainer childContainer) { boolean containsBP = false; for (IBreakpoint containerBP : childContainer.getBreakpoints()) { if (breakpoints.contains(containerBP)) { @@ -973,8 +972,7 @@ protected boolean supportsContextId(String id) { @Override protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { Object input = monitor.getViewerInput(); - if (input instanceof DefaultBreakpointsViewInput) { - DefaultBreakpointsViewInput bpManagerInput = (DefaultBreakpointsViewInput)input; + if (input instanceof DefaultBreakpointsViewInput bpManagerInput) { InputData inputData = getInputData(bpManagerInput); if (inputData != null) { return inputData.fContainer.getChildren().length; @@ -986,8 +984,7 @@ protected int getChildCount(Object element, IPresentationContext context, IViewe @Override protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException { Object input = monitor.getViewerInput(); - if (input instanceof DefaultBreakpointsViewInput) { - DefaultBreakpointsViewInput bpManagerInput = (DefaultBreakpointsViewInput)input; + if (input instanceof DefaultBreakpointsViewInput bpManagerInput) { InputData inputData = getInputData(bpManagerInput); if (inputData != null) { Object[] children = inputData.fContainer.getChildren(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointMementoProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointMementoProvider.java index 1d2f3d418e4..8ac91f7d6d0 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointMementoProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/BreakpointMementoProvider.java @@ -66,8 +66,7 @@ protected boolean encodeElement(Object element, IMemento memento, IPresentationC @Override protected boolean isEqual(Object element, IMemento memento, IPresentationContext context) throws CoreException { - if (element instanceof IBreakpoint) { - IBreakpoint breakpoint =(IBreakpoint)element; + if (element instanceof IBreakpoint breakpoint) { IMarker marker = breakpoint.getMarker(); long markerId = marker.getId(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugElementLabelProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugElementLabelProvider.java index 9fbb033e396..3ad4279db90 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugElementLabelProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/DebugElementLabelProvider.java @@ -34,8 +34,7 @@ public class DebugElementLabelProvider extends ElementLabelProvider { @Override protected String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { Object element = elementPath.getLastSegment(); - if (presentationContext instanceof DebugModelPresentationContext) { - DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext; + if (presentationContext instanceof DebugModelPresentationContext debugContext) { return debugContext.getModelPresentation().getText(element); } return DebugElementHelper.getLabel(element); @@ -44,8 +43,7 @@ protected String getLabel(TreePath elementPath, IPresentationContext presentatio @Override protected RGB getBackground(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { Object element = elementPath.getLastSegment(); - if (presentationContext instanceof DebugModelPresentationContext) { - DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext; + if (presentationContext instanceof DebugModelPresentationContext debugContext) { return DebugElementHelper.getBackground(element, debugContext.getModelPresentation()); } return DebugElementHelper.getBackground(element); @@ -54,8 +52,7 @@ protected RGB getBackground(TreePath elementPath, IPresentationContext presentat @Override protected FontData getFontData(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { Object element = elementPath.getLastSegment(); - if (presentationContext instanceof DebugModelPresentationContext) { - DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext; + if (presentationContext instanceof DebugModelPresentationContext debugContext) { return DebugElementHelper.getFont(element, debugContext.getModelPresentation()); } @@ -65,8 +62,7 @@ protected FontData getFontData(TreePath elementPath, IPresentationContext presen @Override protected RGB getForeground(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { Object element = elementPath.getLastSegment(); - if (presentationContext instanceof DebugModelPresentationContext) { - DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext; + if (presentationContext instanceof DebugModelPresentationContext debugContext) { return DebugElementHelper.getForeground(element, debugContext.getModelPresentation()); } return DebugElementHelper.getForeground(element); @@ -75,8 +71,7 @@ protected RGB getForeground(TreePath elementPath, IPresentationContext presentat @Override protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { Object element = elementPath.getLastSegment(); - if (presentationContext instanceof DebugModelPresentationContext) { - DebugModelPresentationContext debugContext = (DebugModelPresentationContext) presentationContext; + if (presentationContext instanceof DebugModelPresentationContext debugContext) { return DebugElementHelper.getImageDescriptor(element, debugContext.getModelPresentation()); } return DebugElementHelper.getImageDescriptor(element); @@ -90,8 +85,7 @@ protected ImageDescriptor getImageDescriptor(TreePath elementPath, IPresentation * @return debug model presentation or null */ protected IDebugModelPresentation getModelPresentation(IPresentationContext context, String modelId) { - if (context instanceof DebugModelPresentationContext) { - DebugModelPresentationContext debugContext = (DebugModelPresentationContext) context; + if (context instanceof DebugModelPresentationContext debugContext) { IDebugModelPresentation presentation = debugContext.getModelPresentation(); if (presentation instanceof DelegatingModelPresentation) { return ((DelegatingModelPresentation)presentation).getPresentation(modelId); @@ -105,11 +99,9 @@ protected boolean requiresUIJob(ILabelUpdate[] updates) { if (updates.length > 0) { ILabelUpdate update = updates[0]; IPresentationContext context = update.getPresentationContext(); - if (context instanceof DebugModelPresentationContext) { - DebugModelPresentationContext debugContext = (DebugModelPresentationContext) context; + if (context instanceof DebugModelPresentationContext debugContext) { IDebugModelPresentation presentation = debugContext.getModelPresentation(); - if (presentation instanceof IDebugModelPresentationExtension) { - IDebugModelPresentationExtension extension = (IDebugModelPresentationExtension) presentation; + if (presentation instanceof IDebugModelPresentationExtension extension) { for (ILabelUpdate u : updates) { if (extension.requiresUIThread(u.getElement())) { return true; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionContentProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionContentProvider.java index 11e379da427..a888232bc3a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionContentProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionContentProvider.java @@ -172,8 +172,7 @@ private void findDelegates(Map> del @Override protected Object[] getAllChildren(Object parent, IPresentationContext context) throws CoreException { - if (parent instanceof IErrorReportingExpression) { - IErrorReportingExpression expression = (IErrorReportingExpression) parent; + if (parent instanceof IErrorReportingExpression expression) { if (expression.hasErrors()) { String[] messages = expression.getErrorMessages(); LinkedHashSet set = new LinkedHashSet<>(messages.length); @@ -183,8 +182,7 @@ protected Object[] getAllChildren(Object parent, IPresentationContext context) t return set.toArray(); } } - if (parent instanceof IExpression) { - IExpression expression = (IExpression) parent; + if (parent instanceof IExpression expression) { IValue value = expression.getValue(); if (value != null) { return getValueChildren(expression, value, context); @@ -195,8 +193,7 @@ protected Object[] getAllChildren(Object parent, IPresentationContext context) t @Override protected boolean hasChildren(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - if (element instanceof IErrorReportingExpression) { - IErrorReportingExpression expression = (IErrorReportingExpression) element; + if (element instanceof IErrorReportingExpression expression) { if (expression.hasErrors()) { return true; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionLabelProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionLabelProvider.java index 371689c8d0b..be2ea36b977 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionLabelProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ExpressionLabelProvider.java @@ -34,8 +34,7 @@ public class ExpressionLabelProvider extends VariableLabelProvider { @Override protected RGB getForeground(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { Object element = elementPath.getLastSegment(); - if (element instanceof IErrorReportingExpression) { - IErrorReportingExpression expression = (IErrorReportingExpression) element; + if (element instanceof IErrorReportingExpression expression) { if (expression.hasErrors()) { if (columnId == null || columnId.equals(IDebugUIConstants.COLUMN_ID_VARIABLE_VALUE)) { return new RGB(255, 0, 0); @@ -141,8 +140,7 @@ private String getWatchExpressionName(IWatchExpression expression, IPresentation * @since 3.6 */ protected String getExpressionValueText(IExpression expression, IValue value, IPresentationContext context) throws CoreException { - if (expression instanceof IWatchExpression) { - IWatchExpression watchExpression = (IWatchExpression)expression; + if (expression instanceof IWatchExpression watchExpression) { StringBuilder result = new StringBuilder(); if (watchExpression.isPending() && value == null) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryBlockContentProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryBlockContentProvider.java index ff3d2905e5a..6251ec0d25a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryBlockContentProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryBlockContentProvider.java @@ -47,8 +47,9 @@ protected Object[] getChildren(Object parent, int index, int length, @Override protected boolean supportsContextId(String id) { - if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) + if (id.equals(IDebugUIConstants.ID_MEMORY_VIEW)) { return true; + } return false; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryBlockLabelProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryBlockLabelProvider.java index 948abad4459..3c55563d8eb 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryBlockLabelProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryBlockLabelProvider.java @@ -30,8 +30,9 @@ protected String getLabel(TreePath elementPath, throws CoreException { Object element = elementPath.getLastSegment(); - if (element instanceof IMemoryBlock) + if (element instanceof IMemoryBlock) { return getLabel((IMemoryBlock)element); + } return super.getLabel(elementPath, presentationContext, columnId); } @@ -43,8 +44,9 @@ protected ImageDescriptor getImageDescriptor(TreePath elementPath, Object element = elementPath.getLastSegment(); - if (element instanceof IMemoryBlock) + if (element instanceof IMemoryBlock) { return DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_OBJS_VARIABLE); + } return super.getImageDescriptor(elementPath, presentationContext, columnId); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryRetrievalContentProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryRetrievalContentProvider.java index e1736535b5f..f4de259b1dd 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryRetrievalContentProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryRetrievalContentProvider.java @@ -48,8 +48,9 @@ private Object[] getAllChildren(Object parent, IPresentationContext context) { { if (parent instanceof IMemoryBlockRetrieval) { - if (((IMemoryBlockRetrieval)parent).supportsStorageRetrieval()) + if (((IMemoryBlockRetrieval)parent).supportsStorageRetrieval()) { return DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks((IMemoryBlockRetrieval)parent); + } } } return EMPTY; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryViewElementMementoProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryViewElementMementoProvider.java index fc33fb3591a..a28d2490987 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryViewElementMementoProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/MemoryViewElementMementoProvider.java @@ -48,8 +48,9 @@ protected boolean isEqual(Object element, IMemento memento, if (element instanceof IMemoryBlock || element instanceof IMemoryBlockRetrieval) { Integer objectId = memento.getInteger(OBJECT_ID); - if (objectId != null && objectId.intValue() == element.hashCode()) + if (objectId != null && objectId.intValue() == element.hashCode()) { return true; + } } } return false; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameContentProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameContentProvider.java index 2b022749862..5d005905d63 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameContentProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameContentProvider.java @@ -42,9 +42,8 @@ protected Object[] getChildren(Object parent, int index, int length, IPresentati * @return the collection of children, or an empty collection, never null */ protected Object[] getAllChildren(Object parent, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - if (parent instanceof IStackFrame) { + if (parent instanceof IStackFrame frame) { String id = context.getId(); - IStackFrame frame = (IStackFrame) parent; if (id.equals(IDebugUIConstants.ID_VARIABLE_VIEW)) { return frame.getVariables(); } else if (id.equals(IDebugUIConstants.ID_REGISTER_VIEW)) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameMementoProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameMementoProvider.java index 3a969c280c4..e6122395cf7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameMementoProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/StackFrameMementoProvider.java @@ -27,8 +27,7 @@ public class StackFrameMementoProvider extends DebugElementMementoProvider { @Override protected String getElementName(Object element, IPresentationContext context) throws CoreException { - if (element instanceof IStackFrame) { - IStackFrame frame = (IStackFrame) element; + if (element instanceof IStackFrame frame) { if (IDebugUIConstants.ID_REGISTER_VIEW.equals(context.getId())) { // for registers view attempt to maintain expansion for target rather than each frame return frame.getModelIdentifier(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableContentProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableContentProvider.java index f4e93c032db..f15101d0070 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableContentProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableContentProvider.java @@ -126,8 +126,7 @@ protected Object[] getValueChildren(IDebugElement parent, IValue value, IPresent return EMPTY; } IValue logicalValue = getLogicalValue(value, context); - if (logicalValue instanceof IIndexedValue) { - IIndexedValue indexedValue = (IIndexedValue) logicalValue; + if (logicalValue instanceof IIndexedValue indexedValue) { int partitionSize = computeParitionSize(indexedValue); if (partitionSize > 1) { int offset = indexedValue.getInitialOffset(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableLabelProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableLabelProvider.java index 576996b641a..f6dfc3c8129 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableLabelProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableLabelProvider.java @@ -37,8 +37,7 @@ public class VariableLabelProvider extends DebugElementLabelProvider { protected RGB getBackground(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { Object element = elementPath.getLastSegment(); if (columnId != null) { - if (element instanceof IVariable) { - IVariable variable = (IVariable) element; + if (element instanceof IVariable variable) { if (variable.hasValueChanged()) { return DebugUIPlugin.getPreferenceColor(IDebugUIConstants.PREF_CHANGED_VALUE_BACKGROUND).getRGB(); } @@ -51,8 +50,7 @@ protected RGB getBackground(TreePath elementPath, IPresentationContext presentat protected RGB getForeground(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException { Object element = elementPath.getLastSegment(); if (columnId == null) { - if (element instanceof IVariable) { - IVariable variable = (IVariable) element; + if (element instanceof IVariable variable) { if (variable.hasValueChanged()) { return DebugUIPlugin.getPreferenceColor(IDebugUIConstants.PREF_CHANGED_DEBUG_ELEMENT_COLOR).getRGB(); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchPerspectivePreferencePage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchPerspectivePreferencePage.java index 41aae30b9ae..3784a59e33d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchPerspectivePreferencePage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchPerspectivePreferencePage.java @@ -98,8 +98,7 @@ public Set getModes() { } @Override public boolean equals(Object o) { - if(o instanceof PerspectiveChange) { - PerspectiveChange change = (PerspectiveChange) o; + if(o instanceof PerspectiveChange change) { return change.getDelegate() == fDelegate && change.getType().equals(fType) && change.getModes().equals(fModes); @@ -130,8 +129,7 @@ public PerspectivesTreeViewer(Tree tree) { static final class PerspectiveContentProvider implements ITreeContentProvider { @Override public Object[] getChildren(Object parentElement) { - if(parentElement instanceof ILaunchConfigurationType) { - ILaunchConfigurationType type = (ILaunchConfigurationType) parentElement; + if(parentElement instanceof ILaunchConfigurationType type) { return ((LaunchManager)DebugPlugin.getDefault().getLaunchManager()).getLaunchDelegates(type.getIdentifier()); } return new Object[0]; @@ -216,8 +214,7 @@ public void widgetDefaultSelected(SelectionEvent e) {} @Override public void widgetSelected(SelectionEvent e) { Object o = e.getSource(); - if(o instanceof Combo) { - Combo combo = (Combo) o; + if(o instanceof Combo combo) { LaunchDelegate delegate = null; ILaunchConfigurationType type = null; PerspectiveChange change = null; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchersPreferencePage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchersPreferencePage.java index 77f4c36c436..6ff7b3ad2f5 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchersPreferencePage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchersPreferencePage.java @@ -97,8 +97,7 @@ public String getText(Object element) { if(element instanceof ILaunchConfigurationType) { return super.getText(element); } - else if(element instanceof DuplicateDelegate) { - DuplicateDelegate dd = (DuplicateDelegate) element; + else if(element instanceof DuplicateDelegate dd) { return LaunchConfigurationPresentationManager.getDefault().getLaunchModeNames(dd.getModeSet()).toString(); } else if(element instanceof ILaunchDelegate){ @@ -114,8 +113,7 @@ else if(element instanceof ILaunchDelegate){ class TreeProvider implements ITreeContentProvider { @Override public Object[] getChildren(Object parentElement) { - if(parentElement instanceof ILaunchConfigurationType) { - ILaunchConfigurationType type = (ILaunchConfigurationType) parentElement; + if(parentElement instanceof ILaunchConfigurationType type) { Set dupes = fDuplicates.get(type); if(dupes != null) { return dupes.toArray(); @@ -188,9 +186,8 @@ protected Control createContents(Composite parent) { fTreeViewer.expandToLevel(2); fTreeViewer.addSelectionChangedListener(event -> { Object obj = event.getStructuredSelection().getFirstElement(); - if(obj instanceof DuplicateDelegate) { + if(obj instanceof DuplicateDelegate dd) { fTableViewer.setAllChecked(false); - DuplicateDelegate dd = (DuplicateDelegate) obj; fTableViewer.setInput(dd.getDelegates()); fTableViewer.setSelection(null); obj = fDupeSelections.get(dd); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchingPreferencePage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchingPreferencePage.java index 39957a3308a..d15ca46fb4a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchingPreferencePage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/LaunchingPreferencePage.java @@ -128,7 +128,7 @@ protected Control createContents(Composite parent) { addField(editor); int historyMax = IDebugPreferenceConstants.MAX_LAUNCH_HISTORY_SIZE; editor.setTextLimit(Integer.toString(historyMax).length()); - editor.setErrorMessage(MessageFormat.format(DebugPreferencesMessages.DebugPreferencePage_11, new Object[] { Integer.valueOf(1), Integer.valueOf(historyMax)})); + editor.setErrorMessage(MessageFormat.format(DebugPreferencesMessages.DebugPreferencePage_11, Integer.valueOf(1), Integer.valueOf(historyMax))); editor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_KEY_STROKE); editor.setValidRange(1, historyMax); editor.setEmptyStringAllowed(false); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java index dafd071b2f3..ed5bb0c78de 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/RunDebugPropertiesPage.java @@ -108,7 +108,7 @@ protected Control createContents(Composite parent) { SWTFactory.createWrapLabel(topComposite, DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_0, 2, 300); SWTFactory.createVerticalSpacer(topComposite, 2); - SWTFactory.createWrapLabel(topComposite, MessageFormat.format(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_1, new Object[] { getResource().getName() }), 2, 300); + SWTFactory.createWrapLabel(topComposite, MessageFormat.format(DebugPreferencesMessages.DefaultLaunchConfigurationsPropertiesPage_1, getResource().getName()), 2, 300); fViewer = createViewer(topComposite); Composite buttonComp = SWTFactory.createComposite(topComposite, 1, 1, GridData.FILL_VERTICAL); @@ -185,8 +185,7 @@ protected TableViewer createViewer(Composite parent){ viewer.setInput(collectConfigCandidates(resource)); viewer.addSelectionChangedListener(event -> { ISelection sel = event.getSelection(); - if(sel instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) sel; + if(sel instanceof IStructuredSelection ss) { boolean empty = ss.isEmpty(); int size = ss.size(); fEditButton.setEnabled(!empty && size == 1); @@ -405,7 +404,7 @@ private void handleEdit() { fViewer.refresh(config, true, true); } else if(ret == IDialogConstants.ABORT_ID) { - setErrorMessage(MessageFormat.format(DebugPreferencesMessages.RunDebugPropertiesPage_0, new Object[] { config.getName() })); + setErrorMessage(MessageFormat.format(DebugPreferencesMessages.RunDebugPropertiesPage_0, config.getName())); } } @@ -495,7 +494,7 @@ protected String getViewerLabel() { fViewer.setSelection(new StructuredSelection(wc)); } else if(ret == IDialogConstants.ABORT_ID) { - setErrorMessage(MessageFormat.format(DebugPreferencesMessages.RunDebugPropertiesPage_0, new Object[] { wc.getName() })); + setErrorMessage(MessageFormat.format(DebugPreferencesMessages.RunDebugPropertiesPage_0, wc.getName())); } } catch (CoreException e) { setErrorMessage(e.getMessage()); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/StringVariablePreferencePage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/StringVariablePreferencePage.java index dfa14b3bce6..877962313bb 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/StringVariablePreferencePage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/StringVariablePreferencePage.java @@ -297,11 +297,11 @@ private boolean addVariable(String name, String description, String value) { String currentName = currentVariable.getName(); if (currentName.equals(name)) { if (currentVariable.isReadOnly()){ - MessageDialog.openError(getShell(), DebugPreferencesMessages.StringVariablePreferencePage_23, MessageFormat.format(DebugPreferencesMessages.StringVariablePreferencePage_22, new Object[] { name })); + MessageDialog.openError(getShell(), DebugPreferencesMessages.StringVariablePreferencePage_23, MessageFormat.format(DebugPreferencesMessages.StringVariablePreferencePage_22, name)); return false; } else { - MessageDialog dialog = new MessageDialog(getShell(), DebugPreferencesMessages.SimpleVariablePreferencePage_15, null, MessageFormat.format(DebugPreferencesMessages.SimpleVariablePreferencePage_16, new Object[] { name }), MessageDialog.QUESTION, new String[] { + MessageDialog dialog = new MessageDialog(getShell(), DebugPreferencesMessages.SimpleVariablePreferencePage_15, null, MessageFormat.format(DebugPreferencesMessages.SimpleVariablePreferencePage_16, name), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 0); @@ -336,7 +336,7 @@ private void handleEditButtonPressed() { String value= variable.getValue(); String description= variable.getDescription(); String name= variable.getName(); - MultipleInputDialog dialog = new MultipleInputDialog(getShell(), MessageFormat.format(DebugPreferencesMessages.SimpleVariablePreferencePage_14, new Object[] { name })); + MultipleInputDialog dialog = new MultipleInputDialog(getShell(), MessageFormat.format(DebugPreferencesMessages.SimpleVariablePreferencePage_14, name)); dialog.addBrowseField(VALUE_LABEL, value, true); dialog.addTextField(DESCRIPTION_LABEL, description, true); @@ -368,7 +368,7 @@ private void handleRemoveButtonPressed() { } } if (contributedVariablesToRemove.length() > 0) { - boolean remove = MessageDialog.openQuestion(getShell(), DebugPreferencesMessages.SimpleLaunchVariablePreferencePage_21, MessageFormat.format(DebugPreferencesMessages.SimpleLaunchVariablePreferencePage_22, new Object[] { contributedVariablesToRemove.toString() })); // + boolean remove = MessageDialog.openQuestion(getShell(), DebugPreferencesMessages.SimpleLaunchVariablePreferencePage_21, MessageFormat.format(DebugPreferencesMessages.SimpleLaunchVariablePreferencePage_22, contributedVariablesToRemove.toString())); // if (!remove) { return; } @@ -657,8 +657,7 @@ public Image getColumnImage(Object element, int columnIndex) { } @Override public String getColumnText(Object element, int columnIndex) { - if (element instanceof VariableWrapper) { - VariableWrapper variable= (VariableWrapper) element; + if (element instanceof VariableWrapper variable) { switch (columnIndex) { case 0 : StringBuilder name = new StringBuilder(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/EditSourceLookupPathAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/EditSourceLookupPathAction.java index 57dd1834bfa..373d4a1fe70 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/EditSourceLookupPathAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/EditSourceLookupPathAction.java @@ -73,8 +73,7 @@ public void run() { SourceLookupDialog dialog = new SourceLookupDialog(shell, director); if (dialog.open() == Window.OK) { ISelection selection = fView.getViewer().getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection ss) { if (ss.size() == 1) { IWorkbenchPage page = fView.getSite().getPage(); SourceLookupManager.getDefault().displaySource(ss.getFirstElement(), page, true); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/LookupSourceAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/LookupSourceAction.java index f1086a2b94c..4559224c4ab 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/LookupSourceAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/LookupSourceAction.java @@ -62,8 +62,7 @@ protected boolean updateSelection(IStructuredSelection selection) { @Override public void run() { ISelection selection = fView.getViewer().getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection ss) { if (ss.size() == 1) { IWorkbenchPage page = fView.getSite().getPage(); SourceLookupManager.getDefault().displaySource(ss.getFirstElement(), page, true); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java index 2e5f3fcd6cd..d1799cf51bf 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java @@ -40,22 +40,18 @@ public ImageDescriptor getImageDescriptor(Object object) { } @Override public String getLabel(Object o) { - if (o instanceof DirectorySourceContainer) { - DirectorySourceContainer container = (DirectorySourceContainer) o; + if (o instanceof DirectorySourceContainer container) { File file = container.getDirectory(); IPath path = IPath.fromOSString(file.getAbsolutePath()); return SourceElementWorkbenchAdapter.getQualifiedName(path); } - if (o instanceof FolderSourceContainer) { - FolderSourceContainer container = (FolderSourceContainer) o; + if (o instanceof FolderSourceContainer container) { return SourceElementWorkbenchAdapter.getQualifiedName(container.getContainer().getFullPath()); } - if (o instanceof ArchiveSourceContainer) { - ArchiveSourceContainer container = (ArchiveSourceContainer)o; + if (o instanceof ArchiveSourceContainer container) { return SourceElementWorkbenchAdapter.getQualifiedName(container.getFile().getFullPath()); } - if (o instanceof ExternalArchiveSourceContainer) { - ExternalArchiveSourceContainer container = (ExternalArchiveSourceContainer)o; + if (o instanceof ExternalArchiveSourceContainer container) { IPath path = IPath.fromOSString(container.getName()); return SourceElementWorkbenchAdapter.getQualifiedName(path); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceElementWorkbenchAdapter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceElementWorkbenchAdapter.java index b80292a17a1..0558b17551b 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceElementWorkbenchAdapter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceElementWorkbenchAdapter.java @@ -44,13 +44,11 @@ public ImageDescriptor getImageDescriptor(Object o) { @Override public String getLabel(Object o) { - if (o instanceof LocalFileStorage) { - LocalFileStorage storage = (LocalFileStorage) o; + if (o instanceof LocalFileStorage storage) { IPath path = storage.getFullPath(); return getQualifiedName(path); } - if (o instanceof ZipEntryStorage) { - ZipEntryStorage storage = (ZipEntryStorage)o; + if (o instanceof ZipEntryStorage storage) { StringBuilder buffer = new StringBuilder(); buffer.append(storage.getZipEntry().getName()); buffer.append(" - "); //$NON-NLS-1$ diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java index 35d2ae0af1e..3b6503b2cec 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java @@ -230,10 +230,9 @@ public boolean equals(Object obj) { if (this == obj) { return true; } - if (!(obj instanceof ArtifactWithLocator)) { + if (!(obj instanceof ArtifactWithLocator other)) { return false; } - ArtifactWithLocator other = (ArtifactWithLocator) obj; return Objects.equals(artifact, other.artifact) && Objects.equals(locator, other.locator); } @@ -296,8 +295,7 @@ public SourceLookupResult lookup(Object artifact, ISourceLocator locator, boolea String editorId = null; IEditorInput editorInput = null; Object sourceElement = null; - if (localLocator instanceof ISourceLookupDirector) { - ISourceLookupDirector director = (ISourceLookupDirector) localLocator; + if (localLocator instanceof ISourceLookupDirector director) { sourceElement = director.getSourceElement(artifact); } else { if (artifact instanceof IStackFrame) { @@ -309,8 +307,7 @@ public SourceLookupResult lookup(Object artifact, ISourceLocator locator, boolea editorInput = new CommonSourceNotFoundEditorInput(artifact); editorId = IDebugUIConstants.ID_COMMON_SOURCE_NOT_FOUND_EDITOR; } else { - if (artifact instanceof IStackFrame) { - IStackFrame frame = (IStackFrame) artifact; + if (artifact instanceof IStackFrame frame) { editorInput = new SourceNotFoundEditorInput(frame); editorId = IInternalDebugUIConstants.ID_SOURCE_NOT_FOUND_EDITOR; } @@ -766,10 +763,9 @@ public boolean equals(Object obj) { if (this == obj) { return true; } - if (!(obj instanceof SourceLookupTask)) { + if (!(obj instanceof SourceLookupTask other)) { return false; } - SourceLookupTask other = (SourceLookupTask) obj; return fForce == other.fForce && Objects.equals(fPage, other.fPage) && Objects.equals(fLocator, other.fLocator) && Objects.equals(fTarget, other.fTarget); } @@ -824,10 +820,9 @@ public boolean equals(Object obj) { if (this == obj) { return true; } - if (!(obj instanceof SourceDisplayRequest)) { + if (!(obj instanceof SourceDisplayRequest other)) { return false; } - SourceDisplayRequest other = (SourceDisplayRequest) obj; return Objects.equals(fPage, other.fPage) && Objects.equals(fResult, other.fResult); } @@ -938,12 +933,10 @@ public void displaySource(Object context, IWorkbenchPage page, boolean force) { * @param source thread or debug target */ private void clearSourceSelection(Object source) { - if (source instanceof IThread) { - IThread thread = (IThread) source; + if (source instanceof IThread thread) { DecorationManager.removeDecorations(thread); InstructionPointerManager.getDefault().removeAnnotations(thread); - } else if (source instanceof IDebugTarget) { - IDebugTarget target = (IDebugTarget) source; + } else if (source instanceof IDebugTarget target) { DecorationManager.removeDecorations(target); InstructionPointerManager.getDefault().removeAnnotations(target); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupResult.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupResult.java index 55ab3893207..a03bc444bca 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupResult.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupResult.java @@ -88,11 +88,10 @@ public boolean equals(Object obj) { return true; } - if (!(obj instanceof SourceLookupResult)) { + if (!(obj instanceof SourceLookupResult other)) { return false; } - SourceLookupResult other = (SourceLookupResult) obj; return Objects.equals(fEditorId, other.fEditorId) && Objects.equals(fArtifact, other.fArtifact) && Objects.equals(fEditorInput, other.fEditorInput) diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java index c3728fb4297..c6616233cd4 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java @@ -115,8 +115,7 @@ protected synchronized void displaySource(ISelection selection, IWorkbenchPart p return; } - if (selection instanceof IStructuredSelection) { - IStructuredSelection structuredSelection = (IStructuredSelection)selection; + if (selection instanceof IStructuredSelection structuredSelection) { if (structuredSelection.size() == 1) { Object context = (structuredSelection).getFirstElement(); IWorkbenchPage page = null; @@ -132,8 +131,7 @@ protected synchronized void displaySource(ISelection selection, IWorkbenchPart p @Override public void displaySource(Object context, IWorkbenchPage page, boolean forceSourceLookup) { - if (context instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) context; + if (context instanceof IAdaptable adaptable) { ISourceDisplay adapter = adaptable.getAdapter(ISourceDisplay.class); if (adapter == null && !(context instanceof PlatformObject)) { // for objects that don't properly subclass PlatformObject to inherit default diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveFilter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveFilter.java index f9c173eca87..a45f77597fc 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveFilter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveFilter.java @@ -81,8 +81,7 @@ private boolean traverse(IContainer container, Set set) { try { IResource[] resources = container.members(); for (IResource resource : resources) { - if (resource instanceof IFile) { - IFile file = (IFile)resource; + if (resource instanceof IFile file) { String ext = file.getFileExtension(); if (ext != null && (ext.equalsIgnoreCase("jar") || ext.equalsIgnoreCase("zip"))) { //$NON-NLS-1$ //$NON-NLS-2$ set.add(file); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/PromptingResolver.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/PromptingResolver.java index 0908f386204..ad4f000cde9 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/PromptingResolver.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/PromptingResolver.java @@ -83,7 +83,7 @@ protected void setupDialog(String varValue) { } if (promptHint != null) { - dialogMessage = MessageFormat.format(StringSubstitutionMessages.PromptExpanderBase_0, new Object[] { promptHint }); + dialogMessage = MessageFormat.format(StringSubstitutionMessages.PromptExpanderBase_0, promptHint); } else { dialogMessage = StringSubstitutionMessages.PromptExpanderBase_1; } @@ -100,7 +100,7 @@ public String resolveValue(IDynamicVariable variable, String argument) throws Co lastValue = dialogResultString; } else { // dialogResultString == null means prompt was cancelled - throw new DebugException(new Status(IStatus.CANCEL, DebugUIPlugin.getUniqueIdentifier(), IStatus.CANCEL, MessageFormat.format(StringSubstitutionMessages.PromptingResolver_0, new Object[] { variable.getName() }), null)); + throw new DebugException(new Status(IStatus.CANCEL, DebugUIPlugin.getUniqueIdentifier(), IStatus.CANCEL, MessageFormat.format(StringSubstitutionMessages.PromptingResolver_0, variable.getName()), null)); } return value; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceManager.java index 213aed0a091..7d2e3c3325c 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceManager.java @@ -152,8 +152,7 @@ protected IResource getSelectedResource0() { IWorkbenchPage page = window.getActivePage(); if(page != null) { IWorkbenchPart part = page.getActivePart(); - if(part instanceof IEditorPart) { - IEditorPart epart = (IEditorPart) part; + if(part instanceof IEditorPart epart) { resource = epart.getEditorInput().getAdapter(IResource.class); } else if(part != null) { @@ -162,8 +161,7 @@ else if(part != null) { ISelectionProvider provider = site.getSelectionProvider(); if(provider != null) { ISelection selection = provider.getSelection(); - if(selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; + if(selection instanceof IStructuredSelection ss) { if(!ss.isEmpty()) { Iterator iterator = ss.iterator(); while (iterator.hasNext() && resource == null) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceResolver.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceResolver.java index 513696fa93c..375fd6126ac 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceResolver.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceResolver.java @@ -34,7 +34,7 @@ public String resolveValue(IDynamicVariable variable, String argument) throws Co if (resource != null) { return translateToValue(resource, variable); } - abort(MessageFormat.format(StringSubstitutionMessages.SelectedResourceResolver_0, new Object[] { getReferenceExpression(variable, argument) }), null); + abort(MessageFormat.format(StringSubstitutionMessages.SelectedResourceResolver_0, getReferenceExpression(variable, argument)), null); return null; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariableLabelProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariableLabelProvider.java index ca5ea8de15b..b2fd7e93be5 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariableLabelProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariableLabelProvider.java @@ -21,8 +21,7 @@ public class StringVariableLabelProvider extends LabelProvider { @Override public String getText(Object element) { - if (element instanceof IStringVariable) { - IStringVariable variable = (IStringVariable)element; + if (element instanceof IStringVariable variable) { return variable.getName(); } return super.getText(element); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariablePresentationManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariablePresentationManager.java index 7a522ba8dba..db663bd3d13 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariablePresentationManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariablePresentationManager.java @@ -101,7 +101,7 @@ private void initialize() { for (IConfigurationElement element : elements) { String name= element.getAttribute(ATTR_NAME); if (name == null) { - DebugUIPlugin.logErrorMessage(MessageFormat.format("String variable presentation extension missing required 'variableName' attribute: {0}", new Object[] { element.getDeclaringExtension().getLabel() })); //$NON-NLS-1$ + DebugUIPlugin.logErrorMessage(MessageFormat.format("String variable presentation extension missing required 'variableName' attribute: {0}", element.getDeclaringExtension().getLabel())); //$NON-NLS-1$ continue; } fConfigurations.put(name, element); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousModel.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousModel.java index a089c16835d..cf363fabbcc 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousModel.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousModel.java @@ -250,8 +250,7 @@ protected IModelProxyFactory getModelProxyFactoryAdapter(Object element) { IModelProxyFactory adapter = null; if (element instanceof IModelProxyFactory) { adapter = (IModelProxyFactory) element; - } else if (element instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) element; + } else if (element instanceof IAdaptable adaptable) { adapter = adaptable.getAdapter(IModelProxyFactory.class); } return adapter; @@ -430,8 +429,7 @@ protected IAsynchronousLabelAdapter getLabelAdapter(Object element) { IAsynchronousLabelAdapter adapter = null; if (element instanceof IAsynchronousLabelAdapter) { adapter = (IAsynchronousLabelAdapter) element; - } else if (element instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) element; + } else if (element instanceof IAdaptable adaptable) { adapter = adaptable.getAdapter(IAsynchronousLabelAdapter.class); } // if no adapter, use default (i.e. model presentation) @@ -453,8 +451,7 @@ protected IAsynchronousContentAdapter getContentAdapter(Object element) { IAsynchronousContentAdapter adapter = null; if (element instanceof IAsynchronousContentAdapter) { adapter = (IAsynchronousContentAdapter) element; - } else if (element instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) element; + } else if (element instanceof IAdaptable adaptable) { adapter = adaptable.getAdapter(IAsynchronousContentAdapter.class); } return adapter; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousSchedulingRuleFactory.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousSchedulingRuleFactory.java index 4f05e0bc805..53753ef6f2e 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousSchedulingRuleFactory.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousSchedulingRuleFactory.java @@ -58,8 +58,7 @@ public boolean contains(ISchedulingRule rule) { @Override public boolean isConflicting(ISchedulingRule rule) { - if (rule instanceof SerialPerObjectRule) { - SerialPerObjectRule vup = (SerialPerObjectRule) rule; + if (rule instanceof SerialPerObjectRule vup) { return fObject == vup.fObject; } return false; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java index dcb7bcf88ae..77d6d422e64 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousViewer.java @@ -398,8 +398,7 @@ protected Widget doFindItem(Object element) { @Override protected Widget doFindInputItem(Object element) { - if (element instanceof ModelNode) { - ModelNode node = (ModelNode) element; + if (element instanceof ModelNode node) { if (node.getElement().equals(getInput())) { return getControl(); } @@ -548,11 +547,9 @@ protected void handlePostSelect(SelectionEvent e) { * @return selection policy or null */ protected IModelSelectionPolicy getSelectionPolicy(ISelection selection) { - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection ss) { Object element = ss.getFirstElement(); - if (element instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) element; + if (element instanceof IAdaptable adaptable) { IModelSelectionPolicyFactory factory = adaptable.getAdapter(IModelSelectionPolicyFactory.class); if (factory != null) { return factory.createModelSelectionPolicyAdapter(adaptable, getPresentationContext()); @@ -749,8 +746,7 @@ protected boolean selectionExists(ISelection selection) { if (selection.isEmpty()) { return false; } - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection ss) { Iterator iterator = ss.iterator(); while (iterator.hasNext()) { Object element = iterator.next(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableEditorImpl.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableEditorImpl.java index 623ab5ec3ad..41272714424 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableEditorImpl.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/TableEditorImpl.java @@ -80,8 +80,9 @@ private void activateCellEditor() { // even if there is no control. final Control control = fCellEditor.getControl(); fCellEditor.activate(); - if (control == null) + if (control == null) { return; + } setLayoutData(fCellEditor.getLayoutData()); setEditor(control, fTableItem, fColumnNumber); fCellEditor.setFocus(); @@ -195,13 +196,15 @@ public void cancelEditing() { * Start editing the given element. */ public void editElement(Object element, int column) { - if (fCellEditor != null) + if (fCellEditor != null) { applyEditorValue(); + } setSelection(new StructuredSelection(element), true); Item[] selection = getSelection(); - if (selection.length != 1) + if (selection.length != 1) { return; + } fTableItem = selection[0]; @@ -252,11 +255,13 @@ public Object[] getColumnProperties() { * the mouse event that should be handled */ public void handleMouseDown(MouseEvent event) { - if (event.button != 1) + if (event.button != 1) { return; + } - if (fCellEditor != null) + if (fCellEditor != null) { applyEditorValue(); + } // activate the cell editor immediately. If a second mouseDown // is received prior to the expiration of the doubleClick time then @@ -314,8 +319,9 @@ private void saveEditorValue(CellEditor cellEditor, Item tableItem) { // /Do what ??? } String property = null; - if (fColumnProperties != null && fColumnNumber < fColumnProperties.length) + if (fColumnProperties != null && fColumnNumber < fColumnProperties.length) { property = fColumnProperties[fColumnNumber]; + } fCellModifier.modify(tableItem, property, cellEditor.getValue()); } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/AbstractBreadcrumb.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/AbstractBreadcrumb.java index b7fa1d626de..93cab84a742 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/AbstractBreadcrumb.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/AbstractBreadcrumb.java @@ -104,8 +104,9 @@ public ISelectionProvider getSelectionProvider() { * @param element the input element can be null */ public void setInput(Object element) { - if (element == null || fBreadcrumbViewer == null || fBreadcrumbViewer.getControl().isDisposed()) + if (element == null || fBreadcrumbViewer == null || fBreadcrumbViewer.getControl().isDisposed()) { return; + } Object input= fBreadcrumbViewer.getInput(); if (input == element || element.equals(input)) { @@ -128,8 +129,9 @@ protected void refresh() { * actions. */ public void activate() { - if (fBreadcrumbViewer.getSelection().isEmpty()) + if (fBreadcrumbViewer.getSelection().isEmpty()) { fBreadcrumbViewer.setSelection(new StructuredSelection(fBreadcrumbViewer.getInput())); + } fBreadcrumbViewer.setFocus(); } @@ -166,16 +168,20 @@ public Control createContent(Composite parent) { fComposite.setLayout(gridLayout); fDisplayFocusListener= event -> { - if (fComposite.isDisposed()) return; + if (fComposite.isDisposed()) { + return; + } if (isBreadcrumbEvent(event)) { - if (fHasFocus) + if (fHasFocus) { return; + } focusGained(); } else { - if (!fHasFocus) + if (!fHasFocus) { return; + } focusLost(); } @@ -186,12 +192,14 @@ public Control createContent(Composite parent) { fBreadcrumbViewer.addDoubleClickListener(event -> { Object element= ((IStructuredSelection) event.getSelection()).getFirstElement(); - if (element == null) + if (element == null) { return; + } BreadcrumbItem item= (BreadcrumbItem) fBreadcrumbViewer.doFindItem(element); - if (item == null) + if (item == null) { return; + } item.openDropDownMenu(); }); @@ -226,8 +234,9 @@ private void doOpen(ISelection selection) { * Focus has been transfered into the breadcrumb. */ private void focusGained() { - if (fHasFocus) + if (fHasFocus) { focusLost(); + } fHasFocus= true; @@ -255,11 +264,13 @@ private void installDisplayListeners() { deinstallDisplayListeners(); fDisplayKeyListener= event -> { - if (event.keyCode != SWT.ESC) + if (event.keyCode != SWT.ESC) { return; + } - if (!isBreadcrumbEvent(event)) + if (!isBreadcrumbEvent(event)) { return; + } }; Display.getDefault().addFilter(SWT.KeyDown, fDisplayKeyListener); } @@ -281,26 +292,31 @@ private void deinstallDisplayListeners() { * @return true if event was generated by a breadcrumb child */ private boolean isBreadcrumbEvent(Event event) { - if (fBreadcrumbViewer == null) + if (fBreadcrumbViewer == null) { return false; + } Widget item= event.widget; - if (!(item instanceof Control)) + if (!(item instanceof Control)) { return false; + } Shell dropDownShell= fBreadcrumbViewer.getDropDownShell(); - if (dropDownShell != null && isChild((Control) item, dropDownShell)) + if (dropDownShell != null && isChild((Control) item, dropDownShell)) { return true; + } return isChild((Control) item, fBreadcrumbViewer.getControl()); } private boolean isChild(Control child, Control parent) { - if (child == null) + if (child == null) { return false; + } - if (child == parent) + if (child == parent) { return true; + } return isChild(child.getParent(), parent); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbViewer.java index f3b1fd4a337..983a7f4739b 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbViewer.java @@ -284,9 +284,7 @@ protected void doUpdateItem(Widget widget, Object element, boolean fullMap) { } private boolean myDoUpdateItem(Widget widget, Object element, boolean fullMap) { - if (widget instanceof BreadcrumbItem) { - final BreadcrumbItem item= (BreadcrumbItem) widget; - + if (widget instanceof final BreadcrumbItem item) { // remember element we are showing if (fullMap) { associate(element, item); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ChildrenUpdate.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ChildrenUpdate.java index 7799b6d50de..aee4c6453e8 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ChildrenUpdate.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ChildrenUpdate.java @@ -126,8 +126,7 @@ public void setChild(Object child, int index) { */ @Override public synchronized boolean coalesce(ViewerUpdateMonitor request) { - if (request instanceof ChildrenUpdate) { - ChildrenUpdate cu = (ChildrenUpdate) request; + if (request instanceof ChildrenUpdate cu) { if (getElement().equals(cu.getElement()) && getElementPath().equals(cu.getElementPath())) { int end = fIndex + fLength; int otherStart = cu.getOffset(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java index 64215e31cf0..be1fd1a6624 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java @@ -745,7 +745,7 @@ public void paintControl(PaintEvent e) { private void initColumns(int widthHint, int treeWidgetWidth, String[] visibleColumnIds) { for (TreeColumn column : getTree().getColumns()) { Object colData = column.getData(); - String columnId = colData instanceof String ? (String) colData : null; + String columnId = colData instanceof String s ? s : null; Integer width = fColumnSizes.get(colData); if (width == null) { int ans = getInitialColumnWidth(columnId, treeWidgetWidth, visibleColumnIds); @@ -906,8 +906,7 @@ public void saveState(IMemento memento) { } // save presentation context properties IPresentationContext context = getPresentationContext(); - if (context instanceof PresentationContext) { - PresentationContext pc = (PresentationContext) context; + if (context instanceof PresentationContext pc) { pc.saveProperites(memento); } @@ -960,8 +959,7 @@ public void initState(IMemento memento) { // restore presentation context properties // save presentation context properties IPresentationContext context = getPresentationContext(); - if (context instanceof PresentationContext) { - PresentationContext pc = (PresentationContext) context; + if (context instanceof PresentationContext pc) { pc.initProperties(memento); } } @@ -1070,10 +1068,9 @@ public void removeStateUpdateListener(IStateUpdateListener listener) { @Override protected void doUpdateItem(final Item item, Object element) { - if (!(item instanceof TreeItem)) { + if (!(item instanceof TreeItem treeItem)) { return; } - TreeItem treeItem = (TreeItem) item; if (treeItem.isDisposed()) { unmapElement(element, treeItem); return; @@ -1161,8 +1158,7 @@ protected void internalRefreshStruct(Widget widget, Object element, } int index = 0; Widget parent = null; - if (widget instanceof TreeItem) { - TreeItem treeItem = (TreeItem) widget; + if (widget instanceof TreeItem treeItem) { parent = treeItem.getParentItem(); if (parent == null) { parent = treeItem.getParent(); @@ -1385,8 +1381,8 @@ public void setElementData(TreePath path, int numColumns, String[] labels, Image Widget widget = findItem(path); String[] columnIds = getVisibleColumns(); - if (widget != null && widget instanceof TreeItem && !widget.isDisposed()) { - TreeItem item = (TreeItem)widget; + if (widget != null && widget instanceof TreeItem item && !widget.isDisposed()) { + /*Object data = item.getData(); int itemCount = item.getItemCount(); item.clearAll(false); @@ -1591,8 +1587,7 @@ public boolean saveElementState(TreePath path, ModelDelta delta, int flagsToSave delta.setFlags(delta.getFlags() | IModelDelta.EXPAND); } items = tree.getItems(); - } else if (w instanceof TreeItem) { - TreeItem item = (TreeItem)w; + } else if (w instanceof TreeItem item) { if (item.getExpanded()) { int itemCount = item.getData() != null ? item.getItemCount() : -1; delta.setChildCount(((ITreeModelContentProvider)getContentProvider()).viewToModelCount(path, itemCount)); @@ -1661,9 +1656,7 @@ public void updateViewer(IModelDelta delta) { public void setElementChecked(TreePath path, boolean checked, boolean grayed) { Widget widget = findItem(path); - if (widget != null && widget instanceof TreeItem && !widget.isDisposed()) { - TreeItem item = (TreeItem)widget; - + if (widget != null && widget instanceof TreeItem item && !widget.isDisposed()) { item.setChecked(checked); item.setGrayed(grayed); @@ -1676,9 +1669,7 @@ public void setElementChecked(TreePath path, boolean checked, boolean grayed) { public boolean getElementChecked(TreePath path) { Widget widget = findItem(path); - if (widget != null && widget instanceof TreeItem && !widget.isDisposed()) { - TreeItem item = (TreeItem)widget; - + if (widget != null && widget instanceof TreeItem item && !widget.isDisposed()) { return item.getChecked(); } return false; @@ -1694,9 +1685,7 @@ public boolean getElementChecked(TreePath path) { public boolean getElementGrayed(TreePath path) { Widget widget = findItem(path); - if (widget != null && widget instanceof TreeItem && !widget.isDisposed()) { - TreeItem item = (TreeItem)widget; - + if (widget != null && widget instanceof TreeItem item && !widget.isDisposed()) { return item.getGrayed(); } return false; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java index b918bb19f72..5b3b72d60c1 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java @@ -585,8 +585,7 @@ public VirtualItem findItem(TreePath path) { public VirtualItem[] findItems(Object elementOrTreePath) { Object element = elementOrTreePath; - if (elementOrTreePath instanceof TreePath) { - TreePath path = (TreePath)elementOrTreePath; + if (elementOrTreePath instanceof TreePath path) { if (path.getSegmentCount() == 0) { return new VirtualItem[] { getTree() }; } @@ -1281,8 +1280,7 @@ public void saveState(IMemento memento) { } // save presentation context properties IPresentationContext context = getPresentationContext(); - if (context instanceof PresentationContext) { - PresentationContext pc = (PresentationContext) context; + if (context instanceof PresentationContext pc) { pc.saveProperites(memento); } @@ -1316,8 +1314,7 @@ public void initState(IMemento memento) { // restore presentation context properties // save presentation context properties IPresentationContext context = getPresentationContext(); - if (context instanceof PresentationContext) { - PresentationContext pc = (PresentationContext) context; + if (context instanceof PresentationContext pc) { pc.initProperties(memento); } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/SubTreeModelViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/SubTreeModelViewer.java index 30186c297ff..f7327d9e90b 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/SubTreeModelViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/SubTreeModelViewer.java @@ -94,8 +94,7 @@ public void reveal(TreePath path, int index) { @Override public void replace(Object parentOrTreePath, int index, Object element) { - if (parentOrTreePath instanceof TreePath) { - TreePath path = (TreePath)parentOrTreePath; + if (parentOrTreePath instanceof TreePath path) { if (path.startsWith(fRootPath, null)) { SubTreeModelViewer.this.replace(createSubPath(path), index, element); } @@ -106,8 +105,7 @@ public void replace(Object parentOrTreePath, int index, Object element) { @Override public void setChildCount(Object elementOrTreePath, int count) { - if (elementOrTreePath instanceof TreePath) { - TreePath path = (TreePath)elementOrTreePath; + if (elementOrTreePath instanceof TreePath path) { if (path.startsWith(fRootPath, null)) { SubTreeModelViewer.this.setChildCount(createSubPath(path), count); } @@ -118,8 +116,7 @@ public void setChildCount(Object elementOrTreePath, int count) { @Override public void setHasChildren(Object elementOrTreePath, boolean hasChildren) { - if (elementOrTreePath instanceof TreePath) { - TreePath path = (TreePath)elementOrTreePath; + if (elementOrTreePath instanceof TreePath path) { if (path.startsWith(fRootPath, null)) { SubTreeModelViewer.this.setHasChildren(createSubPath(path), hasChildren); } @@ -135,8 +132,7 @@ public void autoExpand(TreePath elementPath) { @Override public void setExpandedState(Object elementOrTreePath, boolean expanded) { - if (elementOrTreePath instanceof TreePath) { - TreePath path = (TreePath)elementOrTreePath; + if (elementOrTreePath instanceof TreePath path) { if (path.startsWith(fRootPath, null)) { SubTreeModelViewer.this.setExpandedState(createSubPath(path), expanded); } @@ -147,8 +143,7 @@ public void setExpandedState(Object elementOrTreePath, boolean expanded) { @Override public void expandToLevel(Object elementOrTreePath, int level) { - if (elementOrTreePath instanceof TreePath) { - TreePath path = (TreePath)elementOrTreePath; + if (elementOrTreePath instanceof TreePath path) { if (path.startsWith(fRootPath, null)) { SubTreeModelViewer.this.expandToLevel(createSubPath(path), level); } @@ -159,8 +154,7 @@ public void expandToLevel(Object elementOrTreePath, int level) { @Override public void remove(Object elementOrTreePath) { - if (elementOrTreePath instanceof TreePath) { - TreePath path = (TreePath)elementOrTreePath; + if (elementOrTreePath instanceof TreePath path) { if (path.startsWith(fRootPath, null)) { SubTreeModelViewer.this.remove(createSubPath(path)); } @@ -171,8 +165,7 @@ public void remove(Object elementOrTreePath) { @Override public void remove(Object parentOrTreePath, final int index) { - if (parentOrTreePath instanceof TreePath) { - TreePath path = (TreePath)parentOrTreePath; + if (parentOrTreePath instanceof TreePath path) { if (path.startsWith(fRootPath, null)) { SubTreeModelViewer.this.remove(createSubPath(path), index); } @@ -183,8 +176,7 @@ public void remove(Object parentOrTreePath, final int index) { @Override public void insert(Object parentOrTreePath, Object element, int position) { - if (parentOrTreePath instanceof TreePath) { - TreePath path = (TreePath)parentOrTreePath; + if (parentOrTreePath instanceof TreePath path) { if (path.startsWith(fRootPath, null)) { SubTreeModelViewer.this.insert(createSubPath(path), element, position); } @@ -195,8 +187,7 @@ public void insert(Object parentOrTreePath, Object element, int position) { @Override public boolean getExpandedState(Object elementOrTreePath) { - if (elementOrTreePath instanceof TreePath) { - TreePath path = (TreePath)elementOrTreePath; + if (elementOrTreePath instanceof TreePath path) { if (path.startsWith(fRootPath, null)) { return SubTreeModelViewer.this.getExpandedState(createSubPath(path)); } @@ -216,8 +207,7 @@ public int getChildCount(TreePath path) { @Override public boolean getHasChildren(Object elementOrTreePath) { - if (elementOrTreePath instanceof TreePath) { - TreePath path = (TreePath)elementOrTreePath; + if (elementOrTreePath instanceof TreePath path) { if (path.startsWith(fRootPath, null)) { return SubTreeModelViewer.this.getHasChildren(createSubPath(path)); } @@ -545,8 +535,7 @@ public boolean areTreeModelViewerFiltersApplicable(Object parentElement) { @Override public boolean shouldFilter(Object parentElementOrTreePath, Object element) { - if (parentElementOrTreePath instanceof TreePath) { - TreePath path = (TreePath)parentElementOrTreePath; + if (parentElementOrTreePath instanceof TreePath path) { return fBaseProvider.shouldFilter(createFullPath(path), element); } else { return fBaseProvider.shouldFilter(parentElementOrTreePath, element); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java index 075bad86e78..2a8655e0cff 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/TreeModelContentProvider.java @@ -443,8 +443,7 @@ public IStatus runInUIThread(IProgressMonitor monitor) { restoreQueue(currentBatch); return Status.CANCEL_STATUS; } - if (task instanceof DelayedDoModelChange) { - DelayedDoModelChange change = (DelayedDoModelChange) task; + if (task instanceof DelayedDoModelChange change) { if (!change.proxy.isDisposed()) { doModelChanged(change.delta, change.proxy); } @@ -667,8 +666,8 @@ public boolean shouldFilter(Object parentElementOrTreePath, Object element) { for (int j = 0; j < filters.length; j++) { if (filters[j] instanceof TreeModelViewerFilter) { // Skip the filter if not applicable to parent element - Object parentElement = parentElementOrTreePath instanceof TreePath - ? ((TreePath)parentElementOrTreePath).getLastSegment() : parentElementOrTreePath; + Object parentElement = parentElementOrTreePath instanceof TreePath t + ? t.getLastSegment() : parentElementOrTreePath; if (parentElement == null) { parentElement = fViewer.getInput(); } @@ -1123,8 +1122,7 @@ private void rescheduleUpdates(TreePath parentPath, int modelIndex) { Iterator iterator = requests.iterator(); while (iterator.hasNext()) { ViewerUpdateMonitor update = iterator.next(); - if (update instanceof IChildrenUpdate) { - IChildrenUpdate childrenUpdate = (IChildrenUpdate) update; + if (update instanceof IChildrenUpdate childrenUpdate) { if (childrenUpdate.getOffset() > modelIndex) { // Cancel update and remove from requests list. Removing from // fRequestsInProgress ensures that isRequestBlocked() won't be triggered @@ -1145,8 +1143,7 @@ private void rescheduleUpdates(TreePath parentPath, int modelIndex) { requests = fWaitingRequests.get(parentPath); if (requests != null) { for (ViewerUpdateMonitor update : requests) { - if (update instanceof IChildrenUpdate) { - IChildrenUpdate childrenUpdate = (IChildrenUpdate) update; + if (update instanceof IChildrenUpdate childrenUpdate) { if (childrenUpdate.getOffset() > modelIndex) { ((ChildrenUpdate) childrenUpdate).setOffset(childrenUpdate.getOffset() - 1); if (DebugUIPlugin.DEBUG_CONTENT_PROVIDER && DebugUIPlugin.DEBUG_TEST_PRESENTATION_ID(getPresentationContext())) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerAdapterService.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerAdapterService.java index 293f64366f3..246382fe904 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerAdapterService.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerAdapterService.java @@ -127,8 +127,7 @@ public static IElementEditor getElementEditor(Object element) { * @return selection policy or null */ public static IModelSelectionPolicy getSelectionPolicy(ISelection selection, IPresentationContext context) { - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection ss) { Object element = ss.getFirstElement(); IModelSelectionPolicyFactory factory = (IModelSelectionPolicyFactory) getAdapter(element, IModelSelectionPolicyFactory.class); if (factory != null) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerStateTracker.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerStateTracker.java index 15bf48ba6e8..858ccb4bd39 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerStateTracker.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ViewerStateTracker.java @@ -194,8 +194,7 @@ private static class CompareRequestKey { @Override public boolean equals(Object obj) { - if (obj instanceof CompareRequestKey) { - CompareRequestKey key = (CompareRequestKey) obj; + if (obj instanceof CompareRequestKey key) { return key.fDelta.equals(fDelta) && key.fPath.equals(fPath); } return false; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/VirtualFindAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/VirtualFindAction.java index 42989b7c093..aac8c5e1ad3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/VirtualFindAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/VirtualFindAction.java @@ -289,7 +289,7 @@ protected void setSelectionToClient(VirtualTreeModelViewer virtualViewer, ILabel DebugUIPlugin.errorDialog( fClientViewer.getControl().getShell(), ActionMessages.VirtualFindAction_0, - MessageFormat.format(ActionMessages.VirtualFindAction_1, new Object[] { labelProvider.getText(findItem) }), + MessageFormat.format(ActionMessages.VirtualFindAction_1, labelProvider.getText(findItem)), new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), ActionMessages.VirtualFindAction_1)); } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ModelDelta.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ModelDelta.java index c22f1cc1239..9e3b7dc985c 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ModelDelta.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ModelDelta.java @@ -152,8 +152,7 @@ public ModelDelta getChildDelta(Object element, int index) { mapNodes(); } Object nodeOrNodes = fNodesMap.get(element); - if (nodeOrNodes instanceof ModelDelta) { - ModelDelta node = (ModelDelta)nodeOrNodes; + if (nodeOrNodes instanceof ModelDelta node) { if (index == node.getIndex()) { return node; } @@ -185,9 +184,8 @@ private void mapNode(ModelDelta node) { // Edge case: already a node for given element was added. ModelDelta[] nodes = new ModelDelta[] { (ModelDelta)oldValue, node }; fNodesMap.put(node.getElement(), nodes); - } else if (oldValue instanceof ModelDelta[]) { + } else if (oldValue instanceof ModelDelta[] oldNodes) { // Even more remote case: multiple delta nodes for the same element were already added - ModelDelta[] oldNodes = (ModelDelta[])oldValue; ModelDelta[] newNodes = new ModelDelta[oldNodes.length + 1]; System.arraycopy(oldNodes, 0, newNodes, 0, oldNodes.length); newNodes[newNodes.length - 1] = node; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualItem.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualItem.java index 4f0601543c3..54f2f24b28c 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualItem.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualItem.java @@ -75,7 +75,7 @@ public int intValue() { @Override public int compareTo(Object obj) { - return obj instanceof Index ? fIndexValue.compareTo(((Index)obj).fIndexValue) : 0; + return obj instanceof Index i ? fIndexValue.compareTo(i.fIndexValue) : 0; } @Override diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultModelProxyFactory.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultModelProxyFactory.java index 0b43d13a9f9..e81abeeaf72 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultModelProxyFactory.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultModelProxyFactory.java @@ -75,8 +75,9 @@ public IModelProxy createModelProxy(Object element, IPresentationContext context } } if (IDebugUIConstants.ID_MEMORY_VIEW.equals(id)) { - if (element instanceof IMemoryBlockRetrieval) + if (element instanceof IMemoryBlockRetrieval) { return new MemoryRetrievalProxy((IMemoryBlockRetrieval)element); + } } if (IDebugUIConstants.ID_BREAKPOINT_VIEW.equals(id)) { if (element instanceof DefaultBreakpointsViewInput) { @@ -92,8 +93,9 @@ public IModelProxy createModelProxy(Object element, IPresentationContext context { if (((MemoryViewPresentationContext)context).getRendering() instanceof AbstractAsyncTableRendering) { - if (element instanceof IMemoryBlock) + if (element instanceof IMemoryBlock) { return new MemoryBlockProxy((IMemoryBlock)element); + } } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java index 29c3c5d8c54..bd60f0aad38 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultSelectionPolicy.java @@ -47,11 +47,9 @@ public DefaultSelectionPolicy(IDebugElement element) { @Override public boolean contains(ISelection selection, IPresentationContext context) { if (IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId())) { - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection ss) { Object element = ss.getFirstElement(); - if (element instanceof IDebugElement) { - IDebugElement debugElement = (IDebugElement) element; + if (element instanceof IDebugElement debugElement) { return fDebugElement.getDebugTarget().equals(debugElement.getDebugTarget()); } } @@ -62,9 +60,7 @@ public boolean contains(ISelection selection, IPresentationContext context) { @Override public boolean overrides(ISelection existing, ISelection candidate, IPresentationContext context) { if (IDebugUIConstants.ID_DEBUG_VIEW.equals(context.getId())) { - if (existing instanceof IStructuredSelection && candidate instanceof IStructuredSelection) { - IStructuredSelection ssExisting = (IStructuredSelection) existing; - IStructuredSelection ssCandidate = (IStructuredSelection) candidate; + if (existing instanceof IStructuredSelection ssExisting && candidate instanceof IStructuredSelection ssCandidate) { return overrides(ssExisting.getFirstElement(), ssCandidate.getFirstElement()); } } @@ -78,9 +74,7 @@ protected boolean overrides(Object existing, Object candidate) { if (existing.equals(candidate)) { return true; } - if (existing instanceof IStackFrame && candidate instanceof IStackFrame) { - IStackFrame curr = (IStackFrame) existing; - IStackFrame next = (IStackFrame) candidate; + if (existing instanceof IStackFrame curr && candidate instanceof IStackFrame next) { return curr.getThread().equals(next.getThread()) || !isSticky(existing); } return !isSticky(existing); @@ -102,8 +96,7 @@ public boolean isSticky(ISelection selection, IPresentationContext context) { * @return true if the selection should remain on the given element false otherwise */ protected boolean isSticky(Object element) { - if (element instanceof IStackFrame) { - IStackFrame frame = (IStackFrame) element; + if (element instanceof IStackFrame frame) { return frame.isSuspended() || frame.isStepping(); } return false; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultWatchExpressionModelProxy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultWatchExpressionModelProxy.java index cc1bd4e8aa6..1bfadc7e4dd 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultWatchExpressionModelProxy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/DefaultWatchExpressionModelProxy.java @@ -102,9 +102,8 @@ protected DebugEventHandler[] createEventHandlers() { */ protected void contextActivated(ISelection selection) { if (fWindow != null) { - if (selection instanceof IStructuredSelection) { + if (selection instanceof IStructuredSelection ss) { IDebugElement context = null; - IStructuredSelection ss = (IStructuredSelection)selection; if (ss.size() < 2) { Object object = ss.getFirstElement(); if (object instanceof IDebugElement) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryBlockProxy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryBlockProxy.java index 760cb8b58e4..54781d6f2f4 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryBlockProxy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryBlockProxy.java @@ -29,14 +29,16 @@ public class MemoryBlockProxy extends EventHandlerModelProxy { @Override protected boolean handlesEvent(DebugEvent event) { - if (event.getKind() == DebugEvent.CHANGE && event.getSource() == fMemoryBlock) + if (event.getKind() == DebugEvent.CHANGE && event.getSource() == fMemoryBlock) { return true; + } Object src = event.getSource(); if (src instanceof IDebugElement) { - if (event.getKind() == DebugEvent.SUSPEND && ((IDebugElement)src).getDebugTarget() == fMemoryBlock.getDebugTarget()) + if (event.getKind() == DebugEvent.SUSPEND && ((IDebugElement)src).getDebugTarget() == fMemoryBlock.getDebugTarget()) { return true; + } } return false; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryRetrievalProxy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryRetrievalProxy.java index 6a34b17ceab..ca24f1d0c51 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryRetrievalProxy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/update/MemoryRetrievalProxy.java @@ -147,8 +147,7 @@ private void addSelectDeltaNode(ModelDelta delta) { private IStructuredSelection getCurrentSelection() { Viewer viewer = getViewer(); - if (viewer instanceof StructuredViewer) { - StructuredViewer sv = (StructuredViewer) viewer; + if (viewer instanceof StructuredViewer sv) { ISelection selection = sv.getSelection(); if (selection instanceof IStructuredSelection) { return (IStructuredSelection) selection; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextService.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextService.java index 691b976f155..a45700d42db 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextService.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/ViewContextService.java @@ -786,8 +786,7 @@ public static Set getDefaultEnabledPerspectives() { public void contextActivated(ISelection selection) { if (isEnabledPerspective()) { - if (selection instanceof IStructuredSelection && !selection.isEmpty()) { - IStructuredSelection ss = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection ss && !selection.isEmpty()) { Iterator iterator = ss.iterator(); while (iterator.hasNext()) { Object target = iterator.next(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointContainer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointContainer.java index f6c7e79a0ee..bcd0d7105c8 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointContainer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointContainer.java @@ -437,8 +437,7 @@ static private void appendContainerDelta(BreakpointContainer container, ModelDel : IModelDelta.INSERTED|IModelDelta.INSTALL|IModelDelta.EXPAND; ModelDelta childDelta = containerDelta.addNode(children[i], i, flag, numChild); - if (children[i] instanceof BreakpointContainer) { - BreakpointContainer childContainer = (BreakpointContainer) children[i]; + if (children[i] instanceof BreakpointContainer childContainer) { appendContainerDelta(childContainer, childDelta); } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointContainerWorkbenchAdapter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointContainerWorkbenchAdapter.java index e2b07dbc122..2a3b12c770e 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointContainerWorkbenchAdapter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointContainerWorkbenchAdapter.java @@ -36,8 +36,7 @@ public Object[] getChildren(Object o) { @Override public ImageDescriptor getImageDescriptor(Object object) { - if (object instanceof IBreakpointContainer) { - IBreakpointContainer container = (IBreakpointContainer) object; + if (object instanceof IBreakpointContainer container) { IAdaptable category = container.getCategory(); if (category != null) { IWorkbenchAdapter adapter = category.getAdapter(IWorkbenchAdapter.class); @@ -52,8 +51,7 @@ public ImageDescriptor getImageDescriptor(Object object) { @Override public String getLabel(Object object) { - if (object instanceof IBreakpointContainer) { - IBreakpointContainer container = (IBreakpointContainer) object; + if (object instanceof IBreakpointContainer container) { IAdaptable category = container.getCategory(); if (category != null) { IWorkbenchAdapter adapter = category.getAdapter(IWorkbenchAdapter.class); @@ -73,8 +71,7 @@ public Object getParent(Object o) { @Override public RGB getForeground(Object object) { - if (object instanceof IBreakpointContainer) { - IBreakpointContainer container = (IBreakpointContainer) object; + if (object instanceof IBreakpointContainer container) { IAdaptable category = container.getCategory(); IWorkbenchAdapter2 adapter = category.getAdapter(IWorkbenchAdapter2.class); if (adapter != null) { @@ -86,8 +83,7 @@ public RGB getForeground(Object object) { @Override public RGB getBackground(Object object) { - if (object instanceof IBreakpointContainer) { - IBreakpointContainer container = (IBreakpointContainer) object; + if (object instanceof IBreakpointContainer container) { IAdaptable category = container.getCategory(); IWorkbenchAdapter2 adapter = category.getAdapter(IWorkbenchAdapter2.class); if (adapter != null) { @@ -99,8 +95,7 @@ public RGB getBackground(Object object) { @Override public FontData getFont(Object object) { - if (object instanceof IBreakpointContainer) { - IBreakpointContainer container = (IBreakpointContainer) object; + if (object instanceof IBreakpointContainer container) { IAdaptable category = container.getCategory(); IWorkbenchAdapter2 adapter = category.getAdapter(IWorkbenchAdapter2.class); if (adapter != null) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointFactory.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointFactory.java index d8ad046c8b4..06e2edc0cd9 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointFactory.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointFactory.java @@ -35,8 +35,7 @@ public IAdaptable createElement(IMemento memento) { IElementFactory elementFactory = PlatformUI.getWorkbench().getElementFactory(factoryId); if (elementFactory != null) { IAdaptable adaptable = elementFactory.createElement(memento); - if (adaptable instanceof IResource) { - IResource resource = (IResource) adaptable; + if (adaptable instanceof IResource resource) { try { long id = Long.parseLong(longString); IMarker marker = resource.findMarker(id); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointSetOrganizer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointSetOrganizer.java index a8129c311cc..57169aaa918 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointSetOrganizer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointSetOrganizer.java @@ -242,8 +242,7 @@ private void clean(IWorkingSet workingSet) { boolean update = false; for (int i = 0; i < elements.length; i++) { IAdaptable adaptable = elements[i]; - if (adaptable instanceof IBreakpoint) { - IBreakpoint breakpoint = (IBreakpoint) adaptable; + if (adaptable instanceof IBreakpoint breakpoint) { if (!manager.isRegistered(breakpoint)) { update = true; elements[i] = null; @@ -309,8 +308,7 @@ public static void setDefaultWorkingSet(IWorkingSet set) { @Override public boolean canRemove(IBreakpoint breakpoint, IAdaptable category) { - if (category instanceof WorkingSetCategory) { - WorkingSetCategory wsc = (WorkingSetCategory) category; + if (category instanceof WorkingSetCategory wsc) { return IDebugUIConstants.BREAKPOINT_WORKINGSET_ID.equals(wsc.getWorkingSet().getId()); } return super.canRemove(breakpoint, category); @@ -318,8 +316,7 @@ public boolean canRemove(IBreakpoint breakpoint, IAdaptable category) { @Override public boolean canAdd(IBreakpoint breakpoint, IAdaptable category) { - if (category instanceof WorkingSetCategory) { - WorkingSetCategory wsc = (WorkingSetCategory) category; + if (category instanceof WorkingSetCategory wsc) { return IDebugUIConstants.BREAKPOINT_WORKINGSET_ID.equals(wsc.getWorkingSet().getId()); } return super.canAdd(breakpoint, category); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetPage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetPage.java index 83f55e5653b..216833deb7a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetPage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetPage.java @@ -109,7 +109,7 @@ public void widgetSelected(SelectionEvent selectionEvent) { BreakpointsViewer viewer = fTViewer.getViewer(); viewer.getTree().selectAll(); viewer.setCheckedElements(viewer.getStructuredSelection().toArray()); - viewer.setGrayedElements(new Object[] {}); + viewer.setGrayedElements(); viewer.getTree().deselectAll(); validateInput(); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsComparator.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsComparator.java index f720c834646..e70528ce8ed 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsComparator.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsComparator.java @@ -59,11 +59,10 @@ public boolean isSorterProperty(Object element,String propertyId) { */ @Override public int compare(Viewer viewer, Object e1, Object e2) { - if (!(e1 instanceof IBreakpoint)) { + if (!(e1 instanceof IBreakpoint b1)) { return super.compare(viewer, e1, e2); } - IBreakpoint b1= (IBreakpoint)e1; IBreakpoint b2= (IBreakpoint)e2; String modelId1= b1.getModelIdentifier(); String modelId2= b2.getModelIdentifier(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDragAdapter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDragAdapter.java index 5b79cd38d61..698faa2b3a5 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDragAdapter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDragAdapter.java @@ -65,8 +65,7 @@ public void dragStart(DragSourceEvent event) { ISelection selection = fViewer.getSelection(); LocalSelectionTransfer.getTransfer().setSelection(selection); LocalSelectionTransfer.getTransfer().setSelectionSetTime(event.time & 0xFFFFFFFFL); - if (fViewer instanceof BreakpointsViewer) { - BreakpointsViewer viewer = (BreakpointsViewer)fViewer; + if (fViewer instanceof BreakpointsViewer viewer) { fItems = viewer.getSelectedItems(); event.doit = viewer.canDrag(fItems); } else { @@ -97,8 +96,7 @@ public void dragSetData(DragSourceEvent event) { public void dragFinished(DragSourceEvent event) { if (event.detail == DND.DROP_MOVE) { // remove from source on move operation - if (fViewer instanceof BreakpointsViewer) { - BreakpointsViewer viewer = (BreakpointsViewer)fViewer; + if (fViewer instanceof BreakpointsViewer viewer) { viewer.performDrag(fItems); } else { fView.performDrag(fTreePaths); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDropAdapter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDropAdapter.java index 85c59a89199..0e20113093d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDropAdapter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDropAdapter.java @@ -75,9 +75,8 @@ public boolean performDrop(Object data) { @Override protected Object determineTarget(DropTargetEvent event) { fTarget = (Item) event.item; - if (fTarget instanceof TreeItem) { + if (fTarget instanceof TreeItem item) { List list = new ArrayList<>(); - TreeItem item = (TreeItem)fTarget; while (item != null) { list.add(item.getData()); item = item.getParentItem(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsView.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsView.java index a681804be00..c14b12f73bc 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsView.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsView.java @@ -566,8 +566,7 @@ public boolean canPaste(Object target, ISelection selection) { * TODO remove in favor of using TreeItem as paste target */ public boolean performPaste(Object target, ISelection selection) { - if (target instanceof IBreakpointContainer && selection instanceof IStructuredSelection) { - IBreakpointContainer container = (IBreakpointContainer) target; + if (target instanceof IBreakpointContainer container && selection instanceof IStructuredSelection) { for (Object object : (IStructuredSelection) selection) { IBreakpoint breakpoint = (IBreakpoint)DebugPlugin.getAdapter(object, IBreakpoint.class); if (breakpoint != null) { @@ -649,8 +648,7 @@ private boolean checkAddableParentContainers(TreePath path, IBreakpoint breakpoi Object element = null; for (int i = path.getSegmentCount()-1; i > -1; i--) { element = path.getSegment(i); - if (element instanceof IBreakpointContainer) { - IBreakpointContainer container = (IBreakpointContainer) element; + if (element instanceof IBreakpointContainer container) { if (container.contains(breakpoint) || !container.getOrganizer().canAdd(breakpoint, container.getCategory())) { return false; } @@ -717,8 +715,7 @@ void performDrag(TreePath[] paths) { List list = entry.getValue(); IBreakpointOrganizer organizer = container.getOrganizer(); IBreakpoint[] breakpoints = list.toArray(new IBreakpoint[list.size()]); - if (organizer instanceof IBreakpointOrganizerDelegateExtension) { - IBreakpointOrganizerDelegateExtension extension = (IBreakpointOrganizerDelegateExtension) organizer; + if (organizer instanceof IBreakpointOrganizerDelegateExtension extension) { extension.removeBreakpoints(breakpoints, container.getCategory()); } else { for (IBreakpoint breakpoint : breakpoints) { @@ -752,8 +749,7 @@ protected boolean performDrop(TreePath target, ITreeSelection selection) { breakpoints.add(breakpoint); } } - if (organizer instanceof IBreakpointOrganizerDelegateExtension) { - IBreakpointOrganizerDelegateExtension extension = (IBreakpointOrganizerDelegateExtension) organizer; + if (organizer instanceof IBreakpointOrganizerDelegateExtension extension) { extension.addBreakpoints( breakpoints.toArray(new IBreakpoint[breakpoints.size()]), container.getCategory()); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsViewer.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsViewer.java index bbe5a5b139d..c8db8a472b8 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsViewer.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsViewer.java @@ -163,9 +163,8 @@ public IBreakpointContainer getAddableContainer(Item item) { TreePath path = getTreePathFromItem(item); if(path != null) { Object element = path.getLastSegment(); - if(element instanceof IBreakpoint) { + if(element instanceof IBreakpoint breakpoint) { IBreakpointContainer container = null; - IBreakpoint breakpoint = (IBreakpoint) element; for(int i = path.getSegmentCount()-2; i > -1; i--) { container = (IBreakpointContainer) path.getSegment(i); if(container.contains(breakpoint) && container.getOrganizer().canAdd(breakpoint, container.getCategory())) { @@ -236,8 +235,7 @@ public void performDrag(Item[] items) { List list = entry.getValue(); IBreakpointOrganizer organizer = container.getOrganizer(); IBreakpoint[] breakpoints = list.toArray(new IBreakpoint[list.size()]); - if (organizer instanceof IBreakpointOrganizerDelegateExtension) { - IBreakpointOrganizerDelegateExtension extension = (IBreakpointOrganizerDelegateExtension) organizer; + if (organizer instanceof IBreakpointOrganizerDelegateExtension extension) { extension.removeBreakpoints(breakpoints, container.getCategory()); } else { for (IBreakpoint bp : breakpoints) { @@ -315,13 +313,12 @@ public boolean performDrop(Item target, IStructuredSelection selection) { } IBreakpoint breakpoint = null; Object element = target.getData(); - IBreakpointContainer container = (element instanceof IBreakpointContainer ? (IBreakpointContainer)element : getAddableContainer(target)); + IBreakpointContainer container = (element instanceof IBreakpointContainer i ? i : getAddableContainer(target)); if(container == null) { return false; } IBreakpointOrganizer organizer = container.getOrganizer(); - if (organizer instanceof IBreakpointOrganizerDelegateExtension) { - IBreakpointOrganizerDelegateExtension extension = (IBreakpointOrganizerDelegateExtension) organizer; + if (organizer instanceof IBreakpointOrganizerDelegateExtension extension) { Object[] array = selection.toArray(); IBreakpoint[] breakpoints = new IBreakpoint[array.length]; System.arraycopy(array, 0, breakpoints, 0, array.length); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/WorkingSetCategory.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/WorkingSetCategory.java index 7f615dd91e3..e050d1c96c3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/WorkingSetCategory.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/WorkingSetCategory.java @@ -71,8 +71,7 @@ public IWorkingSet getWorkingSet() { @Override public boolean equals(Object obj) { - if (obj instanceof WorkingSetCategory) { - WorkingSetCategory category = (WorkingSetCategory) obj; + if (obj instanceof WorkingSetCategory category) { return category.getWorkingSet().equals(fWorkingSet); } return false; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleRemoveLaunchAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleRemoveLaunchAction.java index 9f5e7aaa0d4..59a27c9daa8 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleRemoveLaunchAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleRemoveLaunchAction.java @@ -130,8 +130,7 @@ protected ILaunch getLaunch() { } // else get dynmically, as this action was created via plug-in XML view contribution IConsole console = fConsoleView.getConsole(); - if (console instanceof ProcessConsole) { - ProcessConsole pconsole = (ProcessConsole) console; + if (console instanceof ProcessConsole pconsole) { return pconsole.getProcess().getLaunch(); } return null; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java index 574fc096aca..cfb289138ab 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java @@ -207,10 +207,10 @@ public ProcessConsole(IProcess process, IConsoleColorProvider colorProvider, Str fFileOutputStream = new FileOutputStream(outputFile, append); fileLoc = outputFile.getAbsolutePath(); - message = MessageFormat.format(ConsoleMessages.ProcessConsole_1, new Object[] { fileLoc }); + message = MessageFormat.format(ConsoleMessages.ProcessConsole_1, fileLoc); addPatternMatchListener(new ConsoleLogFilePatternMatcher(fileLoc)); } catch (FileNotFoundException e) { - message = MessageFormat.format(ConsoleMessages.ProcessConsole_2, new Object[] { file }); + message = MessageFormat.format(ConsoleMessages.ProcessConsole_2, file); } catch (CoreException e) { DebugUIPlugin.log(e); } @@ -235,7 +235,7 @@ public ProcessConsole(IProcess process, IConsoleColorProvider colorProvider, Str } } catch (FileNotFoundException e) { - message = MessageFormat.format(ConsoleMessages.ProcessConsole_3, new Object[] { fStdInFile }); + message = MessageFormat.format(ConsoleMessages.ProcessConsole_3, fStdInFile); } if (message != null) { try (IOConsoleOutputStream stream = newOutputStream()) { @@ -398,7 +398,7 @@ protected String computeName() { } if (process.isTerminated()) { - return MessageFormat.format(ConsoleMessages.ProcessConsole_0, new Object[] { label }); + return MessageFormat.format(ConsoleMessages.ProcessConsole_0, label); } return label; } @@ -803,8 +803,7 @@ private void flushAndDisableBuffer() { data = fBinaryStreamMonitor.getData(); } contents = fStreamMonitor.getContents(); - if (fStreamMonitor instanceof IFlushableStreamMonitor) { - IFlushableStreamMonitor m = (IFlushableStreamMonitor) fStreamMonitor; + if (fStreamMonitor instanceof IFlushableStreamMonitor m) { m.flushContents(); m.setBuffered(false); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsoleManager.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsoleManager.java index abf7104eee6..92971a2dcdc 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsoleManager.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsoleManager.java @@ -168,8 +168,7 @@ private void removeProcess(IProcess iProcess) { public IConsole getConsole(IProcess process) { IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager(); for (IConsole console : manager.getConsoles()) { - if (console instanceof ProcessConsole) { - ProcessConsole pc = (ProcessConsole)console; + if (console instanceof ProcessConsole pc) { if (pc.getProcess().equals(process)) { return pc; } @@ -276,7 +275,7 @@ public IConsoleColorProvider getColorProvider(String type) { } DebugUIPlugin.logErrorMessage(MessageFormat.format( "Extension {0} must specify an instanceof IConsoleColorProvider for class attribute.", //$NON-NLS-1$ - new Object[] { extension.getDeclaringExtension().getUniqueIdentifier() })); + extension.getDeclaringExtension().getUniqueIdentifier())); } catch (CoreException e) { DebugUIPlugin.log(e); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsolePageParticipant.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsolePageParticipant.java index ea5455d2b81..817916abf46 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsolePageParticipant.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsolePageParticipant.java @@ -85,8 +85,7 @@ private class EOFHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws org.eclipse.core.commands.ExecutionException { IStreamsProxy proxy = getProcess().getStreamsProxy(); - if (proxy instanceof IStreamsProxy2) { - IStreamsProxy2 proxy2 = (IStreamsProxy2) proxy; + if (proxy instanceof IStreamsProxy2 proxy2) { try { proxy2.closeInputStream(); } catch (IOException e1) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessTypePropertyTester.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessTypePropertyTester.java index 9f42f18cd80..ef3b4e93327 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessTypePropertyTester.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessTypePropertyTester.java @@ -27,8 +27,7 @@ public class ProcessTypePropertyTester extends PropertyTester { @Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if (receiver instanceof TextConsole) { - TextConsole console = (TextConsole) receiver; + if (receiver instanceof TextConsole console) { IProcess process = (IProcess) console.getAttribute(IDebugUIConstants.ATTR_CONSOLE_PROCESS); if (process != null) { String type = process.getAttribute(IProcess.ATTR_PROCESS_TYPE); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java index b8c0826e5b8..7df7c13b770 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionDropAdapter.java @@ -228,8 +228,7 @@ private boolean validateVariableDrop(Object target) { Iterator iterator = selection.iterator(); while (iterator.hasNext()) { Object element = iterator.next(); - if (element instanceof IVariable){ - IVariable variable = (IVariable) element; + if (element instanceof IVariable variable){ if (variable instanceof IndexedVariablePartition) { break; } else if (manager.hasWatchExpressionDelegate(variable.getModelIdentifier()) && isFactoryEnabled(variable)) { @@ -292,8 +291,7 @@ private boolean validateTextDrop(Object target){ */ private boolean isFactoryEnabled(IVariable variable) { IWatchExpressionFactoryAdapter factory = getFactory(variable); - if (factory instanceof IWatchExpressionFactoryAdapterExtension) { - IWatchExpressionFactoryAdapterExtension ext = (IWatchExpressionFactoryAdapterExtension) factory; + if (factory instanceof IWatchExpressionFactoryAdapterExtension ext) { return ext.canCreateWatchExpression(variable); } return true; @@ -442,8 +440,7 @@ private boolean performTextDrop(String text){ */ private String createExpressionString(Object element) { try { - if (element instanceof IVariable) { - IVariable variable = (IVariable)element; + if (element instanceof IVariable variable) { IWatchExpressionFactoryAdapter factory = getFactory(variable); String exp = variable.getName(); if (factory != null) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java index 95ca69e717d..4fbd0a9c92e 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementHelper.java @@ -135,8 +135,7 @@ public static RGB getForeground(Object element) { */ public static RGB getForeground(Object element, IDebugModelPresentation presentation) { Color color = null; - if (presentation instanceof IColorProvider) { - IColorProvider colorProvider = (IColorProvider) presentation; + if (presentation instanceof IColorProvider colorProvider) { color = colorProvider.getForeground(element); } else { color = getPresentation().getForeground(element); @@ -189,8 +188,7 @@ public static RGB getBackground(Object element) { */ public static RGB getBackground(Object element, IDebugModelPresentation presentation) { Color color = null; - if (presentation instanceof IColorProvider) { - IColorProvider colorProvider = (IColorProvider) presentation; + if (presentation instanceof IColorProvider colorProvider) { color = colorProvider.getBackground(element); } else { color = getPresentation().getBackground(element); @@ -227,8 +225,7 @@ public static FontData getFont(Object element) { */ public static FontData getFont(Object element, IDebugModelPresentation presentation) { Font font = null; - if (presentation instanceof IFontProvider) { - IFontProvider provider = (IFontProvider) presentation; + if (presentation instanceof IFontProvider provider) { font = provider.getFont(element); } else { font = getPresentation().getFont(element); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java index 820fc9d2b02..41af1cd0bb9 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchView.java @@ -381,8 +381,7 @@ protected void activate(ISelection selection) { protected void possibleChange(TreePath element, int type) { DebugContextEvent event = null; synchronized (this) { - if (fContext instanceof ITreeSelection) { - ITreeSelection ss = (ITreeSelection) fContext; + if (fContext instanceof ITreeSelection ss) { for (TreePath path : ss.getPaths()) { if (path.startsWith(element, null)) { if (path.getSegmentCount() == element.getSegmentCount()) { @@ -408,8 +407,7 @@ protected void possibleChange(TreePath element, int type) { public IStatus runInUIThread(IProgressMonitor monitor) { // verify selection is still the same context since job was scheduled synchronized (TreeViewerContextProvider.this) { - if (fContext instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) fContext; + if (fContext instanceof IStructuredSelection ss) { Object changed = ((IStructuredSelection)finalEvent.getContext()).getFirstElement(); if (!(ss.size() == 1 && ss.getFirstElement().equals(changed))) { return Status.OK_STATUS; @@ -1118,10 +1116,9 @@ public void selectionChanged(SelectionChangedEvent event) { @Override public void doubleClick(DoubleClickEvent event) { ISelection selection= event.getSelection(); - if (!(selection instanceof IStructuredSelection)) { + if (!(selection instanceof IStructuredSelection ss)) { return; } - IStructuredSelection ss= (IStructuredSelection)selection; Object o= ss.getFirstElement(); if (o == null || o instanceof IStackFrame) { return; @@ -1283,14 +1280,12 @@ protected boolean isActive() { public boolean show(ShowInContext context) { ISelection selection = context.getSelection(); if (selection != null) { - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection)selection; + if (selection instanceof IStructuredSelection ss) { if (ss.size() == 1) { Object obj = ss.getFirstElement(); if (obj instanceof IDebugTarget || obj instanceof IProcess) { Viewer viewer = getViewer(); - if (viewer instanceof InternalTreeModelViewer) { - InternalTreeModelViewer tv = (InternalTreeModelViewer) viewer; + if (viewer instanceof InternalTreeModelViewer tv) { tv.setSelection(selection, true, true); } else { viewer.setSelection(selection, true); @@ -1309,8 +1304,7 @@ public ShowInContext getShowInContext() { IStructuredSelection selection = (IStructuredSelection)getViewer().getSelection(); if (selection.size() == 1) { Object object = selection.getFirstElement(); - if (object instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) object; + if (object instanceof IAdaptable adaptable) { IShowInSource show = adaptable.getAdapter(IShowInSource.class); if (show != null) { return show.getShowInContext(); @@ -1327,8 +1321,7 @@ public String[] getShowInTargetIds() { IStructuredSelection selection = (IStructuredSelection)getViewer().getSelection(); if (selection.size() == 1) { Object object = selection.getFirstElement(); - if (object instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) object; + if (object instanceof IAdaptable adaptable) { IShowInTargetList show = adaptable.getAdapter(IShowInTargetList.class); if (show != null) { return show.getShowInTargetIds(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/SourceNotFoundEditorInput.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/SourceNotFoundEditorInput.java index c8f6f4864af..b6c256df0ed 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/SourceNotFoundEditorInput.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/SourceNotFoundEditorInput.java @@ -97,7 +97,7 @@ public IPersistableElement getPersistable() { */ @Override public String getToolTipText() { - return MessageFormat.format(DebugUIViewsMessages.SourceNotFoundEditorInput_Source_not_found_for__0__2, new Object[] { fFrameText }); + return MessageFormat.format(DebugUIViewsMessages.SourceNotFoundEditorInput_Source_not_found_for__0__2, fFrameText); } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java index 37033eabbb8..81bdb9f946c 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AbstractMemoryViewPane.java @@ -204,8 +204,7 @@ private void createFolder(IMemoryBlockRetrieval memRetrieval) { @Override public IMemoryViewTab getTopMemoryTab() { - if (fStackLayout.topControl instanceof CTabFolder) { - CTabFolder folder = (CTabFolder) fStackLayout.topControl; + if (fStackLayout.topControl instanceof CTabFolder folder) { if (!folder.isDisposed()) { int index = folder.getSelectionIndex(); if (index >= 0) { @@ -263,14 +262,13 @@ public ISelectionProvider getSelectionProvider() { public void handleDebugEvents(DebugEvent[] events) { for (DebugEvent event : events) { Object source = event.getSource(); - if (event.getKind() == DebugEvent.TERMINATE && source instanceof IMemoryBlockRetrieval) { + if (event.getKind() == DebugEvent.TERMINATE && source instanceof final IMemoryBlockRetrieval ret) { if (isDisposed()) { return; } // When a memory block retrieval terminates, it and its // tab folders should be removed from our map. - final IMemoryBlockRetrieval ret = (IMemoryBlockRetrieval) source; if (ret != null) { Display.getDefault().asyncExec(() -> { if (isDisposed()) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java index e78e7b9df0c..171fe87e594 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/AddMemoryBlockAction.java @@ -186,11 +186,9 @@ private boolean addMemoryBlocks(boolean exit, Object elem, IMemoryBlockRetrieval for (String e : expressionsArray) { String expression = e.trim(); try { - if (standardMemRetrieval instanceof IMemoryBlockRetrievalExtension) { + if (standardMemRetrieval instanceof IMemoryBlockRetrievalExtension memRetrieval) { // if the debug session supports // IMemoryBlockExtensionRetrieval - IMemoryBlockRetrievalExtension memRetrieval = (IMemoryBlockRetrievalExtension) standardMemRetrieval; - // get extended memory block with the expression entered IMemoryBlockExtension memBlock = memRetrieval.getExtendedMemoryBlock(expression, elem); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/CodePagesPreferencePage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/CodePagesPreferencePage.java index 732b2a06e2c..126a0096661 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/CodePagesPreferencePage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/CodePagesPreferencePage.java @@ -54,8 +54,9 @@ protected void createFieldEditors() { @Override public boolean performOk() { - if (fAsciiCodePage == null || fEbcdicCodePage == null) + if (fAsciiCodePage == null || fEbcdicCodePage == null) { return super.performOk(); + } // check that the codepages are supported String asciiCodePage = fAsciiCodePage.getStringValue(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java index 719e6d68788..e29fb2e4dfd 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryBlocksTreeViewPane.java @@ -240,8 +240,7 @@ public void contextActivated(ISelection selection) { if (selection instanceof IStructuredSelection) { Object obj = ((IStructuredSelection) selection).getFirstElement(); - if (obj instanceof IAdaptable) { - IAdaptable context = (IAdaptable) obj; + if (obj instanceof IAdaptable context) { IMemoryBlockRetrieval retrieval = MemoryViewUtil.getMemoryBlockRetrieval(context); if (retrieval != null && fTreeViewer != null && (retrieval != fRetrieval || retrieval != fTreeViewer.getInput()) && fTreeViewer.getContentProvider() != null) { // set new setting diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java index 9ed8e716c4a..c24ae9a5e8e 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryView.java @@ -385,8 +385,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { IMemoryRenderingContainer container = getContainer(fActivePaneId); - if (container != null && container instanceof RenderingViewPane) { - RenderingViewPane pane = (RenderingViewPane) container; + if (container != null && container instanceof RenderingViewPane pane) { if (pane.canAddRendering()) { pane.showCreateRenderingTab(); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewIdRegistry.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewIdRegistry.java index 7b484dd001d..2e5715cb7ee 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewIdRegistry.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewIdRegistry.java @@ -50,8 +50,9 @@ public static String getUniqueSecondaryId(String viewId) { } private static ArrayList getRegistry() { - if (fgRegistry == null) + if (fgRegistry == null) { fgRegistry = new ArrayList<>(); + } return fgRegistry; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTab.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTab.java index ffcda97bfd3..5fc36985d9f 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTab.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTab.java @@ -188,8 +188,7 @@ public IStatus runInUIThread(IProgressMonitor monitor) { if (event.getSource() == fRendering) { if (event.getProperty().equals(IBasicPropertyConstants.P_TEXT)) { Object value = event.getNewValue(); - if (value != null && value instanceof String) { - String label = (String) value; + if (value != null && value instanceof String label) { setTabLabel(label); } else { setTabLabel(fRendering.getLabel()); @@ -198,8 +197,7 @@ public IStatus runInUIThread(IProgressMonitor monitor) { if (event.getProperty().equals(IBasicPropertyConstants.P_IMAGE)) { Object value = event.getNewValue(); - if (value != null && value instanceof Image) { - Image image = (Image) value; + if (value != null && value instanceof Image image) { fTabItem.setImage(image); } else { fTabItem.setImage(fRendering.getImage()); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTreeModelContentProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTreeModelContentProvider.java index 14a3f027371..51578dcf282 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTreeModelContentProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewTreeModelContentProvider.java @@ -96,8 +96,9 @@ private boolean isFirstMemoryBlock() { Object input = getViewer().getInput(); if (input instanceof IMemoryBlockRetrieval) { IMemoryBlock[] memoryBlocks = DebugPlugin.getDefault().getMemoryBlockManager().getMemoryBlocks((IMemoryBlockRetrieval) input); - if (memoryBlocks.length == 1) + if (memoryBlocks.length == 1) { return true; + } } return false; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewUtil.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewUtil.java index 6138aa62e15..ae252eff68d 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewUtil.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/MemoryViewUtil.java @@ -194,8 +194,7 @@ public static IMemoryBlockRetrieval getMemoryBlockRetrieval(Object object) { } // check if the object can adapt to a memory block retrieval - if (object instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) object; + if (object instanceof IAdaptable adaptable) { retrieval = adaptable.getAdapter(IMemoryBlockRetrieval.class); } @@ -206,8 +205,7 @@ public static IMemoryBlockRetrieval getMemoryBlockRetrieval(Object object) { } // otherewise, default back to the debug target - if (retrieval == null && object instanceof IDebugElement) { - IDebugElement de = (IDebugElement) object; + if (retrieval == null && object instanceof IDebugElement de) { retrieval = de.getDebugTarget(); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/NewMemoryViewAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/NewMemoryViewAction.java index aec3672ed49..f52d4a1d45a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/NewMemoryViewAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/NewMemoryViewAction.java @@ -37,8 +37,9 @@ public class NewMemoryViewAction implements IViewActionDelegate { @Override public void init(IViewPart view) { - if (view instanceof MemoryView) + if (view instanceof MemoryView) { fView = (MemoryView) view; + } } @Override @@ -61,17 +62,17 @@ public void run(IAction action) { private void setInitialSelection(IViewPart newView) { ISelection selection = fView.getSite().getSelectionProvider().getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection strucSel = (IStructuredSelection) selection; - + if (selection instanceof IStructuredSelection strucSel) { // return if current selection is empty - if (strucSel.isEmpty()) + if (strucSel.isEmpty()) { return; + } Object obj = strucSel.getFirstElement(); - if (obj == null) + if (obj == null) { return; + } if (obj instanceof IMemoryRendering) { IMemoryBlock memBlock = ((IMemoryRendering) obj).getMemoryBlock(); @@ -84,8 +85,7 @@ private void setInitialSelection(IViewPart newView) { } private void setInitialViewSettings(IViewPart newView) { - if (fView != null && newView instanceof MemoryView) { - MemoryView newMView = (MemoryView) newView; + if (fView != null && newView instanceof MemoryView newMView) { IMemoryViewPane[] viewPanes = fView.getViewPanes(); int orientation = fView.getViewPanesOrientation(); for (IMemoryViewPane viewPane : viewPanes) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/PinMemoryBlockAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/PinMemoryBlockAction.java index 368737f6217..33f1b2493e7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/PinMemoryBlockAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/PinMemoryBlockAction.java @@ -30,15 +30,17 @@ public class PinMemoryBlockAction implements IViewActionDelegate { @Override public void init(IViewPart view) { - if (view instanceof MemoryView) + if (view instanceof MemoryView) { fView = (MemoryView) view; + } } @Override public void run(IAction action) { - if (fView == null) + if (fView == null) { return; + } boolean pin = !fView.isPinMBDisplay(); fView.setPinMBDisplay(pin); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java index a17197b4e32..eb6175fa616 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RenderingViewPane.java @@ -269,13 +269,11 @@ public IStatus runInUIThread(IProgressMonitor monitor) { Object elem = ((IStructuredSelection) selection).getFirstElement(); - if (elem instanceof IMemoryBlock) { + if (elem instanceof IMemoryBlock memBlock) { // if the selection event comes from this view if (part == getMemoryRenderingSite()) { // find the folder associated with the given // IMemoryBlockRetrieval - IMemoryBlock memBlock = (IMemoryBlock) elem; - // should never get here... added code for safety if (fTabFolderForMemoryBlock == null) { if (lastViewTab != null) { @@ -982,8 +980,7 @@ public void resetRenderings(IMemoryBlock memoryBlock, boolean resetVisible) { IMemoryRendering rendering = getActiveRendering(); if (rendering != null) { if (rendering.getMemoryBlock() == memoryBlock) { - if (rendering instanceof IResettableMemoryRendering) { - IResettableMemoryRendering resettableRendering = (IResettableMemoryRendering) rendering; + if (rendering instanceof IResettableMemoryRendering resettableRendering) { try { resettableRendering.resetRendering(); } catch (DebugException e) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ResetMemoryBlockAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ResetMemoryBlockAction.java index 1d8f8184787..63369641f3a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ResetMemoryBlockAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ResetMemoryBlockAction.java @@ -57,8 +57,7 @@ public void run(IAction action) { Iterator iter = fSelectedMB.iterator(); while (iter.hasNext()) { IMemoryBlock mb = (IMemoryBlock) iter.next(); - if (fView instanceof MemoryView) { - MemoryView memView = (MemoryView) fView; + if (fView instanceof MemoryView memView) { IMemoryRenderingContainer[] containers = memView.getMemoryRenderingContainers(); for (IMemoryRenderingContainer container : containers) { @@ -73,8 +72,7 @@ public void run(IAction action) { @Override public void selectionChanged(IAction action, ISelection selection) { action.setEnabled(!selection.isEmpty()); - if (selection instanceof IStructuredSelection) { - IStructuredSelection strucSel = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection strucSel) { Object[] objs = strucSel.toArray(); fSelectedMB.clear(); for (Object obj : objs) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RetargetAddMemoryBlockAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RetargetAddMemoryBlockAction.java index 89f69ea707f..25a9105cf47 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RetargetAddMemoryBlockAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/RetargetAddMemoryBlockAction.java @@ -52,8 +52,9 @@ public void run() { try { if (target.supportsAddMemoryBlocks(getMemoryView())) { target.addMemoryBlocks(getMemoryView(), getMemoryView().getSite().getSelectionProvider().getSelection()); - } else + } else { super.run(); + } } catch (CoreException e) { DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), ActionMessages.RetargetAddMemoryBlockAction_0, ActionMessages.RetargetAddMemoryBlockAction_1, e); } @@ -70,12 +71,14 @@ protected void updateAction(Object debugContext) { if (target != null) { if (target.supportsAddMemoryBlocks(getMemoryView())) { - if (getMemoryView().getSite().getSelectionProvider() != null) + if (getMemoryView().getSite().getSelectionProvider() != null) { setEnabled(target.canAddMemoryBlocks(getMemoryView(), getMemoryView().getSite().getSelectionProvider().getSelection())); - else + } else { super.updateAction(debugContext); - } else + } + } else { super.updateAction(debugContext); + } } else { super.updateAction(debugContext); } @@ -87,8 +90,9 @@ protected void updateAction(Object debugContext) { private IAddMemoryBlocksTarget getAddMemoryBlocksTarget(Object debugContext) { IMemoryBlockRetrieval standardMemRetrieval = MemoryViewUtil.getMemoryBlockRetrieval(debugContext); - if (standardMemRetrieval == null) + if (standardMemRetrieval == null) { return null; + } IAddMemoryBlocksTarget target = null; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SwitchMemoryBlockAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SwitchMemoryBlockAction.java index 399dec87763..9c61796dde8 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SwitchMemoryBlockAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SwitchMemoryBlockAction.java @@ -268,8 +268,7 @@ public void init(IViewPart view) { * @return the memory blocks tree viewer or null */ private StructuredViewer getViewer() { - if (fView instanceof MemoryView) { - MemoryView memView = (MemoryView) fView; + if (fView instanceof MemoryView memView) { IMemoryViewPane pane = memView.getViewPane(MemoryBlocksTreeViewPane.PANE_ID); if (pane instanceof MemoryBlocksTreeViewPane) { StructuredViewer viewer = ((MemoryBlocksTreeViewPane) pane).getViewer(); @@ -291,8 +290,7 @@ public void run() { private void switchToNext() { IAdaptable context = getDebugContext(); - if (context instanceof IDebugElement) { - IDebugElement debugContext = (IDebugElement) context; + if (context instanceof IDebugElement debugContext) { IMemoryBlockRetrieval retrieval = MemoryViewUtil.getMemoryBlockRetrieval(debugContext); if (retrieval != null) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SynchronizeInfo.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SynchronizeInfo.java index 98111a9a6d0..4e30dcf369a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SynchronizeInfo.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/SynchronizeInfo.java @@ -50,11 +50,13 @@ public SynchronizeInfo(IMemoryBlock block) { * Set a property and its value to the info object */ public void setProperty(String propertyId, Object value) { - if (propertyId == null) + if (propertyId == null) { return; + } - if (value == null) + if (value == null) { return; + } fProperties.put(propertyId, value); } @@ -65,8 +67,9 @@ public void setProperty(String propertyId, Object value) { * @return value of the property */ public Object getProperty(String propertyId) { - if (propertyId == null) + if (propertyId == null) { return null; + } Object value = fProperties.get(propertyId); @@ -77,8 +80,9 @@ public Object getProperty(String propertyId) { * @return all the property ids stored in this sync info object */ public String[] getPropertyIds() { - if (fProperties == null) + if (fProperties == null) { return new String[0]; + } Enumeration enumeration = fProperties.keys(); ArrayList ids = new ArrayList<>(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewPaneRenderingMgr.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewPaneRenderingMgr.java index 7d4584be6b8..424efb5b1da 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewPaneRenderingMgr.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/ViewPaneRenderingMgr.java @@ -269,8 +269,7 @@ private String getPrefId() { StringBuilder id = new StringBuilder(); IMemoryRenderingSite renderingSite = fViewPane.getMemoryRenderingSite(); IWorkbenchPartSite ps = renderingSite.getSite(); - if (ps instanceof IViewSite) { - IViewSite vs = (IViewSite) ps; + if (ps instanceof IViewSite vs) { String secondaryId = vs.getSecondaryId(); if (secondaryId != null) { id.append(secondaryId); @@ -387,8 +386,7 @@ private void loadPersistedRenderings(String prefId) { private String getViewSiteSecondaryId() { IMemoryRenderingSite renderingSite = fViewPane.getMemoryRenderingSite(); IWorkbenchPartSite ps = renderingSite.getSite(); - if (ps instanceof IViewSite) { - IViewSite vs = (IViewSite) ps; + if (ps instanceof IViewSite vs) { String secondaryId = vs.getSecondaryId(); return secondaryId; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AbstractIntegerRendering.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AbstractIntegerRendering.java index ece230704ac..8ed7c01b1fe 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AbstractIntegerRendering.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/AbstractIntegerRendering.java @@ -36,8 +36,9 @@ public void init(IMemoryRenderingContainer container, IMemoryBlock block) { super.init(container, block); // default to big endian for simple memory block - if (!(block instanceof IMemoryBlockExtension)) + if (!(block instanceof IMemoryBlockExtension)) { fDisplayEndianess = RenderingsUtil.BIG_ENDIAN; + } } /** @@ -57,18 +58,21 @@ public void setDisplayEndianess(int currentEndianess) { protected int getBytesEndianess(MemoryByte[] data) { int endianess = RenderingsUtil.ENDIANESS_UNKNOWN; - if (!data[0].isEndianessKnown()) + if (!data[0].isEndianessKnown()) { return endianess; + } - if (data[0].isBigEndian()) + if (data[0].isBigEndian()) { endianess = RenderingsUtil.BIG_ENDIAN; - else + } else { endianess = RenderingsUtil.LITTLE_ENDIAN; + } for (int i=1; i { Object obj = e.getSource(); - if (obj instanceof Control) + if (obj instanceof Control control) { - Control control = (Control) obj; int row = fCellEditorListener.getRow(); int col = fCellEditorListener.getCol(); @@ -804,10 +803,8 @@ private void doHandleKeyEvent(int row, int col) if (numCharsPerByte > 0) { Object value = getCellEditors()[col].getValue(); - if (getCellEditors()[col] instanceof TextCellEditor && value instanceof String) + if (getCellEditors()[col] instanceof TextCellEditor && value instanceof String str) { - String str = (String)value; - if (str.length() > fRendering.getBytesPerColumn()*numCharsPerByte) { String newValue = str; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/CreateRendering.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/CreateRendering.java index eca14460a04..dc8e20972e8 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/CreateRendering.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/CreateRendering.java @@ -224,10 +224,8 @@ private void addRenderings() ISelection selection = fViewer.getSelection(); Object[] renderings = null; - if (selection instanceof IStructuredSelection) + if (selection instanceof IStructuredSelection strucSelection) { - IStructuredSelection strucSelection = (IStructuredSelection)selection; - renderings = strucSelection.toArray(); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/DefaultEndianessAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/DefaultEndianessAction.java index 90557fbccc9..29ff30caf38 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/DefaultEndianessAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/DefaultEndianessAction.java @@ -56,14 +56,16 @@ public void run(IAction action) { @Override public void selectionChanged(IAction action, ISelection selection) { - if (selection == null) + if (selection == null) { return; + } if (selection instanceof IStructuredSelection) { Object obj = ((IStructuredSelection)selection).getFirstElement(); - if (obj == null) + if (obj == null) { return; + } if (obj instanceof AbstractIntegerRendering) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/FormatTableRenderingDialog.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/FormatTableRenderingDialog.java index ad00fab0bba..cbba38db1f2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/FormatTableRenderingDialog.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/FormatTableRenderingDialog.java @@ -361,11 +361,13 @@ private Control createPreviewPage(Composite parent, int rowSize, int colSize) private boolean isValid(int rowSize, int colSize) { - if (rowSize % colSize != 0) + if (rowSize % colSize != 0) { return false; + } - if (colSize > rowSize) + if (colSize > rowSize) { return false; + } return true; } @@ -413,8 +415,9 @@ private int getDefaultRowSize() IPersistableDebugElement elmt = fRendering.getMemoryBlock().getAdapter(IPersistableDebugElement.class); if (elmt != null) { - if (elmt.supportsProperty(fRendering, IDebugPreferenceConstants.PREF_ROW_SIZE_BY_MODEL)) + if (elmt.supportsProperty(fRendering, IDebugPreferenceConstants.PREF_ROW_SIZE_BY_MODEL)) { return getDefaultFromPersistableElement(IDebugPreferenceConstants.PREF_ROW_SIZE_BY_MODEL); + } } size = getDefaultRowSize(fRendering.getMemoryBlock().getModelIdentifier()); @@ -428,8 +431,9 @@ private int getDefaultColumnSize() IPersistableDebugElement elmt = fRendering.getMemoryBlock().getAdapter(IPersistableDebugElement.class); if (elmt != null) { - if (elmt.supportsProperty(fRendering, IDebugPreferenceConstants.PREF_COL_SIZE_BY_MODEL)) + if (elmt.supportsProperty(fRendering, IDebugPreferenceConstants.PREF_COL_SIZE_BY_MODEL)) { return getDefaultFromPersistableElement(IDebugPreferenceConstants.PREF_COL_SIZE_BY_MODEL); + } } size = getDefaultColumnSize(fRendering.getMemoryBlock().getModelIdentifier()); @@ -534,8 +538,9 @@ public void setCurrentRowColSizes(int row, int col) @Override protected Control createButtonBar(Composite parent) { Control ret = super.createButtonBar(parent); - if (fDisableCancel) + if (fDisableCancel) { getButton(IDialogConstants.CANCEL_ID).setEnabled(false); + } updateButtons(); return ret; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressAction.java index b65e05f21a0..08a58092d36 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressAction.java @@ -113,9 +113,8 @@ public void doGoToAddress(String expression) throws DebugException, NumberFormat // look at this address and figure out if a new memory block should // be opened. IMemoryBlock mb = fRendering.getMemoryBlock(); - if (mb instanceof IMemoryBlockExtension) + if (mb instanceof IMemoryBlockExtension mbExt) { - IMemoryBlockExtension mbExt = (IMemoryBlockExtension)mb; BigInteger mbStart = mbExt.getMemoryBlockStartAddress(); BigInteger mbEnd = mbExt.getMemoryBlockEndAddress(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressComposite.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressComposite.java index 8817795ba71..4f1ab189a18 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressComposite.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/GoToAddressComposite.java @@ -78,10 +78,11 @@ public int getHeight() public Button getButton(int id) { - if (id == IDialogConstants.OK_ID) + if (id == IDialogConstants.OK_ID) { return fOKButton; - else if (id == IDialogConstants.CANCEL_ID) + } else if (id == IDialogConstants.CANCEL_ID) { return fCancelButton; + } return null; } @@ -156,16 +157,19 @@ else if (expression.startsWith("-")) //$NON-NLS-1$ BigInteger gotoAddress = new BigInteger(expression, radix); BigInteger address = baseAddress; - if (isJump()) + if (isJump()) { address = selectedAddress; + } - if (address == null) + if (address == null) { throw new NumberFormatException(DebugUIMessages.GoToAddressComposite_7); + } - if (add) + if (add) { gotoAddress = address.add(gotoAddress); - else + } else { gotoAddress = address.subtract(gotoAddress); + } return gotoAddress; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/MemorySegment.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/MemorySegment.java index f3e497c937d..4f6e65e7751 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/MemorySegment.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/MemorySegment.java @@ -48,8 +48,9 @@ public int getNumAddressableUnits() { public boolean containsAddress(BigInteger address) { - if (getAddress().compareTo(address) <= 0 && getEndAddress().compareTo(address) >= 0) + if (getAddress().compareTo(address) <= 0 && getEndAddress().compareTo(address) >= 0) { return true; + } return false; } @@ -69,11 +70,13 @@ public BigInteger getEndAddress() */ public MemoryByte[] getBytes(int start, int length) { - if (start < 0) + if (start < 0) { return new MemoryByte[0]; + } - if (start + length > fBytes.length) + if (start + length > fBytes.length) { return new MemoryByte[0]; + } ArrayList ret = new ArrayList<>(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ResetToBaseAddressAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ResetToBaseAddressAction.java index 8fb704f2042..4f628cc6811 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ResetToBaseAddressAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/ResetToBaseAddressAction.java @@ -57,7 +57,7 @@ public void run() { // they have migrated to the new #resetRendering API Class renderingClass = fRendering.getClass(); try { - Method method = renderingClass.getMethod("reset", new Class[] {}); //$NON-NLS-1$ + Method method = renderingClass.getMethod("reset"); //$NON-NLS-1$ if (method.getDeclaringClass().equals(AbstractTableRendering.class)) { // client has not overrode, call new method try { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingCellModifier.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingCellModifier.java index 96708b476a2..5f2a1e2841c 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingCellModifier.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingCellModifier.java @@ -101,11 +101,10 @@ private int getAddressableSize() { public Object getValue(Object element, String property) { // give back the value of the column - if (!(element instanceof TableRenderingLine)) { + if (!(element instanceof TableRenderingLine line)) { return null; } - TableRenderingLine line = (TableRenderingLine) element; try { if (TableRenderingLine.P_ADDRESS.equals(property)) { return line.getAddress(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingLabelProvider.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingLabelProvider.java index eab2e509067..2d6bf390c06 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingLabelProvider.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingLabelProvider.java @@ -52,10 +52,8 @@ public void dispose() { @Override public Color getForeground(Object element) { - if (element instanceof TableRenderingLine) + if (element instanceof TableRenderingLine line) { - TableRenderingLine line = (TableRenderingLine)element; - if (line.isMonitored) { return DebugUIPlugin.getPreferenceColor(IDebugUIConstants.PREF_MEMORY_HISTORY_KNOWN_COLOR); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingLabelProviderEx.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingLabelProviderEx.java index ca33edf32a5..4e267a37c77 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingLabelProviderEx.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingLabelProviderEx.java @@ -126,8 +126,7 @@ public Font getFont(Object element, int columnIndex) { * @return memory rendering element or null */ private MemoryRenderingElement getMemoryRenderingElement(Object element, int columnIndex) { - if (element instanceof TableRenderingLine) { - TableRenderingLine line = (TableRenderingLine) element; + if (element instanceof TableRenderingLine line) { BigInteger lineAddress = new BigInteger(line.getAddress(), 16); int offset = (columnIndex - 1) * fRendering.getBytesPerColumn(); if (offset < fRendering.getBytesPerLine() && (offset + fRendering.getBytesPerColumn()) <= fRendering.getBytesPerLine()) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingModel.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingModel.java index 5a91db8714b..8025d5dface 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingModel.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingModel.java @@ -55,8 +55,7 @@ class SupportsChangeMgmtJob extends Job { @Override protected IStatus run(IProgressMonitor monitor) { IMemoryBlock mb = getMemoryBlock(); - if (mb instanceof IMemoryBlockExtension) { - IMemoryBlockExtension mbExt = (IMemoryBlockExtension) mb; + if (mb instanceof IMemoryBlockExtension mbExt) { fMBSupportsChangeManagement = mbExt.supportsChangeManagement(); } return Status.OK_STATUS; @@ -72,13 +71,11 @@ public TableRenderingModel(AsynchronousTableViewer viewer) { @Override public int indexOfKey(Object key) { - if (key instanceof BigInteger) { - BigInteger address = (BigInteger) key; + if (key instanceof BigInteger address) { Object items[] = getElements(); for (int i = 0; i < items.length; i++) { - if (items[i] != null && items[i] instanceof MemorySegment) { - MemorySegment line = (MemorySegment) items[i]; + if (items[i] != null && items[i] instanceof MemorySegment line) { if (line.containsAddress(address)) { return i; } @@ -91,9 +88,7 @@ public int indexOfKey(Object key) { @Override public int columnOf(Object element, Object key) { - if (element instanceof MemorySegment && key instanceof BigInteger) { - BigInteger address = (BigInteger) key; - MemorySegment line = (MemorySegment) element; + if (element instanceof MemorySegment line && key instanceof BigInteger address) { if (line.containsAddress(address)) { if (getAddressableUnitsPerColumn() > 0) { BigInteger offset = address.subtract(line.getAddress()); @@ -136,8 +131,7 @@ public Object getKey(Object element) { @Override public Object getKey(int idx, int col) { Object element = getElement(idx); - if (element != null && element instanceof MemorySegment) { - MemorySegment segment = (MemorySegment) element; + if (element != null && element instanceof MemorySegment segment) { BigInteger rowAddress = segment.getAddress(); int offset; @@ -187,8 +181,7 @@ public Object[] compare(Object[] newElements) { } for (Object obj : newElements) { - if (obj instanceof MemorySegment) { - MemorySegment newSegment = (MemorySegment) obj; + if (obj instanceof MemorySegment newSegment) { MemorySegment oldSegment = (MemorySegment) fCache.get(newSegment.getAddress()); if (oldSegment != null) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPreferencePage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPreferencePage.java index ab5a6e3e773..e619d2d3229 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPreferencePage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPreferencePage.java @@ -192,8 +192,9 @@ public void widgetSelected(SelectionEvent e) { public boolean performOk() { boolean auto = fAuto.getSelection(); boolean currentValue = getPreferenceStore().getBoolean(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM); - if (auto != currentValue) + if (auto != currentValue) { getPreferenceStore().setValue(IDebugPreferenceConstants.PREF_DYNAMIC_LOAD_MEM, auto); + } fPageSize.store(); fPreBufferSize.store(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPropertiesPage.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPropertiesPage.java index b11584e9010..2d37af83f17 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPropertiesPage.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/memory/renderings/TableRenderingPropertiesPage.java @@ -55,8 +55,9 @@ protected Control createContents(Composite parent) { composite.setLayoutData(comositeSpec); String label = rendering.getLabel(); - if (label.startsWith("&&")) //$NON-NLS-1$ + if (label.startsWith("&&")) { //$NON-NLS-1$ label = label.replaceFirst("&&", "&"); //$NON-NLS-1$//$NON-NLS-2$ + } addProperty(composite, DebugUIMessages.TableRenderingPropertiesPage_1, label); MemoryByte[] bytes = rendering.getSelectedAsBytes(); @@ -80,8 +81,9 @@ protected Control createContents(Composite parent) { boolean endianessKnown = bytes[0].isEndianessKnown(); int endianess = RenderingsUtil.ENDIANESS_UNKNOWN; - if (endianessKnown) + if (endianessKnown) { endianess = bytes[0].isBigEndian()?RenderingsUtil.BIG_ENDIAN:RenderingsUtil.LITTLE_ENDIAN; + } boolean allBytesKnown = bytes[0].isHistoryKnown(); boolean allBytesUnchanged = bytes[0].isChanged()?false:true; @@ -96,28 +98,34 @@ protected Control createContents(Composite parent) { if (endianessKnown) { int byteEndianess = bytes[i].isBigEndian()?RenderingsUtil.BIG_ENDIAN:RenderingsUtil.LITTLE_ENDIAN; - if (endianess != RenderingsUtil.ENDIANESS_UNKNOWN && endianess != byteEndianess) + if (endianess != RenderingsUtil.ENDIANESS_UNKNOWN && endianess != byteEndianess) { endianess = RenderingsUtil.ENDIANESS_UNKNOWN; + } } - if (!bytes[i].isHistoryKnown()) + if (!bytes[i].isHistoryKnown()) { allBytesKnown = false; - if (bytes[i].isChanged()) + } + if (bytes[i].isChanged()) { allBytesUnchanged = false; + } - if (!bytes[i].isReadable()) + if (!bytes[i].isReadable()) { allBytesReadable = false; + } - if (!bytes[i].isWritable()) + if (!bytes[i].isWritable()) { allBytesWritable = false; + } } } boolean isChanged = allBytesKnown && !allBytesUnchanged; - if (allBytesKnown) + if (allBytesKnown) { addProperty(composite, DebugUIMessages.TableRenderingPropertiesPage_9, String.valueOf(isChanged)); - else + } else { addProperty(composite, DebugUIMessages.TableRenderingPropertiesPage_10, DebugUIMessages.TableRenderingPropertiesPage_11); + } String dataEndian = DebugUIMessages.TableRenderingPropertiesPage_12; if (endianessKnown) @@ -137,10 +145,9 @@ protected Control createContents(Composite parent) { addProperty(composite, DebugUIMessages.TableRenderingPropertiesPage_16, dataEndian); - if (rendering instanceof AbstractIntegerRendering) + if (rendering instanceof AbstractIntegerRendering intRendering) { - AbstractIntegerRendering intRendering = (AbstractIntegerRendering)rendering; String displayEndian = DebugUIMessages.TableRenderingPropertiesPage_17; endianess = intRendering.getDisplayEndianess(); @@ -152,10 +159,11 @@ protected Control createContents(Composite parent) { displayEndian = DebugUIMessages.TableRenderingPropertiesPage_19; break; default: - if (endianessKnown) + if (endianessKnown) { displayEndian = dataEndian; - else + } else { displayEndian = DebugUIMessages.TableRenderingPropertiesPage_20; + } break; } addProperty(composite, DebugUIMessages.TableRenderingPropertiesPage_21, displayEndian); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/modules/ModulesView.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/modules/ModulesView.java index 35da4bbc053..5f432992111 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/modules/ModulesView.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/modules/ModulesView.java @@ -113,8 +113,7 @@ protected void setViewerInput(Object context) { } private void updateContextHelp(Object context) { - if (context instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) context; + if (context instanceof IAdaptable adaptable) { if (adaptable.getAdapter(IHelpContextIdProvider.class) != null) { IHelpContextIdProvider provider = adaptable .getAdapter(IHelpContextIdProvider.class); @@ -145,8 +144,7 @@ private void updateViewLabels(Object context) } private String getViewName(Object context) { - if (context instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) context; + if (context instanceof IAdaptable adaptable) { if (adaptable.getAdapter(ILabelProvider.class) != null) { ILabelProvider provider = adaptable .getAdapter(ILabelProvider.class); @@ -161,8 +159,7 @@ private String getViewName(Object context) { private Image getViewImage(Object context) { - if (context instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) context; + if (context instanceof IAdaptable adaptable) { if (adaptable.getAdapter(ILabelProvider.class) != null) { ILabelProvider provider = adaptable .getAdapter(ILabelProvider.class); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/AvailableLogicalStructuresAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/AvailableLogicalStructuresAction.java index ff9c356e764..cd714f051b7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/AvailableLogicalStructuresAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/AvailableLogicalStructuresAction.java @@ -129,19 +129,16 @@ public void init() { setValue(null); setTypes(null); ISelection s = getView().getViewer().getSelection(); - if (s instanceof IStructuredSelection) { - IStructuredSelection selection = (IStructuredSelection) s; + if (s instanceof IStructuredSelection selection) { if (selection.size() == 1) { Object obj = selection.getFirstElement(); IValue value = null; - if (obj instanceof IVariable) { - IVariable var = (IVariable) obj; + if (obj instanceof IVariable var) { try { value = var.getValue(); } catch (DebugException e) { } - } else if (obj instanceof IExpression) { - IExpression expression = (IExpression) obj; + } else if (obj instanceof IExpression expression) { value = expression.getValue(); } if (value != null) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/IndexedVariablePartition.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/IndexedVariablePartition.java index 37d1854baac..2e545786530 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/IndexedVariablePartition.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/IndexedVariablePartition.java @@ -86,8 +86,7 @@ public String getName() { @Override public String getReferenceTypeName() throws DebugException { - if (fOriginalVariable instanceof IVariable) { - IVariable variable = (IVariable) fOriginalVariable; + if (fOriginalVariable instanceof IVariable variable) { return variable.getReferenceTypeName(); } return IInternalDebugCoreConstants.EMPTY_STRING; @@ -140,8 +139,7 @@ public boolean verifyValue(IValue value) { @Override public boolean equals(Object obj) { - if (obj instanceof IndexedVariablePartition) { - IndexedVariablePartition partition = (IndexedVariablePartition)obj; + if (obj instanceof IndexedVariablePartition partition) { return fOriginalVariable.equals(partition.fOriginalVariable) && fOffset == partition.fOffset && fLength == partition.fLength; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/LogicalStructureCache.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/LogicalStructureCache.java index 4f1df9d7064..faf4f95f4cb 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/LogicalStructureCache.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/LogicalStructureCache.java @@ -154,10 +154,9 @@ public IValue getLogicalStructure(IValue value) throws CoreException { } public void dispose() { - if (!(fType instanceof ILogicalStructureTypeDelegate3)) { + if (!(fType instanceof ILogicalStructureTypeDelegate3 typeDelegate)) { return; } - ILogicalStructureTypeDelegate3 typeDelegate = (ILogicalStructureTypeDelegate3) fType; synchronized (fKnownValues) { fKnownValues.values().forEach(typeDelegate::releaseValue); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java index 5bcc87389ce..357dfc7aff2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java @@ -1269,12 +1269,10 @@ public void doubleClick(DoubleClickEvent event) { action.run(); } else { ISelection selection = getVariablesViewer().getSelection(); - if (selection instanceof TreeSelection) { - TreeSelection ss = (TreeSelection) selection; + if (selection instanceof TreeSelection ss) { if (ss.size() == 1) { Widget item = getVariablesViewer().findItem(ss.getPaths()[0]); - if (item instanceof TreeItem) { - TreeItem ti = (TreeItem) item; + if (item instanceof TreeItem ti) { if (ti.getExpanded()) { ti.setExpanded(false); } else { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DefaultDetailPane.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DefaultDetailPane.java index 5566bcc36e8..112b14ca97c 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DefaultDetailPane.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DefaultDetailPane.java @@ -202,11 +202,9 @@ protected IStatus run(IProgressMonitor monitor) { } } else if (element instanceof IExpression) { val = ((IExpression)element).getValue(); - } else if (element instanceof IBreakpoint) { - IBreakpoint bp = (IBreakpoint) element; + } else if (element instanceof IBreakpoint bp) { message = bp.getMarker().getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$ - } else if (element instanceof IBreakpointContainer) { - IBreakpointContainer c = (IBreakpointContainer) element; + } else if (element instanceof IBreakpointContainer c) { IAdaptable category = c.getCategory(); if (category != null) { IWorkbenchAdapter adapter = category.getAdapter(IWorkbenchAdapter.class); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneProxy.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneProxy.java index 8e1c8a471e3..1c8e73bd3b3 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneProxy.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/DetailPaneProxy.java @@ -240,11 +240,11 @@ public void focusLost(FocusEvent e) { } } else{ createErrorLabel(DetailMessages.DetailPaneProxy_0); - DebugUIPlugin.log(new CoreException(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), MessageFormat.format(DetailMessages.DetailPaneProxy_2, new Object[] { fCurrentPane.getID() })))); + DebugUIPlugin.log(new CoreException(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), MessageFormat.format(DetailMessages.DetailPaneProxy_2, fCurrentPane.getID())))); } } else { createErrorLabel(DetailMessages.DetailPaneProxy_0); - DebugUIPlugin.log(new CoreException(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), MessageFormat.format(DetailMessages.DetailPaneProxy_3, new Object[] { paneID })))); + DebugUIPlugin.log(new CoreException(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), MessageFormat.format(DetailMessages.DetailPaneProxy_3, paneID)))); } } finally { fParentContainer.getParentComposite().setRedraw(true); @@ -257,8 +257,7 @@ public void focusLost(FocusEvent e) { * @param hasFocus whether the detail pane control has the focus */ protected void updateSelectionProvider(boolean hasFocus) { - if (fParentContainer instanceof IDetailPaneContainer2) { - final IDetailPaneContainer2 container2 = (IDetailPaneContainer2) fParentContainer; + if (fParentContainer instanceof final IDetailPaneContainer2 container2) { if (fCurrentPane instanceof IDetailPane2) { final ISelectionProvider provider= hasFocus ? ((IDetailPane2) fCurrentPane).getSelectionProvider() : null; container2.setSelectionProvider(provider); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/MessageDetailPane.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/MessageDetailPane.java index e6ce5f871a3..98e429cc7da 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/MessageDetailPane.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/details/MessageDetailPane.java @@ -73,8 +73,7 @@ public void display(IStructuredSelection selection) { // re-create controls if the layout has changed if (selection != null && selection.size() == 1) { Object input = selection.getFirstElement(); - if (input instanceof String) { - String message = (String) input; + if (input instanceof String message) { fLabel.setText(message); fControlParent.layout(true); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractDebugView.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractDebugView.java index bd8ffbe6533..59fbc90bbf8 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractDebugView.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/AbstractDebugView.java @@ -436,8 +436,7 @@ protected void saveAllCheckedActionStates() { IToolBarManager tbm= getViewSite().getActionBars().getToolBarManager(); IContributionItem[] items= tbm.getItems(); for (IContributionItem contitem : items) { - if (contitem instanceof ActionContributionItem) { - ActionContributionItem item= (ActionContributionItem)contitem; + if (contitem instanceof ActionContributionItem item) { IAction action= item.getAction(); if (action.getStyle() == IAction.AS_CHECK_BOX && action.isEnabled()) { saveCheckedActionState(action); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/BreakpointTypeCategory.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/BreakpointTypeCategory.java index 0d46e4e2095..2b610c76fad 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/BreakpointTypeCategory.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/BreakpointTypeCategory.java @@ -66,8 +66,7 @@ protected String getName() { @Override public boolean equals(Object object) { - if (object instanceof BreakpointTypeCategory) { - BreakpointTypeCategory type = (BreakpointTypeCategory) object; + if (object instanceof BreakpointTypeCategory type) { return type.getName().equals(getName()); } return false; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java index c11ac8d4c58..43b30492ad2 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/CommonTab.java @@ -607,8 +607,7 @@ private void handleSharedLocationButtonSelected() { dialog.setDialogBoundsSettings(getDialogBoundsSettings(SHARED_LAUNCH_CONFIGURATON_DIALOG), Dialog.DIALOG_PERSISTSIZE); dialog.open(); Object[] results = dialog.getResult(); - if ((results != null) && (results.length > 0) && (results[0] instanceof IPath)) { - IPath path = (IPath)results[0]; + if ((results != null) && (results.length > 0) && (results[0] instanceof IPath path)) { String containerName = path.toOSString(); fSharedLocationText.setText(containerName); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java index ea1376837ba..9436cb503d5 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java @@ -93,8 +93,7 @@ protected String getInfoText() { String infoText = null; if (formattedBinding != null) { - infoText = MessageFormat.format(DebugUIViewsMessages.InspectPopupDialog_1, new Object[] { - formattedBinding, getActionText() }); + infoText = MessageFormat.format(DebugUIViewsMessages.InspectPopupDialog_1, formattedBinding, getActionText()); } return infoText; } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java index 6efce381653..9faaad29c77 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugUITools.java @@ -434,8 +434,7 @@ public static void removePartDebugContextListener(IWorkbenchPartSite site, IDebu * @return an adaptable */ private static IAdaptable getDebugContextElementForSelection(ISelection activeContext) { - if (activeContext instanceof IStructuredSelection) { - IStructuredSelection selection = (IStructuredSelection) activeContext; + if (activeContext instanceof IStructuredSelection selection) { if (!selection.isEmpty()) { Object firstElement = selection.getFirstElement(); if (firstElement instanceof IAdaptable) { @@ -484,8 +483,7 @@ public static IProcess getCurrentProcess() { return (IProcess)context; } - if (context instanceof ILaunch) { - ILaunch launch= (ILaunch)context; + if (context instanceof ILaunch launch) { IDebugTarget target= launch.getDebugTarget(); if (target != null) { IProcess process = target.getProcess(); @@ -864,8 +862,7 @@ private static boolean findToggleLaunchForConfig(ILaunchConfiguration configurat if (input.getAdapter(IResource.class).equals(configResource[0])) { return isShiftTerminateLaunch(key); } - } else if (key instanceof TreeSelection) { - TreeSelection selection = (TreeSelection) key; + } else if (key instanceof TreeSelection selection) { TreePath[] treePath = selection.getPaths(); if (treePath != null && treePath.length == 1) { Object lastSegmentObj = treePath[0].getLastSegment(); @@ -1368,8 +1365,7 @@ public static ILaunchConfiguration getLaunchConfiguration(ILaunchConfigurationDi LaunchConfigurationTabGroupViewer tabViewer = ((LaunchConfigurationsDialog) dialog).getTabViewer(); if (tabViewer != null) { Object input = tabViewer.getInput(); - if (input instanceof ILaunchConfiguration) { - ILaunchConfiguration configuration = (ILaunchConfiguration) input; + if (input instanceof ILaunchConfiguration configuration) { return configuration; } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java index b7192591a3a..64d8cbb32de 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java @@ -173,8 +173,7 @@ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { if (newInput == null) { return; } - if (viewer instanceof TableViewer) { - TableViewer tableViewer = (TableViewer) viewer; + if (viewer instanceof TableViewer tableViewer) { if (tableViewer.getTable().isDisposed()) { return; } @@ -563,7 +562,7 @@ private boolean canRenameVariable(String newVariableName) { boolean overWrite = MessageDialog.openQuestion(getShell(), LaunchConfigurationsMessages.EnvironmentTab_12, MessageFormat.format(LaunchConfigurationsMessages.EnvironmentTab_13, - new Object[] { newVariableName })); + newVariableName)); if (!overWrite) { return false; } @@ -590,7 +589,7 @@ protected boolean addVariable(EnvironmentVariable variable) { boolean overWrite = MessageDialog.openQuestion(getShell(), LaunchConfigurationsMessages.EnvironmentTab_12, - MessageFormat.format(LaunchConfigurationsMessages.EnvironmentTab_13, new Object[] { name })); // + MessageFormat.format(LaunchConfigurationsMessages.EnvironmentTab_13, name)); // if (!overWrite) { return false; } @@ -638,7 +637,7 @@ protected int addVariables(List variables) { boolean overWrite = MessageDialog.openQuestion(getShell(), LaunchConfigurationsMessages.EnvironmentTab_Paste_Overwrite_Title, MessageFormat.format(LaunchConfigurationsMessages.EnvironmentTab_Paste_Overwrite_Message, - new Object[] { names })); // + names)); // if (!overWrite) { return 0; } @@ -984,7 +983,7 @@ public Image getImage(Object element) { public String getText(Object element) { EnvironmentVariable var = (EnvironmentVariable) element; return MessageFormat.format(LaunchConfigurationsMessages.EnvironmentTab_7, - new Object[] { var.getName(), var.getValue() }); + var.getName(), var.getValue()); } @Override diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/PrototypeTab.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/PrototypeTab.java index abd7e4df905..53fc3ad7db1 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/PrototypeTab.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/PrototypeTab.java @@ -529,7 +529,7 @@ private boolean isAttributeModified(Entry element) { /** * Content provider for the prototype attributes table */ - private class PrototypeAttributesContentProvider implements ITreeContentProvider { + private static class PrototypeAttributesContentProvider implements ITreeContentProvider { @Override public Object[] getElements(Object inputElement) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/WorkingDirectoryBlock.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/WorkingDirectoryBlock.java index 32f7a5af479..ee318b0fd68 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/WorkingDirectoryBlock.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/WorkingDirectoryBlock.java @@ -216,8 +216,7 @@ private void handleWorkspaceDirBrowseButtonSelected() { dialog.showClosedProjects(false); dialog.open(); Object[] results = dialog.getResult(); - if ((results != null) && (results.length > 0) && (results[0] instanceof IPath)) { - IPath path = (IPath)results[0]; + if ((results != null) && (results.length > 0) && (results[0] instanceof IPath path)) { String containerName = path.makeRelative().toString(); setOtherWorkingDirectoryText("${workspace_loc:" + containerName + "}"); //$NON-NLS-1$ //$NON-NLS-2$ } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java index 570d115d9e3..5258160aae4 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AbstractLaunchHistoryAction.java @@ -222,8 +222,7 @@ protected String getToolTip(ILaunchConfiguration configuration) { } else { label= ActionMessages.AbstractLaunchHistoryAction_4; } - return MessageFormat.format(ActionMessages.AbstractLaunchHistoryAction_0, new Object[] { - label, launchName }); + return MessageFormat.format(ActionMessages.AbstractLaunchHistoryAction_0, label, launchName); } /** @@ -249,11 +248,10 @@ private String getToolTip() { label = ActionMessages.AbstractLaunchHistoryAction_4; } if(IInternalDebugCoreConstants.EMPTY_STRING.equals(launchName)) { - return MessageFormat.format(ActionMessages.AbstractLaunchHistoryAction_5, new Object[] { label }); + return MessageFormat.format(ActionMessages.AbstractLaunchHistoryAction_5, label); } else { - return MessageFormat.format(ActionMessages.AbstractLaunchHistoryAction_0, new Object[] { - label, launchName }); + return MessageFormat.format(ActionMessages.AbstractLaunchHistoryAction_0, label, launchName); } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AddMemoryRenderingActionDelegate.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AddMemoryRenderingActionDelegate.java index 18ac7420cb2..1616cc80ebf 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AddMemoryRenderingActionDelegate.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/AddMemoryRenderingActionDelegate.java @@ -192,10 +192,9 @@ private void setupActionDelegate(ISelection context) } IAddMemoryRenderingsTarget target = null; - if (fCurrentSelection instanceof IStructuredSelection) + if (fCurrentSelection instanceof IStructuredSelection strucSel) { // get target from current selection - IStructuredSelection strucSel = (IStructuredSelection)fCurrentSelection; Object obj = strucSel.getFirstElement(); target = getAddMemoryRenderingTarget(obj); } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java index eb5aa3d2c5f..8e203b29084 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandAction.java @@ -245,8 +245,7 @@ public void run() { } ISelection selection = getContext(); - if (selection instanceof IStructuredSelection && isEnabled()) { - IStructuredSelection ss = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection ss && isEnabled()) { boolean enabled = execute(ss.toArray()); // disable the action according to the command setEnabled(enabled); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java index 5a6a130440b..45c318a5f68 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/DebugCommandHandler.java @@ -164,13 +164,11 @@ public void setEnabled(Object evaluationContext) { // window and update the current enabled target based on it fCurrentEnabledTarget = null; - if (!(evaluationContext instanceof IEvaluationContext)) { + if (!(evaluationContext instanceof IEvaluationContext context)) { return; } - IEvaluationContext context = (IEvaluationContext) evaluationContext; Object _window = context.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); - if (_window instanceof IWorkbenchWindow) { - IWorkbenchWindow window = (IWorkbenchWindow)_window; + if (_window instanceof IWorkbenchWindow window) { fCurrentEnabledTarget = getEnabledTarget(window); } } @@ -202,8 +200,7 @@ public Object execute(ExecutionEvent event) throws ExecutionException { fCurrentEnabledTarget = getEnabledTarget(window); ISelection selection = getContextService(window).getActiveContext(); - if (selection instanceof IStructuredSelection && isEnabled()) { - IStructuredSelection ss = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection ss && isEnabled()) { boolean enabledAfterExecute = execute(window, ss.toArray()); // enable/disable the action according to the command diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ExportBreakpointsOperation.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ExportBreakpointsOperation.java index dc3366d20a0..423576d1a9e 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ExportBreakpointsOperation.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ExportBreakpointsOperation.java @@ -150,7 +150,7 @@ public void run(IProgressMonitor monitor) throws InvocationTargetException { } catch (CoreException e) { throw new InvocationTargetException(e); } catch (IOException e) { - throw new InvocationTargetException(e, MessageFormat.format("There was a problem writing file: {0}", new Object[] { fFileName })); //$NON-NLS-1$ + throw new InvocationTargetException(e, MessageFormat.format("There was a problem writing file: {0}", fFileName)); //$NON-NLS-1$ } finally { localmonitor.done(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java index 2832704d0d1..2aa0e9f6e83 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java @@ -166,8 +166,7 @@ public void run(final IProgressMonitor monitor) throws InvocationTargetException try (Reader reader = new InputStreamReader(new FileInputStream(fFileName), StandardCharsets.UTF_8)) { memento = XMLMemento.createReadRoot(reader); } catch (FileNotFoundException e) { - throw new InvocationTargetException(e, MessageFormat.format("Breakpoint import file not found: {0}", new Object[] { //$NON-NLS-1$ - fFileName })); + throw new InvocationTargetException(e, MessageFormat.format("Breakpoint import file not found: {0}", fFileName)); //$NON-NLS-1$ } catch (IOException e) { throw new InvocationTargetException(e); } @@ -228,7 +227,7 @@ public void run(final IProgressMonitor monitor) throws InvocationTargetException } catch(CoreException ce) { throw new InvocationTargetException(ce, - MessageFormat.format("There was a problem importing breakpoints from: {0}", new Object[] { fFileName })); //$NON-NLS-1$ + MessageFormat.format("There was a problem importing breakpoints from: {0}", fFileName)); //$NON-NLS-1$ } finally { localmonitor.done(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAction.java index 47c86f18bda..cb43a3138a9 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/LaunchAction.java @@ -102,7 +102,7 @@ public void runWithEvent(Event event) { if(store.getBoolean(IInternalDebugUIConstants.PREF_REMOVE_FROM_LAUNCH_HISTORY)) { MessageDialogWithToggle mdwt = MessageDialogWithToggle.openYesNoQuestion(DebugUIPlugin.getShell(), ActionMessages.LaunchAction_0, - MessageFormat.format(ActionMessages.LaunchAction_1, new Object[] { fConfiguration.getName() }), + MessageFormat.format(ActionMessages.LaunchAction_1, fConfiguration.getName()), ActionMessages.LaunchAction_2, false, null, @@ -147,7 +147,7 @@ private void removeFromLaunchHistories(ILaunchConfiguration config, ILaunchGroup if (history != null) { history.removeFromHistory(fConfiguration); } else { - DebugUIPlugin.logErrorMessage(MessageFormat.format("Unable to remove configuration [{0}] from launch history. The launch history for mode [{1}] does not exist.", new Object[]{config.getName(), group.getMode()})); //$NON-NLS-1$ + DebugUIPlugin.logErrorMessage(MessageFormat.format("Unable to remove configuration [{0}] from launch history. The launch history for mode [{1}] does not exist.", config.getName(), group.getMode())); //$NON-NLS-1$ } } } diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/OpenLaunchDialogAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/OpenLaunchDialogAction.java index 25a24b6b187..633f650ef2f 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/OpenLaunchDialogAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/OpenLaunchDialogAction.java @@ -63,7 +63,7 @@ public OpenLaunchDialogAction(String identifier) { ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(fIdentifier); if(group != null) { String lbl = group.getLabel(); - String actionLabel = MessageFormat.format(ActionMessages.OpenLaunchDialogAction_1, new Object[] { lbl }); + String actionLabel = MessageFormat.format(ActionMessages.OpenLaunchDialogAction_1, lbl); setText(DebugUIPlugin.adjustDBCSAccelerator(actionLabel)); } PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.OPEN_LAUNCH_CONFIGURATION_ACTION); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RelaunchLastAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RelaunchLastAction.java index 782ac43d9b2..1d73278a26f 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RelaunchLastAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RelaunchLastAction.java @@ -130,8 +130,7 @@ private void runInternal(boolean isShift) { } else { String configName = configuration.getName(); String title = ActionMessages.RelaunchLastAction_Cannot_relaunch_1; - String message = MessageFormat.format(ActionMessages.RelaunchLastAction_Cannot_relaunch___0___because_it_does_not_support__2__mode_2, new Object[] { - configName, getMode() }); + String message = MessageFormat.format(ActionMessages.RelaunchLastAction_Cannot_relaunch___0___because_it_does_not_support__2__mode_2, configName, getMode()); MessageDialog.openError(getShell(), title, message); } } else { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointAction.java index 768c73f9f57..a4a3b37d1ab 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RulerBreakpointAction.java @@ -66,8 +66,7 @@ protected IBreakpoint getBreakpoint() { Iterator iterator = annotationModel.getAnnotationIterator(); while (iterator.hasNext()) { Annotation annot = iterator.next(); - if (annot instanceof SimpleMarkerAnnotation) { - SimpleMarkerAnnotation markerAnnotation = (SimpleMarkerAnnotation) annot; + if (annot instanceof SimpleMarkerAnnotation markerAnnotation) { IMarker marker = markerAnnotation.getMarker(); try { if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) { diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineAction.java index 7739acb2099..c319562e15a 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineAction.java @@ -71,8 +71,7 @@ class DebugContextListener implements IDebugContextListener { protected void contextActivated(ISelection selection) { fTargetElement = null; - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection ss) { if (ss.size() == 1) { fTargetElement = (ISuspendResume) DebugPlugin.getAdapter(ss.getFirstElement(), ISuspendResume.class); } @@ -212,8 +211,7 @@ private IDocument getDocument() { if (fDocument != null) { return fDocument; } - if (fActivePart instanceof ITextEditor) { - ITextEditor editor = (ITextEditor) fActivePart; + if (fActivePart instanceof ITextEditor editor) { IDocumentProvider provider = editor.getDocumentProvider(); if (provider != null) { return provider.getDocument(editor.getEditorInput()); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineActionDelegate.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineActionDelegate.java index 3e8804dd24e..cce467c25f1 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineActionDelegate.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineActionDelegate.java @@ -69,8 +69,7 @@ class DebugContextListener implements IDebugContextListener { protected void contextActivated(ISelection selection) { fTargetElement = null; - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection ss) { if (ss.size() == 1) { fTargetElement = (ISuspendResume) DebugPlugin.getAdapter(ss.getFirstElement(), ISuspendResume.class); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineHandler.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineHandler.java index fa7c1db5618..033039585d9 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineHandler.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/RunToLineHandler.java @@ -69,9 +69,8 @@ public RunToLineHandler(IDebugTarget target, ISuspendResume suspendResume, IBrea public void handleDebugEvents(DebugEvent[] events) { for (DebugEvent event : events) { Object source= event.getSource(); - if (source instanceof IThread && event.getKind() == DebugEvent.SUSPEND && + if (source instanceof IThread thread && event.getKind() == DebugEvent.SUSPEND && event.getDetail() == DebugEvent.BREAKPOINT) { - IThread thread = (IThread) source; IDebugTarget suspendee = thread.getAdapter(IDebugTarget.class); if (fTarget.equals(suspendee)) { // cleanup if the breakpoint was hit or not diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java index 53ac3e688f1..a5b3c2194c7 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ToggleBreakpointAction.java @@ -168,8 +168,7 @@ private IDocument getDocument() { return null; } - if (fPart instanceof ITextEditor) { - ITextEditor editor= (ITextEditor)fPart; + if (fPart instanceof ITextEditor editor) { IDocumentProvider provider = editor.getDocumentProvider(); if (provider != null) { return provider.getDocument(editor.getEditorInput()); @@ -199,8 +198,7 @@ public void update() { setEnabled(false); return; } - if (adapter instanceof IToggleBreakpointsTargetExtension) { - IToggleBreakpointsTargetExtension extension = (IToggleBreakpointsTargetExtension) adapter; + if (adapter instanceof IToggleBreakpointsTargetExtension extension) { if (extension.canToggleBreakpoints(fPart, selection)) { setEnabled(true); return; diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java index 2aa17848ac1..d0879019e1b 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/memory/AbstractTableRendering.java @@ -228,7 +228,7 @@ public abstract class AbstractTableRendering extends AbstractBaseTableRendering private int fPreBuffer; private int fPostBuffer; - private class EventHandleLock + private static class EventHandleLock { Object fOwner; @@ -396,11 +396,10 @@ public void propertyChange(PropertyChangeEvent event) { return; } - if (!(evtSrc instanceof IMemoryRendering)) { + if (!(evtSrc instanceof IMemoryRendering rendering)) { return; } - IMemoryRendering rendering = (IMemoryRendering)evtSrc; IMemoryBlock memoryBlock = rendering.getMemoryBlock(); // do not handle event from renderings displaying other memory blocks @@ -3299,11 +3298,10 @@ public MemoryByte[] getSelectedAsBytes() } Object data = rowItem.getData(); - if (data == null || !(data instanceof TableRenderingLine)) { + if (data == null || !(data instanceof TableRenderingLine line)) { return new MemoryByte[0]; } - TableRenderingLine line = (TableRenderingLine)data; int offset = (col-1)*(getAddressableUnitPerColumn()*getAddressableSize()); int end = offset + (getAddressableUnitPerColumn()*getAddressableSize()); @@ -3748,9 +3746,7 @@ protected void toolTipAboutToShow(Control toolTipControl, TableItem item, BigInteger address = getAddressFromTableItem(item, col); if (address != null) { Object data = item.getData(); - if (data instanceof TableRenderingLine) { - TableRenderingLine line = (TableRenderingLine) data; - + if (data instanceof TableRenderingLine line) { if (col > 0) { int start = (col - 1) * getBytesPerColumn(); int end = start + getBytesPerColumn(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditor.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditor.java index 709dd4758d6..853ae12d8ad 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditor.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditor.java @@ -248,8 +248,7 @@ public void dispose() { */ protected Object getArtifact() { IEditorInput editorInput = getEditorInput(); - if (editorInput instanceof CommonSourceNotFoundEditorInput) { - CommonSourceNotFoundEditorInput input = (CommonSourceNotFoundEditorInput) editorInput; + if (editorInput instanceof CommonSourceNotFoundEditorInput input) { return input.getArtifact(); } return null; @@ -267,8 +266,7 @@ protected void initialize() @Override public void launchesTerminated(ILaunch[] launches) { Object artifact = getArtifact(); - if (artifact instanceof IDebugElement) { - IDebugElement element = (IDebugElement)artifact; + if (artifact instanceof IDebugElement element) { for (ILaunch launch : launches) { if (launch.equals(element.getLaunch())) { closeEditor(); diff --git a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditorInput.java b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditorInput.java index 510a0d5a7fb..ca7a8d155c1 100644 --- a/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditorInput.java +++ b/debug/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/sourcelookup/CommonSourceNotFoundEditorInput.java @@ -83,7 +83,7 @@ public IPersistableElement getPersistable() { @Override public String getToolTipText() { - return MessageFormat.format(SourceLookupUIMessages.addSourceLocation_editorMessage, new Object[] { fLabel }); + return MessageFormat.format(SourceLookupUIMessages.addSourceLocation_editorMessage, fLabel); } /**