diff options
author | Karsten Thoms | 2020-11-13 20:06:02 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2021-07-21 08:46:45 +0000 |
commit | 272af288984fc6d20cd032d2ee175eecc2d9e16f (patch) | |
tree | 3dfc125a0d1b070088b8d41d8aa146cc211dead8 | |
parent | 03decc31fefef7c2da0c5ec2403c0bfbd5665a18 (diff) | |
download | eclipse.platform.debug-272af288984fc6d20cd032d2ee175eecc2d9e16f.tar.gz eclipse.platform.debug-272af288984fc6d20cd032d2ee175eecc2d9e16f.tar.xz eclipse.platform.debug-272af288984fc6d20cd032d2ee175eecc2d9e16f.zip |
[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>
6 files changed, 49 insertions, 61 deletions
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 55ac7c851..77fb387d8 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 @@ public class StringSubstitutionEngine { 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 0fe58af12..489f4772a 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 class PDAToggleWatchpointsTarget extends PDABreakpointAdapter { 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 9434e1a6b..61614a587 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 @@ public class PDAMainTab extends AbstractLaunchConfigurationTab { 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 4928cf0c1..63a630b1c 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 @@ public class DebugFileStore extends FileStore { 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 97dbab694..d6ca49bcf 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 @@ public class ConsolePatternMatcher implements IDocumentListener { 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 a0e96b04a..e9dfa46ee 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 @@ public class ExternalToolsBuildTab extends AbstractLaunchConfigurationTab { // 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 |