[cleanup] Combine nested 'if' within 'else' block to 'else if'

Cleanup performed on bundles
- org.eclipse.core.variables
- org.eclipse.ui.console
- org.eclipse.ui.externaltools
- org.eclipse.debug.tests
- org.eclipse.debug.examples.ui

Change-Id: I4751614c0b8598381be75f8a36332614f4d365b8
Signed-off-by: Karsten Thoms <karsten.thoms@karakun.com>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.debug/+/172237
Tested-by: Platform Bot <platform-bot@eclipse.org>
Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringSubstitutionEngine.java b/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringSubstitutionEngine.java
index 55ac7c8..77fb387 100644
--- a/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringSubstitutionEngine.java
+++ b/org.eclipse.core.variables/src/org/eclipse/core/internal/variables/StringSubstitutionEngine.java
@@ -175,37 +175,35 @@
 						VariableReference tos = fStack.peek();
 						tos.append(expression.substring(pos));
 						pos = expression.length();
+					} else if (start >= 0 && start < end) {
+						// start of a nested variable
+						int length = start - pos;
+						if (length > 0) {
+							VariableReference tos = fStack.peek();
+							tos.append(expression.substring(pos, start));
+						}
+						pos = start + 2;
+						fStack.push(new VariableReference());
 					} else {
-						if (start >= 0 && start < end) {
-							// start of a nested variable
-							int length = start - pos;
-							if (length > 0) {
-								VariableReference tos = fStack.peek();
-								tos.append(expression.substring(pos, start));
-							}
-							pos = start + 2;
-							fStack.push(new VariableReference());
-						} else {
-							// end of variable reference
-							VariableReference tos = fStack.pop();
-							String substring = expression.substring(pos, end);
-							tos.append(substring);
-							resolvedVariables.add(substring);
+						// end of variable reference
+						VariableReference tos = fStack.pop();
+						String substring = expression.substring(pos, end);
+						tos.append(substring);
+						resolvedVariables.add(substring);
 
-							pos = end + 1;
-							String value= resolve(tos, reportUndefinedVariables, resolveVariables, manager);
-							if (value == null) {
-								value = ""; //$NON-NLS-1$
-							}
-							if (fStack.isEmpty()) {
-								// append to result
-								fResult.append(value);
-								state = SCAN_FOR_START;
-							} else {
-								// append to previous variable
-								tos = fStack.peek();
-								tos.append(value);
-							}
+						pos = end + 1;
+						String value= resolve(tos, reportUndefinedVariables, resolveVariables, manager);
+						if (value == null) {
+							value = ""; //$NON-NLS-1$
+						}
+						if (fStack.isEmpty()) {
+							// append to result
+							fResult.append(value);
+							state = SCAN_FOR_START;
+						} else {
+							// append to previous variable
+							tos = fStack.peek();
+							tos.append(value);
 						}
 					}
 					break;
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDAToggleWatchpointsTarget.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDAToggleWatchpointsTarget.java
index 0fe58af..489f477 100644
--- a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDAToggleWatchpointsTarget.java
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDAToggleWatchpointsTarget.java
@@ -54,11 +54,9 @@
 	public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) {
 		if (super.canToggleWatchpoints(part, selection)) {
 			return true;
-		} else {
-			if (selection instanceof IStructuredSelection) {
-				IStructuredSelection ss = (IStructuredSelection)selection;
-				return ss.getFirstElement() instanceof PDAVariable;
-			}
+		} else if (selection instanceof IStructuredSelection) {
+			IStructuredSelection ss = (IStructuredSelection)selection;
+			return ss.getFirstElement() instanceof PDAVariable;
 		}
 		return false;
 	}
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/launcher/PDAMainTab.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/launcher/PDAMainTab.java
index 9434e1a..61614a5 100644
--- a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/launcher/PDAMainTab.java
+++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/launcher/PDAMainTab.java
@@ -178,10 +178,8 @@
 			if (member == null) {
 				setErrorMessage("Specified program does not exist"); //$NON-NLS-1$
 				return false;
-			} else {
-				if (member.getType() != IResource.FILE) {
-					setWarningMessage("Specified program is not a file."); //$NON-NLS-1$
-				}
+			} else if (member.getType() != IResource.FILE) {
+				setWarningMessage("Specified program is not a file."); //$NON-NLS-1$
 			}
 		} else {
 			setMessage("Specify a program"); //$NON-NLS-1$
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/DebugFileStore.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/DebugFileStore.java
index 4928cf0..63a630b 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/DebugFileStore.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/DebugFileStore.java
@@ -158,13 +158,11 @@
 			IFileStore parent = getParent();
 			if (parent.fetchInfo().exists()) {
 				DebugFileSystem.getDefault().setContents(toURI(), DebugFileSystem.DIRECTORY_BYTES);
+			} else if ((options & EFS.SHALLOW) > 0) {
+				throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.jdt.debug.tests", //$NON-NLS-1$
+				"mkdir failed - parent does not exist: " + toURI())); //$NON-NLS-1$
 			} else {
-				if ((options & EFS.SHALLOW) > 0) {
-					throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.jdt.debug.tests", //$NON-NLS-1$
-					"mkdir failed - parent does not exist: " + toURI())); //$NON-NLS-1$
-				} else {
-					parent.mkdir(EFS.NONE, null);
-				}
+				parent.mkdir(EFS.NONE, null);
 			}
 		}
 		return this;
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java
index 97dbab6..d6ca49b 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java
@@ -276,12 +276,10 @@
 					for (CompiledPatternMatchListener notifier : fPatterns) {
 						notifier.end = 0;
 					}
