diff options
author | Carsten Hammer | 2019-05-29 17:48:33 +0000 |
---|---|---|
committer | Karsten Thoms | 2019-06-13 10:41:20 +0000 |
commit | 99e752f89849a969a3cd0235ea9a766e4a15bc9c (patch) | |
tree | 65f3ba1ce86376c0b5525e88151c2fad8a3dd7aa /org.eclipse.debug.core | |
parent | ff36325e43f71a96a7927f2a5089af77e28f228b (diff) | |
download | eclipse.platform.debug-99e752f89849a969a3cd0235ea9a766e4a15bc9c.tar.gz eclipse.platform.debug-99e752f89849a969a3cd0235ea9a766e4a15bc9c.tar.xz eclipse.platform.debug-99e752f89849a969a3cd0235ea9a766e4a15bc9c.zip |
Replace chain of ifs with switchI20190614-0330I20190613-1800
Sometimes if statements are chained and form a series of == comparisons
against constants. Such situation is more readable if written using
switch statement.
Change-Id: I699710eb77cb7b84e34d32ec1460daab696c8591
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Diffstat (limited to 'org.eclipse.debug.core')
-rw-r--r-- | org.eclipse.debug.core/core/org/eclipse/debug/internal/core/LaunchConfiguration.java | 81 |
1 files changed, 44 insertions, 37 deletions
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 b8a020ea6..f017d5700 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 @@ -734,51 +734,58 @@ public class LaunchConfiguration extends PlatformObject implements ILaunchConfig try { // bug 28245 - force the delegate to load in case it is interested in launch notifications Set<String> modes = getModes(); - modes.add(mode); - ILaunchDelegate[] delegates = getType().getDelegates(modes); - ILaunchConfigurationDelegate delegate = null; - if (delegates.length == 1) { - delegate = delegates[0].getDelegate(); - } else if (delegates.length == 0) { - IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(promptStatus); - if (handler != null) { - handler.handleStatus(delegateNotAvailable, new Object[] {this, mode}); - } - IStatus status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.LaunchConfiguration_11, null); - throw new CoreException(status); - } else { - ILaunchDelegate del = getPreferredDelegate(modes); - if(del == null) { - del = getType().getPreferredDelegate(modes); - } - if(del == null) { - IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(promptStatus); - IStatus status = null; - if (handler != null) { - status = (IStatus) handler.handleStatus(duplicateDelegates, new Object[] {this, mode}); - } - if(status != null && status.isOK()) { - del = getPreferredDelegate(modes); - if(del == null) { - del = getType().getPreferredDelegate(modes); + modes.add(mode); + ILaunchDelegate[] delegates = getType().getDelegates(modes); + ILaunchConfigurationDelegate delegate = null; + switch (delegates.length) { + case 1: + delegate = delegates[0].getDelegate(); + break; + case 0: + { + IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(promptStatus); + if (handler != null) { + handler.handleStatus(delegateNotAvailable, new Object[] {this, mode}); + } + IStatus status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.LaunchConfiguration_11, null); + throw new CoreException(status); + } + default: + { + ILaunchDelegate del = getPreferredDelegate(modes); + if(del == null) { + del = getType().getPreferredDelegate(modes); + } + if(del == null) { + IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(promptStatus); + IStatus status = null; + if (handler != null) { + status = (IStatus) handler.handleStatus(duplicateDelegates, new Object[] {this, mode}); } - if(del != null) { - delegate = del.getDelegate(); + if(status != null && status.isOK()) { + del = getPreferredDelegate(modes); + if(del == null) { + del = getType().getPreferredDelegate(modes); + } + if(del != null) { + delegate = del.getDelegate(); + } + else { + status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.LaunchConfiguration_13, null); + throw new CoreException(status); + } } else { status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.LaunchConfiguration_13, null); - throw new CoreException(status); + throw new CoreException(status); } } else { - status = new Status(IStatus.CANCEL, DebugPlugin.getUniqueIdentifier(), DebugPlugin.ERROR, DebugCoreMessages.LaunchConfiguration_13, null); - throw new CoreException(status); + delegate = del.getDelegate(); } - } - else { - delegate = del.getDelegate(); - } - } + break; + } + } ILaunchConfigurationDelegate2 delegate2 = null; if (delegate instanceof ILaunchConfigurationDelegate2) { |