Skip to content

Commit 4b7104d

Browse files
eclipse-pde-botlaeubi
authored andcommitted
Perform clean code of ui/org.eclipse.pde.launching
1 parent 7c312c6 commit 4b7104d

20 files changed

+263
-140
lines changed

ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/PDELaunchingPlugin.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ public static void log(IStatus status) {
8484
}
8585

8686
public static void log(Throwable e) {
87-
if (e instanceof InvocationTargetException)
87+
if (e instanceof InvocationTargetException) {
8888
e = ((InvocationTargetException) e).getTargetException();
89+
}
8990
IStatus status = null;
90-
if (e instanceof CoreException)
91+
if (e instanceof CoreException) {
9192
status = ((CoreException) e).getStatus();
92-
else
93+
} else {
9394
status = Status.error(e.getMessage(), e);
95+
}
9496
log(status);
9597
}
9698

@@ -133,8 +135,9 @@ public void bundleChanged(BundleEvent event) {
133135

134136
@Override
135137
public void stop(BundleContext context) throws Exception {
136-
if (fLaunchListener != null)
138+
if (fLaunchListener != null) {
137139
fLaunchListener.shutdown();
140+
}
138141
if (fDebugPluginUtil != null) {
139142
fDebugPluginUtil.removeListener();
140143
}
@@ -143,14 +146,16 @@ public void stop(BundleContext context) throws Exception {
143146
}
144147

145148
public LaunchListener getLaunchListener() {
146-
if (fLaunchListener == null)
149+
if (fLaunchListener == null) {
147150
fLaunchListener = new LaunchListener();
151+
}
148152
return fLaunchListener;
149153
}
150154

151155
public OSGiFrameworkManager getOSGiFrameworkManager() {
152-
if (fOSGiFrameworkManager == null)
156+
if (fOSGiFrameworkManager == null) {
153157
fOSGiFrameworkManager = new OSGiFrameworkManager();
158+
}
154159
return fOSGiFrameworkManager;
155160
}
156161

ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/EclipsePluginValidationOperation.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ public EclipsePluginValidationOperation(ILaunchConfiguration configuration, Set<
5050
@Override
5151
public void run(IProgressMonitor monitor) throws CoreException {
5252
super.run(monitor);
53-
if (!fExtensionErrors.isEmpty())
53+
if (!fExtensionErrors.isEmpty()) {
5454
fExtensionErrors.clear();
55+
}
5556
validateExtensions();
5657
}
5758

@@ -65,10 +66,11 @@ private void validateExtensions() {
6566
Status status = new Status(IStatus.ERROR, IPDEConstants.PLUGIN_ID, CREATE_EXTENSION_ERROR_CODE, message, null);
6667
IStatusHandler statusHandler = DebugPlugin.getDefault().getStatusHandler(status);
6768
Object extensionError = null;
68-
if (statusHandler == null)
69+
if (statusHandler == null) {
6970
extensionError = status.getMessage();
70-
else
71+
} else {
7172
extensionError = statusHandler.handleStatus(status, element);
73+
}
7274
fExtensionErrors.put(extensionError, EMPTY);
7375
}
7476
}

ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/EquinoxInitializer.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ private void initializeVMArguments(ILaunchConfigurationWorkingCopy configuration
5555
configuration.setAttribute(IPDEConstants.LAUNCHER_PDE_VERSION, "3.3"); //$NON-NLS-1$
5656
StringBuilder vmArgs = new StringBuilder(LaunchArgumentsHelper.getInitialVMArguments());
5757
if (vmArgs.indexOf("-Declipse.ignoreApp") == -1) { //$NON-NLS-1$
58-
if (vmArgs.length() > 0)
58+
if (vmArgs.length() > 0) {
5959
vmArgs.append(" "); //$NON-NLS-1$
60+
}
6061
vmArgs.append("-Declipse.ignoreApp=true"); //$NON-NLS-1$
6162
}
6263
if (vmArgs.indexOf("-Dosgi.noShutdown") == -1) { //$NON-NLS-1$
@@ -94,8 +95,9 @@ protected String getStartLevel(String bundleID) {
9495
}
9596

9697
private void initializeBundleState() {
97-
if (fStartLevels == null)
98+
if (fStartLevels == null) {
9899
fStartLevels = new HashMap<>();
100+
}
99101
Properties props = TargetPlatformHelper.getConfigIniProperties();
100102
if (props != null) {
101103
String value = (String) props.get("osgi.bundles"); //$NON-NLS-1$
@@ -120,12 +122,14 @@ private String getStartValue(String value) {
120122
int index = value.indexOf("start"); //$NON-NLS-1$
121123
result.append(Boolean.toString(index != -1));
122124

123-
if (index != -1)
125+
if (index != -1) {
124126
buffer.delete(index, index + 5);
127+
}
125128

126129
int colon = value.indexOf(':');
127-
if (colon != -1)
130+
if (colon != -1) {
128131
buffer.deleteCharAt(colon);
132+
}
129133

130134
// delete the first char '@'
131135
buffer.deleteCharAt(0);

ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LaunchArgumentsHelper.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,9 @@ public static File getWorkingDirectory(ILaunchConfiguration configuration) throw
201201
working = "${workspace_loc}/../"; //$NON-NLS-1$
202202
}
203203
File dir = new File(getSubstitutedString(working));
204-
if (!dir.exists())
204+
if (!dir.exists()) {
205205
dir.mkdirs();
206+
}
206207
return dir;
207208
}
208209

@@ -224,8 +225,9 @@ public static Map<String, Object> getVMSpecificAttributesMap(ILaunchConfiguratio
224225
IPluginModelBase[] models = entry.getExternalModels();
225226
for (IPluginModelBase model : models) {
226227
File file = new File(model.getInstallLocation());
227-
if (!file.isFile())
228+
if (!file.isFile()) {
228229
file = new File(file, "jdi.jar"); //$NON-NLS-1$
230+
}
229231
if (file.exists()) {
230232
map.put(IJavaLaunchConfigurationConstants.ATTR_BOOTPATH_PREPEND, new String[] {file.getAbsolutePath()});
231233
break;
@@ -335,8 +337,9 @@ private static String getEquinoxStartupPath(String packageName) throws CoreExcep
335337
// if source folder, find the output folder
336338
if (kind == IClasspathEntry.CPE_SOURCE) {
337339
IPath path = entrie.getOutputLocation();
338-
if (path == null)
340+
if (path == null) {
339341
path = jProject.getOutputLocation();
342+
}
340343
path = path.removeFirstSegments(1);
341344
return project.getLocation().append(path).toOSString();
342345
}
@@ -359,11 +362,13 @@ private static String getEquinoxStartupPath(String packageName) throws CoreExcep
359362
URL url = FileLocator.resolve(bundle.getEntry("/")); //$NON-NLS-1$
360363
url = FileLocator.toFileURL(url);
361364
String path = url.getFile();
362-
if (path.startsWith("file:")) //$NON-NLS-1$
365+
if (path.startsWith("file:")) { //$NON-NLS-1$
363366
path = path.substring(5);
367+
}
364368
path = new File(path).getAbsolutePath();
365-
if (path.endsWith("!")) //$NON-NLS-1$
369+
if (path.endsWith("!")) { //$NON-NLS-1$
366370
path = path.substring(0, path.length() - 1);
371+
}
367372
return path;
368373
} catch (IOException e) {
369374
}
@@ -385,22 +390,25 @@ private static String getStartupJarPath() throws CoreException {
385390
}
386391
}
387392
}
388-
if (project.getFile("startup.jar").exists()) //$NON-NLS-1$
393+
if (project.getFile("startup.jar").exists()) { //$NON-NLS-1$
389394
return project.getFile("startup.jar").getLocation().toOSString(); //$NON-NLS-1$
395+
}
390396
}
391397
File startupJar = IPath.fromOSString(TargetPlatform.getLocation()).append("startup.jar").toFile(); //$NON-NLS-1$
392398

393399
// if something goes wrong with the preferences, fall back on the startup.jar
394400
// in the running eclipse.
395-
if (!startupJar.exists())
401+
if (!startupJar.exists()) {
396402
startupJar = IPath.fromOSString(TargetPlatform.getDefaultLocation()).append("startup.jar").toFile(); //$NON-NLS-1$
403+
}
397404

398405
return startupJar.exists() ? startupJar.getAbsolutePath() : null;
399406
}
400407

401408
private static String getSubstitutedString(String text) throws CoreException {
402-
if (text == null)
409+
if (text == null) {
403410
return ""; //$NON-NLS-1$
411+
}
404412
IStringVariableManager mgr = VariablesPlugin.getDefault().getStringVariableManager();
405413
return mgr.performStringSubstitution(text);
406414
}

0 commit comments

Comments
 (0)