From 05ca6130ae698c44780fb1875533dfbfcfae4eb9 Mon Sep 17 00:00:00 2001 From: Zsombor Gegesy Date: Wed, 1 Jan 2025 17:42:33 +0100 Subject: [PATCH] Automatic cleanups in tests and in ui --- .../debug/tests/ui/AbstractDebugUiTests.java | 4 +- .../tests/ui/AbstractDebugViewTests.java | 6 +- .../jdt/debug/tests/ui/DebugViewTests.java | 2 +- .../ui/InstructionPointerManagerTests.java | 295 ++++++++---------- .../debug/tests/ui/ViewManagementTests.java | 23 +- .../ui/VirtualThreadsDebugViewTests.java | 33 +- .../debug/ui/BreakpointMarkerUpdater.java | 8 +- .../internal/debug/ui/BreakpointUtils.java | 3 +- .../debug/ui/DetailFormatterDialog.java | 22 +- .../debug/ui/EditLogicalStructureDialog.java | 4 +- .../debug/ui/EvaluationContextManager.java | 22 +- .../ui/EvaluationContextStatusHandler.java | 3 +- ...luationStackFrameContextStatusHandler.java | 3 +- .../ExpressionInformationControlCreator.java | 12 +- .../debug/ui/HeapWalkingPreferencePage.java | 40 +-- .../debug/ui/HotCodeReplaceErrorDialog.java | 48 ++- .../debug/ui/IJDIPreferencesConstants.java | 73 ++--- .../debug/ui/IJDIStatusConstants.java | 2 +- .../debug/ui/IJavaDebugHelpContextIds.java | 110 +++---- .../debug/ui/ImageDescriptorRegistry.java | 16 +- .../internal/debug/ui/JDIDebugUIPlugin.java | 87 +++--- .../debug/ui/JDIElementImageDescriptor.java | 3 +- .../internal/debug/ui/JDIImageDescriptor.java | 3 +- .../debug/ui/JDIModelPresentation.java | 50 ++- .../internal/debug/ui/JDISourceViewer.java | 15 +- ...JavaBreakpointWorkbenchAdapterFactory.java | 6 +- .../jdt/internal/debug/ui/JavaDebugHover.java | 36 +-- .../debug/ui/JavaDebugOptionsManager.java | 91 +++--- .../debug/ui/JavaDebugPreferencePage.java | 9 +- .../debug/ui/JavaDetailFormattersManager.java | 62 ++-- .../JavaDetailFormattersPreferencePage.java | 65 +--- .../debug/ui/JavaHotCodeReplaceListener.java | 56 ++-- .../JavaLogicalStructuresPreferencePage.java | 42 ++- .../ui/JavaPrimitivesPreferencePage.java | 13 +- .../debug/ui/JavaThreadActionFilter.java | 3 +- .../debug/ui/JavaVarActionFilter.java | 6 +- .../debug/ui/JavaWatchExpressionDelegate.java | 57 ++-- .../jdt/internal/debug/ui/LambdaUtils.java | 9 +- .../internal/debug/ui/MemberActionFilter.java | 6 +- .../NoLineNumberAttributesStatusHandler.java | 19 +- .../debug/ui/SuspendTimeoutStatusHandler.java | 9 +- .../monitors/JavaThreadContentProvider.java | 6 +- 42 files changed, 559 insertions(+), 823 deletions(-) diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/AbstractDebugUiTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/AbstractDebugUiTests.java index a490af79c0..11b2bd8ec1 100644 --- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/AbstractDebugUiTests.java +++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/AbstractDebugUiTests.java @@ -362,9 +362,7 @@ protected static void closeAllEditors() throws RuntimeException { * @return the handle to the {@link IDebugView} with the given id */ protected static IViewPart openView(final String viewId) throws RuntimeException { - return sync(() -> { - return getActivePage().showView(viewId); - }); + return sync(() -> getActivePage().showView(viewId)); } private void assertBreakpointExists(IJavaLineBreakpoint bp, IBreakpoint[] bps) throws Exception { diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/AbstractDebugViewTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/AbstractDebugViewTests.java index 564cde63b5..dc906db434 100644 --- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/AbstractDebugViewTests.java +++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/AbstractDebugViewTests.java @@ -208,7 +208,7 @@ protected void waitForNonConsoleJobs() throws Exception { } protected Object[] selectedText(TreeItem[] selected) throws Exception { - Object[] selectedText = sync(() -> Arrays.stream(selected).map(x -> x.getText()).toArray()); + Object[] selectedText = sync(() -> Arrays.stream(selected).map(TreeItem::getText).toArray()); return selectedText; } @@ -230,7 +230,7 @@ protected void terminateAndCleanUp(IJavaThread thread) throws Exception { } protected String dumpFrames(Object[] childrenData) { - return Arrays.toString(Arrays.stream(childrenData).map(x -> Objects.toString(x)).toArray()); + return Arrays.toString(Arrays.stream(childrenData).map(Objects::toString).toArray()); } protected TreeItem[] getSelectedItemsFromDebugView(boolean wait) throws Exception { @@ -263,7 +263,7 @@ protected void setDebugViewSelection(IThread thread) throws Exception { IDebugTarget debugTarget = thread.getDebugTarget(); ILaunch launch = debugTarget.getLaunch(); - Object[] segments = new Object[] { launch, debugTarget, thread, frame }; + Object[] segments = { launch, debugTarget, thread, frame }; TreePath newPath = new TreePath(segments); TreeSelection newSelection = new TreeSelection(newPath); debugView.getViewer().setSelection(newSelection); diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/DebugViewTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/DebugViewTests.java index 71afcf3920..0e2a904398 100644 --- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/DebugViewTests.java +++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/DebugViewTests.java @@ -87,7 +87,7 @@ public void testLastStackElementShown() throws Exception { // Now we inspect the children of the stopped thread (parent element of selected method) TreeItem threadItem = sync(() -> selectedTreeItem.getParentItem()); TreeItem[] children = sync(() -> threadItem.getItems()); - Object[] childrenText = sync(() -> Arrays.stream(children).map(x -> x.getText()).toArray()); + Object[] childrenText = sync(() -> Arrays.stream(children).map(TreeItem::getText).toArray()); // we expect to see one monitor + frames final int expectedChildrenCount = expectedFramesNumber + 1; diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/InstructionPointerManagerTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/InstructionPointerManagerTests.java index ae5dcf7abd..196d8d162f 100644 --- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/InstructionPointerManagerTests.java +++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/InstructionPointerManagerTests.java @@ -14,7 +14,6 @@ package org.eclipse.jdt.debug.tests.ui; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; import org.eclipse.debug.core.DebugException; @@ -101,20 +100,15 @@ public void testManagerWithEditorReuse() throws Exception{ if (target2 != null){ terminateAndRemove(target2); } - Iterator annModels = fAnnotationModelsWithListeners.iterator(); - while (annModels.hasNext()) { - IAnnotationModel currentModel = annModels.next(); + for (IAnnotationModel currentModel : fAnnotationModelsWithListeners) { currentModel.removeAnnotationModelListener(getAnnotationListener()); } removeAllBreakpoints(); DebugUIPlugin.getDefault().getPreferenceStore().setValue(IDebugUIConstants.PREF_REUSE_EDITOR, restore); - Runnable cleanup = new Runnable() { - @Override - public void run() { - IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - activeWorkbenchWindow.removePerspectiveListener(getPerspectiveListener()); - } - }; + Runnable cleanup = () -> { + IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + activeWorkbenchWindow.removePerspectiveListener(getPerspectiveListener()); + }; DebugUIPlugin.getStandardDisplay().asyncExec(cleanup); } } @@ -133,20 +127,15 @@ public void testManagerWithNoEditorReuse() throws Exception{ if (target2 != null){ terminateAndRemove(target2); } - Iterator annModels = fAnnotationModelsWithListeners.iterator(); - while (annModels.hasNext()) { - IAnnotationModel currentModel = annModels.next(); + for (IAnnotationModel currentModel : fAnnotationModelsWithListeners) { currentModel.removeAnnotationModelListener(getAnnotationListener()); } removeAllBreakpoints(); DebugUIPlugin.getDefault().getPreferenceStore().setValue(IDebugUIConstants.PREF_REUSE_EDITOR, restore); - Runnable cleanup = new Runnable() { - @Override - public void run() { - IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - activeWorkbenchWindow.removePerspectiveListener(getPerspectiveListener()); - } - }; + Runnable cleanup = () -> { + IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + activeWorkbenchWindow.removePerspectiveListener(getPerspectiveListener()); + }; DebugUIPlugin.getStandardDisplay().asyncExec(cleanup); } } @@ -185,14 +174,11 @@ private void addAndRemoveAnnotations(int[] expectedIPCCounts, int[] expectedMapp assertEquals("Incorrect number of expected counts", 8, expectedMappingCounts.length); // Close all editors - Runnable closeAll = new Runnable() { - @Override - public void run() { - IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - activeWorkbenchWindow.getActivePage().closeAllEditors(false); - activeWorkbenchWindow.addPerspectiveListener(getPerspectiveListener()); - } - }; + Runnable closeAll = () -> { + IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + activeWorkbenchWindow.getActivePage().closeAllEditors(false); + activeWorkbenchWindow.addPerspectiveListener(getPerspectiveListener()); + }; DebugUIPlugin.getStandardDisplay().syncExec(closeAll); assertEquals("Instruction pointer count was incorrect", 0, InstructionPointerManager.getDefault().getInstructionPointerCount()); assertEquals("Editor mapping count was incorrect", 0, InstructionPointerManager.getDefault().getEditorMappingCount()); @@ -212,28 +198,25 @@ public void run() { assertEquals("Editor mapping count was incorrect", expectedMappingCounts[0], InstructionPointerManager.getDefault().getEditorMappingCount()); // Find and select the top stack frame of the other thread - Runnable openParent = new Runnable() { - @Override - public void run() { - IDebugView debugView = (IDebugView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("org.eclipse.debug.ui.DebugView"); - Object[] newSegments = new Object[4]; - newSegments[0] = target1.getLaunch(); - newSegments[1] = target1; - try{ - IThread[] threads = ((IJavaDebugTarget)newSegments[1]).getThreads(); - for (int i = 0; i < threads.length; i++) { - if (threads[i].isSuspended() && !threads[i].equals(thread1)){ - thread2 = (IJavaThread)threads[i]; - newSegments[2] = threads[i]; - newSegments[3] = threads[i].getTopStackFrame(); - } + Runnable openParent = () -> { + IDebugView debugView = (IDebugView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("org.eclipse.debug.ui.DebugView"); + Object[] newSegments = new Object[4]; + newSegments[0] = target1.getLaunch(); + newSegments[1] = target1; + try{ + IThread[] threads = ((IJavaDebugTarget)newSegments[1]).getThreads(); + for (IThread thread : threads) { + if (thread.isSuspended() && !thread.equals(thread1)){ + thread2 = (IJavaThread)thread; + newSegments[2] = thread; + newSegments[3] = thread.getTopStackFrame(); } - ((InternalTreeModelViewer)debugView.getViewer()).setSelection(new TreeSelection(new TreePath(newSegments)), true, true); - } catch (DebugException e){ - fail("Exception: " + e.getMessage()); - } - } - }; + } + ((InternalTreeModelViewer)debugView.getViewer()).setSelection(new TreeSelection(new TreePath(newSegments)), true, true); + } catch (DebugException e){ + fail("Exception: " + e.getMessage()); + } + }; fAddedAnnotation = null; getPerspectiveListener().setTitle(typeClassOne); DebugUIPlugin.getStandardDisplay().syncExec(openParent); @@ -243,22 +226,19 @@ public void run() { assertEquals("Editor mapping count was incorrect", expectedMappingCounts[1], InstructionPointerManager.getDefault().getEditorMappingCount()); // Select the same stack frame and make sure IPC count doesn't change - Runnable selectSameStackFrame = new Runnable() { - @Override - public void run() { - IDebugView debugView = (IDebugView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("org.eclipse.debug.ui.DebugView"); - Object[] newSegments = new Object[4]; - newSegments[0] = target1.getLaunch(); - newSegments[1] = target1; - newSegments[2] = thread2; - try { - newSegments[3] = thread2.getTopStackFrame(); - } catch (DebugException e) { - fail("Exception: " + e.getMessage()); - } - ((InternalTreeModelViewer)debugView.getViewer()).setSelection(new TreeSelection(new TreePath(newSegments)), true, true); - } - }; + Runnable selectSameStackFrame = () -> { + IDebugView debugView = (IDebugView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("org.eclipse.debug.ui.DebugView"); + Object[] newSegments = new Object[4]; + newSegments[0] = target1.getLaunch(); + newSegments[1] = target1; + newSegments[2] = thread2; + try { + newSegments[3] = thread2.getTopStackFrame(); + } catch (DebugException e) { + fail("Exception: " + e.getMessage()); + } + ((InternalTreeModelViewer)debugView.getViewer()).setSelection(new TreeSelection(new TreePath(newSegments)), true, true); + }; fAddedAnnotation = null; getPerspectiveListener().setTitle(typeClassOne); DebugUIPlugin.getStandardDisplay().syncExec(selectSameStackFrame); @@ -267,22 +247,19 @@ public void run() { assertEquals("Editor mapping count was incorrect", expectedMappingCounts[1], InstructionPointerManager.getDefault().getEditorMappingCount()); // Select the next stack frame in the same thread - Runnable selectSecondStackFrame = new Runnable() { - @Override - public void run() { - IDebugView debugView = (IDebugView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("org.eclipse.debug.ui.DebugView"); - Object[] newSegments = new Object[4]; - newSegments[0] = target1.getLaunch(); - newSegments[1] = target1; - newSegments[2] = thread2; - try{ - newSegments[3] = thread2.getStackFrames()[1]; // Select the next stack frame - } catch (DebugException e){ - fail("Exception: " + e.getMessage()); - } - ((InternalTreeModelViewer)debugView.getViewer()).setSelection(new TreeSelection(new TreePath(newSegments)), true, true); - } - }; + Runnable selectSecondStackFrame = () -> { + IDebugView debugView = (IDebugView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("org.eclipse.debug.ui.DebugView"); + Object[] newSegments = new Object[4]; + newSegments[0] = target1.getLaunch(); + newSegments[1] = target1; + newSegments[2] = thread2; + try{ + newSegments[3] = thread2.getStackFrames()[1]; // Select the next stack frame + } catch (DebugException e){ + fail("Exception: " + e.getMessage()); + } + ((InternalTreeModelViewer)debugView.getViewer()).setSelection(new TreeSelection(new TreePath(newSegments)), true, true); + }; fAddedAnnotation = null; getPerspectiveListener().setTitle(typeThreadStack); DebugUIPlugin.getStandardDisplay().syncExec(selectSecondStackFrame); @@ -301,37 +278,34 @@ public void run() { assertEquals("Editor mapping count was incorrect", expectedMappingCounts[2], InstructionPointerManager.getDefault().getEditorMappingCount()); // Select the stack frame from the new debug target displaying ThreadStack - Runnable openOtherDebugTarget = new Runnable() { - @Override - public void run() { - IDebugView debugView = (IDebugView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("org.eclipse.debug.ui.DebugView"); - ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches(); - Object[] newSegments = new Object[4]; - for (int i = 0; i < launches.length; i++) { - if (target2.equals(launches[i].getDebugTarget())){ - newSegments[0] = launches[i]; - newSegments[1] = target2; - try{ - IThread[] threads = target2.getThreads(); - for (int j = 0; j < threads.length; j++) { - if (threads[j].isSuspended()){ - if (typeThreadStack.equals(((IJavaStackFrame)threads[j].getTopStackFrame()).getDeclaringTypeName())){ - thread3 = (IJavaThread)threads[j]; - newSegments[2] = threads[j]; - newSegments[3] = threads[j].getTopStackFrame(); - break; - } - } + Runnable openOtherDebugTarget = () -> { + IDebugView debugView = (IDebugView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("org.eclipse.debug.ui.DebugView"); + ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches(); + Object[] newSegments = new Object[4]; + for (ILaunch element : launches) { + if (target2.equals(element.getDebugTarget())){ + newSegments[0] = element; + newSegments[1] = target2; + try{ + IThread[] threads = target2.getThreads(); + for (IThread thread : threads) { + if (thread.isSuspended()){ + if (typeThreadStack.equals(((IJavaStackFrame)thread.getTopStackFrame()).getDeclaringTypeName())){ + thread3 = (IJavaThread)thread; + newSegments[2] = thread; + newSegments[3] = thread.getTopStackFrame(); + break; } - } catch (DebugException e){ - fail("Exception: " + e.getMessage()); } - break; } + } catch (DebugException e){ + fail("Exception: " + e.getMessage()); } - ((InternalTreeModelViewer)debugView.getViewer()).setSelection(new TreeSelection(new TreePath(newSegments)), true, true); - } - }; + break; + } + } + ((InternalTreeModelViewer)debugView.getViewer()).setSelection(new TreeSelection(new TreePath(newSegments)), true, true); + }; fAddedAnnotation = null; getPerspectiveListener().setTitle(typeThreadStack); DebugUIPlugin.getStandardDisplay().syncExec(openOtherDebugTarget); @@ -341,28 +315,25 @@ public void run() { assertEquals("Editor mapping count was incorrect", expectedMappingCounts[3], InstructionPointerManager.getDefault().getEditorMappingCount()); // Select the other thread from the new target displaying ClassTwo - Runnable openOtherThread = new Runnable() { - @Override - public void run() { - IDebugView debugView = (IDebugView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("org.eclipse.debug.ui.DebugView"); - Object[] newSegments = new Object[4]; - newSegments[0] = target2.getLaunch(); - newSegments[1] = target2; - try{ - IThread[] threads = target2.getThreads(); - for (int i = 0; i < threads.length; i++) { - if (threads[i].isSuspended() && !threads[i].equals(thread3)){ - thread4 = (IJavaThread)threads[i]; - newSegments[2] = threads[i]; - newSegments[3] = threads[i].getTopStackFrame(); - } - } - ((InternalTreeModelViewer)debugView.getViewer()).setSelection(new TreeSelection(new TreePath(newSegments)), true, true); - } catch (DebugException e){ - fail("Exception: " + e.getMessage()); - } - } - }; + Runnable openOtherThread = () -> { + IDebugView debugView = (IDebugView)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("org.eclipse.debug.ui.DebugView"); + Object[] newSegments = new Object[4]; + newSegments[0] = target2.getLaunch(); + newSegments[1] = target2; + try{ + IThread[] threads = target2.getThreads(); + for (IThread thread : threads) { + if (thread.isSuspended() && !thread.equals(thread3)){ + thread4 = (IJavaThread)thread; + newSegments[2] = thread; + newSegments[3] = thread.getTopStackFrame(); + } + } + ((InternalTreeModelViewer)debugView.getViewer()).setSelection(new TreeSelection(new TreePath(newSegments)), true, true); + } catch (DebugException e){ + fail("Exception: " + e.getMessage()); + } + }; fAddedAnnotation = null; getPerspectiveListener().setTitle(typeClassTwo); DebugUIPlugin.getStandardDisplay().syncExec(openOtherThread); @@ -390,20 +361,17 @@ public void run() { assertEquals("Editor mapping count was incorrect", expectedMappingCounts[6], InstructionPointerManager.getDefault().getEditorMappingCount()); // Close the editor displaying ThreadStack.java if it is open - Runnable closeEditor2 = new Runnable() { - @Override - public void run() { - IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - IEditorReference[] editors = activeWorkbenchWindow.getActivePage().getEditorReferences(); - for (int i = 0; i < editors.length; i++) { - if (editors[i].getTitle().equals("ThreadStack.java")){ - activeWorkbenchWindow.getActivePage().closeEditors(new IEditorReference[]{editors[i]},false); - fRemovedAnnotation = null; // Clear the removed annotation so the test waits for the annotation to be removed - break; - } - } - } - }; + Runnable closeEditor2 = () -> { + IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + IEditorReference[] editors = activeWorkbenchWindow.getActivePage().getEditorReferences(); + for (IEditorReference editor : editors) { + if (editor.getTitle().equals("ThreadStack.java")){ + activeWorkbenchWindow.getActivePage().closeEditors(new IEditorReference[]{editor},false); + fRemovedAnnotation = null; // Clear the removed annotation so the test waits for the annotation to be removed + break; + } + } + }; // fRemovedAnnotation is used here to check if the editor has been found and closed successfully. It is set to a annotation object, and will only be reset to null (causing the wait to occur) if the editor is closed. fRemovedAnnotation = new Annotation(true); DebugUIPlugin.getStandardDisplay().syncExec(closeEditor2); @@ -412,13 +380,10 @@ public void run() { assertEquals("Editor mapping count was incorrect", expectedMappingCounts[7], InstructionPointerManager.getDefault().getEditorMappingCount()); // Close all editors - Runnable closeAllEditors = new Runnable() { - @Override - public void run() { - IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - activeWorkbenchWindow.getActivePage().closeAllEditors(false); - } - }; + Runnable closeAllEditors = () -> { + IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + activeWorkbenchWindow.getActivePage().closeAllEditors(false); + }; fRemovedAnnotation = null; DebugUIPlugin.getStandardDisplay().syncExec(closeAllEditors); waitForAnnotationToBeRemoved(); @@ -459,11 +424,8 @@ private void waitForAnnotationToBeAdded() throws Exception{ assertNotNull("Annotation was not added properly"); // Synchronize with the UI thread so we know that the annotations have finished - Runnable runner = new Runnable(){ - @Override - public void run() { - // Do nothing, just waiting for the UI thread to finish annotations - } + Runnable runner = () -> { + // Do nothing, just waiting for the UI thread to finish annotations }; DebugUIPlugin.getStandardDisplay().syncExec(runner); } @@ -477,11 +439,8 @@ private void waitForAnnotationToBeRemoved() throws Exception{ assertNotNull("Annotation was not removed properly"); // Synchronize with the UI thread so we know that the annotations have finished - Runnable runner = new Runnable(){ - @Override - public void run() { - // Do nothing, just waiting for the UI thread to finish annotations - } + Runnable runner = () -> { + // Do nothing, just waiting for the UI thread to finish annotations }; DebugUIPlugin.getStandardDisplay().syncExec(runner); } @@ -579,10 +538,10 @@ class MyAnnotationListener implements IAnnotationModelListener, IAnnotationModel @Override public void modelChanged(AnnotationModelEvent event) { Annotation[] annotations = event.getAddedAnnotations(); - for (int i = 0; i < annotations.length; i++) { - if (annotations[i] instanceof InstructionPointerAnnotation){ + for (Annotation annotation : annotations) { + if (annotation instanceof InstructionPointerAnnotation){ synchronized (fLock) { - fAddedAnnotation = annotations[i]; + fAddedAnnotation = annotation; fLock.notifyAll(); System.out.println("Annotation added to editor: " + fAddedAnnotation + " (" + this + ")" + event.getAnnotationModel()); @@ -590,10 +549,10 @@ public void modelChanged(AnnotationModelEvent event) { } } annotations = event.getRemovedAnnotations(); - for (int i = 0; i < annotations.length; i++) { - if (annotations[i] instanceof InstructionPointerAnnotation){ + for (Annotation annotation : annotations) { + if (annotation instanceof InstructionPointerAnnotation){ synchronized (fLock) { - fRemovedAnnotation = annotations[i]; + fRemovedAnnotation = annotation; fLock.notifyAll(); } } diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/ViewManagementTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/ViewManagementTests.java index 55af630079..ae703ca493 100644 --- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/ViewManagementTests.java +++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/ViewManagementTests.java @@ -77,14 +77,8 @@ public ViewManagementTests(String name) { * Returns whether the specified view is open */ protected boolean isViewOpen(final IWorkbenchWindow window, final String id) throws Exception { - final IViewReference[] refs = new IViewReference[1]; - sync(new Runnable() { - @Override - public void run() { - refs[0] = window.getActivePage().findViewReference(id); - } - }); - return refs[0] != null; + final IViewReference refs = sync(() -> window.getActivePage().findViewReference(id)); + return refs != null; } @Override @@ -275,8 +269,8 @@ private void partsMessage(String header, List partIds, StringBuilder buf * Adds ids of views to 'expecting open' queue. */ protected void expectingViewOpenEvents(IWorkbenchWindow window, String[] viewIds) { - for (int i = 0; i < viewIds.length; i++) { - fExpectingOpenEvents.add(viewIds[i]); + for (String viewId : viewIds) { + fExpectingOpenEvents.add(viewId); } window.addPerspectiveListener(this); } @@ -285,8 +279,8 @@ protected void expectingViewOpenEvents(IWorkbenchWindow window, String[] viewIds * Adds ids of views to 'expecting open' queue. */ protected void expectingViewCloseEvents(IWorkbenchWindow window, String[] viewIds) { - for (int i = 0; i < viewIds.length; i++) { - fExpectingCloseEvents.add(viewIds[i]); + for (String viewId : viewIds) { + fExpectingCloseEvents.add(viewId); } window.addPerspectiveListener(this); } @@ -351,10 +345,7 @@ public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor persp * Check if all expected events have occurred. */ protected boolean checkComplete() { - if (!fExpectingOpenEvents.isEmpty()) { - return false; - } - if (!fExpectingCloseEvents.isEmpty()) { + if (!fExpectingOpenEvents.isEmpty() || !fExpectingCloseEvents.isEmpty()) { return false; } // all expected events have occurred, notify diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/VirtualThreadsDebugViewTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/VirtualThreadsDebugViewTests.java index fc2f4a656d..7ef850b2a3 100644 --- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/VirtualThreadsDebugViewTests.java +++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/VirtualThreadsDebugViewTests.java @@ -94,24 +94,21 @@ public void testVirtualThreadDebugView() throws Exception { mainThread = launchToBreakpoint(typeName); assertNotNull("Launch unsuccessful", mainThread); openEditorInDebug(file); - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - IDebugView debugViewer = (IDebugView) getActivePage().findView(IDebugUIConstants.ID_DEBUG_VIEW); - ISelection currentSelection = debugViewer.getViewer().getSelection(); - assertNotNull("Debug View is not available", debugViewer); - if (currentSelection instanceof IStructuredSelection) { - Object sel = ((IStructuredSelection) currentSelection).getFirstElement(); - if (sel instanceof IStackFrame stackFrame) { - IThread thread = stackFrame.getThread(); - JDIThread vThread = (JDIThread) stackFrame.getThread(); - assertTrue("Not a Virtual thread", vThread.isVirtualThread()); - StructuredSelection select = new StructuredSelection(thread); - debugViewer.getViewer().setSelection(select, true); - IDebugModelPresentation md = DebugUITools.newDebugModelPresentation(); - String groupName = md.getText(thread); - assertTrue("Not a Virtual thread grouping", groupName.contains("Virtual")); - } + Display.getDefault().asyncExec(() -> { + IDebugView debugViewer = (IDebugView) getActivePage().findView(IDebugUIConstants.ID_DEBUG_VIEW); + ISelection currentSelection = debugViewer.getViewer().getSelection(); + assertNotNull("Debug View is not available", debugViewer); + if (currentSelection instanceof IStructuredSelection) { + Object sel = ((IStructuredSelection) currentSelection).getFirstElement(); + if (sel instanceof IStackFrame stackFrame) { + IThread thread = stackFrame.getThread(); + JDIThread vThread = (JDIThread) stackFrame.getThread(); + assertTrue("Not a Virtual thread", vThread.isVirtualThread()); + StructuredSelection select = new StructuredSelection(thread); + debugViewer.getViewer().setSelection(select, true); + IDebugModelPresentation md = DebugUITools.newDebugModelPresentation(); + String groupName = md.getText(thread); + assertTrue("Not a Virtual thread grouping", groupName.contains("Virtual")); } } }); diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/BreakpointMarkerUpdater.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/BreakpointMarkerUpdater.java index ad267f2247..fb1afb8258 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/BreakpointMarkerUpdater.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/BreakpointMarkerUpdater.java @@ -129,11 +129,8 @@ public boolean updateMarker(IMarker marker, IDocument document, Position positio loc = new ValidBreakpointLocationLocator(unit, document.getLineOfOffset(position.getOffset()) + 1, true, true); } unit.accept(loc); - if(loc.getLocationType() == ValidBreakpointLocationLocator.LOCATION_NOT_FOUND) { - return false; - } // Remove the watch point if it is not a valid watch point now - if (loc.getLocationType() != ValidBreakpointLocationLocator.LOCATION_FIELD && breakpoint instanceof IJavaWatchpoint) { + if ((loc.getLocationType() == ValidBreakpointLocationLocator.LOCATION_NOT_FOUND) || (loc.getLocationType() != ValidBreakpointLocationLocator.LOCATION_FIELD && breakpoint instanceof IJavaWatchpoint)) { return false; } int line = loc.getLineLocation(); @@ -203,10 +200,9 @@ private IJavaLineBreakpoint lineBreakpointExists(IResource resource, String type String markerType= JavaLineBreakpoint.getMarkerType(); IBreakpointManager manager= DebugPlugin.getDefault().getBreakpointManager(); for (IBreakpoint b : manager.getBreakpoints(modelId)) { - if (!(b instanceof IJavaLineBreakpoint)) { + if (!(b instanceof IJavaLineBreakpoint breakpoint)) { continue; } - IJavaLineBreakpoint breakpoint = (IJavaLineBreakpoint) b; IMarker marker = breakpoint.getMarker(); if (marker != null && marker.exists() && marker.getType().equals(markerType) && currentmarker.getId() != marker.getId()) { String breakpointTypeName = breakpoint.getTypeName(); diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/BreakpointUtils.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/BreakpointUtils.java index 82e1ce50a9..f3a69ab92f 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/BreakpointUtils.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/BreakpointUtils.java @@ -345,8 +345,7 @@ public static IBreakpoint getBreakpointFromEditor(ITextEditor editor, IVerticalR Iterator iterator = annotationModel.getAnnotationIterator(); while (iterator.hasNext()) { Object object = iterator.next(); - if (object instanceof SimpleMarkerAnnotation) { - SimpleMarkerAnnotation markerAnnotation = (SimpleMarkerAnnotation) object; + if (object instanceof SimpleMarkerAnnotation markerAnnotation) { IMarker marker = markerAnnotation.getMarker(); try { if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) { diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/DetailFormatterDialog.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/DetailFormatterDialog.java index 47d7830e81..930983ca3d 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/DetailFormatterDialog.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/DetailFormatterDialog.java @@ -53,15 +53,11 @@ import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; @@ -175,22 +171,14 @@ protected Control createDialogArea(Composite parent) { fTypeNameText = SWTFactory.createSingleText(innerContainer, 1); fTypeNameText.setEditable(fEditTypeName); fTypeNameText.setText(fDetailFormatter.getTypeName()); - fTypeNameText.addModifyListener(new ModifyListener() { - @Override - public void modifyText(ModifyEvent e) { - fTypeSearched= false; - checkValues(); - } + fTypeNameText.addModifyListener(e -> { + fTypeSearched= false; + checkValues(); }); Button typeSearchButton = SWTFactory.createPushButton(innerContainer, DebugUIMessages.DetailFormatterDialog_Select__type_4, null); typeSearchButton.setEnabled(fEditTypeName); - typeSearchButton.addListener(SWT.Selection, new Listener() { - @Override - public void handleEvent(Event e) { - selectType(); - } - }); + typeSearchButton.addListener(SWT.Selection, e -> selectType()); String labelText = null; IBindingService bindingService = workbench.getAdapter(IBindingService.class); @@ -373,7 +361,7 @@ public void acceptSearchMatch(SearchMatch match) throws CoreException { return; } IJavaSearchScope scope= SearchEngine.createWorkspaceScope(); - SearchParticipant[] participants = new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}; + SearchParticipant[] participants = {SearchEngine.getDefaultSearchParticipant()}; try { engine.search(searchPattern, participants, scope, collector, monitor); } catch (CoreException e) { diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EditLogicalStructureDialog.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EditLogicalStructureDialog.java index fd40a78eed..e66250c16d 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EditLogicalStructureDialog.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EditLogicalStructureDialog.java @@ -428,7 +428,7 @@ public void handleEvent(Event event) { // code for add attribute button private void addAttribute() { - String[] newAttribute= new String[] {DebugUIMessages.EditLogicalStructureDialog_14, DebugUIMessages.EditLogicalStructureDialog_15}; // + String[] newAttribute= {DebugUIMessages.EditLogicalStructureDialog_14, DebugUIMessages.EditLogicalStructureDialog_15}; // fAttributesContentProvider.add(newAttribute); fAttributeListViewer.refresh(); fAttributeListViewer.setSelection(new StructuredSelection((Object)newAttribute)); @@ -744,7 +744,7 @@ public void acceptSearchMatch(SearchMatch match) throws CoreException { return; } IJavaSearchScope scope= SearchEngine.createWorkspaceScope(); - SearchParticipant[] participants = new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()}; + SearchParticipant[] participants = {SearchEngine.getDefaultSearchParticipant()}; try { engine.search(searchPattern, participants, scope, collector, monitor); } catch (CoreException e) { diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EvaluationContextManager.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EvaluationContextManager.java index f69be74bce..718e2a2ad5 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EvaluationContextManager.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EvaluationContextManager.java @@ -73,18 +73,15 @@ private EvaluationContextManager() { } public static void startup() { - Runnable r = new Runnable() { - @Override - public void run() { - if (fgManager == null) { - fgManager = new EvaluationContextManager(); - IWorkbench workbench = PlatformUI.getWorkbench(); - for (IWorkbenchWindow window : workbench.getWorkbenchWindows()) { - fgManager.windowOpened(window); - } - workbench.addWindowListener(fgManager); - fgManager.fActiveWindow = workbench.getActiveWorkbenchWindow(); + Runnable r = () -> { + if (fgManager == null) { + fgManager = new EvaluationContextManager(); + IWorkbench workbench = PlatformUI.getWorkbench(); + for (IWorkbenchWindow window : workbench.getWorkbenchWindows()) { + fgManager.windowOpened(window); } + workbench.addWindowListener(fgManager); + fgManager.fActiveWindow = workbench.getActiveWorkbenchWindow(); } }; JDIDebugUIPlugin.getStandardDisplay().asyncExec(r); @@ -255,8 +252,7 @@ public void debugContextChanged(DebugContextEvent event) { if (part != null) { IWorkbenchPage page = part.getSite().getPage(); ISelection selection = event.getContext(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection)selection; + if (selection instanceof IStructuredSelection ss) { if (ss.size() == 1) { Object element = ss.getFirstElement(); if (element instanceof IAdaptable) { diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EvaluationContextStatusHandler.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EvaluationContextStatusHandler.java index 67bd3fce1e..f18e24ed2d 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EvaluationContextStatusHandler.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EvaluationContextStatusHandler.java @@ -34,8 +34,7 @@ public class EvaluationContextStatusHandler implements IStatusHandler { */ @Override public Object handleStatus(IStatus status, Object source) { - if (source instanceof IDebugElement) { - IDebugElement element = (IDebugElement) source; + if (source instanceof IDebugElement element) { IJavaDebugTarget target = element.getDebugTarget().getAdapter(IJavaDebugTarget.class); if (target != null) { IJavaStackFrame frame = EvaluationContextManager.getEvaluationContext((IWorkbenchWindow)null); diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EvaluationStackFrameContextStatusHandler.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EvaluationStackFrameContextStatusHandler.java index 4617e8d729..2dd3d72fbd 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EvaluationStackFrameContextStatusHandler.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/EvaluationStackFrameContextStatusHandler.java @@ -33,8 +33,7 @@ public class EvaluationStackFrameContextStatusHandler implements IStatusHandler */ @Override public Object handleStatus(IStatus status, Object source) { - if (source instanceof IDebugElement) { - IDebugElement element = (IDebugElement) source; + if (source instanceof IDebugElement element) { IJavaDebugTarget target = element.getDebugTarget().getAdapter(IJavaDebugTarget.class); if (target != null) { IJavaStackFrame frame = EvaluationContextManager.getEvaluationContext((IWorkbenchWindow)null); diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/ExpressionInformationControlCreator.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/ExpressionInformationControlCreator.java index 98d68fbec8..4d5bedfa95 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/ExpressionInformationControlCreator.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/ExpressionInformationControlCreator.java @@ -300,8 +300,7 @@ protected void createContent(Composite parent) { // copy over properties IPresentationContext copy = ((TreeModelViewer)view.getViewer()).getPresentationContext(); String[] properties = copy.getProperties(); - for (int i = 0; i < properties.length; i++) { - String key = properties[i]; + for (String key : properties) { fContext.setProperty(key, copy.getProperty(key)); } } @@ -314,16 +313,15 @@ protected void createContent(Composite parent) { StructuredViewer structuredViewer = (StructuredViewer) view.getViewer(); if (structuredViewer != null) { ViewerFilter[] filters = structuredViewer.getFilters(); - for (int i = 0; i < filters.length; i++) { - fViewer.addFilter(filters[i]); + for (ViewerFilter filter : filters) { + fViewer.addFilter(filter); } } } 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; } @@ -402,7 +400,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/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/HeapWalkingPreferencePage.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/HeapWalkingPreferencePage.java index 978b226d11..cb7da33d5f 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/HeapWalkingPreferencePage.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/HeapWalkingPreferencePage.java @@ -20,8 +20,6 @@ import org.eclipse.debug.internal.ui.SWTFactory; import org.eclipse.jdt.internal.debug.core.HeapWalkingManager; import org.eclipse.jface.preference.PreferencePage; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; @@ -83,36 +81,30 @@ protected Control createContents(Composite parent) { SWTFactory.createLabel(group, DebugUIMessages.HeapWalkingPreferencePage_1, 1); fAllInstancesMaxCount = SWTFactory.createSingleText(group, 1); - fAllInstancesMaxCount.addModifyListener(new ModifyListener(){ - @Override - public void modifyText(ModifyEvent e) { - try{ - int result = Integer.parseInt(fAllInstancesMaxCount.getText()); - if (result < 0) { - throw new NumberFormatException(); - } - clearErrorMessage(fAllInstancesMaxCount); - } catch (NumberFormatException exception){ - setErrorMessage(fAllInstancesMaxCount, DebugUIMessages.HeapWalkingPreferencePage_6); + fAllInstancesMaxCount.addModifyListener(e -> { + try{ + int result = Integer.parseInt(fAllInstancesMaxCount.getText()); + if (result < 0) { + throw new NumberFormatException(); } + clearErrorMessage(fAllInstancesMaxCount); + } catch (NumberFormatException exception){ + setErrorMessage(fAllInstancesMaxCount, DebugUIMessages.HeapWalkingPreferencePage_6); } }); fAllInstancesMaxCount.setText("" + HeapWalkingManager.getDefault().getAllInstancesMaxCount()); //$NON-NLS-1$ SWTFactory.createLabel(group, DebugUIMessages.HeapWalkingPreferencePage_2, 1); fAllReferencesMaxCount = SWTFactory.createSingleText(group, 1); - fAllReferencesMaxCount.addModifyListener(new ModifyListener(){ - @Override - public void modifyText(ModifyEvent e) { - try{ - int result = Integer.parseInt(fAllReferencesMaxCount.getText()); - if (result < 0) { - throw new NumberFormatException(); - } - clearErrorMessage(fAllReferencesMaxCount); - } catch (NumberFormatException exception){ - setErrorMessage(fAllReferencesMaxCount, DebugUIMessages.HeapWalkingPreferencePage_6); + fAllReferencesMaxCount.addModifyListener(e -> { + try{ + int result = Integer.parseInt(fAllReferencesMaxCount.getText()); + if (result < 0) { + throw new NumberFormatException(); } + clearErrorMessage(fAllReferencesMaxCount); + } catch (NumberFormatException exception){ + setErrorMessage(fAllReferencesMaxCount, DebugUIMessages.HeapWalkingPreferencePage_6); } }); fAllReferencesMaxCount.setText("" + HeapWalkingManager.getDefault().getAllReferencesMaxCount()); //$NON-NLS-1$ diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/HotCodeReplaceErrorDialog.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/HotCodeReplaceErrorDialog.java index 63511be2e0..210eab979f 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/HotCodeReplaceErrorDialog.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/HotCodeReplaceErrorDialog.java @@ -24,8 +24,6 @@ import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.events.TraverseEvent; -import org.eclipse.swt.events.TraverseListener; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; @@ -94,12 +92,9 @@ protected Button createButton(Composite parent, int id, String label, boolean de * @since 3.6 */ protected void blockMnemonicWithoutModifier(Button button) { - button.addTraverseListener(new TraverseListener() { - @Override - public void keyTraversed(TraverseEvent e) { - if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit == true && e.stateMask != SWT.MOD3) { - e.doit= false; - } + button.addTraverseListener(e -> { + if (e.detail == SWT.TRAVERSE_MNEMONIC && e.doit && e.stateMask != SWT.MOD3) { + e.doit= false; } }); } @@ -113,28 +108,25 @@ protected void buttonPressed(final int id) { final DebugException[] ex = new DebugException[1]; final String[] operation = new String[1]; ex[0] = null; - Runnable r = new Runnable() { - @Override - public void run() { - try { - if (id == TERMINATE_ID) { - operation[0]= DebugUIMessages.HotCodeReplaceErrorDialog_5; - target.terminate(); - } else if (id == DISCONNECT_ID){ - operation[0]= DebugUIMessages.HotCodeReplaceErrorDialog_6; - target.disconnect(); - } else { - operation[0]= DebugUIMessages.HotCodeReplaceErrorDialog_8; - ILaunch launch = target.getLaunch(); - launch.terminate(); - ILaunchConfiguration config = launch.getLaunchConfiguration(); - if (config != null && config.exists()) { - DebugUITools.launch(config, launch.getLaunchMode()); - } + Runnable r = () -> { + try { + if (id == TERMINATE_ID) { + operation[0]= DebugUIMessages.HotCodeReplaceErrorDialog_5; + target.terminate(); + } else if (id == DISCONNECT_ID){ + operation[0]= DebugUIMessages.HotCodeReplaceErrorDialog_6; + target.disconnect(); + } else { + operation[0]= DebugUIMessages.HotCodeReplaceErrorDialog_8; + ILaunch launch = target.getLaunch(); + launch.terminate(); + ILaunchConfiguration config = launch.getLaunchConfiguration(); + if (config != null && config.exists()) { + DebugUITools.launch(config, launch.getLaunchMode()); } - } catch (DebugException e) { - ex[0] = e; } + } catch (DebugException e) { + ex[0] = e; } }; BusyIndicator.showWhile(getShell().getDisplay(), r); diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/IJDIPreferencesConstants.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/IJDIPreferencesConstants.java index 6f0af1f7d4..78ead13eaf 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/IJDIPreferencesConstants.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/IJDIPreferencesConstants.java @@ -26,49 +26,49 @@ public interface IJDIPreferencesConstants { * execution when an uncaught Java exceptions encountered * (while debugging). */ - public static final String PREF_SUSPEND_ON_UNCAUGHT_EXCEPTIONS= IJavaDebugUIConstants.PLUGIN_ID + ".javaDebug.SuspendOnUncaughtExceptions"; //$NON-NLS-1$ + String PREF_SUSPEND_ON_UNCAUGHT_EXCEPTIONS= IJavaDebugUIConstants.PLUGIN_ID + ".javaDebug.SuspendOnUncaughtExceptions"; //$NON-NLS-1$ /** * Boolean preference controlling whether to suspend * execution when a compilation error is encountered * (while debugging). */ - public static final String PREF_SUSPEND_ON_COMPILATION_ERRORS = IJavaDebugUIConstants.PLUGIN_ID + ".suspend_on_compilation_errors"; //$NON-NLS-1$ + String PREF_SUSPEND_ON_COMPILATION_ERRORS = IJavaDebugUIConstants.PLUGIN_ID + ".suspend_on_compilation_errors"; //$NON-NLS-1$ /** * Boolean preference controlling whether synthetic * methods are to be filtered when stepping (and step * filters are enabled). */ - public static final String PREF_FILTER_SYNTHETICS = IJavaDebugUIConstants.PLUGIN_ID + ".filter_synthetics"; //$NON-NLS-1$ + String PREF_FILTER_SYNTHETICS = IJavaDebugUIConstants.PLUGIN_ID + ".filter_synthetics"; //$NON-NLS-1$ /** * Boolean preference controlling whether static * initializers are to be filtered when stepping (and step * filters are enabled). */ - public static final String PREF_FILTER_STATIC_INITIALIZERS = IJavaDebugUIConstants.PLUGIN_ID + ".filter_statics"; //$NON-NLS-1$ + String PREF_FILTER_STATIC_INITIALIZERS = IJavaDebugUIConstants.PLUGIN_ID + ".filter_statics"; //$NON-NLS-1$ /** * Boolean preference controlling whether simple getters * are to be filtered when stepping (and step * filters are enabled). */ - public static final String PREF_FILTER_GETTERS = IJavaDebugUIConstants.PLUGIN_ID + ".filter_get"; //$NON-NLS-1$ + String PREF_FILTER_GETTERS = IJavaDebugUIConstants.PLUGIN_ID + ".filter_get"; //$NON-NLS-1$ /** * Boolean preference controlling whether simple setters * are to be filtered when stepping (and step * filters are enabled). */ - public static final String PREF_FILTER_SETTERS = IJavaDebugUIConstants.PLUGIN_ID + ".filter_setters"; //$NON-NLS-1$ + String PREF_FILTER_SETTERS = IJavaDebugUIConstants.PLUGIN_ID + ".filter_setters"; //$NON-NLS-1$ /** * Boolean preference controlling whether constructors * are to be filtered when stepping (and step * filters are enabled). */ - public static final String PREF_FILTER_CONSTRUCTORS = IJavaDebugUIConstants.PLUGIN_ID + ".filter_constructors"; //$NON-NLS-1$ + String PREF_FILTER_CONSTRUCTORS = IJavaDebugUIConstants.PLUGIN_ID + ".filter_constructors"; //$NON-NLS-1$ /** @@ -77,38 +77,38 @@ public interface IJDIPreferencesConstants { * * @since 3.3 */ - public static final String PREF_STEP_THRU_FILTERS = IJavaDebugUIConstants.PLUGIN_ID + ".step_thru_filters"; //$NON-NLS-1$ + String PREF_STEP_THRU_FILTERS = IJavaDebugUIConstants.PLUGIN_ID + ".step_thru_filters"; //$NON-NLS-1$ /** * List of active step filters. A String containing a comma * separated list of fully qualified type names/patterns. */ - public static final String PREF_ACTIVE_FILTERS_LIST = IJavaDebugUIConstants.PLUGIN_ID + ".active_filters"; //$NON-NLS-1$ + String PREF_ACTIVE_FILTERS_LIST = IJavaDebugUIConstants.PLUGIN_ID + ".active_filters"; //$NON-NLS-1$ /** * List of inactive step filters. A String containing a comma * separated list of fully qualified type names/patterns. */ - public static final String PREF_INACTIVE_FILTERS_LIST = IJavaDebugUIConstants.PLUGIN_ID + ".inactive_filters"; //$NON-NLS-1$ + String PREF_INACTIVE_FILTERS_LIST = IJavaDebugUIConstants.PLUGIN_ID + ".inactive_filters"; //$NON-NLS-1$ /** * Boolean preference controlling whether to alert * with a dialog when hot code replace fails. */ - public static final String PREF_ALERT_HCR_FAILED = IJavaDebugUIConstants.PLUGIN_ID + ".javaDebug.alertHCRFailed"; //$NON-NLS-1$ + String PREF_ALERT_HCR_FAILED = IJavaDebugUIConstants.PLUGIN_ID + ".javaDebug.alertHCRFailed"; //$NON-NLS-1$ /** * Boolean preference controlling whether to alert * with a dialog when hot code replace is not supported. */ - public static final String PREF_ALERT_HCR_NOT_SUPPORTED = IJavaDebugUIConstants.PLUGIN_ID + ".javaDebug.alertHCRNotSupported"; //$NON-NLS-1$ + String PREF_ALERT_HCR_NOT_SUPPORTED = IJavaDebugUIConstants.PLUGIN_ID + ".javaDebug.alertHCRNotSupported"; //$NON-NLS-1$ /** * Boolean preference controlling whether to alert * with a dialog when hot code replace results in * obsolete methods. */ - public static final String PREF_ALERT_OBSOLETE_METHODS = IJavaDebugUIConstants.PLUGIN_ID + "javaDebug.alertObsoleteMethods"; //$NON-NLS-1$ + String PREF_ALERT_OBSOLETE_METHODS = IJavaDebugUIConstants.PLUGIN_ID + "javaDebug.alertObsoleteMethods"; //$NON-NLS-1$ /** * Boolean preference controlling whether the debugger shows @@ -117,14 +117,14 @@ public interface IJDIPreferencesConstants { * * @since 2.0 */ - public static final String PREF_SHOW_QUALIFIED_NAMES= IJavaDebugUIConstants.PLUGIN_ID + ".show_qualified_names"; //$NON-NLS-1$ + String PREF_SHOW_QUALIFIED_NAMES= IJavaDebugUIConstants.PLUGIN_ID + ".show_qualified_names"; //$NON-NLS-1$ /** * List of defined detail formatters.A String containing a comma * separated list of fully qualified type names, the associated * code snippet and an 'enabled' flag. */ - public static final String PREF_DETAIL_FORMATTERS_LIST= IJavaDebugUIConstants.PLUGIN_ID + ".detail_formatters"; //$NON-NLS-1$ + String PREF_DETAIL_FORMATTERS_LIST= IJavaDebugUIConstants.PLUGIN_ID + ".detail_formatters"; //$NON-NLS-1$ /** * Boolean preference indicating whether (non-final) static varibles should be shown @@ -133,7 +133,7 @@ public interface IJDIPreferencesConstants { * * @since 2.1 */ - public static final String PREF_SHOW_STATIC_VARIABLES= IJavaDebugUIConstants.PLUGIN_ID + ".show_static_variables"; //$NON-NLS-1$ + String PREF_SHOW_STATIC_VARIABLES= IJavaDebugUIConstants.PLUGIN_ID + ".show_static_variables"; //$NON-NLS-1$ /** * Boolean preference indicating whether constant (final static) varibles should be shown @@ -142,7 +142,7 @@ public interface IJDIPreferencesConstants { * * @since 2.1 */ - public static final String PREF_SHOW_CONSTANTS= IJavaDebugUIConstants.PLUGIN_ID + ".show_constants"; //$NON-NLS-1$ + String PREF_SHOW_CONSTANTS= IJavaDebugUIConstants.PLUGIN_ID + ".show_constants"; //$NON-NLS-1$ /** * Boolean preference indicating whether null array entries should be shown @@ -151,7 +151,7 @@ public interface IJDIPreferencesConstants { * * @since 3.0 */ - public static final String PREF_SHOW_NULL_ARRAY_ENTRIES = IJavaDebugUIConstants.PLUGIN_ID + ".show_null_entries"; //$NON-NLS-1$ + String PREF_SHOW_NULL_ARRAY_ENTRIES = IJavaDebugUIConstants.PLUGIN_ID + ".show_null_entries"; //$NON-NLS-1$ /** * Boolean preference indicating whether hex values should be shown for primitives @@ -160,7 +160,7 @@ public interface IJDIPreferencesConstants { * * @since 2.1 */ - public static final String PREF_SHOW_HEX = IJavaDebugUIConstants.PLUGIN_ID + ".show_hex"; //$NON-NLS-1$ + String PREF_SHOW_HEX = IJavaDebugUIConstants.PLUGIN_ID + ".show_hex"; //$NON-NLS-1$ /** * Boolean preference indicating whether char values should be shown for primitives @@ -169,7 +169,7 @@ public interface IJDIPreferencesConstants { * * @since 2.1 */ - public static final String PREF_SHOW_CHAR = IJavaDebugUIConstants.PLUGIN_ID + ".show_char"; //$NON-NLS-1$ + String PREF_SHOW_CHAR = IJavaDebugUIConstants.PLUGIN_ID + ".show_char"; //$NON-NLS-1$ /** * Boolean preference indicating whether unsigned values should be shown for primitives @@ -178,7 +178,7 @@ public interface IJDIPreferencesConstants { * * @since 2.1 */ - public static final String PREF_SHOW_UNSIGNED = IJavaDebugUIConstants.PLUGIN_ID + ".show_unsigned"; //$NON-NLS-1$ + String PREF_SHOW_UNSIGNED = IJavaDebugUIConstants.PLUGIN_ID + ".show_unsigned"; //$NON-NLS-1$ /** * String preference indication when and where variable details should appear. @@ -189,21 +189,21 @@ public interface IJDIPreferencesConstants { *
  • DETAIL_PANE to show details only in the detail pane * */ - public static final String PREF_SHOW_DETAILS = IJavaDebugUIConstants.PLUGIN_ID + ".show_details"; //$NON-NLS-1$ + String PREF_SHOW_DETAILS = IJavaDebugUIConstants.PLUGIN_ID + ".show_details"; //$NON-NLS-1$ /** * "Show detail" preference values. */ - public static final String INLINE_ALL="INLINE_ALL"; //$NON-NLS-1$ - public static final String INLINE_FORMATTERS="INLINE_FORMATTERS"; //$NON-NLS-1$ - public static final String DETAIL_PANE="DETAIL_PANE"; //$NON-NLS-1$ + String INLINE_ALL="INLINE_ALL"; //$NON-NLS-1$ + String INLINE_FORMATTERS="INLINE_FORMATTERS"; //$NON-NLS-1$ + String DETAIL_PANE="DETAIL_PANE"; //$NON-NLS-1$ /** * Common dialog settings */ - public static final String DIALOG_ORIGIN_X = "DIALOG_ORIGIN_X"; //$NON-NLS-1$ - public static final String DIALOG_ORIGIN_Y = "DIALOG_ORIGIN_Y"; //$NON-NLS-1$ - public static final String DIALOG_WIDTH = "DIALOG_WIDTH"; //$NON-NLS-1$ - public static final String DIALOG_HEIGHT = "DIALOG_HEIGHT"; //$NON-NLS-1$ + String DIALOG_ORIGIN_X = "DIALOG_ORIGIN_X"; //$NON-NLS-1$ + String DIALOG_ORIGIN_Y = "DIALOG_ORIGIN_Y"; //$NON-NLS-1$ + String DIALOG_WIDTH = "DIALOG_WIDTH"; //$NON-NLS-1$ + String DIALOG_HEIGHT = "DIALOG_HEIGHT"; //$NON-NLS-1$ /** @@ -211,29 +211,30 @@ public interface IJDIPreferencesConstants { * with a dialog when unable to install a breakpoint * (line info not available, ...) */ - public static final String PREF_ALERT_UNABLE_TO_INSTALL_BREAKPOINT = IJavaDebugUIConstants.PLUGIN_ID + ".prompt_unable_to_install_breakpoint"; //$NON-NLS-1$ + String PREF_ALERT_UNABLE_TO_INSTALL_BREAKPOINT = IJavaDebugUIConstants.PLUGIN_ID + ".prompt_unable_to_install_breakpoint"; //$NON-NLS-1$ - public static final String PREF_PROMPT_BEFORE_MODIFYING_FINAL_FIELDS = IJavaDebugUIConstants.PLUGIN_ID + ".prompt_before_modifying_final_fields"; //$NON-NLS-1$ + String PREF_PROMPT_BEFORE_MODIFYING_FINAL_FIELDS = IJavaDebugUIConstants.PLUGIN_ID + ".prompt_before_modifying_final_fields"; //$NON-NLS-1$ - public static final String PREF_THREAD_MONITOR_IN_DEADLOCK_COLOR= "org.eclipse.jdt.debug.ui.InDeadlockColor"; //$NON-NLS-1$ + String PREF_THREAD_MONITOR_IN_DEADLOCK_COLOR= "org.eclipse.jdt.debug.ui.InDeadlockColor"; //$NON-NLS-1$ + + String PREF_LABELED_OBJECT_COLOR = IJavaDebugUIConstants.PLUGIN_ID + ".LabeledObject"; //$NON-NLS-1$ - public static final String PREF_LABELED_OBJECT_COLOR = IJavaDebugUIConstants.PLUGIN_ID + ".LabeledObject"; //$NON-NLS-1$ /** * @since 3.2 */ - public static final String PREF_OPEN_INSPECT_POPUP_ON_EXCEPTION = IJavaDebugUIConstants.PLUGIN_ID + ".open_inspect_popup_on_exception"; //$NON-NLS-1$ + String PREF_OPEN_INSPECT_POPUP_ON_EXCEPTION = IJavaDebugUIConstants.PLUGIN_ID + ".open_inspect_popup_on_exception"; //$NON-NLS-1$ /** * Boolean preference controlling whether the java stack trace * console should be formatted when ever a paste occurs. * @since 3.3 */ - public static final String PREF_AUTO_FORMAT_JSTCONSOLE = IJavaDebugUIConstants.PLUGIN_ID + ".auto_format_jstconsole"; //$NON-NLS-1$; + String PREF_AUTO_FORMAT_JSTCONSOLE = IJavaDebugUIConstants.PLUGIN_ID + ".auto_format_jstconsole"; //$NON-NLS-1$; /** * Boolean preference controlling whether to prompt with a dialog when deleting a conditional * breakpoint. */ - public static final String PREF_PROMPT_DELETE_CONDITIONAL_BREAKPOINT= IJavaDebugUIConstants.PLUGIN_ID + ".prompt_delete_conditional_breakpoint"; //$NON-NLS-1$ + String PREF_PROMPT_DELETE_CONDITIONAL_BREAKPOINT= IJavaDebugUIConstants.PLUGIN_ID + ".prompt_delete_conditional_breakpoint"; //$NON-NLS-1$ } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/IJDIStatusConstants.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/IJDIStatusConstants.java index 08d55aa9fa..e105936295 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/IJDIStatusConstants.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/IJDIStatusConstants.java @@ -22,6 +22,6 @@ public interface IJDIStatusConstants { /** * Indicates a connection could not be made with a remote VM */ - public static final int CODE_CONNECTION_FAILED= 1; + int CODE_CONNECTION_FAILED= 1; } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/IJavaDebugHelpContextIds.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/IJavaDebugHelpContextIds.java index 33b90bcef7..08ccaabd30 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/IJavaDebugHelpContextIds.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/IJavaDebugHelpContextIds.java @@ -25,75 +25,75 @@ */ public interface IJavaDebugHelpContextIds { - public static final String PREFIX= IJavaDebugUIConstants.PLUGIN_ID + '.'; + String PREFIX= IJavaDebugUIConstants.PLUGIN_ID + '.'; // view parts - public static final String DISPLAY_VIEW= PREFIX + "display_view_context"; //$NON-NLS-1$ - public static final String STACK_TRACE_CONSOLE = PREFIX + "stack_trace_console_context"; //$NON-NLS-1$ + String DISPLAY_VIEW= PREFIX + "display_view_context"; //$NON-NLS-1$ + String STACK_TRACE_CONSOLE = PREFIX + "stack_trace_console_context"; //$NON-NLS-1$ //dialogs - public static final String JRE_DETAILS_DIALOG= PREFIX + "jre_details_dialog_context"; //$NON-NLS-1$ - public static final String MAIN_TYPE_SELECTION_DIALOG= PREFIX + "main_type_selection_dialog_context"; //$NON-NLS-1$ - public static final String EDIT_DETAIL_FORMATTER_DIALOG= PREFIX + "edit_detail_formatter_dialog_context"; //$NON-NLS-1$ - public static final String EDIT_LOGICAL_STRUCTURE_DIALOG= PREFIX + "edit_logical_structure_dialog_context"; //$NON-NLS-1$ - public static final String INSTANCE_BREAKPOINT_SELECTION_DIALOG= PREFIX + "instance_breakpoint_selection_dialog_context"; //$NON-NLS-1$ - public static final String SNIPPET_IMPORTS_DIALOG= PREFIX + "snippet_imports_dialog_context"; //$NON-NLS-1$ - public static final String ADD_EXCEPTION_DIALOG= PREFIX + "add_exception_dialog_context"; //$NON-NLS-1$ - public static final String DETAIL_DISPLAY_OPTIONS_DIALOG= PREFIX + "detail_options_dialog_context"; //$NON-NLS-1$ - public static final String SELECT_MAIN_METHOD_DIALOG = PREFIX + "select_main_method_dialog"; //$NON-NLS-1$ - public static final String EXPRESSION_INPUT_DIALOG = PREFIX + "expression_input_dialog"; //$NON-NLS-1$ - public static final String STRING_VALUE_INPUT_DIALOG = PREFIX + "string_value_input_dialog"; //$NON-NLS-1$ - public static final String DEFAULT_INPUT_DIALOG = PREFIX + "default_input_dialog"; //$NON-NLS-1$ - public static final String SELECT_PROJECT_DIALOG = PREFIX + "select_project_dialog"; //$NON-NLS-1$ + String JRE_DETAILS_DIALOG= PREFIX + "jre_details_dialog_context"; //$NON-NLS-1$ + String MAIN_TYPE_SELECTION_DIALOG= PREFIX + "main_type_selection_dialog_context"; //$NON-NLS-1$ + String EDIT_DETAIL_FORMATTER_DIALOG= PREFIX + "edit_detail_formatter_dialog_context"; //$NON-NLS-1$ + String EDIT_LOGICAL_STRUCTURE_DIALOG= PREFIX + "edit_logical_structure_dialog_context"; //$NON-NLS-1$ + String INSTANCE_BREAKPOINT_SELECTION_DIALOG= PREFIX + "instance_breakpoint_selection_dialog_context"; //$NON-NLS-1$ + String SNIPPET_IMPORTS_DIALOG= PREFIX + "snippet_imports_dialog_context"; //$NON-NLS-1$ + String ADD_EXCEPTION_DIALOG= PREFIX + "add_exception_dialog_context"; //$NON-NLS-1$ + String DETAIL_DISPLAY_OPTIONS_DIALOG= PREFIX + "detail_options_dialog_context"; //$NON-NLS-1$ + String SELECT_MAIN_METHOD_DIALOG = PREFIX + "select_main_method_dialog"; //$NON-NLS-1$ + String EXPRESSION_INPUT_DIALOG = PREFIX + "expression_input_dialog"; //$NON-NLS-1$ + String STRING_VALUE_INPUT_DIALOG = PREFIX + "string_value_input_dialog"; //$NON-NLS-1$ + String DEFAULT_INPUT_DIALOG = PREFIX + "default_input_dialog"; //$NON-NLS-1$ + String SELECT_PROJECT_DIALOG = PREFIX + "select_project_dialog"; //$NON-NLS-1$ // Preference/Property pages - public static final String JRE_PREFERENCE_PAGE= PREFIX + "jre_preference_page_context"; //$NON-NLS-1$ - public static final String JRE_PROFILES_PAGE= PREFIX + "jre_profiles_page_context"; //$NON-NLS-1$ - public static final String LAUNCH_JRE_PROPERTY_PAGE= PREFIX + "launch_jre_property_page_context"; //$NON-NLS-1$ - public static final String JAVA_DEBUG_PREFERENCE_PAGE= PREFIX + "java_debug_preference_page_context"; //$NON-NLS-1$ - public static final String JAVA_STEP_FILTER_PREFERENCE_PAGE= PREFIX + "java_step_filter_preference_page_context"; //$NON-NLS-1$ - public static final String JAVA_BREAKPOINT_PREFERENCE_PAGE= PREFIX + "java_breakpoint_preference_page_context"; //$NON-NLS-1$ - public static final String JAVA_DETAIL_FORMATTER_PREFERENCE_PAGE= PREFIX + "java_detail_formatter_preference_page_context"; //$NON-NLS-1$ - public static final String JAVA_PRIMITIVES_PREFERENCE_PAGE= PREFIX + "java_primitives_preference_page_context"; //$NON-NLS-1$ - public static final String JAVA_LOGICAL_STRUCTURES_PAGE = PREFIX + "java_logical_structures_page"; //$NON-NLS-1$ - public static final String VMCAPABILITIES_PROPERTY_PAGE = PREFIX + "vm_capabilities_property_page"; //$NON-NLS-1$ - public static final String JAVA_HEAPWALKING_PREFERENCE_PAGE = PREFIX + "java_heapwalking_preference_page"; //$NON-NLS-1$ - public static final String JAVA_BREAKPOINT_PROPERTY_PAGE = PREFIX + "java_breakpoint_property_page"; //$NON-NLS-1$ - public static final String JAVA_BREAKPOINT_ADVANCED_PROPERTY_PAGE = PREFIX + "java_breakpoint_advanced_property_page"; //$NON-NLS-1$ - public static final String JAVA_EXCEPTION_BREAKPOINT_PROPERTY_PAGE = PREFIX + "java_exception_breakpoint_property_page"; //$NON-NLS-1$ - public static final String JAVA_EXCEPTION_BREAKPOINT_FILTERING_PROPERTY_PAGE = PREFIX + "java_exception_breakpoint_filtering_property_page"; //$NON-NLS-1$ - public static final String JAVA_LINE_BREAKPOINT_PROPERTY_PAGE = PREFIX + "java_line_breakpoint_property_page"; //$NON-NLS-1$ + String JRE_PREFERENCE_PAGE= PREFIX + "jre_preference_page_context"; //$NON-NLS-1$ + String JRE_PROFILES_PAGE= PREFIX + "jre_profiles_page_context"; //$NON-NLS-1$ + String LAUNCH_JRE_PROPERTY_PAGE= PREFIX + "launch_jre_property_page_context"; //$NON-NLS-1$ + String JAVA_DEBUG_PREFERENCE_PAGE= PREFIX + "java_debug_preference_page_context"; //$NON-NLS-1$ + String JAVA_STEP_FILTER_PREFERENCE_PAGE= PREFIX + "java_step_filter_preference_page_context"; //$NON-NLS-1$ + String JAVA_BREAKPOINT_PREFERENCE_PAGE= PREFIX + "java_breakpoint_preference_page_context"; //$NON-NLS-1$ + String JAVA_DETAIL_FORMATTER_PREFERENCE_PAGE= PREFIX + "java_detail_formatter_preference_page_context"; //$NON-NLS-1$ + String JAVA_PRIMITIVES_PREFERENCE_PAGE= PREFIX + "java_primitives_preference_page_context"; //$NON-NLS-1$ + String JAVA_LOGICAL_STRUCTURES_PAGE = PREFIX + "java_logical_structures_page"; //$NON-NLS-1$ + String VMCAPABILITIES_PROPERTY_PAGE = PREFIX + "vm_capabilities_property_page"; //$NON-NLS-1$ + String JAVA_HEAPWALKING_PREFERENCE_PAGE = PREFIX + "java_heapwalking_preference_page"; //$NON-NLS-1$ + String JAVA_BREAKPOINT_PROPERTY_PAGE = PREFIX + "java_breakpoint_property_page"; //$NON-NLS-1$ + String JAVA_BREAKPOINT_ADVANCED_PROPERTY_PAGE = PREFIX + "java_breakpoint_advanced_property_page"; //$NON-NLS-1$ + String JAVA_EXCEPTION_BREAKPOINT_PROPERTY_PAGE = PREFIX + "java_exception_breakpoint_property_page"; //$NON-NLS-1$ + String JAVA_EXCEPTION_BREAKPOINT_FILTERING_PROPERTY_PAGE = PREFIX + "java_exception_breakpoint_filtering_property_page"; //$NON-NLS-1$ + String JAVA_LINE_BREAKPOINT_PROPERTY_PAGE = PREFIX + "java_line_breakpoint_property_page"; //$NON-NLS-1$ // reused ui-blocks - public static final String SOURCE_ATTACHMENT_BLOCK= PREFIX + "source_attachment_context"; //$NON-NLS-1$ - public static final String WORKING_DIRECTORY_BLOCK= PREFIX + "working_directory_context"; //$NON-NLS-1$ + String SOURCE_ATTACHMENT_BLOCK= PREFIX + "source_attachment_context"; //$NON-NLS-1$ + String WORKING_DIRECTORY_BLOCK= PREFIX + "working_directory_context"; //$NON-NLS-1$ // application launch configuration dialog tabs - public static final String LAUNCH_CONFIGURATION_DIALOG_ARGUMENTS_TAB= PREFIX + "launch_configuration_dialog_arguments_tab"; //$NON-NLS-1$ - public static final String LAUNCH_CONFIGURATION_DIALOG_CLASSPATH_TAB= PREFIX + "launch_configuration_dialog_classpath_tab"; //$NON-NLS-1$ - public static final String LAUNCH_CONFIGURATION_DIALOG_DEPENDENCIES_TAB = PREFIX + "launch_configuration_dialog_classpath_tab"; //$NON-NLS-1$ - public static final String LAUNCH_CONFIGURATION_DIALOG_CONNECT_TAB= PREFIX + "launch_configuration_dialog_connect_tab"; //$NON-NLS-1$ - public static final String LAUNCH_CONFIGURATION_DIALOG_JRE_TAB= PREFIX + "launch_configuration_dialog_jre_tab"; //$NON-NLS-1$ - public static final String LAUNCH_CONFIGURATION_DIALOG_MAIN_TAB= PREFIX + "launch_configuration_dialog_main_tab"; //$NON-NLS-1$ - public static final String LAUNCH_CONFIGURATION_DIALOG_SOURCE_TAB= PREFIX + "launch_configuration_dialog_source_tab"; //$NON-NLS-1$ + String LAUNCH_CONFIGURATION_DIALOG_ARGUMENTS_TAB= PREFIX + "launch_configuration_dialog_arguments_tab"; //$NON-NLS-1$ + String LAUNCH_CONFIGURATION_DIALOG_CLASSPATH_TAB= PREFIX + "launch_configuration_dialog_classpath_tab"; //$NON-NLS-1$ + String LAUNCH_CONFIGURATION_DIALOG_DEPENDENCIES_TAB = PREFIX + "launch_configuration_dialog_classpath_tab"; //$NON-NLS-1$ + String LAUNCH_CONFIGURATION_DIALOG_CONNECT_TAB= PREFIX + "launch_configuration_dialog_connect_tab"; //$NON-NLS-1$ + String LAUNCH_CONFIGURATION_DIALOG_JRE_TAB= PREFIX + "launch_configuration_dialog_jre_tab"; //$NON-NLS-1$ + String LAUNCH_CONFIGURATION_DIALOG_MAIN_TAB= PREFIX + "launch_configuration_dialog_main_tab"; //$NON-NLS-1$ + String LAUNCH_CONFIGURATION_DIALOG_SOURCE_TAB= PREFIX + "launch_configuration_dialog_source_tab"; //$NON-NLS-1$ // applet launch configuration dialog tabs - public static final String LAUNCH_CONFIGURATION_DIALOG_APPLET_MAIN_TAB = PREFIX + "launch_configuration_dialog_applet_main_tab"; //$NON-NLS-1$ - public static final String LAUNCH_CONFIGURATION_DIALOG_APPLET_ARGUMENTS_TAB = PREFIX + "launch_configuration_dialog_applet_arguments_tab"; //$NON-NLS-1$ - public static final String LAUNCH_CONFIGURATION_DIALOG_APPLET_PARAMETERS_TAB = PREFIX +"launch_configuration_dialog_applet_parameters_tab"; //$NON-NLS-1$ + String LAUNCH_CONFIGURATION_DIALOG_APPLET_MAIN_TAB = PREFIX + "launch_configuration_dialog_applet_main_tab"; //$NON-NLS-1$ + String LAUNCH_CONFIGURATION_DIALOG_APPLET_ARGUMENTS_TAB = PREFIX + "launch_configuration_dialog_applet_arguments_tab"; //$NON-NLS-1$ + String LAUNCH_CONFIGURATION_DIALOG_APPLET_PARAMETERS_TAB = PREFIX +"launch_configuration_dialog_applet_parameters_tab"; //$NON-NLS-1$ //actions - public static final String STEP_INTO_SELECTION_ACTION = PREFIX + "step_into_selection_action"; //$NON-NLS-1$ - public static final String SHOW_STATICS_ACTION = PREFIX + "show_static_action_context"; //$NON-NLS-1$ - public static final String SHOW_CONSTANTS_ACTION = PREFIX + "show_constants_action_context"; //$NON-NLS-1$ - public static final String CLEAR_DISPLAY_VIEW_ACTION = PREFIX + "clear_display_view_action_context"; //$NON-NLS-1$ - public static final String TERMINATE_SCRAPBOOK_VM_ACTION = PREFIX + "terminate_scrapbook_vm_action_context"; //$NON-NLS-1$ - public static final String SCRAPBOOK_IMPORTS_ACTION = PREFIX + "scrapbook_imports_action_context"; //$NON-NLS-1$ - public static final String CONSOLE_AUTOFORMAT_STACKTRACES_ACTION = PREFIX + "console_autoformat_stacktraces_action"; //$NON-NLS-1$ + String STEP_INTO_SELECTION_ACTION = PREFIX + "step_into_selection_action"; //$NON-NLS-1$ + String SHOW_STATICS_ACTION = PREFIX + "show_static_action_context"; //$NON-NLS-1$ + String SHOW_CONSTANTS_ACTION = PREFIX + "show_constants_action_context"; //$NON-NLS-1$ + String CLEAR_DISPLAY_VIEW_ACTION = PREFIX + "clear_display_view_action_context"; //$NON-NLS-1$ + String TERMINATE_SCRAPBOOK_VM_ACTION = PREFIX + "terminate_scrapbook_vm_action_context"; //$NON-NLS-1$ + String SCRAPBOOK_IMPORTS_ACTION = PREFIX + "scrapbook_imports_action_context"; //$NON-NLS-1$ + String CONSOLE_AUTOFORMAT_STACKTRACES_ACTION = PREFIX + "console_autoformat_stacktraces_action"; //$NON-NLS-1$ //wizards - public static final String ADD_NEW_JRE_WIZARD_PAGE= PREFIX + "add_new_jre_wizard_page_context"; //$NON-NLS-1$ - public static final String EDIT_JRE_STD_VM_WIZARD_PAGE= PREFIX + "edit_std_vm_jre_wizard_page_context"; //$NON-NLS-1$ - public static final String EDIT_JRE_EE_FILE_WIZARD_PAGE= PREFIX + "edit_ee_file_jre_wizard_page_context"; //$NON-NLS-1$ - public static final String NEW_SNIPPET_WIZARD_PAGE= PREFIX + "new_snippet_wizard_page_context"; //$NON-NLS-1$ + String ADD_NEW_JRE_WIZARD_PAGE= PREFIX + "add_new_jre_wizard_page_context"; //$NON-NLS-1$ + String EDIT_JRE_STD_VM_WIZARD_PAGE= PREFIX + "edit_std_vm_jre_wizard_page_context"; //$NON-NLS-1$ + String EDIT_JRE_EE_FILE_WIZARD_PAGE= PREFIX + "edit_ee_file_jre_wizard_page_context"; //$NON-NLS-1$ + String NEW_SNIPPET_WIZARD_PAGE= PREFIX + "new_snippet_wizard_page_context"; //$NON-NLS-1$ } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/ImageDescriptorRegistry.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/ImageDescriptorRegistry.java index 18ce91f2d1..0aa11e3a6b 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/ImageDescriptorRegistry.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/ImageDescriptorRegistry.java @@ -16,7 +16,6 @@ import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import org.eclipse.core.runtime.Assert; @@ -81,25 +80,14 @@ public Image get(ImageDescriptor descriptor) { * Disposes all images managed by this registry. */ public void dispose() { - for (Iterator iter= fRegistry.values().iterator(); iter.hasNext(); ) { - Image image= iter.next(); + for (Image image : fRegistry.values()) { image.dispose(); } fRegistry.clear(); } private void hookDisplay() { - fDisplay.asyncExec(new Runnable() { - @Override - public void run() { - fDisplay.disposeExec(new Runnable() { - @Override - public void run() { - dispose(); - } - }); - } - }); + fDisplay.asyncExec(() -> fDisplay.disposeExec(() -> dispose())); } } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIDebugUIPlugin.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIDebugUIPlugin.java index b95bdd0cdb..687aeffa0d 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIDebugUIPlugin.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIDebugUIPlugin.java @@ -31,7 +31,6 @@ import org.eclipse.core.runtime.IAdapterManager; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; @@ -339,14 +338,11 @@ public static Object createExtension(final IConfigurationElement element, final final Object [] ret = new Object[1]; final CoreException [] exc = new CoreException[1]; - BusyIndicator.showWhile(null, new Runnable() { - @Override - public void run() { - try { - ret[0] = element.createExecutableExtension(classAttribute); - } catch (CoreException e) { - exc[0] = e; - } + BusyIndicator.showWhile(null, () -> { + try { + ret[0] = element.createExecutableExtension(classAttribute); + } catch (CoreException e) { + exc[0] = e; } }); if (exc[0] != null) { @@ -543,38 +539,34 @@ public static ElementListSelectionDialog createAllPackagesDialog(Shell shell, IJ } final IJavaProject[] projects= originals; final JavaModelException[] exception= new JavaModelException[1]; - final boolean[] monitorCanceled = new boolean[] {false}; - IRunnableWithProgress r= new IRunnableWithProgress() { - @Override - public void run(IProgressMonitor monitor) { - try { - Set packageNameSet= new HashSet<>(); - monitor.beginTask(DebugUIMessages.JDIDebugUIPlugin_Searching_1, projects.length); - for (int i = 0; i < projects.length; i++) { - IPackageFragment[] pkgs= projects[i].getPackageFragments(); - for (int j = 0; j < pkgs.length; j++) { - if (monitor.isCanceled()) { - monitorCanceled[0] = true; - return; - } - IPackageFragment pkg = pkgs[j]; - if (!pkg.hasChildren() && (pkg.getNonJavaResources().length > 0)) { - continue; - } - String pkgName= pkg.getElementName(); - if (!includeDefaultPackage && pkgName.length() == 0) { - continue; - } - if (packageNameSet.add(pkgName)) { - packageList.add(pkg); - } + final boolean[] monitorCanceled = {false}; + IRunnableWithProgress r= monitor -> { + try { + Set packageNameSet= new HashSet<>(); + monitor.beginTask(DebugUIMessages.JDIDebugUIPlugin_Searching_1, projects.length); + for (IJavaProject project : projects) { + IPackageFragment[] pkgs= project.getPackageFragments(); + for (IPackageFragment pkg : pkgs) { + if (monitor.isCanceled()) { + monitorCanceled[0] = true; + return; + } + if (!pkg.hasChildren() && (pkg.getNonJavaResources().length > 0)) { + continue; + } + String pkgName= pkg.getElementName(); + if (!includeDefaultPackage && pkgName.length() == 0) { + continue; + } + if (packageNameSet.add(pkgName)) { + packageList.add(pkg); } - monitor.worked(1); } - monitor.done(); - } catch (JavaModelException jme) { - exception[0]= jme; + monitor.worked(1); } + monitor.done(); + } catch (JavaModelException jme) { + exception[0]= jme; } }; try { @@ -623,9 +615,9 @@ protected void initializeVMInstallTypePageMap() { IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(getUniqueIdentifier(), IJavaDebugUIConstants.EXTENSION_POINT_VM_INSTALL_TYPE_PAGE); IConfigurationElement[] infos= extensionPoint.getConfigurationElements(); - for (int i = 0; i < infos.length; i++) { - String id = infos[i].getAttribute("vmInstallTypeID"); //$NON-NLS-1$ - fVmInstallTypePageMap.put(id, infos[i]); + for (IConfigurationElement element : infos) { + String id = element.getAttribute("vmInstallTypeID"); //$NON-NLS-1$ + fVmInstallTypePageMap.put(id, element); } } @@ -656,14 +648,11 @@ public static void showPreferencePage(String id, IPreferencePage page) { PreferenceManager manager = new PreferenceManager(); manager.addToRoot(targetNode); final PreferenceDialog dialog = new PreferenceDialog(JDIDebugUIPlugin.getActiveWorkbenchShell(), manager); - final boolean [] result = new boolean[] { false }; - BusyIndicator.showWhile(JDIDebugUIPlugin.getStandardDisplay(), new Runnable() { - @Override - public void run() { - dialog.create(); - dialog.setMessage(targetNode.getLabelText()); - result[0]= (dialog.open() == Window.OK); - } + final boolean [] result = { false }; + BusyIndicator.showWhile(JDIDebugUIPlugin.getStandardDisplay(), () -> { + dialog.create(); + dialog.setMessage(targetNode.getLabelText()); + result[0]= (dialog.open() == Window.OK); }); } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIElementImageDescriptor.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIElementImageDescriptor.java index a1a5416b9b..64411a4570 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIElementImageDescriptor.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIElementImageDescriptor.java @@ -73,10 +73,9 @@ protected Point getSize() { */ @Override public boolean equals(Object object) { - if (!(object instanceof JDIElementImageDescriptor)) { + if (!(object instanceof JDIElementImageDescriptor other)) { return false; } - JDIElementImageDescriptor other = (JDIElementImageDescriptor) object; return (fBaseImage.equals(other.fBaseImage) && fFlags == other.fFlags); } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIImageDescriptor.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIImageDescriptor.java index 02a2086f47..f464e9f721 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIImageDescriptor.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIImageDescriptor.java @@ -99,11 +99,10 @@ protected Point getSize() { */ @Override public boolean equals(Object object) { - if (!(object instanceof JDIImageDescriptor)){ + if (!(object instanceof JDIImageDescriptor other)){ return false; } - JDIImageDescriptor other= (JDIImageDescriptor)object; return (getBaseImage().equals(other.getBaseImage()) && getFlags() == other.getFlags()); } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIModelPresentation.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIModelPresentation.java index 93eff38706..224242947d 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIModelPresentation.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDIModelPresentation.java @@ -199,9 +199,9 @@ public static IJavaThread getEvaluationThread(IJavaDebugTarget target) { if (thread == null) { try { IThread[] threads = target.getThreads(); - for (int i = 0; i < threads.length; i++) { - if (threads[i].isSuspended()) { - thread = (IJavaThread)threads[i]; + for (IThread thread2 : threads) { + if (thread2.isSuspended()) { + thread = (IJavaThread)thread2; break; } } @@ -344,10 +344,10 @@ protected String getThreadText(IJavaThread thread, boolean qualified) throws Cor key.append("suspended"); //$NON-NLS-1$ if (breakpoints.length > 0) { IJavaBreakpoint breakpoint= (IJavaBreakpoint)breakpoints[0]; - for (int i= 0, numBreakpoints= breakpoints.length; i < numBreakpoints; i++) { - if (BreakpointUtils.isProblemBreakpoint(breakpoints[i])) { + for (IBreakpoint breakpoint2 : breakpoints) { + if (BreakpointUtils.isProblemBreakpoint(breakpoint2)) { // If a compilation error breakpoint exists, display it instead of the first breakpoint - breakpoint= (IJavaBreakpoint)breakpoints[i]; + breakpoint= (IJavaBreakpoint)breakpoint2; break; } } @@ -380,8 +380,7 @@ protected String getThreadText(IJavaThread thread, boolean qualified) throws Cor if (exName != null) { args = new String[] { thread.getName(), exName }; } - } else if (breakpoint instanceof IJavaWatchpoint) { - IJavaWatchpoint wp = (IJavaWatchpoint)breakpoint; + } else if (breakpoint instanceof IJavaWatchpoint wp) { String fieldName = wp.getFieldName(); args = new String[] {thread.getName(), fieldName, typeName}; if (wp.isAccessSuspend(thread.getDebugTarget())) { @@ -389,8 +388,7 @@ protected String getThreadText(IJavaThread thread, boolean qualified) throws Cor } else { key.append("_fieldmodification"); //$NON-NLS-1$ } - } else if (breakpoint instanceof IJavaMethodBreakpoint) { - IJavaMethodBreakpoint me= (IJavaMethodBreakpoint)breakpoint; + } else if (breakpoint instanceof IJavaMethodBreakpoint me) { String methodName= me.getMethodName(); args = new String[] {thread.getName(), methodName, typeName}; if (me.isEntrySuspend(thread.getDebugTarget())) { @@ -398,8 +396,7 @@ protected String getThreadText(IJavaThread thread, boolean qualified) throws Cor } else { key.append("_methodexit"); //$NON-NLS-1$ } - } else if (breakpoint instanceof IJavaLineBreakpoint) { - IJavaLineBreakpoint jlbp = (IJavaLineBreakpoint)breakpoint; + } else if (breakpoint instanceof IJavaLineBreakpoint jlbp) { int lineNumber= jlbp.getLineNumber(); if (lineNumber > -1) { args = new String[] {thread.getName(), String.valueOf(lineNumber), typeName}; @@ -1329,16 +1326,10 @@ public boolean isShowLabelDetails(IJavaValue value) { private String getVariableDetail(IJavaValue value) { final String[] detail= new String[1]; final Object lock= new Object(); - computeDetail(value, new IValueDetailListener() { - /* (non-Javadoc) - * @see org.eclipse.debug.ui.IValueDetailListener#detailComputed(org.eclipse.debug.core.model.IValue, java.lang.String) - */ - @Override - public void detailComputed(IValue computedValue, String result) { - synchronized (lock) { - detail[0]= result; - lock.notifyAll(); - } + computeDetail(value, (computedValue, result) -> { + synchronized (lock) { + detail[0]= result; + lock.notifyAll(); } }); synchronized (lock) { @@ -1970,7 +1961,7 @@ public static String getFormattedString(String string, String[] args) { } interface IValueDetailProvider { - public void computeDetail(IValue value, IJavaThread thread, IValueDetailListener listener) throws DebugException; + void computeDetail(IValue value, IJavaThread thread, IValueDetailListener listener) throws DebugException; } protected void appendSuspendPolicy(IJavaBreakpoint breakpoint, StringBuilder buffer) throws CoreException { @@ -1996,8 +1987,8 @@ protected void appendConditional(IJavaLineBreakpoint breakpoint, StringBuilder b protected void appendInstanceFilter(IJavaBreakpoint breakpoint, StringBuilder buffer) throws CoreException { IJavaObject[] instances = breakpoint.getInstanceFilters(); - for (int i = 0; i < instances.length; i++) { - String instanceText= instances[i].getValueString(); + for (IJavaObject instance : instances) { + String instanceText= instance.getValueString(); if (instanceText != null) { buffer.append(' '); buffer.append(NLS.bind(DebugUIMessages.JDIModelPresentation_instance_1, new String[] {instanceText})); @@ -2056,8 +2047,8 @@ protected boolean isDuplicateName(IJavaFieldVariable variable) { try { String[] names = javaType.getAllFieldNames(); boolean found= false; - for (int i = 0; i < names.length; i++) { - if (variable.getName().equals(names[i])) { + for (String name : names) { + if (variable.getName().equals(name)) { if (found) { return true; } @@ -2099,10 +2090,7 @@ public Color getForeground(Object element) { var value = inspectExpression.getValue(); return getForeground(value); } - if (element instanceof JavaContendedMonitor contendedMonitor && contendedMonitor.getMonitor().isInDeadlock()) { - return getColorFromRegistry(IJDIPreferencesConstants.PREF_THREAD_MONITOR_IN_DEADLOCK_COLOR); - } - if (element instanceof JavaOwnedMonitor ownedMonitor && ownedMonitor.getMonitor().isInDeadlock()) { + if ((element instanceof JavaContendedMonitor contendedMonitor && contendedMonitor.getMonitor().isInDeadlock()) || (element instanceof JavaOwnedMonitor ownedMonitor && ownedMonitor.getMonitor().isInDeadlock())) { return getColorFromRegistry(IJDIPreferencesConstants.PREF_THREAD_MONITOR_IN_DEADLOCK_COLOR); } if (element instanceof JavaWaitingThread waitingThread && waitingThread.getThread().isInDeadlock()) { diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDISourceViewer.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDISourceViewer.java index 46620e4489..1a23481c15 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDISourceViewer.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JDISourceViewer.java @@ -36,8 +36,6 @@ import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.BidiSegmentEvent; -import org.eclipse.swt.custom.BidiSegmentListener; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; @@ -79,14 +77,11 @@ public JDISourceViewer(Composite parent, IVerticalRuler ruler, IOverviewRuler ov super(parent, ruler, overviewRuler, isOverviewRulerVisible, styles); StyledText text= this.getTextWidget(); final int baseLevel= (styles & SWT.RIGHT_TO_LEFT) != 0 ? Bidi.DIRECTION_RIGHT_TO_LEFT : Bidi.DIRECTION_LEFT_TO_RIGHT; - text.addBidiSegmentListener(new BidiSegmentListener() { - @Override - public void lineGetSegments(BidiSegmentEvent event) { - try { - event.segments= getBidiLineSegments(getDocument(), baseLevel, widgetOffset2ModelOffset(event.lineOffset), event.lineText); - } catch (BadLocationException x) { - // ignore - } + text.addBidiSegmentListener(event -> { + try { + event.segments= getBidiLineSegments(getDocument(), baseLevel, widgetOffset2ModelOffset(event.lineOffset), event.lineText); + } catch (BadLocationException x) { + // ignore } }); } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaBreakpointWorkbenchAdapterFactory.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaBreakpointWorkbenchAdapterFactory.java index 3dd4ae23b9..c257d57a27 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaBreakpointWorkbenchAdapterFactory.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaBreakpointWorkbenchAdapterFactory.java @@ -56,10 +56,9 @@ public ImageDescriptor getImageDescriptor(Object object) { */ @Override public String getLabel(Object o) { - if (!(o instanceof IJavaBreakpoint)) { + if (!(o instanceof IJavaBreakpoint breakpoint)) { return null; } - IJavaBreakpoint breakpoint = (IJavaBreakpoint) o; StringBuilder label = new StringBuilder(); try { String type= breakpoint.getTypeName(); @@ -88,8 +87,7 @@ public String getLabel(Object o) { JDIDebugUIPlugin.log(e); } } - if (breakpoint instanceof IJavaLineBreakpoint) { - IJavaLineBreakpoint lineBreakpoint= ((IJavaLineBreakpoint) breakpoint); + if (breakpoint instanceof IJavaLineBreakpoint lineBreakpoint) { try { int lineNumber= lineBreakpoint.getLineNumber(); if (lineNumber != -1) { diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugHover.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugHover.java index c23df9d2f1..bc783ce95e 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugHover.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugHover.java @@ -123,8 +123,7 @@ protected IJavaStackFrame getFrame() { @Override public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) { Object object = getHoverInfo2(textViewer, hoverRegion); - if (object instanceof IVariable) { - IVariable var = (IVariable) object; + if (object instanceof IVariable var) { return getVariableText(var); } return null; @@ -194,8 +193,7 @@ private static String getVariableText(IVariable variable) { private static String replaceHTMLChars(String variableText) { StringBuilder buffer= new StringBuilder(variableText.length()); char[] characters = variableText.toCharArray(); - for (int i = 0; i < characters.length; i++) { - char character= characters[i]; + for (char character : characters) { switch (character) { case '<': buffer.append("<"); //$NON-NLS-1$ @@ -225,9 +223,9 @@ private static JDIModelPresentation getModelPresentation() { String[][] booleanPrefs= { {IJDIPreferencesConstants.PREF_SHOW_QUALIFIED_NAMES, JDIModelPresentation.DISPLAY_QUALIFIED_NAMES}}; String viewId= IDebugUIConstants.ID_VARIABLE_VIEW; - for (int i = 0; i < booleanPrefs.length; i++) { - boolean preferenceValue = getBooleanPreferenceValue(viewId, booleanPrefs[i][0]); - presentation.setAttribute(booleanPrefs[i][1], (preferenceValue ? Boolean.TRUE : Boolean.FALSE)); + for (String[] booleanPref : booleanPrefs) { + boolean preferenceValue = getBooleanPreferenceValue(viewId, booleanPref[0]); + presentation.setAttribute(booleanPref[1], (preferenceValue ? Boolean.TRUE : Boolean.FALSE)); } return presentation; } @@ -309,19 +307,15 @@ public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { && isArrayTypeVariable(resolve[0]); } - for (int i = 0; i < resolve.length; i++) { - IJavaElement javaElement = resolve[i]; - if (javaElement instanceof IField) { - IField field = (IField) javaElement; + for (IJavaElement javaElement : resolve) { + if (javaElement instanceof IField field) { IJavaVariable variable = null; IJavaDebugTarget debugTarget = (IJavaDebugTarget) frame.getDebugTarget(); if (Flags.isStatic(field.getFlags()) && !onArrayLength) { IJavaType[] javaTypes = debugTarget.getJavaTypes(field.getDeclaringType().getFullyQualifiedName()); if (javaTypes != null) { - for (int j = 0; j < javaTypes.length; j++) { - IJavaType type = javaTypes[j]; - if (type instanceof IJavaReferenceType) { - IJavaReferenceType referenceType = (IJavaReferenceType) type; + for (IJavaType type : javaTypes) { + if (type instanceof IJavaReferenceType referenceType) { variable = referenceType.getField(field.getElementName()); } if (variable != null) { @@ -365,10 +359,9 @@ public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { if ((!frame.isStatic() || isLocalOrMemberVariable(javaElement)) && !frame.isNative()) { // we resolve chain elements which are either on "this" or local variables. In case of // local variables we also consider static frames. - if (!(codeAssist instanceof ITypeRoot)) { + if (!(codeAssist instanceof ITypeRoot typeRoot)) { return null; } - ITypeRoot typeRoot = (ITypeRoot) codeAssist; ASTNode node = findNodeAtRegion(typeRoot, hoverRegion); if (node == null) { return null; @@ -393,14 +386,12 @@ public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { } break; } - if (javaElement instanceof ILocalVariable) { - ILocalVariable var = (ILocalVariable) javaElement; + if (javaElement instanceof ILocalVariable var) { // if we are on a array, regardless where we are send it to evaluation engine if (onArrayLength) { - if (!(codeAssist instanceof ITypeRoot)) { + if (!(codeAssist instanceof ITypeRoot typeRoot)) { return null; } - ITypeRoot typeRoot = (ITypeRoot) codeAssist; ASTNode node = findNodeAtRegion(typeRoot, hoverRegion); if (node == null) { return null; @@ -416,8 +407,7 @@ public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) { && "".equals(frame.getMethodName())) { //$NON-NLS-1$ return findLocalVariable(frame, var.getElementName()); } - if (parent instanceof IMethod) { - IMethod method = (IMethod) parent; + if (parent instanceof IMethod method) { boolean equal = false; if (method.isBinary()) { // compare resolved signatures diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugOptionsManager.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugOptionsManager.java index 82441ed462..2fc2154c1a 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugOptionsManager.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugOptionsManager.java @@ -266,9 +266,8 @@ protected void initializeProblemHandling() { */ protected void notifyTargets(IBreakpoint breakpoint, int kind) { IDebugTarget[] targets = DebugPlugin.getDefault().getLaunchManager().getDebugTargets(); - for (int i = 0; i < targets.length; i++) { - if (targets[i] instanceof IJavaDebugTarget) { - IJavaDebugTarget target = (IJavaDebugTarget)targets[i]; + for (IDebugTarget target2 : targets) { + if (target2 instanceof IJavaDebugTarget target) { notifyTarget(target, breakpoint, kind); } } @@ -298,9 +297,8 @@ protected void notifyTargetOfFilters(IJavaDebugTarget target) { */ protected void notifyTargetsOfFilters() { IDebugTarget[] targets = DebugPlugin.getDefault().getLaunchManager().getDebugTargets(); - for (int i = 0; i < targets.length; i++) { - if (targets[i] instanceof IJavaDebugTarget) { - IJavaDebugTarget target = (IJavaDebugTarget)targets[i]; + for (IDebugTarget target2 : targets) { + if (target2 instanceof IJavaDebugTarget target) { notifyTargetOfFilters(target); } } @@ -521,13 +519,10 @@ protected void updateActiveFilters() { */ @Override public void handleDebugEvents(DebugEvent[] events) { - for (int i = 0; i < events.length; i++) { - DebugEvent event = events[i]; + for (DebugEvent event : events) { if (event.getKind() == DebugEvent.CREATE) { Object source = event.getSource(); - if (source instanceof IJavaDebugTarget) { - IJavaDebugTarget javaTarget = (IJavaDebugTarget)source; - + if (source instanceof IJavaDebugTarget javaTarget) { // compilation breakpoints if (isSuspendOnCompilationErrors()) { notifyTarget(javaTarget, getSuspendOnCompilationErrorBreakpoint(), ADDED); @@ -640,7 +635,7 @@ private AskRecurrenceDialog(Shell parentShell) { MessageDialog.QUESTION, 0, // DebugUIMessages.JavaDebugOptionsManager_skip_buttonLabel, // DebugUIMessages.JavaDebugOptionsManager_suspend_buttonLabel); - parentShell.getDisplay().syncExec(() -> open()); + parentShell.getDisplay().syncExec(this::open); } @Override @@ -724,8 +719,7 @@ public IMarker getProblem(IJavaStackFrame frame) { IResource resource = (IResource) sourceElement; IMarker[] markers = resource.findMarkers("org.eclipse.jdt.core.problem", true, IResource.DEPTH_INFINITE); //$NON-NLS-1$ int line = frame.getLineNumber(); - for (int i = 0; i < markers.length; i++) { - IMarker marker = markers[i]; + for (IMarker marker : markers) { if (marker.getAttribute(IMarker.LINE_NUMBER, -1) == line && marker.getAttribute(IMarker.SEVERITY, -1) == IMarker.SEVERITY_ERROR) { return marker; } @@ -744,8 +738,7 @@ public IMarker getProblem(IJavaStackFrame frame) { public void breakpointHasRuntimeException(final IJavaLineBreakpoint breakpoint, final DebugException exception) { IStatus status; Throwable wrappedException= exception.getStatus().getException(); - if (wrappedException instanceof InvocationException) { - InvocationException ie= (InvocationException) wrappedException; + if (wrappedException instanceof InvocationException ie) { ObjectReference ref= ie.exception(); status= new Status(IStatus.ERROR,JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, ref.referenceType().name(), null); } else { @@ -761,8 +754,8 @@ public void breakpointHasRuntimeException(final IJavaLineBreakpoint breakpoint, public void breakpointHasCompilationErrors(final IJavaLineBreakpoint breakpoint, final Message[] errors) { StringBuilder message= new StringBuilder(); Message error; - for (int i=0, numErrors= errors.length; i < numErrors; i++) { - error= errors[i]; + for (Message error2 : errors) { + error= error2; message.append(error.getMessage()); message.append("\n "); //$NON-NLS-1$ } @@ -776,20 +769,17 @@ private void openConditionErrorDialog(final IJavaLineBreakpoint breakpoint, fina return; } final String message= NLS.bind(errorMessage, new String[] {fLabelProvider.getText(breakpoint)}); - display.asyncExec(new Runnable() { - @Override - public void run() { - if (display.isDisposed()) { - return; - } - Shell shell= JDIDebugUIPlugin.getActiveWorkbenchShell(); - ConditionalBreakpointErrorDialog dialog= new ConditionalBreakpointErrorDialog(shell, message, status); - int result = dialog.open(); - if (result == Window.OK) { - JavaBreakpointPropertiesAction action= new JavaBreakpointPropertiesAction(); - action.selectionChanged(null, new StructuredSelection(breakpoint)); - action.run(null); - } + display.asyncExec(() -> { + if (display.isDisposed()) { + return; + } + Shell shell= JDIDebugUIPlugin.getActiveWorkbenchShell(); + ConditionalBreakpointErrorDialog dialog= new ConditionalBreakpointErrorDialog(shell, message, status); + int result = dialog.open(); + if (result == Window.OK) { + JavaBreakpointPropertiesAction action= new JavaBreakpointPropertiesAction(); + action.selectionChanged(null, new StructuredSelection(breakpoint)); + action.run(null); } }); } @@ -848,8 +838,7 @@ public void launchRemoved(ILaunch launch) { public void breakpointsAdded(final IBreakpoint[] breakpoints) { // if a breakpoint is added, but already has a message, do not update it List update = new ArrayList<>(); - for (int i = 0; i < breakpoints.length; i++) { - IBreakpoint breakpoint = breakpoints[i]; + for (IBreakpoint breakpoint : breakpoints) { try { if (breakpoint instanceof IJavaBreakpoint && breakpoint.getMarker().getAttribute(IMarker.MESSAGE) == null) { update.add(breakpoint); @@ -869,25 +858,21 @@ public void breakpointsAdded(final IBreakpoint[] breakpoints) { * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsAdded(org.eclipse.debug.core.model.IBreakpoint[]) */ private void updateBreakpointMessages(final IBreakpoint[] breakpoints) { - IWorkspaceRunnable runnable = new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - for (int i = 0; i < breakpoints.length; i++) { - IBreakpoint breakpoint = breakpoints[i]; - if (breakpoint instanceof IJavaBreakpoint) { - String info = fLabelProvider.getText(breakpoint); - String type = DebugUIMessages.JavaDebugOptionsManager_Breakpoint___1; - if (breakpoint instanceof IJavaMethodBreakpoint || breakpoint instanceof IJavaMethodEntryBreakpoint) { - type = DebugUIMessages.JavaDebugOptionsManager_Method_breakpoint___2; - } else if (breakpoint instanceof IJavaWatchpoint) { - type = DebugUIMessages.JavaDebugOptionsManager_Watchpoint___3; - } else if (breakpoint instanceof IJavaLineBreakpoint) { - type = DebugUIMessages.JavaDebugOptionsManager_Line_breakpoint___4; - } - IMarker marker = breakpoint.getMarker(); - if (marker.exists()) { - marker.setAttribute(IMarker.MESSAGE, type + info); - } + IWorkspaceRunnable runnable = monitor -> { + for (IBreakpoint breakpoint : breakpoints) { + if (breakpoint instanceof IJavaBreakpoint) { + String info = fLabelProvider.getText(breakpoint); + String type = DebugUIMessages.JavaDebugOptionsManager_Breakpoint___1; + if (breakpoint instanceof IJavaMethodBreakpoint || breakpoint instanceof IJavaMethodEntryBreakpoint) { + type = DebugUIMessages.JavaDebugOptionsManager_Method_breakpoint___2; + } else if (breakpoint instanceof IJavaWatchpoint) { + type = DebugUIMessages.JavaDebugOptionsManager_Watchpoint___3; + } else if (breakpoint instanceof IJavaLineBreakpoint) { + type = DebugUIMessages.JavaDebugOptionsManager_Line_breakpoint___4; + } + IMarker marker = breakpoint.getMarker(); + if (marker.exists()) { + marker.setAttribute(IMarker.MESSAGE, type + info); } } } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugPreferencePage.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugPreferencePage.java index f3871f589a..c1cc50aa8f 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugPreferencePage.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugPreferencePage.java @@ -138,10 +138,7 @@ protected Control createContents(Composite parent) { SWTFactory.createLabel(group, DebugUIMessages.JavaDebugPreferencePage_SuspendOnRecurrencePolicy, 1); fSuspendOnRecurringExceptionBreakpoints = new Combo(group, SWT.BORDER | SWT.READ_ONLY); - fSuspendOnRecurringExceptionBreakpoints.setItems(new String[] { - DebugUIMessages.JavaDebugPreferencePage_SuspendOnRecurrencePolicy_Unconfigured, - DebugUIMessages.JavaDebugPreferencePage_SuspendOnRecurrencePolicy_Always, - DebugUIMessages.JavaDebugPreferencePage_SuspendOnRecurrencePolicy_OnlyOnce }); + fSuspendOnRecurringExceptionBreakpoints.setItems(DebugUIMessages.JavaDebugPreferencePage_SuspendOnRecurrencePolicy_Unconfigured, DebugUIMessages.JavaDebugPreferencePage_SuspendOnRecurrencePolicy_Always, DebugUIMessages.JavaDebugPreferencePage_SuspendOnRecurrencePolicy_OnlyOnce); fSuspendOnRecurringExceptionBreakpoints.setFont(group.getFont()); fSuspendOnCompilationErrors = SWTFactory.createCheckButton(group, DebugUIMessages.JavaDebugPreferencePage_Suspend_execution_on_co_mpilation_errors_1, null, false, 2); @@ -150,12 +147,12 @@ protected Control createContents(Composite parent) { SWTFactory.createLabel(group, DebugUIMessages.JavaDebugPreferencePage_21, 1); fSuspendVMorThread = new Combo(group, SWT.BORDER|SWT.READ_ONLY); - fSuspendVMorThread.setItems(new String[]{DebugUIMessages.JavaDebugPreferencePage_22, DebugUIMessages.JavaDebugPreferencePage_23}); + fSuspendVMorThread.setItems(DebugUIMessages.JavaDebugPreferencePage_22, DebugUIMessages.JavaDebugPreferencePage_23); fSuspendVMorThread.setFont(group.getFont()); SWTFactory.createLabel(group, DebugUIMessages.JavaDebugPreferencePage_24, 1); fWatchpoint = new Combo(group, SWT.BORDER | SWT.READ_ONLY); - fWatchpoint.setItems(new String[] {DebugUIMessages.JavaDebugPreferencePage_25, DebugUIMessages.JavaDebugPreferencePage_26, DebugUIMessages.JavaDebugPreferencePage_27}); + fWatchpoint.setItems(DebugUIMessages.JavaDebugPreferencePage_25, DebugUIMessages.JavaDebugPreferencePage_26, DebugUIMessages.JavaDebugPreferencePage_27); fWatchpoint.setFont(group.getFont()); group = SWTFactory.createGroup(composite, DebugUIMessages.JavaDebugPreferencePage_Hot_Code_Replace_2, 1, 1, GridData.FILL_HORIZONTAL); diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDetailFormattersManager.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDetailFormattersManager.java index 41d1001a03..1f6b29f6f2 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDetailFormattersManager.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDetailFormattersManager.java @@ -19,7 +19,6 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; @@ -133,18 +132,12 @@ private void populateDetailFormattersMap() { * @param listener the listener */ public void computeValueDetail(final IJavaValue objectValue, final IJavaThread thread, final IValueDetailListener listener) { - thread.queueRunnable(new Runnable() { - @Override - public void run() { - resolveFormatter(objectValue, thread, listener); - } - }); + thread.queueRunnable(() -> resolveFormatter(objectValue, thread, listener)); } private void resolveFormatter(final IJavaValue value, final IJavaThread thread, final IValueDetailListener listener) { EvaluationListener evaluationListener= new EvaluationListener(value, thread, listener); - if (value instanceof IJavaObject) { - IJavaObject objectValue= (IJavaObject) value; + if (value instanceof IJavaObject objectValue) { try { if(value instanceof JDIAllInstancesValue) { listener.detailComputed(value, ((JDIAllInstancesValue)value).getDetailString()); @@ -220,8 +213,8 @@ public DetailFormatter getDetailFormatterFromInterface(IJavaClassType type) { try { IJavaInterfaceType[] inter = type.getAllInterfaces(); Object formatter = null; - for (int i = 0; i < inter.length; i++) { - formatter = fDetailFormattersMap.get(inter[i].getName()); + for (IJavaInterfaceType element : inter) { + formatter = fDetailFormattersMap.get(element.getName()); if(formatter != null) { return (DetailFormatter) formatter; } @@ -308,8 +301,7 @@ private void savePreference() { Collection valuesList= fDetailFormattersMap.values(); String[] values= new String[valuesList.size() * 3]; int i= 0; - for (Iterator iter= valuesList.iterator(); iter.hasNext();) { - DetailFormatter detailFormatter= iter.next(); + for (DetailFormatter detailFormatter : valuesList) { values[i++]= detailFormatter.getTypeName(); values[i++]= detailFormatter.getSnippet().replace(',','\u0000'); values[i++]= detailFormatter.isEnabled() ? JavaDetailFormattersPreferencePage.DETAIL_FORMATTER_IS_ENABLED : JavaDetailFormattersPreferencePage.DETAIL_FORMATTER_IS_DISABLED; @@ -331,8 +323,8 @@ private String getDetailFormatter(IJavaClassType type) throws DebugException { return snippet; } IJavaInterfaceType[] allInterfaces= type.getAllInterfaces(); - for (int i= 0; i < allInterfaces.length; i++) { - DetailFormatter detailFormatter= fDetailFormattersMap.get(allInterfaces[i].getName()); + for (IJavaInterfaceType element : allInterfaces) { + DetailFormatter detailFormatter= fDetailFormattersMap.get(element.getName()); if (detailFormatter != null && detailFormatter.isEnabled()) { return detailFormatter.getSnippet(); } @@ -469,8 +461,7 @@ public void propertyChange(PropertyChangeEvent event) { */ @Override public void handleDebugEvents(DebugEvent[] events) { - for (int i = 0; i < events.length; i++) { - DebugEvent event = events[i]; + for (DebugEvent event : events) { if (event.getSource() instanceof IJavaDebugTarget && event.getKind() == DebugEvent.TERMINATE) { deleteCacheForTarget((IJavaDebugTarget) event.getSource()); } @@ -496,12 +487,11 @@ public void launchesChanged(ILaunch[] launches) { */ @Override public void launchesRemoved(ILaunch[] launches) { - for (int i = 0; i < launches.length; i++) { - ILaunch launch = launches[i]; + for (ILaunch launch : launches) { IDebugTarget[] debugTargets= launch.getDebugTargets(); - for (int j = 0; j < debugTargets.length; j++) { - if (debugTargets[j] instanceof IJavaDebugTarget) { - deleteCacheForTarget((IJavaDebugTarget)debugTargets[j]); + for (IDebugTarget debugTarget : debugTargets) { + if (debugTarget instanceof IJavaDebugTarget) { + deleteCacheForTarget((IJavaDebugTarget)debugTarget); } } } @@ -537,8 +527,7 @@ static private class Key { @Override public boolean equals(Object obj) { - if (obj instanceof Key) { - Key key= (Key) obj; + if (obj instanceof Key key) { return fTypeName != null && fDebugTarget != null && fTypeName.equals(key.fTypeName) && fDebugTarget.equals(key.fDebugTarget); } return false; @@ -623,8 +612,8 @@ public void evaluationComplete(IEvaluationResult result) { } } else { String[] errors= result.getErrorMessages(); - for (int i= 0, length= errors.length; i < length; i++) { - error.append("\n\t\t").append(errors[i]); //$NON-NLS-1$ + for (String error2 : errors) { + error.append("\n\t\t").append(error2); //$NON-NLS-1$ } } fListener.detailComputed(fValue, error.toString()); @@ -665,19 +654,16 @@ public void valueToString(final IJavaValue objectValue) throws DebugException { return; } - IEvaluationRunnable eval = new IEvaluationRunnable() { - @Override - public void run(IJavaThread thread, IProgressMonitor monitor) throws DebugException { - StringBuilder buf= new StringBuilder(); - if (objectValue instanceof IJavaArray) { - appendArrayDetail(buf, (IJavaArray) objectValue); - } else if (objectValue instanceof IJavaObject) { - appendObjectDetail(buf, (IJavaObject) objectValue); - } else { - appendJDIValueString(buf, objectValue); - } - fListener.detailComputed(fValue, buf.toString()); + IEvaluationRunnable eval = (thread, monitor) -> { + StringBuilder buf= new StringBuilder(); + if (objectValue instanceof IJavaArray) { + appendArrayDetail(buf, (IJavaArray) objectValue); + } else if (objectValue instanceof IJavaObject) { + appendObjectDetail(buf, (IJavaObject) objectValue); + } else { + appendJDIValueString(buf, objectValue); } + fListener.detailComputed(fValue, buf.toString()); }; fThread.runEvaluation(eval, null, DebugEvent.EVALUATION_IMPLICIT, false); } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDetailFormattersPreferencePage.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDetailFormattersPreferencePage.java index 820563a0eb..7cf7c8dd59 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDetailFormattersPreferencePage.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDetailFormattersPreferencePage.java @@ -14,7 +14,6 @@ package org.eclipse.jdt.internal.debug.ui; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.TreeSet; @@ -26,16 +25,10 @@ import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.window.Window; @@ -48,10 +41,8 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Table; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; @@ -171,24 +162,11 @@ public String getText(Object element) { return null; } }); - fFormatterListViewer.addCheckStateListener(new ICheckStateListener() { - @Override - public void checkStateChanged(CheckStateChangedEvent event) { - ((DetailFormatter)event.getElement()).setEnabled(event.getChecked()); - } - }); - fFormatterListViewer.addSelectionChangedListener(new ISelectionChangedListener() { - @Override - public void selectionChanged(SelectionChangedEvent event) { - updatePage((IStructuredSelection)event.getSelection()); - } - }); - fFormatterListViewer.addDoubleClickListener(new IDoubleClickListener() { - @Override - public void doubleClick(DoubleClickEvent event) { - if (!event.getSelection().isEmpty()) { - editType(); - } + fFormatterListViewer.addCheckStateListener(event -> ((DetailFormatter)event.getElement()).setEnabled(event.getChecked())); + fFormatterListViewer.addSelectionChangedListener(event -> updatePage((IStructuredSelection)event.getSelection())); + fFormatterListViewer.addDoubleClickListener(event -> { + if (!event.getSelection().isEmpty()) { + editType(); } }); table.addKeyListener(new KeyAdapter() { @@ -236,12 +214,7 @@ private void createDetailFormatsButtons(Composite container) { fAddFormatterButton.setLayoutData(gd); fAddFormatterButton.setFont(font); setButtonLayoutData(fAddFormatterButton); - fAddFormatterButton.addListener(SWT.Selection, new Listener() { - @Override - public void handleEvent(Event e) { - addType(); - } - }); + fAddFormatterButton.addListener(SWT.Selection, e -> addType()); // Edit button fEditFormatterButton = new Button(buttonContainer, SWT.PUSH); @@ -249,12 +222,7 @@ public void handleEvent(Event e) { fEditFormatterButton.setToolTipText(DebugUIMessages.JavaDetailFormattersPreferencePage_Edit_the_selected_detail_formatter_10); fEditFormatterButton.setFont(font); setButtonLayoutData(fEditFormatterButton); - fEditFormatterButton.addListener(SWT.Selection, new Listener() { - @Override - public void handleEvent(Event e) { - editType(); - } - }); + fEditFormatterButton.addListener(SWT.Selection, e -> editType()); fEditFormatterButton.setEnabled(false); // Remove button @@ -263,12 +231,7 @@ public void handleEvent(Event e) { fRemoveFormatterButton.setToolTipText(DebugUIMessages.JavaDetailFormattersPreferencePage_Remove_all_selected_detail_formatters_8); fRemoveFormatterButton.setFont(font); setButtonLayoutData(fRemoveFormatterButton); - fRemoveFormatterButton.addListener(SWT.Selection, new Listener() { - @Override - public void handleEvent(Event e) { - removeTypes(); - } - }); + fRemoveFormatterButton.addListener(SWT.Selection, e -> removeTypes()); fRemoveFormatterButton.setEnabled(false); } @@ -391,8 +354,7 @@ public FormatterListViewerContentProvider(CheckboxTableViewer viewer) { public void saveDetailFormatters() { String[] values= new String[fDetailFormattersSet.size() * 3]; int i= 0; - for (Iterator iter= fDetailFormattersSet.iterator(); iter.hasNext();) { - DetailFormatter detailFormatter= iter.next(); + for (DetailFormatter detailFormatter : fDetailFormattersSet) { values[i++]= detailFormatter.getTypeName(); values[i++]= detailFormatter.getSnippet().replace(',','\u0000'); values[i++]= detailFormatter.isEnabled() ? DETAIL_FORMATTER_IS_ENABLED : DETAIL_FORMATTER_IS_DISABLED; @@ -431,9 +393,9 @@ public void removeDetailFormatter(DetailFormatter detailFormatter) { * Remove detailFormatters */ public void removeDetailFormatters(Object[] detailFormatters) { - for (int i= 0, length= detailFormatters.length; i < length; i++) { - fDetailFormattersSet.remove(detailFormatters[i]); - fDefinedTypes.remove(((DetailFormatter)detailFormatters[i]).getTypeName()); + for (Object detailFormatter : detailFormatters) { + fDetailFormattersSet.remove(detailFormatter); + fDefinedTypes.remove(((DetailFormatter)detailFormatter).getTypeName()); } fViewer.refresh(); IStructuredSelection selection= new StructuredSelection(); @@ -447,8 +409,7 @@ public void removeDetailFormatters(Object[] detailFormatters) { private void refreshViewer() { DetailFormatter[] checkedElementsTmp= new DetailFormatter[fDetailFormattersSet.size()]; int i= 0; - for (Iterator iter= fDetailFormattersSet.iterator(); iter.hasNext();) { - DetailFormatter detailFormatter= iter.next(); + for (DetailFormatter detailFormatter : fDetailFormattersSet) { if (detailFormatter.isEnabled()) { checkedElementsTmp[i++]= detailFormatter; } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaHotCodeReplaceListener.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaHotCodeReplaceListener.java index 8eaca1ca13..3e65fd43ec 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaHotCodeReplaceListener.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaHotCodeReplaceListener.java @@ -88,29 +88,26 @@ public void hotCodeReplaceFailed(final IJavaDebugTarget target, final DebugExcep } final String title = DebugUIMessages.JDIDebugUIPlugin_Hot_code_replace_failed_1; final String message = NLS.bind(DebugUIMessages.JDIDebugUIPlugin__0__was_unable_to_replace_the_running_code_with_the_code_in_the_workspace__2, new Object[] {vmName, launchName}); - display.asyncExec(new Runnable() { - @Override - public void run() { - if (display.isDisposed()) { + display.asyncExec(() -> { + if (display.isDisposed()) { + return; + } + if (fHotCodeReplaceFailedErrorDialog != null) { + Shell shell = fHotCodeReplaceFailedErrorDialog.getShell(); + if (shell != null && !shell.isDisposed()) { return; } - if (fHotCodeReplaceFailedErrorDialog != null) { - Shell shell = fHotCodeReplaceFailedErrorDialog.getShell(); - if (shell != null && !shell.isDisposed()) { - return; - } - } - Shell shell= JDIDebugUIPlugin.getActiveWorkbenchShell(); - fHotCodeReplaceFailedErrorDialog = new HotCodeReplaceErrorDialog(shell, title, message, status, preference, alertMessage, JDIDebugUIPlugin.getDefault().getPreferenceStore(), target) { - @Override - public boolean close() { - fHotCodeReplaceFailedErrorDialog = null; - return super.close(); - } - }; - fHotCodeReplaceFailedErrorDialog.setBlockOnOpen(false); - fHotCodeReplaceFailedErrorDialog.open(); } + Shell shell= JDIDebugUIPlugin.getActiveWorkbenchShell(); + fHotCodeReplaceFailedErrorDialog = new HotCodeReplaceErrorDialog(shell, title, message, status, preference, alertMessage, JDIDebugUIPlugin.getDefault().getPreferenceStore(), target) { + @Override + public boolean close() { + fHotCodeReplaceFailedErrorDialog = null; + return super.close(); + } + }; + fHotCodeReplaceFailedErrorDialog.setBlockOnOpen(false); + fHotCodeReplaceFailedErrorDialog.open(); }); } @@ -131,18 +128,15 @@ public void obsoleteMethods(final IJavaDebugTarget target) { final String message= NLS.bind(DebugUIMessages.JDIDebugUIPlugin__0__contains_obsolete_methods_1, new Object[] {vmName}); final IStatus status= new Status(IStatus.WARNING, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.WARNING, DebugUIMessages.JDIDebugUIPlugin_Stepping_may_be_hazardous_1, null); final String toggleMessage= DebugUIMessages.JDIDebugUIPlugin_2; - display.asyncExec(new Runnable() { - @Override - public void run() { - if (display.isDisposed()) { - return; - } - Shell shell= JDIDebugUIPlugin.getActiveWorkbenchShell(); - HotCodeReplaceErrorDialog dialog= new HotCodeReplaceErrorDialog(shell, dialogTitle, message, status, IJDIPreferencesConstants.PREF_ALERT_OBSOLETE_METHODS, - toggleMessage, JDIDebugUIPlugin.getDefault().getPreferenceStore(), target); - dialog.setBlockOnOpen(false); - dialog.open(); + display.asyncExec(() -> { + if (display.isDisposed()) { + return; } + Shell shell= JDIDebugUIPlugin.getActiveWorkbenchShell(); + HotCodeReplaceErrorDialog dialog= new HotCodeReplaceErrorDialog(shell, dialogTitle, message, status, IJDIPreferencesConstants.PREF_ALERT_OBSOLETE_METHODS, + toggleMessage, JDIDebugUIPlugin.getDefault().getPreferenceStore(), target); + dialog.setBlockOnOpen(false); + dialog.open(); }); } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaLogicalStructuresPreferencePage.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaLogicalStructuresPreferencePage.java index 640ba1012d..7ed767b3fc 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaLogicalStructuresPreferencePage.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaLogicalStructuresPreferencePage.java @@ -28,8 +28,6 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.viewers.ColumnLayoutData; import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredContentProvider; @@ -104,8 +102,8 @@ public class LogicalStructuresListViewerContentProvider implements IStructuredCo LogicalStructuresListViewerContentProvider() { fLogicalStructures = new ArrayList<>(); JavaLogicalStructure[] logicalStructures= JavaLogicalStructures.getJavaLogicalStructures(); - for (int i= 0; i < logicalStructures.length; i++) { - add(logicalStructures[i]); + for (JavaLogicalStructure logicalStructure : logicalStructures) { + add(logicalStructure); } } @@ -174,8 +172,7 @@ public void refresh(JavaLogicalStructure logicalStructure) { public void saveUserDefinedJavaLogicalStructures() { List logicalStructures = new ArrayList<>(); - for (Iterator iter = fLogicalStructures.iterator(); iter.hasNext();) { - JavaLogicalStructure logicalStructure= iter.next(); + for (JavaLogicalStructure logicalStructure : fLogicalStructures) { if (!logicalStructure.isContributed()) { logicalStructures.add(logicalStructure); } @@ -218,11 +215,11 @@ public JavaLogicalStructuresPreferencePage() { public void applyData(Object data) { if (data instanceof String) { Object[] logicalStructures = fLogicalStructuresContentProvider.getElements(null); - for (int i = 0, length = logicalStructures.length; i < length; i++) { - JavaLogicalStructure javaLogicalStructure = ((JavaLogicalStructure) logicalStructures[i]); + for (Object logicalStructure : logicalStructures) { + JavaLogicalStructure javaLogicalStructure = ((JavaLogicalStructure) logicalStructure); if (((String) data).compareToIgnoreCase(javaLogicalStructure.getId() + javaLogicalStructure.getDescription() + javaLogicalStructure.hashCode()) == 0) { - fLogicalStructuresViewer.setSelection(new StructuredSelection(logicalStructures[i])); + fLogicalStructuresViewer.setSelection(new StructuredSelection(logicalStructure)); return; } } @@ -323,15 +320,12 @@ private void createTable(Composite parent) { fLogicalStructuresViewer.setLabelProvider(new LogicalStructuresListViewerLabelProvider()); fLogicalStructuresViewer.addSelectionChangedListener(this); fLogicalStructuresViewer.setInput(this); - fLogicalStructuresViewer.addDoubleClickListener(new IDoubleClickListener() { - @Override - public void doubleClick(DoubleClickEvent event) { - IStructuredSelection selection= ((IStructuredSelection) fLogicalStructuresViewer.getSelection()); - if (selection.size() == 1 && !((JavaLogicalStructure) selection.getFirstElement()).isContributed()) { - editLogicalStructure(); - } - } - }); + fLogicalStructuresViewer.addDoubleClickListener(event -> { + IStructuredSelection selection= ((IStructuredSelection) fLogicalStructuresViewer.getSelection()); + if (selection.size() == 1 && !((JavaLogicalStructure) selection.getFirstElement()).isContributed()) { + editLogicalStructure(); + } + }); table.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent event) { @@ -411,10 +405,10 @@ private void refreshCodeViewer(JavaLogicalStructure structure){ buffer.append(snippet); } else { String[][] variables = structure.getVariables(); - for (int i = 0; i < variables.length; i++) { - buffer.append(variables[i][0]); + for (String[] variable : variables) { + buffer.append(variable[0]); buffer.append(" = "); //$NON-NLS-1$ - buffer.append(variables[i][1]); + buffer.append(variable[1]); if (buffer.charAt(buffer.length() - 1) != '\n') { buffer.append('\n'); } @@ -473,9 +467,9 @@ protected void removeLogicalStrutures() { List selectedElements= selection.toList(); Object[] elements= fLogicalStructuresContentProvider.getElements(null); Object newSelectedElement= null; - for (int i= 0; i < elements.length; i++) { - if (!selectedElements.contains(elements[i])) { - newSelectedElement= elements[i]; + for (Object element : elements) { + if (!selectedElements.contains(element)) { + newSelectedElement= element; } else { break; } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaPrimitivesPreferencePage.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaPrimitivesPreferencePage.java index 9a900b4d5b..4bd6e58676 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaPrimitivesPreferencePage.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaPrimitivesPreferencePage.java @@ -15,7 +15,6 @@ import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.eclipse.jface.preference.BooleanFieldEditor; @@ -109,9 +108,7 @@ public boolean performOk() { */ @Override protected void performDefaults() { - Iterator iterator = fEdtiors.iterator(); - while (iterator.hasNext()) { - BooleanFieldEditor editor = iterator.next(); + for (BooleanFieldEditor editor : fEdtiors) { editor.loadDefault(); } super.performDefaults(); @@ -122,9 +119,7 @@ protected void performDefaults() { * values in the preference store */ private void loadValues() { - Iterator iterator = fEdtiors.iterator(); - while (iterator.hasNext()) { - BooleanFieldEditor editor = iterator.next(); + for (BooleanFieldEditor editor : fEdtiors) { editor.load(); } } @@ -134,9 +129,7 @@ private void loadValues() { * component widgets */ private void storeValues() { - Iterator iterator = fEdtiors.iterator(); - while (iterator.hasNext()) { - BooleanFieldEditor editor = iterator.next(); + for (BooleanFieldEditor editor : fEdtiors) { editor.store(); } } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaThreadActionFilter.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaThreadActionFilter.java index c8e56f4a79..6a9ff3fd3c 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaThreadActionFilter.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaThreadActionFilter.java @@ -37,8 +37,7 @@ public boolean testAttribute(Object target, String name, String value) { && value.equals("suspendedAtException")) { //$NON-NLS-1$ IJavaThread thread = (IJavaThread) target; IBreakpoint[] breakpoints= thread.getBreakpoints(); - for (int i = 0; i < breakpoints.length; i++) { - IBreakpoint breakpoint= breakpoints[i]; + for (IBreakpoint breakpoint : breakpoints) { try { if (breakpoint.isRegistered() && breakpoint instanceof IJavaExceptionBreakpoint) { return true; diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaVarActionFilter.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaVarActionFilter.java index 447fd29a01..7e88eb0c90 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaVarActionFilter.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaVarActionFilter.java @@ -166,8 +166,7 @@ protected String removeArray(String type) { */ @Override public boolean testAttribute(Object target, String name, String value) { - if (target instanceof IJavaVariable) { - IJavaVariable var = (IJavaVariable) target; + if (target instanceof IJavaVariable var) { IValue varValue; try { varValue = var.getValue(); @@ -230,8 +229,7 @@ else if (name.equals("DetailFormatterFilter") && (varValue instanceof IJavaObjec } } catch (DebugException e) {} } - else if (target instanceof JavaInspectExpression) { - JavaInspectExpression exp = (JavaInspectExpression) target; + else if (target instanceof JavaInspectExpression exp) { if (name.equals("PrimitiveVariableActionFilter") && value.equals("isNotPrimitive")) { //$NON-NLS-1$ //$NON-NLS-2$ return !isPrimitiveType(exp); } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaWatchExpressionDelegate.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaWatchExpressionDelegate.java index 816f13b26c..66f2044c04 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaWatchExpressionDelegate.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaWatchExpressionDelegate.java @@ -28,7 +28,6 @@ import org.eclipse.jdt.debug.core.IJavaThread; import org.eclipse.jdt.debug.eval.IAstEvaluationEngine; import org.eclipse.jdt.debug.eval.IEvaluationListener; -import org.eclipse.jdt.debug.eval.IEvaluationResult; import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin; import org.eclipse.jdt.internal.debug.core.JavaDebugUtils; import org.eclipse.jdt.internal.debug.core.model.JDIThread; @@ -88,10 +87,7 @@ protected void doEvaluation(IJavaStackFrame javaStackFrame) { } private boolean preEvaluationCheck(IJavaThread javaThread) { - if (javaThread == null) { - return false; - } - if (javaThread.isSuspended() && ((JDIThread)javaThread).isInvokingMethod()) { + if ((javaThread == null) || (javaThread.isSuspended() && ((JDIThread)javaThread).isInvokingMethod())) { return false; } return true; @@ -117,33 +113,30 @@ public void run() { } IAstEvaluationEngine evaluationEngine= JDIDebugPlugin.getDefault().getEvaluationEngine(project, (IJavaDebugTarget) fStackFrame.getDebugTarget()); // the evaluation listener - IEvaluationListener listener= new IEvaluationListener() { - @Override - public void evaluationComplete(final IEvaluationResult result) { - IWatchExpressionResult watchResult= new IWatchExpressionResult() { - @Override - public IValue getValue() { - return result.getValue(); - } - @Override - public boolean hasErrors() { - return result.hasErrors(); - } - @Override - public String[] getErrorMessages() { - return JavaInspectExpression.getErrorMessages(result); - } - @Override - public String getExpressionText() { - return result.getSnippet(); - } - @Override - public DebugException getException() { - return result.getException(); - } - }; - fListener.watchEvaluationFinished(watchResult); - } + IEvaluationListener listener= result -> { + IWatchExpressionResult watchResult= new IWatchExpressionResult() { + @Override + public IValue getValue() { + return result.getValue(); + } + @Override + public boolean hasErrors() { + return result.hasErrors(); + } + @Override + public String[] getErrorMessages() { + return JavaInspectExpression.getErrorMessages(result); + } + @Override + public String getExpressionText() { + return result.getSnippet(); + } + @Override + public DebugException getException() { + return result.getException(); + } + }; + fListener.watchEvaluationFinished(watchResult); }; try { evaluationEngine.evaluate(fExpressionText, fStackFrame, listener, DebugEvent.EVALUATION_IMPLICIT, false); diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/LambdaUtils.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/LambdaUtils.java index e430c70517..7f67fdace7 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/LambdaUtils.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/LambdaUtils.java @@ -87,21 +87,16 @@ public static IVariable findLocalVariableFromLambdaScope(IJavaStackFrame frame, if (methodName.equals(enclosingMethodName) && typeNames.equals(methodTypeNames)) { var = JavaDebugHover.findLocalVariable(currFrame, local.getElementName()); - if (var != null) { - return var; - } - // we can stop searching now - return null; + return var; } } return null; } private static List getArgumentTypeNames(IJavaElement parent) throws CoreException { - if (!(parent instanceof IMethod)) { + if (!(parent instanceof IMethod method)) { return null; } - IMethod method = (IMethod) parent; IType type = method.getDeclaringType(); if (type == null) { return null; diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/MemberActionFilter.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/MemberActionFilter.java index 7aeb4aa14d..7bfe0ce7fd 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/MemberActionFilter.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/MemberActionFilter.java @@ -39,8 +39,7 @@ public class MemberActionFilter implements IActionFilter { @Override public boolean testAttribute(Object target, String name, String value) { if (name.equals("MemberActionFilter")) { //$NON-NLS-1$ - if (target instanceof IMember) { - IMember member = (IMember) target; + if (target instanceof IMember member) { if (value.equals("isRemote")) { //$NON-NLS-1$ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if(window != null) { @@ -95,8 +94,7 @@ public boolean testAttribute(Object target, String name, String value) { IAdaptable adapt = DebugUITools.getDebugContext(); if(adapt != null) { IDebugTarget adapter = adapt.getAdapter(IDebugTarget.class); - if(adapter instanceof IJavaDebugTarget) { - IJavaDebugTarget dtarget = (IJavaDebugTarget) adapter; + if(adapter instanceof IJavaDebugTarget dtarget) { return dtarget.supportsInstanceRetrieval(); } } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/NoLineNumberAttributesStatusHandler.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/NoLineNumberAttributesStatusHandler.java index 4b1ba63959..626d235884 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/NoLineNumberAttributesStatusHandler.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/NoLineNumberAttributesStatusHandler.java @@ -34,17 +34,14 @@ public Object handleStatus(IStatus status, Object source) { IPreferenceStore preferenceStore= JDIDebugUIPlugin.getDefault().getPreferenceStore(); if (preferenceStore.getBoolean(IJDIPreferencesConstants.PREF_ALERT_UNABLE_TO_INSTALL_BREAKPOINT)) { Display display= JDIDebugUIPlugin.getStandardDisplay(); - display.syncExec(new Runnable() { - @Override - public void run() { - final ErrorDialogWithToggle dialog = new ErrorDialogWithToggle(PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(), - DebugUIMessages.NoLineNumberAttributesStatusHandler_Java_Breakpoint_1, - NLS.bind(DebugUIMessages.NoLineNumberAttributesStatusHandler_2, new String[] {type.name()}), - status, IJDIPreferencesConstants.PREF_ALERT_UNABLE_TO_INSTALL_BREAKPOINT, - DebugUIMessages.NoLineNumberAttributesStatusHandler_3, - preferenceStore); - dialog.open(); - } + display.syncExec(() -> { + final ErrorDialogWithToggle dialog = new ErrorDialogWithToggle(PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(), + DebugUIMessages.NoLineNumberAttributesStatusHandler_Java_Breakpoint_1, + NLS.bind(DebugUIMessages.NoLineNumberAttributesStatusHandler_2, new String[] {type.name()}), + status, IJDIPreferencesConstants.PREF_ALERT_UNABLE_TO_INSTALL_BREAKPOINT, + DebugUIMessages.NoLineNumberAttributesStatusHandler_3, + preferenceStore); + dialog.open(); }); } return null; diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/SuspendTimeoutStatusHandler.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/SuspendTimeoutStatusHandler.java index 58b5d1beb6..1752e4afae 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/SuspendTimeoutStatusHandler.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/SuspendTimeoutStatusHandler.java @@ -33,12 +33,9 @@ public Object handleStatus(IStatus status, Object source) throws CoreException { IJavaThread thread= (IJavaThread) source; String threadName = thread.getName(); Display display= JDIDebugUIPlugin.getStandardDisplay(); - display.syncExec(new Runnable() { - @Override - public void run() { - final ErrorDialog dialog= new ErrorDialog(PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(), DebugUIMessages.SuspendTimeoutHandler_suspend, NLS.bind(DebugUIMessages.SuspendTimeoutHandler_timeout_occurred, new String[] {threadName}), status, IStatus.WARNING | IStatus.ERROR | IStatus.INFO); // - dialog.open(); - } + display.syncExec(() -> { + final ErrorDialog dialog= new ErrorDialog(PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(), DebugUIMessages.SuspendTimeoutHandler_suspend, NLS.bind(DebugUIMessages.SuspendTimeoutHandler_timeout_occurred, new String[] {threadName}), status, IStatus.WARNING | IStatus.ERROR | IStatus.INFO); // + dialog.open(); }); return null; } diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/monitors/JavaThreadContentProvider.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/monitors/JavaThreadContentProvider.java index 69524111c5..77df04c1e4 100644 --- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/monitors/JavaThreadContentProvider.java +++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/monitors/JavaThreadContentProvider.java @@ -73,8 +73,7 @@ protected Object[] getChildren(Object parent, int index, int length, IPresentati protected Object[] getChildren(IJavaThread thread) { try { - if (thread instanceof JDIThread) { - JDIThread jThread = (JDIThread) thread; + if (thread instanceof JDIThread jThread) { if (!jThread.getDebugTarget().isSuspended() ) { if (jThread.isSuspendVoteInProgress()) { return EMPTY; @@ -120,8 +119,7 @@ protected Object[] getChildren(IJavaThread thread) { */ @Override protected boolean hasChildren(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - if (element instanceof JDIThread) { - JDIThread jThread = (JDIThread) element; + if (element instanceof JDIThread jThread) { if (!jThread.getDebugTarget().isSuspended()) { if (jThread.isSuspendVoteInProgress()) { return false;