From bfce155d0fe4d88d996a76261f66ee8a92877c96 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 7 Dec 2023 20:30:36 +0100 Subject: [PATCH 1/3] Bump maven-pmd-plugin from 3.21.0 to 3.21.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5776b711..8296ccae 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 22 10.7.0 3.2.2 - 3.21.0 + 3.21.2 6.55.0 .ci/files/pmd-eclipse-plugin.p12 From 7406d491ffc9b7859e7acaaff8326a03cec1c8c7 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 7 Dec 2023 20:31:19 +0100 Subject: [PATCH 2/3] Bump pmd.check.version from 6.55.0 to 7.0.0-rc4 --- pom.xml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8296ccae..8328b326 100644 --- a/pom.xml +++ b/pom.xml @@ -22,11 +22,11 @@ 3.0.4 UTF-8 7.0.0-rc4 - 22 + 23-SNAPSHOT 10.7.0 3.2.2 3.21.2 - 6.55.0 + 7.0.0-rc4 .ci/files/pmd-eclipse-plugin.p12 ${basedir}/${keystorePath} @@ -390,6 +390,11 @@ + + net.sourceforge.pmd + pmd-compat6 + ${pmd.check.version} + net.sourceforge.pmd pmd-core @@ -400,6 +405,16 @@ pmd-java ${pmd.check.version} + + net.sourceforge.pmd + pmd-javascript + ${pmd.check.version} + + + net.sourceforge.pmd + pmd-jsp + ${pmd.check.version} + net.sourceforge.pmd From a70380d48da412bd73b80de9e3f4c817e3f39e77 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Thu, 7 Dec 2023 21:21:17 +0100 Subject: [PATCH 3/3] Fix various PMD issues --- .../src/main/java/test/RuleSetsExtension.java | 2 +- .../sourceforge/pmd/eclipse/EclipseUtils.java | 3 +- .../core/ext/RuleSetsExtensionProcessor.java | 5 +- .../eclipse/plugin/FileChangeReviewer.java | 2 +- .../pmd/eclipse/plugin/PMDPlugin.java | 1 - .../eclipse/runtime/builder/PMDNature.java | 4 +- .../runtime/cmd/AbstractDefaultCommand.java | 10 +--- .../pmd/eclipse/runtime/cmd/BaseVisitor.java | 11 ++-- .../runtime/cmd/DetectCutAndPasteCmd.java | 2 +- .../runtime/cmd/JobCommandProcessor.java | 6 +-- .../pmd/eclipse/runtime/cmd/MarkerInfo2.java | 2 +- .../pmd/eclipse/ui/actions/RuleSetUtil.java | 4 +- .../actions/internal/InternalRuleSetUtil.java | 4 +- .../eclipse/ui/dialogs/NewPropertyDialog.java | 2 +- .../eclipse/ui/editors/StyleExtractor.java | 10 +--- .../eclipse/ui/filters/FilterColumnUI.java | 34 +++++++----- .../ui/filters/FilterPreferencesPage.java | 2 +- .../eclipse/ui/model/AbstractPMDRecord.java | 2 +- .../pmd/eclipse/ui/model/FileRecord.java | 2 +- .../eclipse/ui/preferences/IconSelector.java | 6 +-- .../ui/preferences/br/MarkerColumnsUI.java | 45 +++++++++------- .../br/RuleSetTreeItemProvider.java | 10 ++-- .../eclipse/ui/preferences/br/RuleUtil.java | 16 ++---- .../preferences/br/TextColumnDescriptor.java | 2 +- .../AbstractMultiValueEditorFactory.java | 2 +- .../editors/EnumerationEditorFactory.java | 5 +- .../ui/preferences/editors/SWTUtil.java | 2 +- .../DescriptionPanelManager.java | 6 +-- .../panelmanagers/FormArranger.java | 5 +- .../PerRulePropertyPanelManager.java | 8 +-- .../panelmanagers/RulePanelManager.java | 2 +- .../eclipse/ui/priority/PriorityColumnUI.java | 52 ++++++++++++------- .../eclipse/ui/reports/ReportColumnUI.java | 30 +++++++---- .../ui/reports/ReportPreferencesPage.java | 2 +- .../ViolationOverviewContentProvider.java | 2 +- .../pmd/eclipse/ui/views/ast/ASTViewPage.java | 4 +- .../eclipse/ui/views/ast/NodeColumnUI.java | 52 ++++++++++++------- .../ui/views/ast/NodeImageDeriver.java | 2 +- .../ui/views/dataflow/DataflowGraph.java | 6 +-- .../util/AbstractCellPainterBuilder.java | 2 +- .../sourceforge/pmd/eclipse/util/Util.java | 2 +- 41 files changed, 196 insertions(+), 175 deletions(-) diff --git a/net.sourceforge.pmd.eclipse.plugin.test.fragment/src/main/java/test/RuleSetsExtension.java b/net.sourceforge.pmd.eclipse.plugin.test.fragment/src/main/java/test/RuleSetsExtension.java index db9a8848..3d88abc1 100644 --- a/net.sourceforge.pmd.eclipse.plugin.test.fragment/src/main/java/test/RuleSetsExtension.java +++ b/net.sourceforge.pmd.eclipse.plugin.test.fragment/src/main/java/test/RuleSetsExtension.java @@ -100,7 +100,7 @@ private RuleSet getRuleSet2() throws RuleSetLoadException { return this.ruleSet2; } - private static class RulesetLoaderMessageReporter implements MessageReporter { + private static final class RulesetLoaderMessageReporter implements MessageReporter { private int errors = 0; @Override diff --git a/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/EclipseUtils.java b/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/EclipseUtils.java index 6b8c5181..64ec8f83 100644 --- a/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/EclipseUtils.java +++ b/net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/EclipseUtils.java @@ -9,7 +9,6 @@ import java.io.InputStream; import java.io.PrintStream; import java.util.Collection; -import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; @@ -223,7 +222,7 @@ public static void addJavaNature(final IProject project) throws CoreException { JavaRuntime.getDefaultJREContainerEntry() }, null); - Hashtable javaOptions = JavaCore.getOptions(); + Map javaOptions = JavaCore.getOptions(); IVMInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall(); if (defaultVMInstall instanceof AbstractVMInstall) { diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/core/ext/RuleSetsExtensionProcessor.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/core/ext/RuleSetsExtensionProcessor.java index 8733cf59..dc6776bc 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/core/ext/RuleSetsExtensionProcessor.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/core/ext/RuleSetsExtensionProcessor.java @@ -5,6 +5,7 @@ package net.sourceforge.pmd.eclipse.core.ext; import java.util.LinkedHashSet; +import java.util.Set; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; @@ -54,12 +55,12 @@ private void processExecutableExtension(IConfigurationElement element) throws Co if (object instanceof IRuleSetsExtension) { final IRuleSetsExtension extension = (IRuleSetsExtension) object; - LinkedHashSet registeredRulesets = new LinkedHashSet<>(ruleSetManager.getRegisteredRuleSets()); + Set registeredRulesets = new LinkedHashSet<>(ruleSetManager.getRegisteredRuleSets()); extension.registerRuleSets(registeredRulesets); ruleSetManager.getRegisteredRuleSets().clear(); ruleSetManager.getRegisteredRuleSets().addAll(registeredRulesets); - LinkedHashSet defaultRegisteredRulesets = new LinkedHashSet<>(ruleSetManager.getDefaultRuleSets()); + Set defaultRegisteredRulesets = new LinkedHashSet<>(ruleSetManager.getDefaultRuleSets()); extension.registerDefaultRuleSets(defaultRegisteredRulesets); ruleSetManager.getDefaultRuleSets().clear(); ruleSetManager.getDefaultRuleSets().addAll(defaultRegisteredRulesets); diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/plugin/FileChangeReviewer.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/plugin/FileChangeReviewer.java index 3abf837d..462c989e 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/plugin/FileChangeReviewer.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/plugin/FileChangeReviewer.java @@ -36,7 +36,7 @@ private enum ChangeType { ADDED, REMOVED, CHANGED } - private class ResourceChange { + private final class ResourceChange { public final ChangeType resourceDeltaType; public final int flags; public final IFile file; diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/plugin/PMDPlugin.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/plugin/PMDPlugin.java index bef6b3a7..99f77286 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/plugin/PMDPlugin.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/plugin/PMDPlugin.java @@ -678,7 +678,6 @@ private void addFilesTo(IResource resource, Collection allKids) { } addKids(allKids, kids); allKids.add(project); - return; } } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/builder/PMDNature.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/builder/PMDNature.java index eccf7ba9..db7b79a3 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/builder/PMDNature.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/builder/PMDNature.java @@ -44,7 +44,7 @@ public void deconfigure() throws CoreException { if (pmdBuilderFound(commands)) { ICommand[] newCommands = new ICommand[commands.length - 1]; for (int i = 0, j = 0; i < commands.length; i++) { - if (!commands[i].getBuilderName().equals(PMDBuilder.PMD_BUILDER)) { + if (!PMDBuilder.PMD_BUILDER.equals(commands[i].getBuilderName())) { newCommands[j++] = commands[i]; } } @@ -133,7 +133,7 @@ public static boolean removePMDNature(final IProject project, final IProgressMon private boolean pmdBuilderFound(ICommand[] commands) { for (ICommand command : commands) { - if (command.getBuilderName().equals(PMDBuilder.PMD_BUILDER)) { + if (PMDBuilder.PMD_BUILDER.equals(command.getBuilderName())) { return true; } } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/AbstractDefaultCommand.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/AbstractDefaultCommand.java index ca858aae..02ca7dbe 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/AbstractDefaultCommand.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/AbstractDefaultCommand.java @@ -52,17 +52,11 @@ public static void logError(String message, Throwable error) { * @deprecated we support multiple languages now */ public static boolean isJavaFile(IFile file) { - if (file == null) { - return false; - } - return "JAVA".equalsIgnoreCase(file.getFileExtension()); + return file != null && "JAVA".equalsIgnoreCase(file.getFileExtension()); } public static boolean isLanguageFile(IFile file, Language language) { - if (file == null) { - return false; - } - return language.hasExtension(file.getFileExtension()); + return file != null && language.hasExtension(file.getFileExtension()); } /** diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java index 38a34bee..75d1262f 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java @@ -9,14 +9,15 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; +import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; +import java.util.Deque; import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.Stack; import org.apache.commons.lang3.StringUtils; import org.eclipse.core.resources.IFile; @@ -404,7 +405,7 @@ public static String markerTypeFor(RuleViolation violation) { private void prepareMarkerAccumulator(IFile file) { Map> accumulator = getAccumulator(); if (accumulator != null) { - accumulator.put(file, new HashSet()); + accumulator.put(file, new HashSet<>()); } } @@ -462,7 +463,7 @@ private List findReviewedViolations(final IFile file) { int lineNumber = 0; boolean findLine = false; boolean comment = false; - final Stack pendingReviews = new Stack<>(); + final Deque pendingReviews = new ArrayDeque<>(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents()))) { while (reader.ready()) { String line = reader.readLine(); @@ -480,7 +481,7 @@ private List findReviewedViolations(final IFile file) { findLine = true; } else if (!comment && findLine && StringUtils.isNotBlank(line) && !line.startsWith("//")) { findLine = false; - while (!pendingReviews.empty()) { + while (!pendingReviews.isEmpty()) { // @PMD:REVIEWED:AvoidInstantiatingObjectsInLoops: // by Herlin on 01/05/05 18:36 final Review review = new Review(); @@ -547,7 +548,7 @@ private MarkerInfo2 getMarkerInfo(RuleViolation violation, String type) throws P /** * Private inner type to handle reviews. */ - private class Review { + private final class Review { public String ruleName; public int lineNumber; diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/DetectCutAndPasteCmd.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/DetectCutAndPasteCmd.java index 10d0306c..a06da0fa 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/DetectCutAndPasteCmd.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/DetectCutAndPasteCmd.java @@ -198,7 +198,7 @@ private List findCandidateFiles() throws PropertiesException, CoreExceptio visitor.setWorkingSet(properties.getProjectWorkingSet()); visitor.setIncludeDerivedFiles(properties.isIncludeDerivedFiles()); visitor.setLanguage(language); - visitor.setFiles(new ArrayList()); + visitor.setFiles(new ArrayList<>()); visitProjectResourcesWith(visitor); return visitor.getFiles(); } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/JobCommandProcessor.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/JobCommandProcessor.java index 2f14ecff..85fec5bb 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/JobCommandProcessor.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/JobCommandProcessor.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.Queue; import java.util.Set; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicInteger; @@ -30,10 +31,9 @@ */ public class JobCommandProcessor { private static final Logger LOG = LoggerFactory.getLogger(JobCommandProcessor.class); - private final Map jobs = Collections - .synchronizedMap(new HashMap()); + private final Map jobs = Collections.synchronizedMap(new HashMap<>()); - private static ConcurrentLinkedQueue outstanding = new ConcurrentLinkedQueue<>(); + private static Queue outstanding = new ConcurrentLinkedQueue<>(); private static AtomicInteger count = new AtomicInteger(); private static final JobCommandProcessor INSTANCE = new JobCommandProcessor(); diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/MarkerInfo2.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/MarkerInfo2.java index 1fbf1ca8..d73979a1 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/MarkerInfo2.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/MarkerInfo2.java @@ -36,7 +36,7 @@ public void add(String name, int value) { public void addAsMarkerTo(IFile file) throws CoreException { IMarker marker = file.createMarker(type); - marker.setAttributes(data.keySet().toArray(new String[data.size()]), data.values().toArray()); + marker.setAttributes(data.keySet().toArray(new String[0]), data.values().toArray()); } @Override diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/actions/RuleSetUtil.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/actions/RuleSetUtil.java index fac28027..fc3b9a77 100755 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/actions/RuleSetUtil.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/actions/RuleSetUtil.java @@ -168,12 +168,12 @@ public static RuleSet setFileName(RuleSet ruleSet, String fileName) { @Deprecated public static RuleSet addExcludePatterns(RuleSet rs, Collection excludePatterns) { - return addExcludePatterns(rs, excludePatterns, new HashSet()); + return addExcludePatterns(rs, excludePatterns, new HashSet<>()); } @Deprecated public static RuleSet addIncludePatterns(RuleSet rs, Collection includePatterns) { - return addIncludePatterns(rs, includePatterns, new HashSet()); + return addIncludePatterns(rs, includePatterns, new HashSet<>()); } public static RuleSet clearRules(RuleSet ruleSet) { diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/actions/internal/InternalRuleSetUtil.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/actions/internal/InternalRuleSetUtil.java index e46f7347..20930507 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/actions/internal/InternalRuleSetUtil.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/actions/internal/InternalRuleSetUtil.java @@ -40,11 +40,11 @@ public static RuleSet setFileInclusions(RuleSet ruleSet, Collection inc } public static RuleSet addFileExclusions(RuleSet rs, Collection excludePatterns) { - return addExcludePatterns(rs, excludePatterns, new HashSet()); + return addExcludePatterns(rs, excludePatterns, new HashSet<>()); } public static RuleSet addFileInclusions(RuleSet rs, Collection includePatterns) { - return addIncludePatterns(rs, includePatterns, new HashSet()); + return addIncludePatterns(rs, includePatterns, new HashSet<>()); } public static RuleSet addExcludePatterns(RuleSet ruleSet, Collection activeExclusionPatterns, diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/dialogs/NewPropertyDialog.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/dialogs/NewPropertyDialog.java index 5067917a..56da719b 100755 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/dialogs/NewPropertyDialog.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/dialogs/NewPropertyDialog.java @@ -99,7 +99,7 @@ public NewPropertyDialog(Shell parent, Map, EditorFactory> theEditor public static Map, EditorFactory> withOnly(Map, EditorFactory> factoriesByType, Class[] legalTypeKeys) { - Map, EditorFactory> results = new HashMap, EditorFactory>(legalTypeKeys.length); + Map, EditorFactory> results = new HashMap<>(legalTypeKeys.length); for (Class type : legalTypeKeys) { if (factoriesByType.containsKey(type)) { diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/editors/StyleExtractor.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/editors/StyleExtractor.java index 4289a5f0..8315d3d0 100755 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/editors/StyleExtractor.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/editors/StyleExtractor.java @@ -125,17 +125,11 @@ private boolean atStringStart(String text, int position) { } private boolean atVarnameReference(String text, int position) { - if (syntaxData.varnameReference == null) { - return false; - } - return text.indexOf(syntaxData.varnameReference, position) == position; + return syntaxData.varnameReference != null && text.indexOf(syntaxData.varnameReference, position) == position; } private boolean atSingleLineComment(String text, int position) { - if (syntaxData.getComment() == null) { - return false; - } - return text.indexOf(syntaxData.getComment(), position) == position; + return syntaxData.getComment() != null && text.indexOf(syntaxData.getComment(), position) == position; } private int getKeywordEnd(String lineText, int start) { diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/filters/FilterColumnUI.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/filters/FilterColumnUI.java index 2569ddc6..0561853d 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/filters/FilterColumnUI.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/filters/FilterColumnUI.java @@ -16,30 +16,36 @@ * * @author Brian Remedios */ -public interface FilterColumnUI { +public final class FilterColumnUI { + private FilterColumnUI() { + // utility / constants class + } - ItemFieldAccessor INCLUDE_ACCESSOR = new ItemFieldAccessorAdapter(null) { + public static final ItemFieldAccessor INCLUDE_ACCESSOR = new ItemFieldAccessorAdapter( + null) { @Override public Image imageFor(FilterHolder holder) { return FilterPreferencesPage.typeIconFor(holder); } }; - ItemFieldAccessor PMD_ACCESSOR = new ItemFieldAccessorAdapter(Util.COMP_STR) { + public static final ItemFieldAccessor PMD_ACCESSOR = new ItemFieldAccessorAdapter( + Util.COMP_STR) { @Override public String valueFor(FilterHolder holder) { return holder.forPMD ? "Y" : ""; } }; - ItemFieldAccessor CPD_ACCESSOR = new ItemFieldAccessorAdapter(Util.COMP_STR) { + public static final ItemFieldAccessor CPD_ACCESSOR = new ItemFieldAccessorAdapter( + Util.COMP_STR) { @Override public String valueFor(FilterHolder holder) { return holder.forCPD ? "Y" : ""; } }; - ItemFieldAccessor PATTERN_ACCESSOR = new ItemFieldAccessorAdapter( + public static final ItemFieldAccessor PATTERN_ACCESSOR = new ItemFieldAccessorAdapter( Util.COMP_STR) { @Override public String valueFor(FilterHolder holder) { @@ -47,17 +53,17 @@ public String valueFor(FilterHolder holder) { } }; - ItemColumnDescriptor INCLUDE_DESCRIPTOR = new ItemColumnDescriptor<>("", " Type", - SWT.LEFT, 85, false, INCLUDE_ACCESSOR); - ItemColumnDescriptor PMD_DESCRIPTOR = new ItemColumnDescriptor<>("", "PMD", - SWT.CENTER, 55, false, PMD_ACCESSOR); - ItemColumnDescriptor CPD_DESCRIPTOR = new ItemColumnDescriptor<>("", "CPD", - SWT.CENTER, 55, false, CPD_ACCESSOR); - ItemColumnDescriptor PATTERN_DESCRIPTOR = new ItemColumnDescriptor<>("", "Pattern", - SWT.LEFT, 55, true, PATTERN_ACCESSOR); + public static final ItemColumnDescriptor INCLUDE_DESCRIPTOR = new ItemColumnDescriptor<>("", + " Type", SWT.LEFT, 85, false, INCLUDE_ACCESSOR); + public static final ItemColumnDescriptor PMD_DESCRIPTOR = new ItemColumnDescriptor<>("", + "PMD", SWT.CENTER, 55, false, PMD_ACCESSOR); + public static final ItemColumnDescriptor CPD_DESCRIPTOR = new ItemColumnDescriptor<>("", + "CPD", SWT.CENTER, 55, false, CPD_ACCESSOR); + public static final ItemColumnDescriptor PATTERN_DESCRIPTOR = new ItemColumnDescriptor<>("", + "Pattern", SWT.LEFT, 55, true, PATTERN_ACCESSOR); @SuppressWarnings("rawtypes") - ItemColumnDescriptor[] VISIBLE_COLUMNS = new ItemColumnDescriptor[] { INCLUDE_DESCRIPTOR, + public static final ItemColumnDescriptor[] VISIBLE_COLUMNS = new ItemColumnDescriptor[] { INCLUDE_DESCRIPTOR, // pmd, cpd, PATTERN_DESCRIPTOR }; } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/filters/FilterPreferencesPage.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/filters/FilterPreferencesPage.java index 24a0f889..39147000 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/filters/FilterPreferencesPage.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/filters/FilterPreferencesPage.java @@ -439,7 +439,7 @@ private Set selectedFilters() { Set holders = new HashSet<>(); for (Object tItem : tableViewer.getTable().getSelection()) { - holders.add((FilterHolder) (((TableItem) tItem).getData())); + holders.add((FilterHolder) ((TableItem) tItem).getData()); } return holders; } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/model/AbstractPMDRecord.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/model/AbstractPMDRecord.java index 551f96bc..e9eaf1c9 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/model/AbstractPMDRecord.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/model/AbstractPMDRecord.java @@ -56,7 +56,7 @@ public abstract class AbstractPMDRecord { * @return an ArrayList with the child-Elements */ public List getChildrenAsList() { - return new ArrayList(Arrays.asList(getChildren())); + return new ArrayList<>(Arrays.asList(getChildren())); } /** diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/model/FileRecord.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/model/FileRecord.java index ee716d31..2b09b430 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/model/FileRecord.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/model/FileRecord.java @@ -173,7 +173,7 @@ protected final AbstractPMDRecord[] createChildren() { } } - children = allMarkerMap.values().toArray(new MarkerRecord[allMarkerMap.size()]); + children = allMarkerMap.values().toArray(new MarkerRecord[0]); } catch (CoreException e) { PMDPlugin.getDefault().logError(StringKeys.ERROR_CORE_EXCEPTION + this.toString(), e); } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/IconSelector.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/IconSelector.java index 6a654b7f..d630e4b9 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/IconSelector.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/IconSelector.java @@ -22,7 +22,7 @@ public class IconSelector { private Composite composite; - private ListenerList listeners = new ListenerList(); + private ListenerList listeners = new ListenerList<>(); private PriorityDescriptorIcon selectedIcon; public IconSelector(Composite parent) { @@ -72,8 +72,8 @@ public void setSelectedIcon(PriorityDescriptorIcon icon) { PropertyChangeEvent event = new PropertyChangeEvent(this, "selectedIcon", this.selectedIcon, icon); this.selectedIcon = icon; - for (Object listener : listeners.getListeners()) { - ((IPropertyChangeListener) listener).propertyChange(event); + for (IPropertyChangeListener listener : listeners) { + listener.propertyChange(event); } } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/MarkerColumnsUI.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/MarkerColumnsUI.java index 19181050..3c9b8aa9 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/MarkerColumnsUI.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/MarkerColumnsUI.java @@ -23,16 +23,19 @@ * * @author Brian Remedios */ -public interface MarkerColumnsUI { +public final class MarkerColumnsUI { + private MarkerColumnsUI() { + // utility / constants class + } - Comparator COMP_PRIORITY = new Comparator() { + public static final Comparator COMP_PRIORITY = new Comparator() { @Override public int compare(RulePriority a, RulePriority b) { return a.compareTo(b); } }; - ItemFieldAccessor PRIORITY_ACC = new ItemFieldAccessorAdapter( + public static final ItemFieldAccessor PRIORITY_ACC = new ItemFieldAccessorAdapter( COMP_PRIORITY) { @Override public RulePriority valueFor(IMarker marker) { @@ -41,7 +44,8 @@ public RulePriority valueFor(IMarker marker) { } }; - ItemFieldAccessor PRIORITY_IMG_ACC = new ItemFieldAccessorAdapter(null) { + public static final ItemFieldAccessor PRIORITY_IMG_ACC = new ItemFieldAccessorAdapter( + null) { @Override public Image imageFor(IMarker marker) { RulePriority rp = PRIORITY_ACC.valueFor(marker); @@ -49,52 +53,57 @@ public Image imageFor(IMarker marker) { } }; - ItemFieldAccessor LINE_NO_ACC = new ItemFieldAccessorAdapter(Util.COMP_INT) { + public static final ItemFieldAccessor LINE_NO_ACC = new ItemFieldAccessorAdapter( + Util.COMP_INT) { @Override public Integer valueFor(IMarker marker) { return (Integer) marker.getAttribute(IMarker.LINE_NUMBER, 0); } }; - ItemFieldAccessor CREATED_ACC = new ItemFieldAccessorAdapter(Util.COMP_LONG) { + public static final ItemFieldAccessor CREATED_ACC = new ItemFieldAccessorAdapter( + Util.COMP_LONG) { @Override public Long valueFor(IMarker marker) { return MarkerUtil.createdOn(marker, -1); } }; - ItemFieldAccessor DONE_ACC = new ItemFieldAccessorAdapter(Util.COMP_BOOL) { + public static final ItemFieldAccessor DONE_ACC = new ItemFieldAccessorAdapter( + Util.COMP_BOOL) { @Override public Boolean valueFor(IMarker marker) { return MarkerUtil.doneState(marker, false); } }; - ItemFieldAccessor RULE_NAME_ACC = new ItemFieldAccessorAdapter(Util.COMP_STR) { + public static final ItemFieldAccessor RULE_NAME_ACC = new ItemFieldAccessorAdapter( + Util.COMP_STR) { @Override public String valueFor(IMarker marker) { return MarkerUtil.ruleNameFor(marker); } }; - ItemFieldAccessor MESSAGE_ACC = new ItemFieldAccessorAdapter(Util.COMP_STR) { + public static final ItemFieldAccessor MESSAGE_ACC = new ItemFieldAccessorAdapter( + Util.COMP_STR) { @Override public String valueFor(IMarker marker) { return MarkerUtil.messageFor(marker, "??"); } }; - ItemColumnDescriptor PRIORITY = new ItemColumnDescriptor<>("tPriority", "Priority", - SWT.CENTER, 20, false, PRIORITY_IMG_ACC); - ItemColumnDescriptor DONE = new ItemColumnDescriptor<>("tDone", "done", SWT.LEFT, - 50, false, DONE_ACC); - ItemColumnDescriptor CREATED = new ItemColumnDescriptor<>("tCreated", "created", + public static final ItemColumnDescriptor PRIORITY = new ItemColumnDescriptor<>("tPriority", + "Priority", SWT.CENTER, 20, false, PRIORITY_IMG_ACC); + public static final ItemColumnDescriptor DONE = new ItemColumnDescriptor<>("tDone", "done", + SWT.LEFT, 50, false, DONE_ACC); + public static final ItemColumnDescriptor CREATED = new ItemColumnDescriptor<>("tCreated", "created", SWT.LEFT, 130, true, CREATED_ACC, ValueFormatter.TIME_FORMATTERS); - ItemColumnDescriptor RULE_NAME = new ItemColumnDescriptor<>("tRuleName", "Rule", - SWT.LEFT, 190, true, RULE_NAME_ACC); - ItemColumnDescriptor MESSAGE = new ItemColumnDescriptor<>("tMsg", + public static final ItemColumnDescriptor RULE_NAME = new ItemColumnDescriptor<>("tRuleName", + "Rule", SWT.LEFT, 190, true, RULE_NAME_ACC); + public static final ItemColumnDescriptor MESSAGE = new ItemColumnDescriptor<>("tMsg", StringKeys.VIEW_OUTLINE_COLUMN_MESSAGE, SWT.LEFT, 260, true, MESSAGE_ACC); - ItemColumnDescriptor LINE_NUMBER = new ItemColumnDescriptor<>("tLineNo", + public static final ItemColumnDescriptor LINE_NUMBER = new ItemColumnDescriptor<>("tLineNo", StringKeys.VIEW_OUTLINE_COLUMN_LINE, SWT.LEFT, 50, false, LINE_NO_ACC); } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleSetTreeItemProvider.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleSetTreeItemProvider.java index fb2127c9..0e337c05 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleSetTreeItemProvider.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleSetTreeItemProvider.java @@ -91,7 +91,7 @@ private RuleGroup[] asRuleGroups(Collection rules) { } } - RuleGroup[] groups = ruleGroups.values().toArray(new RuleGroup[ruleGroups.size()]); + RuleGroup[] groups = ruleGroups.values().toArray(new RuleGroup[0]); // TODO sort within groups for (RuleGroup group : groups) { @@ -148,14 +148,10 @@ public boolean hasChildren(Object element) { if (element instanceof RuleSet) { RuleSet ruleSet = (RuleSet) element; - return ruleSet.getRules().size() > 0; + return !ruleSet.getRules().isEmpty(); } - if (element instanceof RuleGroup) { - return ((RuleGroup) element).hasRules(); - } - - return false; + return element instanceof RuleGroup && ((RuleGroup) element).hasRules(); } @Override diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleUtil.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleUtil.java index b97d06a0..ec255f3a 100755 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleUtil.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/RuleUtil.java @@ -50,14 +50,8 @@ public static boolean isXPathRule(PropertySource source) { // return rule.hasDescriptor(XPathRule.XPATH_DESCRIPTOR); // not // reliable since it may not have it yet - if (source instanceof XPathRule) { - return true; - } - if (source instanceof RuleReference) { - return ((RuleReference) source).getRule() instanceof XPathRule; - } - - return false; + return source instanceof XPathRule + || source instanceof RuleReference && ((RuleReference) source).getRule() instanceof XPathRule; } // TODO move elsewhere @@ -109,7 +103,7 @@ public static boolean hasDefaultValues(Rule rule) { public static Set> modifiedPropertiesIn(Rule rule) { - Set> descs = new HashSet>(); + Set> descs = new HashSet<>(); for (Map.Entry, Object> entry : Configuration.filteredPropertiesOf(rule).entrySet()) { if (isDefaultValue(entry)) { @@ -124,7 +118,7 @@ public static Set> modifiedPropertiesIn(Rule rule) { public static Set> uniqueItemsIn(Object item, RuleFieldAccessor getter) { if (item instanceof Rule) { - Set> values = new HashSet>(1); + Set> values = new HashSet<>(1); values.add(getter.valueFor((Rule) item)); return values; } @@ -369,7 +363,7 @@ public static Set> uniqueAspects(RuleCollection collection, final return Collections.emptySet(); } - final Set> aspects = new HashSet>(); + final Set> aspects = new HashSet<>(); RuleVisitor visitor = new RuleVisitor() { @Override diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/TextColumnDescriptor.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/TextColumnDescriptor.java index 68f88bdc..888285dd 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/TextColumnDescriptor.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/br/TextColumnDescriptor.java @@ -134,7 +134,7 @@ public void handleEvent(Event event) { } Point size = event.gc.textExtent(text); - event.width = size.x + 2 * (3); + event.width = size.x + 2 * 3; // event.height = Math.max(event.height, size.y + (3)); } }; diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractMultiValueEditorFactory.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractMultiValueEditorFactory.java index 0cc0b0ce..00c96a14 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractMultiValueEditorFactory.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/AbstractMultiValueEditorFactory.java @@ -92,7 +92,7 @@ public Control newEditorOn(final Composite parent, final PropertyDescriptor items = new ArrayList(); + List items = new ArrayList<>(); @Override public void handleEvent(Event event) { diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/EnumerationEditorFactory.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/EnumerationEditorFactory.java index 07dceb8a..e26fd14e 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/EnumerationEditorFactory.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/EnumerationEditorFactory.java @@ -5,6 +5,7 @@ package net.sourceforge.pmd.eclipse.ui.preferences.editors; import java.util.HashMap; +import java.util.Objects; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; @@ -39,7 +40,7 @@ protected Object valueFrom(Control valueControl) { @Override public PropertyDescriptor createDescriptor(String name, String optionalDescription, Control[] otherData) { - return PropertyFactory.enumProperty(name, new HashMap()).desc("Value set " + name).build(); + return PropertyFactory.enumProperty(name, new HashMap<>()).desc("Value set " + name).build(); } @@ -74,7 +75,7 @@ public void widgetSelected(SelectionEvent e) { int selectionIdx = combo.getSelectionIndex(); Object[][] choices = (Object[][]) combo.getData(); Object newValue = choices[selectionIdx][1]; - if (newValue == valueFor(source, desc)) { + if (Objects.equals(newValue, valueFor(source, desc))) { return; } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/SWTUtil.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/SWTUtil.java index 3fe29874..0a8dc45f 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/SWTUtil.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/editors/SWTUtil.java @@ -69,7 +69,7 @@ public void handleEvent(Event e) { // TODO move this to to Collections utility public static Set asStringSet(String input, char separator) { List values = Arrays.asList(input.split("" + separator)); - return new HashSet(values); + return new HashSet<>(values); } // TODO move this to to Collections utility diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/DescriptionPanelManager.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/DescriptionPanelManager.java index fb615a31..6065e5c8 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/DescriptionPanelManager.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/DescriptionPanelManager.java @@ -281,10 +281,8 @@ public static boolean isValidURL(String url) { private boolean hasValidURL() { String url = externalURLField.getText().trim(); - if (StringUtils.isBlank(url)) { - return true; // not required - } - return isValidURL(url); + // empty url is allowed, the URL is not required + return StringUtils.isBlank(url) || isValidURL(url); } private void adjustBrowseButton(boolean hasValidURL) { diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/FormArranger.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/FormArranger.java index 66527bea..68eb2ccf 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/FormArranger.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/FormArranger.java @@ -68,7 +68,7 @@ public FormArranger(Composite theParent, Map, EditorFactory> factori changeListener = chain(listener, this); sizeChangeListener = sizeListener; - controlsByProperty = new HashMap, Control[]>(); + controlsByProperty = new HashMap<>(); } /** @@ -203,8 +203,7 @@ private int rearrangeFor(PropertySource theSource) { return 0; } - PropertyDescriptor[] orderedDescs = valuesByDescriptor.keySet() - .toArray(new PropertyDescriptor[valuesByDescriptor.size()]); + PropertyDescriptor[] orderedDescs = valuesByDescriptor.keySet().toArray(new PropertyDescriptor[0]); Arrays.sort(orderedDescs); int rowCount = 0; // count up the actual rows with widgets needed, not all have editors yet diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/PerRulePropertyPanelManager.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/PerRulePropertyPanelManager.java index 8cb4b118..8c3dee8e 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/PerRulePropertyPanelManager.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/PerRulePropertyPanelManager.java @@ -52,7 +52,7 @@ public class PerRulePropertyPanelManager extends AbstractRulePanelManager implem public static final Map, EditorFactory> EDITOR_FACTORIES_BY_PROPERTY_TYPE; static { - Map, EditorFactory> factoriesByPropertyType = new HashMap, EditorFactory>(); + Map, EditorFactory> factoriesByPropertyType = new HashMap<>(); factoriesByPropertyType.put(Boolean.class, BooleanEditorFactory.INSTANCE); factoriesByPropertyType.put(Character.class, CharacterEditorFactory.INSTANCE); @@ -84,11 +84,7 @@ protected boolean canManageMultipleRules() { @Override protected boolean canWorkWith(Rule rule) { - if (RuleUtil.isXPathRule(rule)) { - return true; - } - - return !Configuration.filteredPropertiesOf(rule).isEmpty(); + return RuleUtil.isXPathRule(rule) || !Configuration.filteredPropertiesOf(rule).isEmpty(); } @Override diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/RulePanelManager.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/RulePanelManager.java index 937940c9..93a4eb77 100755 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/RulePanelManager.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/RulePanelManager.java @@ -651,7 +651,7 @@ private void buildPriorityControls(Composite parent) { priorityCombo = buildPriorityCombo(parent); - priorityDisplay = new ShapePicker(parent, SWT.NONE, 14); + priorityDisplay = new ShapePicker<>(parent, SWT.NONE, 14); priorityDisplay.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 4, 1)); priorityDisplay.setShapeMap(UISettings.shapesByPriority()); priorityDisplay.tooltipProvider(new LabelProvider() { diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/priority/PriorityColumnUI.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/priority/PriorityColumnUI.java index 21c4af15..d998ba6e 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/priority/PriorityColumnUI.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/priority/PriorityColumnUI.java @@ -15,81 +15,97 @@ import net.sourceforge.pmd.eclipse.ui.Shape; import net.sourceforge.pmd.eclipse.ui.nls.StringKeys; -public interface PriorityColumnUI { +public final class PriorityColumnUI { + private PriorityColumnUI() { + // utility / constants class + } - ItemFieldAccessor NAME_ACC = new ItemFieldAccessorAdapter(null) { + public static final ItemFieldAccessor NAME_ACC = new ItemFieldAccessorAdapter( + null) { @Override public String valueFor(RulePriority priority) { return PriorityDescriptorCache.INSTANCE.descriptorFor(priority).label; } }; - ItemFieldAccessor PMD_NAME_ACC = new ItemFieldAccessorAdapter(null) { + public static final ItemFieldAccessor PMD_NAME_ACC = new ItemFieldAccessorAdapter( + null) { @Override public String valueFor(RulePriority priority) { return priority.getName(); } }; - ItemFieldAccessor DESCRIPTION_ACC = new ItemFieldAccessorAdapter(null) { + public static final ItemFieldAccessor DESCRIPTION_ACC = new ItemFieldAccessorAdapter( + null) { @Override public String valueFor(RulePriority priority) { return PriorityDescriptorCache.INSTANCE.descriptorFor(priority).description; } }; - ItemFieldAccessor SHAPE_ACC = new ItemFieldAccessorAdapter(null) { + public static final ItemFieldAccessor SHAPE_ACC = new ItemFieldAccessorAdapter( + null) { @Override public Shape valueFor(RulePriority priority) { return PriorityDescriptorCache.INSTANCE.descriptorFor(priority).shape.shape; } }; - ItemFieldAccessor COLOR_ACC = new ItemFieldAccessorAdapter(null) { + public static final ItemFieldAccessor COLOR_ACC = new ItemFieldAccessorAdapter( + null) { @Override public RGB valueFor(RulePriority priority) { return PriorityDescriptorCache.INSTANCE.descriptorFor(priority).shape.rgbColor; } }; - ItemFieldAccessor SIZE_ACC = new ItemFieldAccessorAdapter(null) { + public static final ItemFieldAccessor SIZE_ACC = new ItemFieldAccessorAdapter( + null) { @Override public Integer valueFor(RulePriority priority) { return PriorityDescriptorCache.INSTANCE.descriptorFor(priority).shape.size; } }; - ItemFieldAccessor VALUE_ACC = new ItemFieldAccessorAdapter(null) { + public static final ItemFieldAccessor VALUE_ACC = new ItemFieldAccessorAdapter( + null) { @Override public Integer valueFor(RulePriority priority) { return priority.getPriority(); } }; - ItemFieldAccessor IMAGE_ACC = new ItemFieldAccessorAdapter(null) { + public static final ItemFieldAccessor IMAGE_ACC = new ItemFieldAccessorAdapter( + null) { @Override public Image imageFor(RulePriority priority) { - // Note: Not using the cached annotation image, but create a new image based on the + // Note: Not using the cached annotation image, but create a new + // image based on the // current priority descriptor settings. return PriorityDescriptorCache.INSTANCE.descriptorFor(priority).createImage(); } }; - ItemColumnDescriptor NAME = new ItemColumnDescriptor<>("", + public static final ItemColumnDescriptor NAME = new ItemColumnDescriptor<>("", StringKeys.PRIORITY_COLUMN_NAME, SWT.LEFT, 25, true, NAME_ACC); - ItemColumnDescriptor PMD_NAME = new ItemColumnDescriptor<>("", + public static final ItemColumnDescriptor PMD_NAME = new ItemColumnDescriptor<>("", StringKeys.PRIORITY_COLUMN_PMD_NAME, SWT.LEFT, 25, true, PMD_NAME_ACC); - ItemColumnDescriptor VALUE = new ItemColumnDescriptor<>("", + public static final ItemColumnDescriptor VALUE = new ItemColumnDescriptor<>("", StringKeys.PRIORITY_COLUMN_VALUE, SWT.CENTER, 25, true, VALUE_ACC); - // PriorityColumnDescriptor size = new PriorityColumnDescriptor("", StringKeys.PRIORITY_COLUMN_SIZE, SWT.RIGHT, 25, + // PriorityColumnDescriptor size = new PriorityColumnDescriptor("", + // StringKeys.PRIORITY_COLUMN_SIZE, SWT.RIGHT, 25, // true, sizeAcc); - ItemColumnDescriptor IMAGE = new ItemColumnDescriptor<>("", + public static final ItemColumnDescriptor IMAGE = new ItemColumnDescriptor<>("", StringKeys.PRIORITY_COLUMN_SYMBOL, SWT.CENTER, 25, true, IMAGE_ACC).disposeImage(); - // PriorityColumnDescriptor color = new PriorityColumnDescriptor("", StringKeys.PRIORITY_COLUMN_COLOR, SWT.RIGHT, + // PriorityColumnDescriptor color = new PriorityColumnDescriptor("", + // StringKeys.PRIORITY_COLUMN_COLOR, SWT.RIGHT, // 25, true, colorAcc); - // PriorityColumnDescriptor description = new PriorityColumnDescriptor("", StringKeys.PRIORITY_COLUMN_DESC, + // PriorityColumnDescriptor description = new PriorityColumnDescriptor("", + // StringKeys.PRIORITY_COLUMN_DESC, // SWT.LEFT, 25, true, descriptionAcc); - ItemColumnDescriptor[] VISIBLE_COLUMNS = new ItemColumnDescriptor[] { IMAGE, VALUE, NAME, PMD_NAME }; // , description + public static final ItemColumnDescriptor[] VISIBLE_COLUMNS = new ItemColumnDescriptor[] { IMAGE, VALUE, NAME, + PMD_NAME }; // , description } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/reports/ReportColumnUI.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/reports/ReportColumnUI.java index 883ab9c4..27ed6980 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/reports/ReportColumnUI.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/reports/ReportColumnUI.java @@ -15,45 +15,53 @@ * * @author Brian Remedios */ -public interface ReportColumnUI { +public final class ReportColumnUI { + private ReportColumnUI() { + // utility / constants class + } - ItemFieldAccessor NAME_ACC = new ItemFieldAccessorAdapter(null) { + public static final ItemFieldAccessor NAME_ACC = new ItemFieldAccessorAdapter( + null) { @Override public String valueFor(Renderer renderer) { return renderer.getName(); } }; - ItemFieldAccessor DESCRIPTION_ACC = new ItemFieldAccessorAdapter(null) { + public static final ItemFieldAccessor DESCRIPTION_ACC = new ItemFieldAccessorAdapter( + null) { @Override public String valueFor(Renderer renderer) { return renderer.getDescription(); } }; - ItemFieldAccessor SHOW_SUPPRESSED_ACC = new ItemFieldAccessorAdapter(null) { + public static final ItemFieldAccessor SHOW_SUPPRESSED_ACC = new ItemFieldAccessorAdapter( + null) { @Override public Boolean valueFor(Renderer renderer) { return renderer.isShowSuppressedViolations(); } }; - ItemFieldAccessor PROPERTIES_ACC = new ItemFieldAccessorAdapter(null) { + public static final ItemFieldAccessor PROPERTIES_ACC = new ItemFieldAccessorAdapter( + null) { @Override public String valueFor(Renderer renderer) { return ReportManager.asString(renderer.getPropertiesByPropertyDescriptor()); } }; - ItemColumnDescriptor NAME = new ItemColumnDescriptor<>("", "Name", SWT.LEFT, 55, - true, NAME_ACC); - ItemColumnDescriptor DESCRIPTION = new ItemColumnDescriptor<>("", "Format", + public static final ItemColumnDescriptor NAME = new ItemColumnDescriptor<>("", "Name", SWT.LEFT, + 55, true, NAME_ACC); + public static final ItemColumnDescriptor DESCRIPTION = new ItemColumnDescriptor<>("", "Format", SWT.LEFT, 99, true, DESCRIPTION_ACC); - ItemColumnDescriptor SUPPRESSED = new ItemColumnDescriptor<>("", + public static final ItemColumnDescriptor SUPPRESSED = new ItemColumnDescriptor<>("", "Show suppressed", SWT.LEFT, 40, true, SHOW_SUPPRESSED_ACC); - ItemColumnDescriptor PROPERTIES = new ItemColumnDescriptor<>("", "Properties", + public static final ItemColumnDescriptor PROPERTIES = new ItemColumnDescriptor<>("", "Properties", SWT.LEFT, 99, true, PROPERTIES_ACC); @SuppressWarnings("rawtypes") - ItemColumnDescriptor[] VISIBLE_COLUMNS = new ItemColumnDescriptor[] { NAME, /* suppressed, */ PROPERTIES }; + public static final ItemColumnDescriptor[] VISIBLE_COLUMNS = new ItemColumnDescriptor[] { NAME, + /* suppressed, */ PROPERTIES }; } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/reports/ReportPreferencesPage.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/reports/ReportPreferencesPage.java index 8fafefa0..e8f25f26 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/reports/ReportPreferencesPage.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/reports/ReportPreferencesPage.java @@ -128,7 +128,7 @@ public Object[] getElements(Object inputElement) { }; BasicTableLabelProvider labelProvider = new BasicTableLabelProvider(ReportColumnUI.VISIBLE_COLUMNS); - BasicTableManager reportTableMgr = new BasicTableManager("renderers", null, ReportColumnUI.VISIBLE_COLUMNS); + BasicTableManager reportTableMgr = new BasicTableManager<>("renderers", null, ReportColumnUI.VISIBLE_COLUMNS); tableViewer = reportTableMgr.buildTableViewer(group, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK); reportTableMgr.setupColumns(ReportColumnUI.VISIBLE_COLUMNS); diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ViolationOverviewContentProvider.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ViolationOverviewContentProvider.java index 3a91f7dd..b3c8ef68 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ViolationOverviewContentProvider.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ViolationOverviewContentProvider.java @@ -138,7 +138,7 @@ private Object[] getChildrenOfPackageOrFolder(AbstractPMDRecord record) { } } - return markers.values().toArray(new MarkerRecord[markers.size()]); + return markers.values().toArray(new MarkerRecord[0]); } else { return record.getChildren(); } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/ASTViewPage.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/ASTViewPage.java index 48d1da02..077739b8 100755 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/ASTViewPage.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/ASTViewPage.java @@ -75,7 +75,7 @@ public class ASTViewPage extends AbstractStructureInspectorPage { private static Set> hiddenNodeTypes; static { - hiddenNodeTypes = new HashSet>(); + hiddenNodeTypes = new HashSet<>(); hiddenNodeTypes.add(ASTImportDeclaration.class); } @@ -192,7 +192,7 @@ public void widgetSelected(SelectionEvent e) { // outputField.setLayoutData(gridData); // SyntaxManager.adapt(outputField, "xpath", null); - BasicTableManager tableMgr = new BasicTableManager("ast", null, NodeColumnUI.VISIBLE_COLUMNS); + BasicTableManager tableMgr = new BasicTableManager<>("ast", null, NodeColumnUI.VISIBLE_COLUMNS); resultsViewer = tableMgr.buildTableViewer(xpathTestPanel); tableMgr.setupColumns(NodeColumnUI.VISIBLE_COLUMNS); diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/NodeColumnUI.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/NodeColumnUI.java index e3423313..43d51071 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/NodeColumnUI.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/NodeColumnUI.java @@ -17,75 +17,87 @@ * * @author Brian Remedios */ -public interface NodeColumnUI { +public final class NodeColumnUI { + private NodeColumnUI() { + // utility / constants class + } - ItemFieldAccessor TYPE_NAME_ACC = new ItemFieldAccessorAdapter(Util.COMP_STR) { + public static final ItemFieldAccessor TYPE_NAME_ACC = new ItemFieldAccessorAdapter( + Util.COMP_STR) { @Override public String valueFor(Node node) { return node.toString(); } }; - ItemFieldAccessor IMAGE_ACC = new ItemFieldAccessorAdapter(Util.COMP_STR) { + public static final ItemFieldAccessor IMAGE_ACC = new ItemFieldAccessorAdapter( + Util.COMP_STR) { @Override public String valueFor(Node node) { return node.getImage(); } }; - ItemFieldAccessor BEGIN_LINE_NUM_ACC = new ItemFieldAccessorAdapter(Util.COMP_INT) { + public static final ItemFieldAccessor BEGIN_LINE_NUM_ACC = new ItemFieldAccessorAdapter( + Util.COMP_INT) { @Override public Integer valueFor(Node node) { return node.getBeginLine(); } }; - ItemFieldAccessor END_LINE_NUM_ACC = new ItemFieldAccessorAdapter(Util.COMP_INT) { + public static final ItemFieldAccessor END_LINE_NUM_ACC = new ItemFieldAccessorAdapter( + Util.COMP_INT) { @Override public Integer valueFor(Node node) { return node.getEndLine(); } }; - ItemFieldAccessor BEGIN_COLUMN_ACC = new ItemFieldAccessorAdapter(Util.COMP_INT) { + public static final ItemFieldAccessor BEGIN_COLUMN_ACC = new ItemFieldAccessorAdapter( + Util.COMP_INT) { @Override public Integer valueFor(Node node) { return node.getBeginColumn(); } }; - ItemFieldAccessor END_COLUMN_ACC = new ItemFieldAccessorAdapter(Util.COMP_INT) { + public static final ItemFieldAccessor END_COLUMN_ACC = new ItemFieldAccessorAdapter( + Util.COMP_INT) { @Override public Integer valueFor(Node node) { return node.getEndColumn(); } }; - ItemFieldAccessor DERIVED_ACC = new ItemFieldAccessorAdapter(Util.COMP_STR) { + public static final ItemFieldAccessor DERIVED_ACC = new ItemFieldAccessorAdapter( + Util.COMP_STR) { @Override public String valueFor(Node node) { return NodeImageDeriver.derivedTextFor(node); } }; - ItemFieldAccessor IMAGE_OR_DERIVED_ACC = new ItemFieldAccessorAdapter(Util.COMP_STR) { + public static final ItemFieldAccessor IMAGE_OR_DERIVED_ACC = new ItemFieldAccessorAdapter( + Util.COMP_STR) { @Override public String valueFor(Node node) { return node.getImage() == null ? NodeImageDeriver.derivedTextFor(node) : node.getImage(); } }; - ItemColumnDescriptor TYPE_NAME = new ItemColumnDescriptor<>("", StringKeys.NODE_COLUMN_NAME, - SWT.LEFT, 85, true, TYPE_NAME_ACC); - ItemColumnDescriptor IMAGE_DATA = new ItemColumnDescriptor<>("", StringKeys.NODE_IMAGE_DATA, - SWT.LEFT, 25, true, IMAGE_ACC); - ItemColumnDescriptor LINE_NUM = new ItemColumnDescriptor<>("", StringKeys.NODE_LINE_NUM, - SWT.RIGHT, 35, true, BEGIN_LINE_NUM_ACC); - ItemColumnDescriptor DERIVED = new ItemColumnDescriptor<>("", StringKeys.NODE_DERIVED, - SWT.LEFT, 25, true, DERIVED_ACC); - ItemColumnDescriptor IMAGE_OR_DERIVED = new ItemColumnDescriptor<>("", StringKeys.NODE_IMG_OR_DERIVED, - SWT.LEFT, 25, true, IMAGE_OR_DERIVED_ACC); + public static final ItemColumnDescriptor TYPE_NAME = new ItemColumnDescriptor<>("", + StringKeys.NODE_COLUMN_NAME, SWT.LEFT, 85, true, TYPE_NAME_ACC); + public static final ItemColumnDescriptor IMAGE_DATA = new ItemColumnDescriptor<>("", + StringKeys.NODE_IMAGE_DATA, SWT.LEFT, 25, true, IMAGE_ACC); + public static final ItemColumnDescriptor LINE_NUM = new ItemColumnDescriptor<>("", + StringKeys.NODE_LINE_NUM, SWT.RIGHT, 35, true, BEGIN_LINE_NUM_ACC); + public static final ItemColumnDescriptor DERIVED = new ItemColumnDescriptor<>("", + StringKeys.NODE_DERIVED, SWT.LEFT, 25, true, DERIVED_ACC); + public static final ItemColumnDescriptor IMAGE_OR_DERIVED = new ItemColumnDescriptor<>("", + StringKeys.NODE_IMG_OR_DERIVED, SWT.LEFT, 25, true, IMAGE_OR_DERIVED_ACC); - ItemColumnDescriptor[] VISIBLE_COLUMNS = new ItemColumnDescriptor[] { LINE_NUM, TYPE_NAME, IMAGE_OR_DERIVED }; + public static final ItemColumnDescriptor[] VISIBLE_COLUMNS = new ItemColumnDescriptor[] { LINE_NUM, TYPE_NAME, + IMAGE_OR_DERIVED }; } diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/NodeImageDeriver.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/NodeImageDeriver.java index 6f57a656..ce5b4031 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/NodeImageDeriver.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/ast/NodeImageDeriver.java @@ -84,7 +84,7 @@ public String deriveFrom(Node node) { methodDeclarationDeriver, localVariableDeclarationDeriver, fieldDeclarationDeriver, annotationDeriver, compilationUnitDeriver, throwStatementDeriver }; - private static final Map, NodeImageDeriver> DERIVERS_BY_TYPE = new HashMap, NodeImageDeriver>( + private static final Map, NodeImageDeriver> DERIVERS_BY_TYPE = new HashMap<>( NodeImageDeriver.ALL_DERIVERS.length); public final Class target; diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/dataflow/DataflowGraph.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/dataflow/DataflowGraph.java index 57ccd27b..bae92a84 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/dataflow/DataflowGraph.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/views/dataflow/DataflowGraph.java @@ -37,7 +37,6 @@ public class DataflowGraph extends Composite { protected int lineLength = 25; protected int rowHeight = 2 * nodeRadius + lineLength; - protected Color bgColor; protected Color nodeColor; protected Color textColor; protected boolean marked; @@ -55,7 +54,6 @@ private class NodeCanvas extends Canvas implements PaintListener { //private DataFlowNode node; private int radius; - private Color bgColor; private Color nodeColor; private Color textColor; @@ -82,7 +80,7 @@ private class NodeCanvas extends Canvas implements PaintListener { Display display = parent.getDisplay(); // Default Colors - bgColor = display.getSystemColor(SWT.COLOR_WHITE); // new Color(null,255,255,255); + Color bgColor = display.getSystemColor(SWT.COLOR_WHITE); // new Color(null,255,255,255); nodeColor = display.getSystemColor(SWT.COLOR_GRAY); // new Color(null,128,128,128); textColor = display.getSystemColor(SWT.COLOR_WHITE); // new Color(null,255,255,255); markColor = display.getSystemColor(SWT.COLOR_RED); // new Color(null,192,0,0); @@ -418,7 +416,7 @@ public DataflowGraph(Composite parent, Node node, int radius, int length, int he Display display = parent.getDisplay(); // Default Colors - bgColor = display.getSystemColor(SWT.COLOR_WHITE); // new Color(null,255,255,255); + Color bgColor = display.getSystemColor(SWT.COLOR_WHITE); // new Color(null,255,255,255); nodeColor = display.getSystemColor(SWT.COLOR_GRAY); // new Color(null,192,192,192); textColor = display.getSystemColor(SWT.COLOR_BLACK); // new Color(null,0,0,0); markColor = new Color(null, 192, 0, 0); diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/util/AbstractCellPainterBuilder.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/util/AbstractCellPainterBuilder.java index 7ec41b07..714273dd 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/util/AbstractCellPainterBuilder.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/util/AbstractCellPainterBuilder.java @@ -42,7 +42,7 @@ public static void addListener(Control control, int eventType, Listener listener control.addListener(eventType, listener); if (!listenersByEventCode.containsKey(eventCode)) { - listenersByEventCode.put(eventCode, new ArrayList()); + listenersByEventCode.put(eventCode, new ArrayList<>()); } listenersByEventCode.get(eventCode).add(listener); diff --git a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/util/Util.java b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/util/Util.java index 0d38540c..19980721 100644 --- a/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/util/Util.java +++ b/net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/util/Util.java @@ -318,7 +318,7 @@ public static void addListener(Control control, int eventType, Listener listener control.addListener(eventType, listener); if (!listenersByEventCode.containsKey(eventCode)) { - listenersByEventCode.put(eventCode, new ArrayList()); + listenersByEventCode.put(eventCode, new ArrayList<>()); } listenersByEventCode.get(eventCode).add(listener);