Skip to content

Commit cf54e17

Browse files
eclipse-platform-botHeikoKlare
authored andcommitted
Perform clean code of debug/org.eclipse.debug.ui
1 parent 2124e50 commit cf54e17

File tree

227 files changed

+629
-890
lines changed

Some content is hidden

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

227 files changed

+629
-890
lines changed

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

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

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ public static void launchInForeground(final ILaunchConfiguration configuration,
10991099
* Build & launch (98)
11001100
*/
11011101
final SubMonitor subMonitor = SubMonitor.convert(monitor, MessageFormat
1102-
.format(DebugUIMessages.DebugUIPlugin_25, new Object[] { configuration.getName() }), 100);
1102+
.format(DebugUIMessages.DebugUIPlugin_25, configuration.getName()), 100);
11031103
try {
11041104
jobManager.join(ResourcesPlugin.FAMILY_MANUAL_BUILD, subMonitor.split(1));
11051105
jobManager.join(ResourcesPlugin.FAMILY_AUTO_BUILD, subMonitor.split(1));
@@ -1127,7 +1127,7 @@ public static void launchInForeground(final ILaunchConfiguration configuration,
11271127
* Setup progress monitor - Build & launch (1)
11281128
*/
11291129
final SubMonitor subMonitor = SubMonitor.convert(monitor, MessageFormat
1130-
.format(DebugUIMessages.DebugUIPlugin_25, new Object[] { configuration.getName() }), 1);
1130+
.format(DebugUIMessages.DebugUIPlugin_25, configuration.getName()), 1);
11311131
try {
11321132
buildAndLaunch(configuration, mode, subMonitor);
11331133
} catch (CoreException e) {
@@ -1151,8 +1151,7 @@ private static void handleInvocationTargetException(InvocationTargetException e,
11511151
if (targetException instanceof CoreException) {
11521152
t = targetException;
11531153
}
1154-
if (t instanceof CoreException) {
1155-
CoreException ce = (CoreException)t;
1154+
if (t instanceof CoreException ce) {
11561155
IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(ce.getStatus());
11571156
if (handler != null) {
11581157
ILaunchGroup group = DebugUITools.getLaunchGroup(configuration, mode);
@@ -1207,7 +1206,7 @@ public static void launchInBackground(final ILaunchConfiguration configuration,
12071206
}
12081207
}
12091208
final boolean waitInJob = wait;
1210-
Job job = new Job(MessageFormat.format(DebugUIMessages.DebugUIPlugin_25, new Object[] {configuration.getName()})) {
1209+
Job job = new Job(MessageFormat.format(DebugUIMessages.DebugUIPlugin_25, configuration.getName())) {
12111210
@Override
12121211
public IStatus run(final IProgressMonitor monitor) {
12131212
/* Setup progress monitor
@@ -1280,7 +1279,7 @@ public void done(IJobChangeEvent event) {
12801279

12811280
job.setPriority(Job.INTERACTIVE);
12821281
job.setProperty(IProgressConstants2.SHOW_IN_TASKBAR_ICON_PROPERTY, Boolean.TRUE);
1283-
job.setName(MessageFormat.format(DebugUIMessages.DebugUIPlugin_25, new Object[] {configuration.getName()}));
1282+
job.setName(MessageFormat.format(DebugUIMessages.DebugUIPlugin_25, configuration.getName()));
12841283

12851284
if (wait) {
12861285
progressService.showInDialog(getShell(), job);

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,15 @@ 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) {
136-
IThread thread = (IThread)element;
135+
} else if (element instanceof IThread thread) {
137136
if (thread.isSuspended()) {
138137
return IDebugUIConstants.IMG_OBJS_THREAD_SUSPENDED;
139138
} else if (thread.isTerminated()) {
140139
return IDebugUIConstants.IMG_OBJS_THREAD_TERMINATED;
141140
} else {
142141
return IDebugUIConstants.IMG_OBJS_THREAD_RUNNING;
143142
}
144-
} else if (element instanceof IDebugTarget) {
145-
IDebugTarget target= (IDebugTarget) element;
143+
} else if (element instanceof IDebugTarget target) {
146144
if (target.isTerminated() || target.isDisconnected()) {
147145
return IDebugUIConstants.IMG_OBJS_DEBUG_TARGET_TERMINATED;
148146
} else if (target.isSuspended()) {
@@ -163,9 +161,8 @@ public String getImageKey(Object element) {
163161
return IDebugUIConstants.IMG_OBJS_OS_PROCESS_TERMINATED;
164162
}
165163
return IDebugUIConstants.IMG_OBJS_OS_PROCESS;
166-
} else if (element instanceof ILaunch) {
164+
} else if (element instanceof ILaunch launch) {
167165
// determine the image from the launch config type
168-
ILaunch launch= (ILaunch)element;
169166
ILaunchConfiguration configuration = launch.getLaunchConfiguration();
170167
if (configuration != null) {
171168
try {
@@ -237,8 +234,7 @@ public String getText(Object element) {
237234
label.append(((ILaunchConfiguration)element).getName());
238235
} else if (element instanceof ILaunchConfigurationType) {
239236
label.append(((ILaunchConfigurationType)element).getName());
240-
} else if(element instanceof ILaunchDelegate) {
241-
ILaunchDelegate delegate = (ILaunchDelegate) element;
237+
} else if(element instanceof ILaunchDelegate delegate) {
242238
String name = delegate.getName();
243239
if(name == null) {
244240
name = delegate.getContributorName();
@@ -255,10 +251,9 @@ public String getText(Object element) {
255251
if (element instanceof ITerminate) {
256252
if (((ITerminate) element).isTerminated()) {
257253
String terminatedMessage= null;
258-
if (element instanceof IProcess) {
259-
IProcess process = (IProcess)element;
254+
if (element instanceof IProcess process) {
260255
int exit = process.getExitValue();
261-
terminatedMessage = MessageFormat.format(DebugUIMessages.DefaultLabelProvider_16, new Object[] { Integer.toString(exit) });
256+
terminatedMessage = MessageFormat.format(DebugUIMessages.DefaultLabelProvider_16, Integer.toString(exit));
262257
} else {
263258
terminatedMessage= DebugUIMessages.DefaultLabelProvider_1;
264259
}
@@ -290,7 +285,7 @@ private String getBreakpointText(IBreakpoint breakpoint) {
290285
if (breakpoint instanceof ILineBreakpoint) {
291286
try {
292287
int lineNumber = ((ILineBreakpoint)breakpoint).getLineNumber();
293-
label.append(MessageFormat.format(DebugUIMessages.DefaultLabelProvider_17, new Object[] { Integer.toString(lineNumber) }));
288+
label.append(MessageFormat.format(DebugUIMessages.DefaultLabelProvider_17, Integer.toString(lineNumber)));
294289
} catch (CoreException e) {
295290
}
296291
}
@@ -437,8 +432,7 @@ protected String getBreakpointImageKey(IBreakpoint breakpoint) {
437432
if (breakpoint != null && breakpoint.getMarker().exists()) {
438433
try {
439434
boolean enabled = breakpoint.isEnabled();
440-
if (breakpoint instanceof IWatchpoint) {
441-
IWatchpoint watchpoint = (IWatchpoint) breakpoint;
435+
if (breakpoint instanceof IWatchpoint watchpoint) {
442436
if (watchpoint.isAccess()) {
443437
if (watchpoint.isModification()) {
444438
//access and modification

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,9 @@ public boolean isLabelProperty(Object element, String property) {
231231
*/
232232
protected IDebugModelPresentation getConfiguredPresentation(Object element) {
233233
String id= null;
234-
if (element instanceof IDebugElement) {
235-
IDebugElement de= (IDebugElement) element;
234+
if (element instanceof IDebugElement de) {
236235
id= de.getModelIdentifier();
237-
} else if (element instanceof IMarker) {
238-
IMarker m= (IMarker) element;
236+
} else if (element instanceof IMarker m) {
239237
IBreakpoint bp = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(m);
240238
if (bp != null) {
241239
id= bp.getModelIdentifier();
@@ -320,8 +318,7 @@ protected HashMap<String, IDebugModelPresentation> getLabelProviders() {
320318
@Override
321319
public Color getForeground(Object element) {
322320
IDebugModelPresentation presentation = getConfiguredPresentation(element);
323-
if (presentation instanceof IColorProvider) {
324-
IColorProvider colorProvider = (IColorProvider) presentation;
321+
if (presentation instanceof IColorProvider colorProvider) {
325322
return colorProvider.getForeground(element);
326323
}
327324
return null;
@@ -330,8 +327,7 @@ public Color getForeground(Object element) {
330327
@Override
331328
public Color getBackground(Object element) {
332329
IDebugModelPresentation presentation = getConfiguredPresentation(element);
333-
if (presentation instanceof IColorProvider) {
334-
IColorProvider colorProvider = (IColorProvider) presentation;
330+
if (presentation instanceof IColorProvider colorProvider) {
335331
return colorProvider.getBackground(element);
336332
}
337333
return null;
@@ -340,8 +336,7 @@ public Color getBackground(Object element) {
340336
@Override
341337
public Font getFont(Object element) {
342338
IDebugModelPresentation presentation = getConfiguredPresentation(element);
343-
if (presentation instanceof IFontProvider) {
344-
IFontProvider fontProvider = (IFontProvider) presentation;
339+
if (presentation instanceof IFontProvider fontProvider) {
345340
return fontProvider.getFont(element);
346341
}
347342
return null;
@@ -354,9 +349,8 @@ public Annotation getInstructionPointerAnnotation(IEditorPart editorPart, IStack
354349
String id = null;
355350
Image image = null;
356351
String text = null;
357-
if (presentation instanceof IInstructionPointerPresentation) {
352+
if (presentation instanceof IInstructionPointerPresentation pointerPresentation) {
358353
// first check if an annotaion object is provided
359-
IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation;
360354
annotation = pointerPresentation.getInstructionPointerAnnotation(editorPart, frame);
361355
if (annotation == null) {
362356
// next check for a marker annotation specification extension

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

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

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

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,7 @@ public Map<String, Object> getAttributes() {
396396
@Override
397397
public Color getForeground(Object element) {
398398
IDebugModelPresentation presentation = getPresentation();
399-
if (presentation instanceof IColorProvider) {
400-
IColorProvider colorProvider = (IColorProvider) presentation;
399+
if (presentation instanceof IColorProvider colorProvider) {
401400
return colorProvider.getForeground(element);
402401
}
403402
return null;
@@ -406,8 +405,7 @@ public Color getForeground(Object element) {
406405
@Override
407406
public Color getBackground(Object element) {
408407
IDebugModelPresentation presentation = getPresentation();
409-
if (presentation instanceof IColorProvider) {
410-
IColorProvider colorProvider = (IColorProvider) presentation;
408+
if (presentation instanceof IColorProvider colorProvider) {
411409
return colorProvider.getBackground(element);
412410
}
413411
return null;
@@ -416,8 +414,7 @@ public Color getBackground(Object element) {
416414
@Override
417415
public Font getFont(Object element) {
418416
IDebugModelPresentation presentation = getPresentation();
419-
if (presentation instanceof IFontProvider) {
420-
IFontProvider fontProvider = (IFontProvider) presentation;
417+
if (presentation instanceof IFontProvider fontProvider) {
421418
return fontProvider.getFont(element);
422419
}
423420
return null;
@@ -426,8 +423,7 @@ public Font getFont(Object element) {
426423
@Override
427424
public Annotation getInstructionPointerAnnotation(IEditorPart editorPart, IStackFrame frame) {
428425
IDebugModelPresentation presentation = getPresentation();
429-
if (presentation instanceof IInstructionPointerPresentation) {
430-
IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation;
426+
if (presentation instanceof IInstructionPointerPresentation pointerPresentation) {
431427
return pointerPresentation.getInstructionPointerAnnotation(editorPart, frame);
432428
}
433429
return null;
@@ -436,8 +432,7 @@ public Annotation getInstructionPointerAnnotation(IEditorPart editorPart, IStack
436432
@Override
437433
public String getInstructionPointerAnnotationType(IEditorPart editorPart, IStackFrame frame) {
438434
IDebugModelPresentation presentation = getPresentation();
439-
if (presentation instanceof IInstructionPointerPresentation) {
440-
IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation;
435+
if (presentation instanceof IInstructionPointerPresentation pointerPresentation) {
441436
return pointerPresentation.getInstructionPointerAnnotationType(editorPart, frame);
442437
}
443438
return null;
@@ -446,8 +441,7 @@ public String getInstructionPointerAnnotationType(IEditorPart editorPart, IStack
446441
@Override
447442
public Image getInstructionPointerImage(IEditorPart editorPart, IStackFrame frame) {
448443
IDebugModelPresentation presentation = getPresentation();
449-
if (presentation instanceof IInstructionPointerPresentation) {
450-
IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation;
444+
if (presentation instanceof IInstructionPointerPresentation pointerPresentation) {
451445
return pointerPresentation.getInstructionPointerImage(editorPart, frame);
452446
}
453447
return null;
@@ -456,8 +450,7 @@ public Image getInstructionPointerImage(IEditorPart editorPart, IStackFrame fram
456450
@Override
457451
public String getInstructionPointerText(IEditorPart editorPart, IStackFrame frame) {
458452
IDebugModelPresentation presentation = getPresentation();
459-
if (presentation instanceof IInstructionPointerPresentation) {
460-
IInstructionPointerPresentation pointerPresentation = (IInstructionPointerPresentation) presentation;
453+
if (presentation instanceof IInstructionPointerPresentation pointerPresentation) {
461454
return pointerPresentation.getInstructionPointerText(editorPart, frame);
462455
}
463456
return null;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,9 @@ 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) || !resource.exists()) {
122+
if (resource == null || !(resource instanceof IFile file) || !resource.exists()) {
123123
return false;
124124
}
125-
IFile file = (IFile) resource;
126125
IContentDescription description;
127126
try {
128127
description = file.getContentDescription();

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

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected boolean updateSelection(IStructuredSelection selection) {
8888
setGroup(group);
8989
setLaunchConfiguration(configuration);
9090
setMode(launch.getLaunchMode());
91-
setText(MessageFormat.format(ActionMessages.AddToFavoritesAction_1, new Object[] { DebugUIPlugin.removeAccelerators(getGroup().getLabel()) }));
91+
setText(MessageFormat.format(ActionMessages.AddToFavoritesAction_1, DebugUIPlugin.removeAccelerators(getGroup().getLabel())));
9292
}
9393
}
9494
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected boolean updateSelection(IStructuredSelection selection) {
9595
setLaunchConfiguration(configuration);
9696
setMode(launch.getLaunchMode());
9797
setIsTerminated(launch.isTerminated());
98-
setText(MessageFormat.format(ActionMessages.EditLaunchConfigurationAction_1, new Object[] { configuration.getName() }));
98+
setText(MessageFormat.format(ActionMessages.EditLaunchConfigurationAction_1, configuration.getName()));
9999
ImageDescriptor descriptor = null;
100100
try {
101101
descriptor = DebugPluginImages.getImageDescriptor(configuration.getType().getIdentifier());

0 commit comments

Comments
 (0)