diff options
author | Paul Pazderski | 2019-05-09 19:40:03 +0000 |
---|---|---|
committer | Paul Pazderski | 2019-08-12 14:04:47 +0000 |
commit | fbfee8d1413f408c644681303c5a4e844c700874 (patch) | |
tree | c864066f42ccdd9c41c5096f0a0ac39807201678 /org.eclipse.debug.core | |
parent | 36d4b6c1b9fd73256c3d5c3ee0a900fbc635a0eb (diff) | |
download | eclipse.platform.debug-fbfee8d1413f408c644681303c5a4e844c700874.tar.gz eclipse.platform.debug-fbfee8d1413f408c644681303c5a4e844c700874.tar.xz eclipse.platform.debug-fbfee8d1413f408c644681303c5a4e844c700874.zip |
Bug 549903 - Replace usage of deprecated SubProgressMonitor withI20190813-1800I20190812-1800
SubMonitor
Also replaced the anti-pattern:
if(doMore) {
doSomething(new SubProgressMonitor(monitor));
} else {
monitor.worked();
}
As consequence skipped optional work will not move the progress bar
anymore but leave the space for the remaining tasks.
Change-Id: Id58944194449f58f887e8969d7ba9d7c16939f9c
Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
Diffstat (limited to 'org.eclipse.debug.core')
-rw-r--r-- | org.eclipse.debug.core/core/org/eclipse/debug/core/model/LaunchConfigurationDelegate.java | 22 | ||||
-rw-r--r-- | org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java | 33 |
2 files changed, 18 insertions, 37 deletions
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 c5585dd4d..142c01828 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2018 IBM Corporation and others. + * Copyright (c) 2004, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -35,7 +35,6 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.IBreakpointManager; import org.eclipse.debug.core.ILaunch; @@ -117,21 +116,12 @@ public abstract class LaunchConfigurationDelegate implements ILaunchConfiguratio @Override public boolean buildForLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException { - if (monitor != null) { - monitor.beginTask("", 1); //$NON-NLS-1$ - } - try { - IProject[] projects = getBuildOrder(configuration, mode); - if (projects == null) { - return true; - } - buildProjects(projects, new SubProgressMonitor(monitor, 1)); - return false; - } finally { - if (monitor != null) { - monitor.done(); - } + IProject[] projects = getBuildOrder(configuration, mode); + if (projects == null) { + return true; } + buildProjects(projects, SubMonitor.convert(monitor, 1)); + return false; } /** diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java index 0a10cb9cb..eece9bb85 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -48,7 +48,6 @@ import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; @@ -730,7 +729,7 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig * - Final launch validation (1) * - Initialize source locator (1) * - Launch delegate (10) */ - SubMonitor lmonitor = SubMonitor.convert(monitor, DebugCoreMessages.LaunchConfiguration_9, build ? 23 : 13); + SubMonitor lmonitor = SubMonitor.convert(monitor, DebugCoreMessages.LaunchConfiguration_9, 23); try { // bug 28245 - force the delegate to load in case it is interested in launch notifications Set<String> modes = getModes(); @@ -821,42 +820,34 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig lmonitor.subTask(DebugCoreMessages.LaunchConfiguration_8); if (delegate2 != null) { - if (!(delegate2.preLaunchCheck(this, mode, new SubProgressMonitor(lmonitor, 1)))) { + if (!(delegate2.preLaunchCheck(this, mode, lmonitor.split(1)))) { getLaunchManager().removeLaunch(launch); return launch; } } - else { - lmonitor.worked(1); /* No pre-launch-check */ - } + lmonitor.setWorkRemaining(22); // perform pre-launch build if (build) { - IProgressMonitor buildMonitor = new SubProgressMonitor(lmonitor, 10, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK); - buildMonitor.beginTask(DebugCoreMessages.LaunchConfiguration_7, 10); - buildMonitor.subTask(DebugCoreMessages.LaunchConfiguration_6); + lmonitor.subTask(DebugCoreMessages.LaunchConfiguration_7 + DebugCoreMessages.LaunchConfiguration_6); boolean tempbuild = build; if (delegate2 != null) { - tempbuild = delegate2.buildForLaunch(this, mode, new SubProgressMonitor(buildMonitor, 7)); + tempbuild = delegate2.buildForLaunch(this, mode, lmonitor.split(7)); } if (tempbuild) { - buildMonitor.subTask(DebugCoreMessages.LaunchConfiguration_5); - ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new SubProgressMonitor(buildMonitor, 3)); - } - else { - buildMonitor.worked(3); /* No incremental build required */ + lmonitor.subTask(DebugCoreMessages.LaunchConfiguration_7 + DebugCoreMessages.LaunchConfiguration_5); + ResourcesPlugin.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, lmonitor.split(3)); } } + lmonitor.setWorkRemaining(12); // final validation lmonitor.subTask(DebugCoreMessages.LaunchConfiguration_4); if (delegate2 != null) { - if (!(delegate2.finalLaunchCheck(this, mode, new SubProgressMonitor(lmonitor, 1)))) { + if (!(delegate2.finalLaunchCheck(this, mode, lmonitor.split(1)))) { getLaunchManager().removeLaunch(launch); return launch; } } - else { - lmonitor.worked(1); /* No validation */ - } + lmonitor.setWorkRemaining(11); try { //initialize the source locator @@ -866,7 +857,7 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig /* Launch the delegate */ lmonitor.subTask(DebugCoreMessages.LaunchConfiguration_2); - delegate.launch(this, mode, launch, new SubProgressMonitor(lmonitor, 10)); + delegate.launch(this, mode, launch, lmonitor.split(10)); } catch (CoreException e) { // if there was an exception, and the launch is empty, remove it if (!launch.hasChildren()) { |