diff options
author | Lars Vogel | 2020-02-12 14:02:30 +0000 |
---|---|---|
committer | Lars Vogel | 2020-03-19 09:50:03 +0000 |
commit | d8a7a8ee5df706b89765ebe09096b61af89ae620 (patch) | |
tree | 031b6ccc79a46f51aca8e74fe12d600a246947dc | |
parent | 4ded5dee80624ca4c29750bb6ee12a75147068c2 (diff) | |
download | eclipse.platform.debug-d8a7a8ee5df706b89765ebe09096b61af89ae620.tar.gz eclipse.platform.debug-d8a7a8ee5df706b89765ebe09096b61af89ae620.tar.xz eclipse.platform.debug-d8a7a8ee5df706b89765ebe09096b61af89ae620.zip |
Clean-up use method references in debug coreI20200320-1800I20200319-1800I20200319-0550
Using the JDT cleanup action -> Use lambda where possible
Simplify lambda expression and method reference syntax
Change-Id: I93d3cc199321c22e96e514d0f8c601fee0a147d4
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
4 files changed, 57 insertions, 114 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/Breakpoint.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/Breakpoint.java index ef7c44ebf..492323041 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/Breakpoint.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/Breakpoint.java @@ -23,7 +23,6 @@ import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.Status; @@ -209,12 +208,7 @@ public abstract class Breakpoint extends PlatformObject implements IBreakpoint, */ protected void setAttribute(final String attributeName, final boolean value) throws CoreException { IWorkspace workspace= ResourcesPlugin.getWorkspace(); - IWorkspaceRunnable runnable= new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - ensureMarker().setAttribute(attributeName, value); - } - }; + IWorkspaceRunnable runnable= monitor -> ensureMarker().setAttribute(attributeName, value); workspace.run(runnable, getMarkerRule(), IWorkspace.AVOID_UPDATE, null); } @@ -232,12 +226,7 @@ public abstract class Breakpoint extends PlatformObject implements IBreakpoint, */ protected void setAttribute(final String attributeName, final int value) throws CoreException { IWorkspace workspace= ResourcesPlugin.getWorkspace(); - IWorkspaceRunnable runnable= new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - ensureMarker().setAttribute(attributeName, value); - } - }; + IWorkspaceRunnable runnable= monitor -> ensureMarker().setAttribute(attributeName, value); workspace.run(runnable, getMarkerRule(), IWorkspace.AVOID_UPDATE, null); } @@ -255,12 +244,7 @@ public abstract class Breakpoint extends PlatformObject implements IBreakpoint, */ protected void setAttribute(final String attributeName, final Object value) throws CoreException { IWorkspace workspace= ResourcesPlugin.getWorkspace(); - IWorkspaceRunnable runnable= new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - ensureMarker().setAttribute(attributeName, value); - } - }; + IWorkspaceRunnable runnable= monitor -> ensureMarker().setAttribute(attributeName, value); workspace.run(runnable, getMarkerRule(), IWorkspace.AVOID_UPDATE, null); } @@ -278,12 +262,7 @@ public abstract class Breakpoint extends PlatformObject implements IBreakpoint, */ protected void setAttributes(final String[] attributeNames, final Object[] values) throws CoreException { IWorkspace workspace= ResourcesPlugin.getWorkspace(); - IWorkspaceRunnable runnable= new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - ensureMarker().setAttributes(attributeNames, values); - } - }; + IWorkspaceRunnable runnable= monitor -> ensureMarker().setAttributes(attributeNames, values); workspace.run(runnable, getMarkerRule(), IWorkspace.AVOID_UPDATE, null); } @@ -300,12 +279,7 @@ public abstract class Breakpoint extends PlatformObject implements IBreakpoint, */ protected void setAttributes(final Map<String, ? extends Object> attributes) throws CoreException { IWorkspace workspace= ResourcesPlugin.getWorkspace(); - IWorkspaceRunnable runnable= new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - ensureMarker().setAttributes(attributes); - } - }; + IWorkspaceRunnable runnable= monitor -> ensureMarker().setAttributes(attributes); workspace.run(runnable, getMarkerRule(), IWorkspace.AVOID_UPDATE, null); } diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/LaunchConfigurationDelegate.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/LaunchConfigurationDelegate.java index fbb9f8135..1fc955867 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/model/LaunchConfigurationDelegate.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/model/LaunchConfigurationDelegate.java @@ -397,20 +397,17 @@ public abstract class LaunchConfigurationDelegate implements ILaunchConfiguratio * @throws CoreException if an exception occurs while building */ protected void buildProjects(final IProject[] projects, IProgressMonitor monitor) throws CoreException { - IWorkspaceRunnable build = new IWorkspaceRunnable(){ - @Override - public void run(IProgressMonitor pm) throws CoreException { - SubMonitor localmonitor = SubMonitor.convert(pm, DebugCoreMessages.LaunchConfigurationDelegate_scoped_incremental_build, projects.length); - try { - for (IProject project : projects) { - if (localmonitor.isCanceled()) { - throw new OperationCanceledException(); - } - project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, localmonitor.newChild(1)); + IWorkspaceRunnable build = pm -> { + SubMonitor localmonitor = SubMonitor.convert(pm, DebugCoreMessages.LaunchConfigurationDelegate_scoped_incremental_build, projects.length); + try { + for (IProject project : projects) { + if (localmonitor.isCanceled()) { + throw new OperationCanceledException(); } - } finally { - localmonitor.done(); + project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, localmonitor.newChild(1)); } + } finally { + localmonitor.done(); } }; ResourcesPlugin.getWorkspace().run(build, monitor); diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java index 65ac016cd..3afd49a2a 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java @@ -331,12 +331,9 @@ public class BreakpointManager implements IBreakpointManager, IResourceChangeLis // delete any markers that are not to be restored if (!delete.isEmpty()) { final IMarker[] delMarkers = delete.toArray(new IMarker[delete.size()]); - IWorkspaceRunnable wr = new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor pm) throws CoreException { - for (IMarker marker : delMarkers) { - marker.delete(); - } + IWorkspaceRunnable wr = pm -> { + for (IMarker marker : delMarkers) { + marker.delete(); } }; new BreakpointManagerJob(wr).schedule(); @@ -510,23 +507,20 @@ public class BreakpointManager implements IBreakpointManager, IResourceChangeLis } fireUpdate(remove, null, REMOVED); refreshTriggerpointDisplay(); - IWorkspaceRunnable r = new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor montitor) throws CoreException { - for (IBreakpoint breakpoint : remove) { - if (delete) { - breakpoint.delete(); - } else { - // if the breakpoint is being removed from the manager - // because the project is closing, the breakpoint should - // remain as registered, otherwise, the breakpoint should - // be marked as unregistered - IMarker marker = breakpoint.getMarker(); - if (marker.exists()) { - IProject project = breakpoint.getMarker().getResource().getProject(); - if (project == null || project.isOpen()) { - breakpoint.setRegistered(false); - } + IWorkspaceRunnable r = monitor -> { + for (IBreakpoint breakpoint : remove) { + if (delete) { + breakpoint.delete(); + } else { + // if the breakpoint is being removed from the manager + // because the project is closing, the breakpoint should + // remain as registered, otherwise, the breakpoint should + // be marked as unregistered + IMarker marker = breakpoint.getMarker(); + if (marker.exists()) { + IProject project = breakpoint.getMarker().getResource().getProject(); + if (project == null || project.isOpen()) { + breakpoint.setRegistered(false); } } } @@ -619,15 +613,12 @@ public class BreakpointManager implements IBreakpointManager, IResourceChangeLis fireUpdate(added, null, ADDED); } if (!update.isEmpty()) { - IWorkspaceRunnable r = new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - List<IBreakpoint> bps = getBreakpoints0(); - for (IBreakpoint breakpoint : update) { - bps.add(breakpoint); - breakpoint.setRegistered(true); - fMarkersToBreakpoints.put(breakpoint.getMarker(), breakpoint); - } + IWorkspaceRunnable r = monitor -> { + List<IBreakpoint> bps = getBreakpoints0(); + for (IBreakpoint breakpoint : update) { + bps.add(breakpoint); + breakpoint.setRegistered(true); + fMarkersToBreakpoints.put(breakpoint.getMarker(), breakpoint); } }; // Need to suppress change notification, since this is really @@ -747,12 +738,9 @@ public class BreakpointManager implements IBreakpointManager, IResourceChangeLis public void update() { if (!fMoved.isEmpty()) { // delete moved markers - IWorkspaceRunnable wRunnable= new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - for (IMarker marker : fMoved) { - marker.delete(); - } + IWorkspaceRunnable wRunnable= monitor -> { + for (IMarker marker : fMoved) { + marker.delete(); } }; try { @@ -769,13 +757,10 @@ public class BreakpointManager implements IBreakpointManager, IResourceChangeLis } if (!fAdded.isEmpty()) { try { - IWorkspaceRunnable runnable= new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - for (IBreakpoint breakpoint : fAdded) { - breakpoint.getMarker().setAttribute(DebugPlugin.ATTR_BREAKPOINT_IS_DELETED, false); - breakpoint.setRegistered(true); - } + IWorkspaceRunnable runnable= monitor -> { + for (IBreakpoint breakpoint : fAdded) { + breakpoint.getMarker().setAttribute(DebugPlugin.ATTR_BREAKPOINT_IS_DELETED, false); + breakpoint.setRegistered(true); } }; getWorkspace().run(runnable, null, 0, null); @@ -1396,19 +1381,16 @@ public class BreakpointManager implements IBreakpointManager, IResourceChangeLis * Touch and refresh display of all breakpoints */ private void touchAllBreakpoints() { - IWorkspaceRunnable runnable = new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - for (IBreakpoint breakpoint : getBreakpoints()) { - // Touch the marker (but don't actually change anything) so - // that the icon in - // the editor ruler will be updated (editors listen to - // marker changes). - try { - breakpoint.getMarker().setAttribute(IBreakpoint.ENABLED, breakpoint.isEnabled()); - } catch (CoreException e) { - // don't care if marker was already deleted - } + IWorkspaceRunnable runnable = monitor -> { + for (IBreakpoint breakpoint : getBreakpoints()) { + // Touch the marker (but don't actually change anything) so + // that the icon in + // the editor ruler will be updated (editors listen to + // marker changes). + try { + breakpoint.getMarker().setAttribute(IBreakpoint.ENABLED, breakpoint.isEnabled()); + } catch (CoreException e) { + // don't care if marker was already deleted } } }; diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java index 295145c1b..bbf103ab4 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchManager.java @@ -993,13 +993,8 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe final File directory = containerPath.toFile(); if (directory.isDirectory()) { List<ILaunchConfiguration> configs = new ArrayList<>(); - FilenameFilter configFilter = new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return dir.equals(directory) && - name.endsWith(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION); - } - }; + FilenameFilter configFilter = (dir, name) -> dir.equals(directory) && + name.endsWith(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION); File[] configFiles = directory.listFiles(configFilter); if (configFiles != null && configFiles.length > 0) { LaunchConfiguration config = null; @@ -1008,12 +1003,7 @@ public class LaunchManager extends PlatformObject implements ILaunchManager, IRe configs.add(config); } } - FilenameFilter prototypeFilter = new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return dir.equals(directory) && name.endsWith(ILaunchConfiguration.LAUNCH_CONFIGURATION_PROTOTYPE_FILE_EXTENSION); - } - }; + FilenameFilter prototypeFilter = (dir, name) -> dir.equals(directory) && name.endsWith(ILaunchConfiguration.LAUNCH_CONFIGURATION_PROTOTYPE_FILE_EXTENSION); File[] prototypeFiles = directory.listFiles(prototypeFilter); if (prototypeFiles != null && prototypeFiles.length > 0) { LaunchConfiguration config = null; |