-				} else {
-					if (event.fOffset == 0) {
-						//document was trimmed
-						for (CompiledPatternMatchListener notifier : fPatterns) {
-							notifier.end = notifier.end > event.fLength ? notifier.end - event.fLength : 0;
-						}
+				} else if (event.fOffset == 0) {
+					//document was trimmed
+					for (CompiledPatternMatchListener notifier : fPatterns) {
+						notifier.end = notifier.end > event.fLength ? notifier.end - event.fLength : 0;
 					}
 				}
 			}
diff --git a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuildTab.java b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuildTab.java
index a0e96b0..e9dfa46 100644
--- a/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuildTab.java
+++ b/org.eclipse.ui.externaltools/External Tools Base/org/eclipse/ui/externaltools/internal/launchConfigurations/ExternalToolsBuildTab.java
@@ -232,17 +232,15 @@
 			// select the workspace by default
 			fBuildButton.setSelection(true);
 			fWorkspaceButton.setSelection(true);
-		} else {
-			if (scope.equals("${none}")) { //$NON-NLS-1$
-				fBuildButton.setSelection(false);
-			} else if (scope.equals("${project}")) { //$NON-NLS-1$
-				fProjectButton.setSelection(true);
-			} else if (scope.startsWith("${projects:")) { //$NON-NLS-1$
-				fSpecificProjectsButton.setSelection(true);
-				IProject[] projects = getBuildProjects(configuration, IExternalToolConstants.ATTR_BUILD_SCOPE);
-				fProjects = new ArrayList<>(projects.length);
-				Collections.addAll(fProjects, projects);
-			}
+		} else if (scope.equals("${none}")) { //$NON-NLS-1$
+			fBuildButton.setSelection(false);
+		} else if (scope.equals("${project}")) { //$NON-NLS-1$
+			fProjectButton.setSelection(true);
+		} else if (scope.startsWith("${projects:")) { //$NON-NLS-1$
+			fSpecificProjectsButton.setSelection(true);
+			IProject[] projects = getBuildProjects(configuration, IExternalToolConstants.ATTR_BUILD_SCOPE);
+			fProjects = new ArrayList<>(projects.length);
+			Collections.addAll(fProjects, projects);
 		}
 	}
 	@Override