Skip to content

Commit 6bc4f4d

Browse files
committed
Formatting, whitespace
1 parent 2b7f121 commit 6bc4f4d

File tree

108 files changed

+9705
-8735
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+9705
-8735
lines changed
Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
package net.sourceforge.pmd.eclipse.plugin;
23

34
import org.eclipse.core.runtime.IProgressMonitor;
@@ -7,16 +8,35 @@
78
* @author Brian Remedios
89
*/
910
public class EclipseUtil {
11+
private EclipseUtil() {
12+
// utility class
13+
}
14+
15+
public static final IProgressMonitor DUMMY_MONITOR = new IProgressMonitor() {
16+
17+
public void beginTask(String name, int totalWork) {
18+
}
19+
20+
public void done() {
21+
}
22+
23+
public void internalWorked(double work) {
24+
}
25+
26+
public boolean isCanceled() {
27+
return false;
28+
}
29+
30+
public void setCanceled(boolean value) {
31+
}
32+
33+
public void setTaskName(String name) {
34+
}
35+
36+
public void subTask(String name) {
37+
}
1038

11-
public static final IProgressMonitor DUMMY_MONITOR = new IProgressMonitor() {
12-
13-
public void beginTask(String name, int totalWork) { }
14-
public void done() { }
15-
public void internalWorked(double work) { }
16-
public boolean isCanceled() { return false; }
17-
public void setCanceled(boolean value) { }
18-
public void setTaskName(String name) { }
19-
public void subTask(String name) { }
20-
public void worked(int work) { }
21-
};
39+
public void worked(int work) {
40+
}
41+
};
2242
}

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/plugin/FileChangeReviewer.java

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1+
12
package net.sourceforge.pmd.eclipse.plugin;
23

34
import java.util.HashSet;
45
import java.util.Set;
56

6-
import name.herlin.command.CommandException;
7-
import net.sourceforge.pmd.eclipse.runtime.builder.MarkerUtil;
8-
import net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd;
9-
10-
import org.apache.log4j.Logger;
117
import org.eclipse.core.resources.IFile;
128
import org.eclipse.core.resources.IResource;
139
import org.eclipse.core.resources.IResourceChangeEvent;
1410
import org.eclipse.core.resources.IResourceChangeListener;
1511
import org.eclipse.core.resources.IResourceDelta;
1612
import org.eclipse.core.resources.IWorkspaceDescription;
1713
import org.eclipse.core.resources.ResourcesPlugin;
18-
import org.eclipse.core.runtime.CoreException;
1914
import org.eclipse.core.runtime.IProgressMonitor;
2015
import org.eclipse.core.runtime.IStatus;
2116
import org.eclipse.core.runtime.NullProgressMonitor;
2217

