Skip to content

Commit 24afacd

Browse files
committed
Revert "Automatic cleanup - Java 16 instanceof pattern matching in Debug.ui"
This reverts commit cc726618e3f51c8cd8c04244ffee7ac6db895071.
1 parent 8288adb commit 24afacd

File tree

166 files changed

+674
-330
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+674
-330
lines changed

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CompositeDebugImageDescriptor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ protected Point getSize() {
6161
*/
6262
@Override
6363
public boolean equals(Object object) {
64-
if (!(object instanceof CompositeDebugImageDescriptor other)){
64+
if (!(object instanceof CompositeDebugImageDescriptor)){
6565
return false;
6666
}
67+
CompositeDebugImageDescriptor other= (CompositeDebugImageDescriptor)object;
6768
return (getBaseImage().equals(other.getBaseImage()) && getFlags() == other.getFlags());
6869
}
6970

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,8 @@ private static void handleInvocationTargetException(InvocationTargetException e,
11511151
if (targetException instanceof CoreException) {
11521152
t = targetException;
11531153
}
1154-
if (t instanceof CoreException ce) {
1154+
if (t instanceof CoreException) {
1155+
CoreException ce = (CoreException)t;
11551156
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(ce.getStatus());
11561157
if (handler != null) {
11571158
ILaunchGroup group = DebugUITools.getLaunchGroup(configuration, mode);

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DefaultLabelProvider.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,17 @@ public String getImageKey(Object element) {
132132
return IDebugUIConstants.IMG_OBJS_STACKFRAME;
133133
}
134134
return IDebugUIConstants.IMG_OBJS_STACKFRAME_RUNNING;
135-
} else if (element instanceof IThread thread) {
135+
} else if (element instanceof IThread) {
136+
IThread thread = (IThread)element;
136137
if (thread.isSuspended()) {
137138
return IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED;
138139
} else if (thread.isTerminated()) {
139140
return IDebugUIConstants.IMG_OBJS_THREAD_TERMINATED;
140141
} else {
141142
return IDebugUIConstants.IMG_OBJS_THREAD_RUNNING;
142143
}
143-
} else if (element instanceof IDebugTarget target) {
144+
} else if (element instanceof IDebugTarget) {
145+
IDebugTarget target= (IDebugTarget) element;
144146
if (target.isTerminated() || target.isDisconnected()) {
145147
return IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_TERMINATED;
146148
} else if (target.isSuspended()) {
@@ -161,8 +163,9 @@ public String getImageKey(Object element) {
161163
return IDebugUIConstants.IMG_OBJS_OS_PROCESS_TERMINATED;
162164
}
163165
return IDebugUIConstants.IMG_OBJS_OS_PROCESS;
164-
} else if (element instanceof ILaunch launch) {
166+
} else if (element instanceof ILaunch) {
165167
// determine the image from the launch config type
168+
ILaunch launch= (ILaunch)element;
166169
ILaunchConfiguration configuration = launch.getLaunchConfiguration();
167170
if (configuration != null) {
168171
try {
@@ -234,7 +237,8 @@ public String getText(Object element) {
234237
label.append(((ILaunchConfiguration)element).getName());
235238
} else if (element instanceof ILaunchConfigurationType) {
236239
label.append(((ILaunchConfigurationType)element).getName());
237-
} else if(element instanceof ILaunchDelegate delegate) {
240+
} else if(element instanceof ILaunchDelegate) {
241+
ILaunchDelegate delegate = (ILaunchDelegate) element;
238242
String name = delegate.getName();
239243
if(name == null) {
240244
name = delegate.getContributorName();
@@ -251,7 +255,8 @@ public String getText(Object element) {
251255
if (element instanceof ITerminate) {
252256
if (((ITerminate) element).isTerminated()) {
253257
String terminatedMessage= null;
254-
if (element instanceof IProcess process) {
258+
if (element instanceof IProcess) {
259+
IProcess process = (IProcess)element;
255260
int exit = process.getExitValue();
256261
terminatedMessage = MessageFormat.format(DebugUIMessages.DefaultLabelProvider_16, new Object[] { Integer.toString(exit) });
257262
} else {
@@ -432,7 +437,8 @@ protected String getBreakpointImageKey(IBreakpoint breakpoint) {
432437
if (breakpoint != null && breakpoint.getMarker().exists()) {
433438
try {
434439
boolean enabled = breakpoint.isEnabled();
435-
if (breakpoint instanceof IWatchpoint watchpoint) {
440+
if (breakpoint instanceof IWatchpoint) {
441+
IWatchpoint watchpoint = (IWatchpoint) breakpoint;
436442
if (watchpoint.isAccess()) {
437443
if (watchpoint.isModification()) {
438444
//access and modification

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DelegatingModelPresentation.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,11 @@ public boolean isLabelProperty(Object element, String property) {
231231
*/
232232
protected IDebugModelPresentation getConfiguredPresentation(Object element) {
233233
String id= null;
234-
if (element instanceof IDebugElement de) {
234+
if (element instanceof IDebugElement) {
235+
IDebugElement de= (IDebugElement) element;
235236
id= de.getModelIdentifier();
236-
} else if (element instanceof IMarker m) {
237+
} else if (element instanceof IMarker) {
238+
IMarker m= (IMarker) element;
237239
IBreakpoint bp = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(m);
238240
if (bp != null) {
239241
id= bp.getModelIdentifier();
@@ -318,7 +320,8 @@ protected HashMap<String, IDebugModelPresentation> getLabelProviders() {
318320
@Override
319321
public Color getForeground(Object element) {
320322
IDebugModelPresentation presentation = getConfiguredPresentation(element);
321-
if (presentation instanceof IColorProvider colorProvider) {
323+
if (presentation instanceof IColorProvider) {
324+
IColorProvider colorProvider = (IColorProvider) presentation;
322325
return colorProvider.getForeground(element);
323326
}
324327
return null;
@@ -327,7 +330,8 @@ public Color getForeground(Object element) {
327330
@Override
328331
public Color getBackground(Object element) {
329332
IDebugModelPresentation presentation = getConfiguredPresentation(element);
330-
if (presentation instanceof IColorProvider colorProvider) {
333+
if (presentation instanceof IColorProvider) {
334+
IColorProvider colorProvider = (IColorProvider) presentation;
331335
return colorProvider.getBackground(element);
332336
}
333337
return null;
@@ -336,7 +340,8 @@ public Color getBackground(Object element) {
336340
@Override
337341
public Font getFont(Object element) {
338342
IDebugModelPresentation presentation = getConfiguredPresentation(element);
339-
if (presentation instanceof IFontProvider fontProvider) {
343+
if (presentation instanceof IFontProvider) {
344+
IFontProvider fontProvider = (IFontProvider) presentation;
340345
return fontProvider.getFont(element);
341346
}
342347
return null;
@@ -349,8 +354,9 @@ public Annotation getInstructionPointerAnnotation(IEditorPart editorPart, IStack
349354
String id = null;
350355
Image image = null;
351356
String text = null;
352-
if (presentation instanceof IInstructionPointerPresentation pointerPresentation) {
357+
if (presentation instanceof IInstructionPointerPresentation) {
353358
// first check if an annotaion object is provided
359+
IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation;
354360
annotation = pointerPresentation.getInstructionPointerAnnotation(editorPart, frame);
355361
if (annotation == null) {
356362
// next check for a marker annotation specification extension

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/InstructionPointerContext.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public InstructionPointerContext(IDebugTarget target, IThread thread, ITextEdito
5454

5555
@Override
5656
public boolean equals(Object other) {
57-
if (other instanceof InstructionPointerContext otherContext) {
57+
if (other instanceof InstructionPointerContext) {
58+
InstructionPointerContext otherContext = (InstructionPointerContext) other;
5859
if (getAnnotation().equals(otherContext.getAnnotation())){
5960
return getEditor().equals(otherContext.getEditor());
6061
}

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LazyModelPresentation.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,8 @@ public Map<String, Object> getAttributes() {
396396
@Override
397397
public Color getForeground(Object element) {
398398
IDebugModelPresentation presentation = getPresentation();
399-
if (presentation instanceof IColorProvider colorProvider) {
399+
if (presentation instanceof IColorProvider) {
400+
IColorProvider colorProvider = (IColorProvider) presentation;
400401
return colorProvider.getForeground(element);
401402
}
402403
return null;
@@ -405,7 +406,8 @@ public Color getForeground(Object element) {
405406
@Override
406407
public Color getBackground(Object element) {
407408
IDebugModelPresentation presentation = getPresentation();
408-
if (presentation instanceof IColorProvider colorProvider) {
409+
if (presentation instanceof IColorProvider) {
410+
IColorProvider colorProvider = (IColorProvider) presentation;
409411
return colorProvider.getBackground(element);
410412
}
411413
return null;
@@ -414,7 +416,8 @@ public Color getBackground(Object element) {
414416
@Override
415417
public Font getFont(Object element) {
416418
IDebugModelPresentation presentation = getPresentation();
417-
if (presentation instanceof IFontProvider fontProvider) {
419+
if (presentation instanceof IFontProvider) {
420+
IFontProvider fontProvider = (IFontProvider) presentation;
418421
return fontProvider.getFont(element);
419422
}
420423
return null;
@@ -423,7 +426,8 @@ public Font getFont(Object element) {
423426
@Override
424427
public Annotation getInstructionPointerAnnotation(IEditorPart editorPart, IStackFrame frame) {
425428
IDebugModelPresentation presentation = getPresentation();
426-
if (presentation instanceof IInstructionPointerPresentation pointerPresentation) {
429+
if (presentation instanceof IInstructionPointerPresentation) {
430+
IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation;
427431
return pointerPresentation.getInstructionPointerAnnotation(editorPart, frame);
428432
}
429433
return null;
@@ -432,7 +436,8 @@ public Annotation getInstructionPointerAnnotation(IEditorPart editorPart, IStack
432436
@Override
433437
public String getInstructionPointerAnnotationType(IEditorPart editorPart, IStackFrame frame) {
434438
IDebugModelPresentation presentation = getPresentation();
435-
if (presentation instanceof IInstructionPointerPresentation pointerPresentation) {
439+
if (presentation instanceof IInstructionPointerPresentation) {
440+
IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation;
436441
return pointerPresentation.getInstructionPointerAnnotationType(editorPart, frame);
437442
}
438443
return null;
@@ -441,7 +446,8 @@ public String getInstructionPointerAnnotationType(IEditorPart editorPart, IStack
441446
@Override
442447
public Image getInstructionPointerImage(IEditorPart editorPart, IStackFrame frame) {
443448
IDebugModelPresentation presentation = getPresentation();
444-
if (presentation instanceof IInstructionPointerPresentation pointerPresentation) {
449+
if (presentation instanceof IInstructionPointerPresentation) {
450+
IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation;
445451
return pointerPresentation.getInstructionPointerImage(editorPart, frame);
446452
}
447453
return null;
@@ -450,7 +456,8 @@ public Image getInstructionPointerImage(IEditorPart editorPart, IStackFrame fram
450456
@Override
451457
public String getInstructionPointerText(IEditorPart editorPart, IStackFrame frame) {
452458
IDebugModelPresentation presentation = getPresentation();
453-
if (presentation instanceof IInstructionPointerPresentation pointerPresentation) {
459+
if (presentation instanceof IInstructionPointerPresentation) {
460+
IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation;
454461
return pointerPresentation.getInstructionPointerText(editorPart, frame);
455462
}
456463
return null;

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ResourceExtender.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ private boolean matchesContentType(IContentType type, String typeId) {
119119
* @return whether or not the given resource has the given content type
120120
*/
121121
private boolean matchesContentType(IResource resource, String contentType) {
122-
if (resource == null || !(resource instanceof IFile file) || !resource.exists()) {
122+
if (resource == null || !(resource instanceof IFile) || !resource.exists()) {
123123
return false;
124124
}
125+
IFile file = (IFile) resource;
125126
IContentDescription description;
126127
try {
127128
description = file.getContentDescription();

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/AbstractSelectionActionDelegate.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public void dispose() {
7474

7575
@Override
7676
public void selectionChanged(IAction action, ISelection s) {
77-
if (s instanceof IStructuredSelection ss) {
77+
if (s instanceof IStructuredSelection) {
78+
IStructuredSelection ss = (IStructuredSelection) s;
7879
action.setEnabled(getEnableStateForSelection(ss));
7980
setSelection(ss);
8081
} else {

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ public void run(IAction action) {
133133
@Override
134134
public void selectionChanged(IAction action, ISelection selection) {
135135
// if the active part did not provide an adapter, see if the selection does
136-
if (fTargetAdapter == null && selection instanceof IStructuredSelection ss) {
136+
if (fTargetAdapter == null && selection instanceof IStructuredSelection) {
137+
IStructuredSelection ss = (IStructuredSelection) selection;
137138
if (!ss.isEmpty()) {
138139
Object object = ss.getFirstElement();
139140
if (object instanceof IAdaptable) {

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/RetargetRunToLineAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class DebugContextListener implements IDebugContextListener {
4242

4343
protected void contextActivated(ISelection selection) {
4444
fTargetElement = null;
45-
if (selection instanceof IStructuredSelection ss) {
45+
if (selection instanceof IStructuredSelection) {
46+
IStructuredSelection ss = (IStructuredSelection) selection;
4647
if (ss.size() == 1) {
4748
fTargetElement = (ISuspendResume)
4849
DebugPlugin.getAdapter(ss.getFirstElement(), ISuspendResume.class);

0 commit comments

Comments
 (0)