18+
import net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd;
19+
20+
import name.herlin.command.CommandException;
21+
2322
/**
2423
* Monitors for changes in the workspace and initiates the ReviewCodeCmd when
2524
* suitable file changes in some meaningful way.
@@ -51,10 +50,12 @@ public int hashCode() {
5150
}
5251

5352
public boolean equals(Object other) {
54-
if (other == null)
53+
if (other == null) {
5554
return false;
56-
if (other == this)
55+
}
56+
if (other == this) {
5757
return true;
58+
}
5859
if (other.getClass() == getClass()) {
5960
ResourceChange chg = (ResourceChange) other;
6061
return chg.file.equals(file) && resourceDeltaType == chg.resourceDeltaType && flags == chg.flags;
@@ -69,7 +70,8 @@ public boolean equals(Object other) {
6970
public void resourceChanged(IResourceChangeEvent event) {
7071
IWorkspaceDescription workspaceSettings = ResourcesPlugin.getWorkspace().getDescription();
7172
if (workspaceSettings.isAutoBuilding()) {
72-
PMDPlugin.getDefault().logInformation("Not running PMD via FileChangeReviewer, as autoBuilding is enabled for this workspace");
73+
PMDPlugin.getDefault().logInformation(
74+
"Not running PMD via FileChangeReviewer, as autoBuilding is enabled for this workspace");
7375
return;
7476
}
7577

@@ -84,16 +86,21 @@ public void resourceChanged(IResourceChangeEvent event) {
8486

8587
case IResourceChangeEvent.POST_CHANGE:
8688
changed(itemsChanged, event.getDelta(), new NullProgressMonitor());
89+
break;
90+
default:
91+
//TODO
8792
}
8893

89-
if (itemsChanged.isEmpty())
94+
if (itemsChanged.isEmpty()) {
9095
return;
96+
}
9197

9298
ReviewCodeCmd cmd = new ReviewCodeCmd(); // separate one for each thread
9399
cmd.reset();
94100

95-
for (ResourceChange chg : itemsChanged)
101+
for (ResourceChange chg : itemsChanged) {
96102
cmd.addResource(chg.file);
103+
}
97104

98105
try {
99106
cmd.performExecute();
@@ -118,8 +125,9 @@ private void changed(Set<ResourceChange> itemsChanged, IResourceDelta delta, IPr
118125
// removed(itemsChanged, (IFile)rsc, flags, true);
119126
// }
120127
for (IResourceDelta grandkidDelta : delta.getAffectedChildren()) {
121-
if (monitor.isCanceled())
128+
if (monitor.isCanceled()) {
122129
return;
130+
}
123131
changed(itemsChanged, grandkidDelta, monitor);
124132
}
125133
break;
@@ -131,8 +139,9 @@ private void changed(Set<ResourceChange> itemsChanged, IResourceDelta delta, IPr
131139
added(itemsChanged, (IFile) rsc, flags, true);
132140
}
133141
for (IResourceDelta grandkidDelta : delta.getAffectedChildren()) {
134-
if (monitor.isCanceled())
142+
if (monitor.isCanceled()) {
135143
return;
144+
}
136145
changed(itemsChanged, grandkidDelta, monitor);
137146
}
138147
break;
@@ -144,15 +153,17 @@ private void changed(Set<ResourceChange> itemsChanged, IResourceDelta delta, IPr
144153
changed(itemsChanged, (IFile) rsc, flags, true);
145154
}
146155
for (IResourceDelta grandkidDelta : delta.getAffectedChildren()) {
147-
if (monitor.isCanceled())
156+
if (monitor.isCanceled()) {
148157
return;
158+
}
149159
changed(itemsChanged, grandkidDelta, monitor);
150160
}
151161
break;
152162
default:
153163
for (IResourceDelta grandkidDelta : delta.getAffectedChildren()) {
154-
if (monitor.isCanceled())
164+
if (monitor.isCanceled()) {
155165
return;
166+
}
156167
changed(itemsChanged, grandkidDelta, monitor);
157168
}
158169
}

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/plugin/PMDPlugin.java

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
package net.sourceforge.pmd.eclipse.plugin;
23

34
import java.io.File;
@@ -87,17 +88,17 @@ public class PMDPlugin extends AbstractUIPlugin {
8788

8889
public static final String PLUGIN_ID = "net.sourceforge.pmd.eclipse.plugin";
8990

90-
private static Map<IProject, IJavaProject> JavaProjectsByIProject = new HashMap<IProject, IJavaProject>();
91+
private static Map<IProject, IJavaProject> javaProjectsByIProject = new HashMap<IProject, IJavaProject>();
9192

9293
// The shared instance
9394
private static PMDPlugin plugin;
9495

95-
public static String VERSION = "unknown";
96+
public static String version = "unknown";
9697

97-
private static final Integer[] priorityValues = new Integer[] { Integer.valueOf(1), Integer.valueOf(2),
98-
Integer.valueOf(3), Integer.valueOf(4), Integer.valueOf(5) };
98+
private static final Integer[] PRIORITY_VALUES = new Integer[] { Integer.valueOf(1), Integer.valueOf(2),
99+
Integer.valueOf(3), Integer.valueOf(4), Integer.valueOf(5), };
99100

100-
private static final Logger log = Logger.getLogger(PMDPlugin.class);
101+
private static final Logger LOG = Logger.getLogger(PMDPlugin.class);
101102

102103
private StringTable stringTable; // NOPMD by Herlin on 11/10/06 00:22
103104

@@ -117,8 +118,9 @@ public PMDPlugin() {
117118
public Color colorFor(RGB rgb) {
118119

119120
Color color = coloursByRGB.get(rgb);
120-
if (color != null)
121+
if (color != null) {
121122
return color;
123+
}
122124

123125
color = new Color(null, rgb.red, rgb.green, rgb.blue);
124126
coloursByRGB.put(rgb, color);
@@ -148,10 +150,10 @@ public static void setJavaClassLoader(PMDConfiguration config, IProject project)
148150
*/
149151
public static LanguageVersion javaVersionFor(IProject project) {
150152

151-
IJavaProject jProject = JavaProjectsByIProject.get(project);
153+
IJavaProject jProject = javaProjectsByIProject.get(project);
152154
if (jProject == null) {
153155
jProject = JavaCore.create(project);
154-
JavaProjectsByIProject.put(project, jProject);
156+
javaProjectsByIProject.put(project, jProject);
155157
}
156158

157159
if (jProject.exists()) {
@@ -162,10 +164,10 @@ public static LanguageVersion javaVersionFor(IProject project) {
162164
}
163165

164166
public static IClasspathEntry buildSourceClassPathEntryFor(IProject project) {
165-
IJavaProject jProject = JavaProjectsByIProject.get(project);
167+
IJavaProject jProject = javaProjectsByIProject.get(project);
166168
if (jProject == null) {
167169
jProject = JavaCore.create(project);
168-
JavaProjectsByIProject.put(project, jProject);
170+
javaProjectsByIProject.put(project, jProject);
169171
}
170172
if (jProject.exists()) {
171173
try {
@@ -177,7 +179,7 @@ public static IClasspathEntry buildSourceClassPathEntryFor(IProject project) {
177179
}
178180
}
179181
} catch (JavaModelException e) {
180-
log.error("Couldn't determine source classpath", e);
182+
LOG.error("Couldn't determine source classpath", e);
181183
}
182184
}
183185
return null;
@@ -189,8 +191,9 @@ private void disposeResources() {
189191
}
190192

191193
public static void disposeAll(Collection<Color> colors) {
192-
for (Color color : colors)
194+
for (Color color : colors) {
193195
color.dispose();
196+
}
194197
}
195198

196199
public static File getPluginFolder() {
@@ -211,9 +214,8 @@ public static File getPluginFolder() {
211214
/*
212215
* (non-Javadoc)
213216
*
214-
* @see
215-
* org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
216-
* )
217+
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.
218+
* BundleContext )
217219
*/
218220
public void start(BundleContext context) throws Exception {
219221
super.start(context);
@@ -238,16 +240,17 @@ public void resourceChanged(IResourceChangeEvent arg0) {
238240
}
239241
});
240242

241-
VERSION = context.getBundle().getHeaders().get("Bundle-Version");
243+
version = context.getBundle().getHeaders().get("Bundle-Version");
242244
}
243245

244246
public void fileChangeListenerEnabled(boolean flag) {
245247

246248
IWorkspace workspace = ResourcesPlugin.getWorkspace();
247249

248250
if (flag) {
249-
if (changeReviewer == null)
251+
if (changeReviewer == null) {
250252
changeReviewer = new FileChangeReviewer();
253+
}
251254
workspace.addResourceChangeListener(changeReviewer);
252255
} else {
253256
if (changeReviewer != null) {
@@ -260,9 +263,8 @@ public void fileChangeListenerEnabled(boolean flag) {
260263
/*
261264
* (non-Javadoc)
262265
*
263-
* @see
264-
* org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
265-
* )
266+
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.
267+
* BundleContext )
266268
*/
267269
public void stop(BundleContext context) throws Exception {
268270

@@ -320,8 +322,8 @@ public Image getImage(String key, String iconPath) {
320322
*/
321323
public void logError(String message, Throwable t) {
322324
getLog().log(new Status(IStatus.ERROR, getBundle().getSymbolicName(), 0, message + t.getMessage(), t));
323-
if (log != null) {
324-
log.error(message, t);
325+
if (LOG != null) {
326+
LOG.error(message, t);
325327
}
326328
}
327329

@@ -332,8 +334,8 @@ public void logError(String message, Throwable t) {
332334
*/
333335
public void logError(IStatus status) {
334336
getLog().log(status);
335-
if (log != null) {
336-
log.error(status.getMessage(), status.getException());
337+
if (LOG != null) {
338+
LOG.error(status.getMessage(), status.getException());
337339
}
338340
}
339341

@@ -382,7 +384,7 @@ public StringTable getStringTable() {
382384
* @deprecated
383385
*/
384386
public Integer[] getPriorityValues() {
385-
return priorityValues;
387+
return PRIORITY_VALUES;
386388
}
387389

388390
/**
@@ -554,8 +556,9 @@ public RuleLabelDecorator ruleLabelDecorator() {
554556
public void changedFiles(Collection<IFile> changedFiles) {
555557

556558
RuleLabelDecorator rld = ruleLabelDecorator();
557-
if (rld == null)
559+
if (rld == null) {
558560
return;
561+
}
559562

560563
Collection<IResource> withParents = new HashSet<IResource>(changedFiles.size() * 2);
561564
withParents.addAll(changedFiles);
@@ -607,8 +610,9 @@ private void addFilesTo(IResource resource, Collection<IResource> allKids) {
607610

608611
private void addKids(Collection<IResource> allKids, IResource[] kids) {
609612

610-
if (kids == null)
613+
if (kids == null) {
611614
return;
615+
}
612616

613617
for (IResource irc : kids) {
614618
if (irc instanceof IFile) {
@@ -624,8 +628,9 @@ private void addKids(Collection<IResource> allKids, IResource[] kids) {
624628
public void removedMarkersIn(IResource resource) {
625629

626630
RuleLabelDecorator decorator = ruleLabelDecorator();
627-
if (decorator == null)
631+
if (decorator == null) {
628632
return;
633+
}
629634

630635
Collection<IResource> changes = new ArrayList<IResource>();
631636

0 commit comments

Comments
 (0)