From 3abb8339801a5ac9bc04c636c40134ddfe4ab798 Mon Sep 17 00:00:00 2001
From: rajeshggwp
Date: Sat, 13 Oct 2018 22:02:51 +0530
Subject: [PATCH 001/139] added new rule - NumericLiteralCovention
---
docs/pages/pmd/rules/java.md | 1 +
docs/pages/pmd/rules/java/codestyle.md | 32 +++++++-
.../resources/category/java/codestyle.xml | 32 ++++++++
.../rule/codestyle/CodeStyleRulesTest.java | 1 +
.../xml/NumericLiteralConvention.xml | 76 +++++++++++++++++++
5 files changed, 141 insertions(+), 1 deletion(-)
create mode 100644 pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/NumericLiteralConvention.xml
diff --git a/docs/pages/pmd/rules/java.md b/docs/pages/pmd/rules/java.md
index 516e0ddd7a..386d9f6ecb 100644
--- a/docs/pages/pmd/rules/java.md
+++ b/docs/pages/pmd/rules/java.md
@@ -98,6 +98,7 @@ folder: pmd/rules
* [MethodNamingConventions](pmd_rules_java_codestyle.html#methodnamingconventions): Configurable naming conventions for method declarations. This rule reports method decl...
* [MIsLeadingVariableName](pmd_rules_java_codestyle.html#misleadingvariablename): Deprecated Detects when a non-field has a name starting with 'm_'. This usually denotes a field and could b...
* [NoPackage](pmd_rules_java_codestyle.html#nopackage): Detects when a class or interface does not have a package definition.
+* [NumericLiteralConvention](pmd_rules_java_codestyle.html#numericliteralconvention): Numeric literals with more than 3 digits must use '_' as a separator.
* [OnlyOneReturn](pmd_rules_java_codestyle.html#onlyonereturn): A method should have only one exit point, and that should be the last statement in the method.
* [PackageCase](pmd_rules_java_codestyle.html#packagecase): Detects when a package definition contains uppercase characters.
* [PrematureDeclaration](pmd_rules_java_codestyle.html#prematuredeclaration): Checks for variables that are defined before they might be used. A reference is deemed to be prem...
diff --git a/docs/pages/pmd/rules/java/codestyle.md b/docs/pages/pmd/rules/java/codestyle.md
index 091987c4e1..1b23f7732b 100644
--- a/docs/pages/pmd/rules/java/codestyle.md
+++ b/docs/pages/pmd/rules/java/codestyle.md
@@ -5,7 +5,7 @@ permalink: pmd_rules_java_codestyle.html
folder: pmd/rules/java
sidebaractiveurl: /pmd_rules_java.html
editmepath: ../pmd-java/src/main/resources/category/java/codestyle.xml
-keywords: Code Style, AbstractNaming, AtLeastOneConstructor, AvoidDollarSigns, AvoidFinalLocalVariable, AvoidPrefixingMethodParameters, AvoidProtectedFieldInFinalClass, AvoidProtectedMethodInFinalClassNotExtending, AvoidUsingNativeCode, BooleanGetMethodName, CallSuperInConstructor, ClassNamingConventions, CommentDefaultAccessModifier, ConfusingTernary, ControlStatementBraces, DefaultPackage, DontImportJavaLang, DuplicateImports, EmptyMethodInAbstractClassShouldBeAbstract, ExtendsObject, FieldDeclarationsShouldBeAtStartOfClass, FieldNamingConventions, ForLoopShouldBeWhileLoop, ForLoopsMustUseBraces, FormalParameterNamingConventions, GenericsNaming, IdenticalCatchBranches, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, LinguisticNaming, LocalHomeNamingConvention, LocalInterfaceSessionNamingConvention, LocalVariableCouldBeFinal, LocalVariableNamingConventions, LongVariable, MDBAndSessionBeanNamingConvention, MethodArgumentCouldBeFinal, MethodNamingConventions, MIsLeadingVariableName, NoPackage, OnlyOneReturn, PackageCase, PrematureDeclaration, RemoteInterfaceNamingConvention, RemoteSessionInterfaceNamingConvention, ShortClassName, ShortMethodName, ShortVariable, SuspiciousConstantFieldName, TooManyStaticImports, UnnecessaryAnnotationValueElement, UnnecessaryConstructor, UnnecessaryFullyQualifiedName, UnnecessaryLocalBeforeReturn, UnnecessaryModifier, UnnecessaryReturn, UselessParentheses, UselessQualifiedThis, VariableNamingConventions, WhileLoopsMustUseBraces
+keywords: Code Style, AbstractNaming, AtLeastOneConstructor, AvoidDollarSigns, AvoidFinalLocalVariable, AvoidPrefixingMethodParameters, AvoidProtectedFieldInFinalClass, AvoidProtectedMethodInFinalClassNotExtending, AvoidUsingNativeCode, BooleanGetMethodName, CallSuperInConstructor, ClassNamingConventions, CommentDefaultAccessModifier, ConfusingTernary, ControlStatementBraces, DefaultPackage, DontImportJavaLang, DuplicateImports, EmptyMethodInAbstractClassShouldBeAbstract, ExtendsObject, FieldDeclarationsShouldBeAtStartOfClass, FieldNamingConventions, ForLoopShouldBeWhileLoop, ForLoopsMustUseBraces, FormalParameterNamingConventions, GenericsNaming, IdenticalCatchBranches, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, LinguisticNaming, LocalHomeNamingConvention, LocalInterfaceSessionNamingConvention, LocalVariableCouldBeFinal, LocalVariableNamingConventions, LongVariable, MDBAndSessionBeanNamingConvention, MethodArgumentCouldBeFinal, MethodNamingConventions, MIsLeadingVariableName, NoPackage, NumericLiteralConvention, OnlyOneReturn, PackageCase, PrematureDeclaration, RemoteInterfaceNamingConvention, RemoteSessionInterfaceNamingConvention, ShortClassName, ShortMethodName, ShortVariable, SuspiciousConstantFieldName, TooManyStaticImports, UnnecessaryAnnotationValueElement, UnnecessaryConstructor, UnnecessaryFullyQualifiedName, UnnecessaryLocalBeforeReturn, UnnecessaryModifier, UnnecessaryReturn, UselessParentheses, UselessQualifiedThis, VariableNamingConventions, WhileLoopsMustUseBraces
language: Java
---
## AbstractNaming
@@ -1505,6 +1505,36 @@ public class ClassInDefaultPackage {
```
+## NumericLiteralConvention
+
+**Since:** PMD 6.9
+
+**Priority:** Medium (3)
+
+Numeric literals with more than 3 digits must use '_' as a separator.
+
+**This rule is defined by the following XPath expression:**
+``` xpath
+//Literal[@IntLiteral = true() or
+ @LongLiteral = true() or
+ @DoubleLiteral = true() or
+ @FloatLiteral = true()]
+ [not(matches(@Image, "^[0-9]{1,3}(_[0-9]{3})*(l|L)?(\.[0-9]+)?(d|D|f|F)?$"))]
+```
+
+**Example(s):**
+
+``` java
+public class Foo {
+ private int num = 1000000; // should be 1_000_000
+}
+```
+
+**Use this rule by referencing it:**
+``` xml
+
+```
+
## OnlyOneReturn
**Since:** PMD 1.0
diff --git a/pmd-java/src/main/resources/category/java/codestyle.xml b/pmd-java/src/main/resources/category/java/codestyle.xml
index 9a9138a4f0..08c7baa296 100644
--- a/pmd-java/src/main/resources/category/java/codestyle.xml
+++ b/pmd-java/src/main/resources/category/java/codestyle.xml
@@ -1351,6 +1351,38 @@ public class ClassInDefaultPackage {
+
+
+ Numeric literals with more than 3 digits must use '_' as a separator.
+
+ 3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+ 1
+
+
+
+
+ 1
+
+
+
+
+ 0
+
+
+
+
+ 1
+
+
+
+
+ 0
+
+
+
From 8f1a44063d031b5157b17774ab03a62a10527ad7 Mon Sep 17 00:00:00 2001
From: rajeshggwp
Date: Sun, 14 Oct 2018 12:17:17 +0530
Subject: [PATCH 002/139] minor changes and more test cases
---
docs/pages/pmd/rules/java/codestyle.md | 6 +-
.../resources/category/java/codestyle.xml | 5 +-
.../xml/NumericLiteralConvention.xml | 72 +++++++++++++++++++
3 files changed, 79 insertions(+), 4 deletions(-)
diff --git a/docs/pages/pmd/rules/java/codestyle.md b/docs/pages/pmd/rules/java/codestyle.md
index 1b23f7732b..4cd706857c 100644
--- a/docs/pages/pmd/rules/java/codestyle.md
+++ b/docs/pages/pmd/rules/java/codestyle.md
@@ -1507,10 +1507,12 @@ public class ClassInDefaultPackage {
## NumericLiteralConvention
-**Since:** PMD 6.9
+**Since:** PMD 6.9.0
**Priority:** Medium (3)
+**Minimum Language Version:** Java 1.7
+
Numeric literals with more than 3 digits must use '_' as a separator.
**This rule is defined by the following XPath expression:**
@@ -1519,7 +1521,7 @@ Numeric literals with more than 3 digits must use '_' as a separator.
@LongLiteral = true() or
@DoubleLiteral = true() or
@FloatLiteral = true()]
- [not(matches(@Image, "^[0-9]{1,3}(_[0-9]{3})*(l|L)?(\.[0-9]+)?(d|D|f|F)?$"))]
+ [not(matches(@Image, "^[0-9]{1,3}(_[0-9]{3})*(l|L|\.[0-9]+)?(d|D|f|F)?$"))]
```
**Example(s):**
diff --git a/pmd-java/src/main/resources/category/java/codestyle.xml b/pmd-java/src/main/resources/category/java/codestyle.xml
index 08c7baa296..82d2aa9f96 100644
--- a/pmd-java/src/main/resources/category/java/codestyle.xml
+++ b/pmd-java/src/main/resources/category/java/codestyle.xml
@@ -1353,7 +1353,8 @@ public class ClassInDefaultPackage {
@@ -1369,7 +1370,7 @@ public class ClassInDefaultPackage {
@LongLiteral = true() or
@DoubleLiteral = true() or
@FloatLiteral = true()]
- [not(matches(@Image, "^[0-9]{1,3}(_[0-9]{3})*(l|L)?(\.[0-9]+)?(d|D|f|F)?$"))]
+ [not(matches(@Image, "^[0-9]{1,3}(_[0-9]{3})*(l|L|\.[0-9]+)?(d|D|f|F)?$"))]
]]>
diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/NumericLiteralConvention.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/NumericLiteralConvention.xml
index 2f2dbd74dd..f51d60d38c 100644
--- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/NumericLiteralConvention.xml
+++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/codestyle/xml/NumericLiteralConvention.xml
@@ -70,6 +70,78 @@ public class Foo {
private callBar() {
bar(314_159_265.359);
}
+}
+ ]]>
+
+
+
+ 0
+
+
+
+
+ 1
+
+
+
+
+ 0
+
+
+
+
+ 0
+
+
+
+
+ 0
+
+
+
+
+ 0
+
From 6cdb4a1002cdaf355502d089d652437770364340 Mon Sep 17 00:00:00 2001
From: rajeshggwp
Date: Sun, 14 Oct 2018 23:41:41 +0530
Subject: [PATCH 003/139] #1232 changes required after merging with master
---
.../rule/codestyle/NumericLiteralConventionTest.java | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/NumericLiteralConventionTest.java
diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/NumericLiteralConventionTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/NumericLiteralConventionTest.java
new file mode 100644
index 0000000000..b753bad7d9
--- /dev/null
+++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/codestyle/NumericLiteralConventionTest.java
@@ -0,0 +1,11 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+
+package net.sourceforge.pmd.lang.java.rule.codestyle;
+
+import net.sourceforge.pmd.testframework.PmdRuleTst;
+
+public class NumericLiteralConventionTest extends PmdRuleTst {
+ // no additional unit tests
+}
From d1a41ffd351cefb80eafd8ff483d4238c681f607 Mon Sep 17 00:00:00 2001
From: rajeshggwp
Date: Mon, 15 Oct 2018 01:46:47 +0530
Subject: [PATCH 004/139] #1232 added xpath version property and more test
cases
---
.../resources/category/java/codestyle.xml | 1 +
.../xml/NumericLiteralConvention.xml | 22 +++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/pmd-java/src/main/resources/category/java/codestyle.xml b/pmd-java/src/main/resources/category/java/codestyle.xml
index 82d2aa9f96..d31da8bdad 100644
--- a/pmd-java/src/main/resources/category/java/codestyle.xml
+++ b/pmd-java/src/main/resources/category/java/codestyle.xml
@@ -1363,6 +1363,7 @@ public class ClassInDefaultPackage {
3
+
+
+
+
+ 0
+
+
+
+
+ 0
+
From 6e3ee3c85740cb51ee59b454463f0a7ab8788a76 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Sun, 28 Oct 2018 00:02:27 +0200
Subject: [PATCH 005/139] Tag XPath implementation as private API
---
.../pmd/lang/ast/xpath/AbstractASTXPathHandler.java | 4 ++++
.../pmd/lang/ast/xpath/AttributeAxisIterator.java | 5 +++++
.../pmd/lang/ast/xpath/DefaultASTXPathHandler.java | 5 +++++
.../sourceforge/pmd/lang/ast/xpath/DocumentNavigator.java | 3 +++
.../net/sourceforge/pmd/lang/ast/xpath/NodeIterator.java | 3 +++
.../pmd/lang/ast/xpath/saxon/AbstractNodeInfo.java | 4 ++++
.../pmd/lang/ast/xpath/saxon/AttributeAxisIterator.java | 3 +++
.../sourceforge/pmd/lang/ast/xpath/saxon/AttributeNode.java | 3 +++
.../sourceforge/pmd/lang/ast/xpath/saxon/DocumentNode.java | 3 +++
.../sourceforge/pmd/lang/ast/xpath/saxon/ElementNode.java | 3 +++
.../sourceforge/pmd/lang/ast/xpath/saxon/IdGenerator.java | 5 +++++
11 files changed, 41 insertions(+)
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AbstractASTXPathHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AbstractASTXPathHandler.java
index 4c9fad1fdf..f4c1e8ddbe 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AbstractASTXPathHandler.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AbstractASTXPathHandler.java
@@ -6,11 +6,15 @@ package net.sourceforge.pmd.lang.ast.xpath;
import org.jaxen.Navigator;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.XPathHandler;
import net.sf.saxon.sxpath.IndependentContext;
+
+@Deprecated
+@InternalApi
public abstract class AbstractASTXPathHandler implements XPathHandler {
@Override
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIterator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIterator.java
index 2a93c13ba5..75807ecd71 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIterator.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIterator.java
@@ -14,6 +14,7 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
@@ -22,7 +23,11 @@ import net.sourceforge.pmd.lang.ast.Node;
* attributes. This is the default way the attributes of a node
* are made accessible to XPath rules, and defines an important
* piece of PMD's XPath support.
+ *
+ * @deprecated Use {@link Node#getXPathAttributesIterator()}
*/
+@Deprecated
+@InternalApi
public class AttributeAxisIterator implements Iterator {
/** Caches the precomputed attribute accessors of a given class. */
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/DefaultASTXPathHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/DefaultASTXPathHandler.java
index 4bf033c437..974d426e80 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/DefaultASTXPathHandler.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/DefaultASTXPathHandler.java
@@ -4,8 +4,13 @@
package net.sourceforge.pmd.lang.ast.xpath;
+import net.sourceforge.pmd.annotation.InternalApi;
+
import net.sf.saxon.sxpath.IndependentContext;
+
+@Deprecated
+@InternalApi
public class DefaultASTXPathHandler extends AbstractASTXPathHandler {
@Override
public void initialize() {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/DocumentNavigator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/DocumentNavigator.java
index 9fcdcf2163..4f90c2cac7 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/DocumentNavigator.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/DocumentNavigator.java
@@ -11,12 +11,15 @@ import org.jaxen.DefaultNavigator;
import org.jaxen.XPath;
import org.jaxen.util.SingleObjectIterator;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.ast.RootNode;
/**
* @author daniels
*/
+@Deprecated
+@InternalApi
public class DocumentNavigator extends DefaultNavigator {
private static final Iterator EMPTY_ITERATOR = new ArrayList().iterator();
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/NodeIterator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/NodeIterator.java
index 2d189cfcef..c442baa8ed 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/NodeIterator.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/NodeIterator.java
@@ -7,6 +7,7 @@ package net.sourceforge.pmd.lang.ast.xpath;
import java.util.Iterator;
import java.util.NoSuchElementException;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
/**
@@ -15,6 +16,8 @@ import net.sourceforge.pmd.lang.ast.Node;
*
* @author daniels
*/
+@Deprecated
+@InternalApi
public abstract class NodeIterator implements Iterator {
private Node node;
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AbstractNodeInfo.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AbstractNodeInfo.java
index d309e65b68..1e7c8e0825 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AbstractNodeInfo.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AbstractNodeInfo.java
@@ -4,6 +4,8 @@
package net.sourceforge.pmd.lang.ast.xpath.saxon;
+import net.sourceforge.pmd.annotation.InternalApi;
+
import net.sf.saxon.Configuration;
import net.sf.saxon.event.Receiver;
import net.sf.saxon.om.Axis;
@@ -27,6 +29,8 @@ import net.sf.saxon.value.Value;
* useful implementations, such as {@link #iterateAxis(byte, NodeTest)} and
* {@link #isSameNodeInfo(NodeInfo)}.
*/
+@Deprecated
+@InternalApi
public class AbstractNodeInfo implements VirtualNode, SiblingCountingNode {
@Override
public String getSystemId() {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeAxisIterator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeAxisIterator.java
index ada6ed8a78..9a0e23baf1 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeAxisIterator.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeAxisIterator.java
@@ -6,6 +6,7 @@ package net.sourceforge.pmd.lang.ast.xpath.saxon;
import java.util.Iterator;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.xpath.Attribute;
import net.sf.saxon.om.Navigator;
@@ -15,6 +16,8 @@ import net.sf.saxon.om.SequenceIterator;
* An adapter over our {@link net.sourceforge.pmd.lang.ast.xpath.AttributeAxisIterator}
* for the Saxon model.
*/
+@Deprecated
+@InternalApi
public class AttributeAxisIterator extends Navigator.BaseEnumeration {
protected final ElementNode startNodeInfo;
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeNode.java
index 69e93cddb4..fc36cf6b24 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeNode.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/AttributeNode.java
@@ -4,6 +4,7 @@
package net.sourceforge.pmd.lang.ast.xpath.saxon;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.xpath.Attribute;
import net.sourceforge.pmd.lang.rule.xpath.SaxonXPathRuleQuery;
@@ -18,6 +19,8 @@ import net.sf.saxon.value.Value;
* Belongs to an {@link ElementNode}, and wraps an
* {@link Attribute}.
*/
+@Deprecated
+@InternalApi
public class AttributeNode extends AbstractNodeInfo {
protected final Attribute attribute;
protected final int id;
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/DocumentNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/DocumentNode.java
index d3aa3bfb5d..f91718c816 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/DocumentNode.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/DocumentNode.java
@@ -8,6 +8,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sf.saxon.om.Axis;
@@ -21,6 +22,8 @@ import net.sf.saxon.type.Type;
/**
* A Saxon OM Document node for an AST Node.
*/
+@Deprecated
+@InternalApi
public class DocumentNode extends AbstractNodeInfo implements DocumentInfo {
/**
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/ElementNode.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/ElementNode.java
index 73b4dbf606..60960f4f4b 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/ElementNode.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/ElementNode.java
@@ -4,6 +4,7 @@
package net.sourceforge.pmd.lang.ast.xpath.saxon;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sf.saxon.om.Axis;
@@ -19,6 +20,8 @@ import net.sf.saxon.type.Type;
/**
* A Saxon OM Element type node for an AST Node.
*/
+@Deprecated
+@InternalApi
public class ElementNode extends AbstractNodeInfo {
protected final DocumentNode document;
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/IdGenerator.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/IdGenerator.java
index a014729421..afb0886811 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/IdGenerator.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/ast/xpath/saxon/IdGenerator.java
@@ -4,9 +4,14 @@
package net.sourceforge.pmd.lang.ast.xpath.saxon;
+import net.sourceforge.pmd.annotation.InternalApi;
+
+
/**
* This class is used to generate unique IDs for nodes.
*/
+@Deprecated
+@InternalApi
public class IdGenerator {
private int id;
From c3113894cf9335d9d41f79365db88d3075edeb35 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Mon, 29 Oct 2018 23:20:24 +0100
Subject: [PATCH 006/139] Tweak RulesetWriter to recognize himself externally
defined descriptors
---
.../java/net/sourceforge/pmd/RuleSetWriter.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java
index 70f6f23b41..0fba770e94 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java
@@ -248,7 +248,7 @@ public class RuleSetWriter {
Element priorityElement = createPriorityElement(priority);
ruleElement.appendChild(priorityElement);
}
- Element propertiesElement = createPropertiesElement(propertyDescriptors, propertiesByPropertyDescriptor);
+ Element propertiesElement = createPropertiesElement(propertyDescriptors, propertiesByPropertyDescriptor, XPathRule.class.getName().equals(clazz));
if (propertiesElement != null) {
ruleElement.appendChild(propertiesElement);
}
@@ -271,9 +271,18 @@ public class RuleSetWriter {
return ruleSetReferenceElement;
}
+ // We consider that any descriptor defined on something else than an XPath rule
+ // declaration is an error and don't care if it's output or not
+ private static boolean isExternallyDefined(boolean isXPathRule, PropertyDescriptor> descriptor) {
+ return isXPathRule && !(descriptor.equals(XPathRule.XPATH_DESCRIPTOR)
+ || descriptor.equals(XPathRule.VERSION_DESCRIPTOR)
+ || descriptor.equals(XPathRule.VIOLATION_SUPPRESS_REGEX_DESCRIPTOR)
+ || descriptor.equals(XPathRule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR));
+ }
+
@SuppressWarnings("PMD.CompareObjectsWithEquals")
private Element createPropertiesElement(List> propertyDescriptors,
- Map, Object> propertiesByPropertyDescriptor) {
+ Map, Object> propertiesByPropertyDescriptor, boolean isXPathRule) {
Element propertiesElement = null;
if (propertyDescriptors != null) {
@@ -281,7 +290,7 @@ public class RuleSetWriter {
for (PropertyDescriptor> propertyDescriptor : propertyDescriptors) {
// For each provided PropertyDescriptor
- if (propertyDescriptor.isDefinedExternally()) {
+ if (isExternallyDefined(isXPathRule, propertyDescriptor)) {
// Any externally defined property needs to go out as a definition.
if (propertiesElement == null) {
propertiesElement = createPropertiesElement();
From 9d954fff0a21a35c59f160504e49497dbe941128 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Tue, 30 Oct 2018 00:01:01 +0100
Subject: [PATCH 007/139] Deprecate isDefinedExternally
---
.../net/sourceforge/pmd/properties/PropertyDescriptor.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
index 09d501e01c..bda1597bd7 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
@@ -154,8 +154,14 @@ public interface PropertyDescriptor extends Comparable>
* to write out the property correctly: if it was defined externally, then its definition must be written out,
* otherwise only its value.
*
+ * @deprecated Not supported anymore. Behaviour may be wrong.
+ * Property descriptors should only be defined in the XML when defining an XPath rule.
+ * Other uses are unspecified, but should cause an error. That means, PropertyDescriptors
+ * don't need to carry this value around, and since this has proven to add very much
+ * boilerplate, we're removing it.
* @return True if the descriptor was defined in xml
*/
+ @Deprecated
boolean isDefinedExternally();
}
From 994c8462d09e8417a4da87f5e963dfb689249f78 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Tue, 30 Oct 2018 00:12:00 +0100
Subject: [PATCH 008/139] Deprecate preferredRowCount
---
.../java/net/sourceforge/pmd/properties/PropertyDescriptor.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
index bda1597bd7..adcdd6d14a 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
@@ -136,8 +136,10 @@ public interface PropertyDescriptor extends Comparable>
* If the datatype is a String then return the preferred number of rows to allocate in the text widget, returns a
* value of one for all other types. Useful for multi-line XPATH editors.
*
+ * @deprecated Was never implemented, and is none of the descriptor's concern
* @return int
*/
+ @Deprecated
int preferredRowCount();
From 8563c802c461173bc1810bab3ac9b097203734f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Tue, 30 Oct 2018 00:17:00 +0100
Subject: [PATCH 009/139] update release notes
---
docs/pages/release_notes.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md
index b8f8783555..97ed71baa1 100644
--- a/docs/pages/release_notes.md
+++ b/docs/pages/release_notes.md
@@ -18,6 +18,9 @@ This is a {{ site.pmd.release_type }} release.
### API Changes
+* The implementation of the adapters for the XPath engines Saxon and Jaxen (package net.sourceforge.pmd.lang.ast.xpath)
+ are now deprecated. They'll be moved to an internal package come 7.0.0. Only Attribute remains public API.
+
### External Contributions
{% endtocmaker %}
From d4b0d79cea6a9fdc301f81f9480a965c176734ac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Tue, 30 Oct 2018 08:33:03 +0100
Subject: [PATCH 010/139] Revert
---
.../java/net/sourceforge/pmd/RuleSetWriter.java | 15 +++------------
.../pmd/properties/PropertyDescriptor.java | 8 ++------
2 files changed, 5 insertions(+), 18 deletions(-)
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java
index 0fba770e94..70f6f23b41 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetWriter.java
@@ -248,7 +248,7 @@ public class RuleSetWriter {
Element priorityElement = createPriorityElement(priority);
ruleElement.appendChild(priorityElement);
}
- Element propertiesElement = createPropertiesElement(propertyDescriptors, propertiesByPropertyDescriptor, XPathRule.class.getName().equals(clazz));
+ Element propertiesElement = createPropertiesElement(propertyDescriptors, propertiesByPropertyDescriptor);
if (propertiesElement != null) {
ruleElement.appendChild(propertiesElement);
}
@@ -271,18 +271,9 @@ public class RuleSetWriter {
return ruleSetReferenceElement;
}
- // We consider that any descriptor defined on something else than an XPath rule
- // declaration is an error and don't care if it's output or not
- private static boolean isExternallyDefined(boolean isXPathRule, PropertyDescriptor> descriptor) {
- return isXPathRule && !(descriptor.equals(XPathRule.XPATH_DESCRIPTOR)
- || descriptor.equals(XPathRule.VERSION_DESCRIPTOR)
- || descriptor.equals(XPathRule.VIOLATION_SUPPRESS_REGEX_DESCRIPTOR)
- || descriptor.equals(XPathRule.VIOLATION_SUPPRESS_XPATH_DESCRIPTOR));
- }
-
@SuppressWarnings("PMD.CompareObjectsWithEquals")
private Element createPropertiesElement(List> propertyDescriptors,
- Map, Object> propertiesByPropertyDescriptor, boolean isXPathRule) {
+ Map, Object> propertiesByPropertyDescriptor) {
Element propertiesElement = null;
if (propertyDescriptors != null) {
@@ -290,7 +281,7 @@ public class RuleSetWriter {
for (PropertyDescriptor> propertyDescriptor : propertyDescriptors) {
// For each provided PropertyDescriptor
- if (isExternallyDefined(isXPathRule, propertyDescriptor)) {
+ if (propertyDescriptor.isDefinedExternally()) {
// Any externally defined property needs to go out as a definition.
if (propertiesElement == null) {
propertiesElement = createPropertiesElement();
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
index adcdd6d14a..98adff86fd 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
@@ -136,7 +136,7 @@ public interface PropertyDescriptor extends Comparable>
* If the datatype is a String then return the preferred number of rows to allocate in the text widget, returns a
* value of one for all other types. Useful for multi-line XPATH editors.
*
- * @deprecated Was never implemented, and is none of the descriptor's concern
+ * @deprecated Was never implemented, and is none of the descriptor's concern. Will be removed with 7.0.0
* @return int
*/
@Deprecated
@@ -156,11 +156,7 @@ public interface PropertyDescriptor extends Comparable>
* to write out the property correctly: if it was defined externally, then its definition must be written out,
* otherwise only its value.
*
- * @deprecated Not supported anymore. Behaviour may be wrong.
- * Property descriptors should only be defined in the XML when defining an XPath rule.
- * Other uses are unspecified, but should cause an error. That means, PropertyDescriptors
- * don't need to carry this value around, and since this has proven to add very much
- * boilerplate, we're removing it.
+ * @deprecated May be removed with 7.0.0
* @return True if the descriptor was defined in xml
*/
@Deprecated
From d5d51469c42c5ba0387487ee5de111c5969f1edf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Tue, 30 Oct 2018 08:50:14 +0100
Subject: [PATCH 011/139] Deprecate some other stuff
---
.../pmd/properties/AbstractMultiNumericProperty.java | 1 +
.../pmd/properties/AbstractMultiPackagedProperty.java | 1 +
.../pmd/properties/AbstractNumericProperty.java | 1 +
.../pmd/properties/AbstractPackagedProperty.java | 1 +
.../pmd/properties/EnumeratedPropertyDescriptor.java | 1 +
.../sourceforge/pmd/properties/FloatMultiProperty.java | 2 ++
.../net/sourceforge/pmd/properties/FloatProperty.java | 3 ++-
.../sourceforge/pmd/properties/MethodMultiProperty.java | 1 +
.../net/sourceforge/pmd/properties/MethodProperty.java | 2 ++
.../pmd/properties/NumericPropertyDescriptor.java | 1 +
.../pmd/properties/PackagedPropertyDescriptor.java | 1 +
.../sourceforge/pmd/properties/PropertyDescriptor.java | 4 ++++
.../pmd/properties/PropertyDescriptorField.java | 2 ++
.../net/sourceforge/pmd/properties/PropertyTypeId.java | 8 +++++++-
.../net/sourceforge/pmd/properties/TypeMultiProperty.java | 3 ++-
.../java/net/sourceforge/pmd/properties/TypeProperty.java | 2 ++
.../sourceforge/pmd/properties/ValueParserConstants.java | 4 ++++
.../properties/builders/MultiNumericPropertyBuilder.java | 1 +
.../properties/builders/MultiPackagedPropertyBuilder.java | 1 +
.../PropertyDescriptorBuilderConversionWrapper.java | 1 +
.../builders/PropertyDescriptorExternalBuilder.java | 1 +
.../properties/builders/SingleNumericPropertyBuilder.java | 1 +
.../builders/SinglePackagedPropertyBuilder.java | 1 +
.../pmd/properties/modules/EnumeratedPropertyModule.java | 1 +
.../pmd/properties/modules/MethodPropertyModule.java | 1 +
.../pmd/properties/modules/NumericPropertyModule.java | 1 +
.../pmd/properties/modules/PackagedPropertyModule.java | 1 +
.../pmd/properties/modules/TypePropertyModule.java | 1 +
28 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractMultiNumericProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractMultiNumericProperty.java
index b72bb6b4cd..2f2d212aff 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractMultiNumericProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractMultiNumericProperty.java
@@ -19,6 +19,7 @@ import net.sourceforge.pmd.properties.modules.NumericPropertyModule;
* @author Clément Fournier
* @version Refactored June 2017 (6.0.0)
*/
+@Deprecated
/* default */ abstract class AbstractMultiNumericProperty extends AbstractMultiValueProperty
implements NumericPropertyDescriptor> {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractMultiPackagedProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractMultiPackagedProperty.java
index a9183adcae..31882c325e 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractMultiPackagedProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractMultiPackagedProperty.java
@@ -19,6 +19,7 @@ import net.sourceforge.pmd.properties.modules.PackagedPropertyModule;
* @author Clément Fournier
* @version Refactored June 2017 (6.0.0)
*/
+@Deprecated
/* default */ abstract class AbstractMultiPackagedProperty extends AbstractMultiValueProperty
implements PackagedPropertyDescriptor> {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractNumericProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractNumericProperty.java
index 9c6c42f9d3..866d88fcca 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractNumericProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractNumericProperty.java
@@ -18,6 +18,7 @@ import net.sourceforge.pmd.properties.modules.NumericPropertyModule;
* @author Clément Fournier
* @version Refactored June 2017 (6.0.0)
*/
+@Deprecated
/* default */ abstract class AbstractNumericProperty extends AbstractSingleValueProperty
implements NumericPropertyDescriptor {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractPackagedProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractPackagedProperty.java
index 3d498026a1..94921e7eae 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractPackagedProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractPackagedProperty.java
@@ -19,6 +19,7 @@ import net.sourceforge.pmd.properties.modules.PackagedPropertyModule;
* @author Clément Fournier
* @version Refactored June 2017 (6.0.0)
*/
+@Deprecated
/* default */ abstract class AbstractPackagedProperty extends AbstractSingleValueProperty
implements PackagedPropertyDescriptor {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/EnumeratedPropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/EnumeratedPropertyDescriptor.java
index 0736db2c4d..c069542aac 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/EnumeratedPropertyDescriptor.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/EnumeratedPropertyDescriptor.java
@@ -16,6 +16,7 @@ import java.util.Map;
* @author Clément Fournier
* @since 6.0.0
*/
+@Deprecated
public interface EnumeratedPropertyDescriptor extends PropertyDescriptor {
/**
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatMultiProperty.java
index 4c06a0f107..ef8c60ac6b 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatMultiProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatMultiProperty.java
@@ -16,7 +16,9 @@ import net.sourceforge.pmd.properties.builders.PropertyDescriptorBuilderConversi
*
* @author Brian Remedios
* @version Refactored June 2017 (6.0.0)
+ * @deprecated Use {@link DoubleMultiProperty}
*/
+@Deprecated
public final class FloatMultiProperty extends AbstractMultiNumericProperty {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatProperty.java
index a3ce5de9a1..19ced229aa 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatProperty.java
@@ -12,9 +12,10 @@ import net.sourceforge.pmd.properties.builders.SingleNumericPropertyBuilder;
/**
* Defines a property type that supports single float property values within an upper and lower boundary.
- *
+ * @deprecated Use {@link DoubleProperty}
* @author Brian Remedios
*/
+@Deprecated
public final class FloatProperty extends AbstractNumericProperty {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodMultiProperty.java
index bac24a7efb..1a0248a07d 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodMultiProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodMultiProperty.java
@@ -24,6 +24,7 @@ import net.sourceforge.pmd.properties.modules.MethodPropertyModule;
* @author Brian Remedios
* @version Refactored June 2017 (6.0.0)
*/
+@Deprecated
public final class MethodMultiProperty extends AbstractMultiPackagedProperty {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodProperty.java
index 66cc0bed81..697f4eadb3 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodProperty.java
@@ -21,9 +21,11 @@ import net.sourceforge.pmd.properties.modules.MethodPropertyModule;
* Rule developers can limit the rules to those within designated packages per the 'legalPackages' argument in the
* constructor which can be an array of partial package names, i.e., ["java.lang", "com.mycompany" ].
*
+ * @deprecated Not useful, will be remove by 7.0.0
* @author Brian Remedios
* @version Refactored June 2017 (6.0.0)
*/
+@Deprecated
public final class MethodProperty extends AbstractPackagedProperty {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericPropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericPropertyDescriptor.java
index 99959662a9..1fdb507fa9 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericPropertyDescriptor.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericPropertyDescriptor.java
@@ -12,6 +12,7 @@ package net.sourceforge.pmd.properties;
* @author Brian Remedios
* @author Clément Fournier
*/
+@Deprecated
public interface NumericPropertyDescriptor extends PropertyDescriptor {
/**
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PackagedPropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PackagedPropertyDescriptor.java
index bfc42fc402..e650d9a9b9 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PackagedPropertyDescriptor.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PackagedPropertyDescriptor.java
@@ -12,6 +12,7 @@ package net.sourceforge.pmd.properties;
*
* @author Clément Fournier
*/
+@Deprecated
public interface PackagedPropertyDescriptor extends PropertyDescriptor {
/** Delimiter used to separate package names. */
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
index 98adff86fd..a7e7a01552 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
@@ -8,6 +8,7 @@ import java.util.Map;
import net.sourceforge.pmd.Rule;
import net.sourceforge.pmd.RuleSetWriter;
+import net.sourceforge.pmd.annotation.InternalApi;
/**
@@ -146,8 +147,10 @@ public interface PropertyDescriptor extends Comparable>
/**
* Returns a map representing all the property attributes of the receiver in string form.
*
+ * @deprecated Will be removed with 7.0.0
* @return map
*/
+ @Deprecated
Map attributeValuesById();
@@ -160,6 +163,7 @@ public interface PropertyDescriptor extends Comparable>
* @return True if the descriptor was defined in xml
*/
@Deprecated
+ @InternalApi
boolean isDefinedExternally();
}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptorField.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptorField.java
index e1d3f1dd09..8a01f07572 100755
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptorField.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptorField.java
@@ -16,7 +16,9 @@ import net.sourceforge.pmd.RuleSetFactory;
* @author Brian Remedios
* @see RuleSetFactory
* @see PropertyTypeId
+ * @deprecated Will be removed with 7.0.0
*/
+@Deprecated
public enum PropertyDescriptorField {
/** The type of the property. */
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyTypeId.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyTypeId.java
index dfe151fead..21b848fde8 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyTypeId.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyTypeId.java
@@ -37,14 +37,17 @@ public enum PropertyTypeId {
INTEGER_LIST("List[Integer]", IntegerMultiProperty.extractor(), ValueParserConstants.INTEGER_PARSER),
LONG("Long", LongProperty.extractor(), ValueParserConstants.LONG_PARSER),
LONG_LIST("List[Long]", LongMultiProperty.extractor(), ValueParserConstants.LONG_PARSER),
+ @Deprecated
FLOAT("Float", FloatProperty.extractor(), ValueParserConstants.FLOAT_PARSER),
+ @Deprecated
FLOAT_LIST("List[Float]", FloatMultiProperty.extractor(), ValueParserConstants.FLOAT_PARSER),
DOUBLE("Double", DoubleProperty.extractor(), ValueParserConstants.DOUBLE_PARSER),
DOUBLE_LIST("List[Double]", DoubleMultiProperty.extractor(), ValueParserConstants.DOUBLE_PARSER),
// ENUM("Enum", EnumeratedProperty.FACTORY), // TODO:cf we need new syntax in the xml to support that
// ENUM_LIST("List[Enum]", EnumeratedMultiProperty.FACTORY),
-
+ @Deprecated
CLASS("Class", TypeProperty.extractor(), ValueParserConstants.CLASS_PARSER),
+ @Deprecated
CLASS_LIST("List[Class]", TypeMultiProperty.extractor(), ValueParserConstants.CLASS_PARSER);
@@ -85,6 +88,7 @@ public enum PropertyTypeId {
*
* @return The factory
*/
+ @Deprecated
public PropertyDescriptorExternalBuilder> getFactory() {
return factory;
}
@@ -96,6 +100,7 @@ public enum PropertyTypeId {
*
* @return whether the property is numeric
*/
+ @Deprecated
public boolean isPropertyNumeric() {
return factory instanceof PropertyDescriptorBuilderConversionWrapper.SingleValue.Numeric
|| factory instanceof PropertyDescriptorBuilderConversionWrapper.MultiValue.Numeric;
@@ -108,6 +113,7 @@ public enum PropertyTypeId {
*
* @return whether the property is packaged
*/
+ @Deprecated
public boolean isPropertyPackaged() {
return factory instanceof PropertyDescriptorBuilderConversionWrapper.SingleValue.Packaged
|| factory instanceof PropertyDescriptorBuilderConversionWrapper.MultiValue.Packaged;
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeMultiProperty.java
index 5e53397e4a..f38dbbbf0f 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeMultiProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeMultiProperty.java
@@ -15,9 +15,10 @@ import net.sourceforge.pmd.properties.modules.TypePropertyModule;
* Defines a property that supports multiple class types, even for primitive values!
*
* TODO - untested for array types
- *
+ * @deprecated Not useful, will be removed by 7.0.0
* @author Brian Remedios
*/
+@Deprecated
public final class TypeMultiProperty extends AbstractMultiPackagedProperty {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeProperty.java
index a7d2ef2898..ed3f5ca3b8 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeProperty.java
@@ -17,7 +17,9 @@ import net.sourceforge.pmd.properties.modules.TypePropertyModule;
* TODO - untested for array types
*
* @author Brian Remedios
+ * @deprecated Not useful, will be removed by 7.0.0
*/
+@Deprecated
public final class TypeProperty extends AbstractPackagedProperty {
/**
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/ValueParserConstants.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/ValueParserConstants.java
index b4f60a7f6e..b452499082 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/ValueParserConstants.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/ValueParserConstants.java
@@ -18,13 +18,17 @@ import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.util.ClassUtil;
/**
+ * @deprecated Was internal API
* @author Clément Fournier
* @since 6.0.0
*/
+@Deprecated
+@InternalApi
public final class ValueParserConstants {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/MultiNumericPropertyBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/MultiNumericPropertyBuilder.java
index 8bcc2340c3..8769731240 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/MultiNumericPropertyBuilder.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/MultiNumericPropertyBuilder.java
@@ -13,6 +13,7 @@ import net.sourceforge.pmd.properties.MultiValuePropertyDescriptor;
* @param Element type of the list
* @param Concrete type of the underlying builder
*/
+@Deprecated
public abstract class MultiNumericPropertyBuilder>
extends MultiValuePropertyBuilder {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/MultiPackagedPropertyBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/MultiPackagedPropertyBuilder.java
index aad9f61895..9ce2836929 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/MultiPackagedPropertyBuilder.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/MultiPackagedPropertyBuilder.java
@@ -11,6 +11,7 @@ import java.util.Arrays;
* @author Clément Fournier
* @since 6.0.0
*/
+@Deprecated
public abstract class MultiPackagedPropertyBuilder>
extends MultiValuePropertyBuilder {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorBuilderConversionWrapper.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorBuilderConversionWrapper.java
index caf9beb9d6..0e8cfa3fd1 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorBuilderConversionWrapper.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorBuilderConversionWrapper.java
@@ -29,6 +29,7 @@ import net.sourceforge.pmd.properties.ValueParserConstants;
* @author Clément Fournier
* @since 6.0.0
*/
+@Deprecated
public abstract class PropertyDescriptorBuilderConversionWrapper>
implements PropertyDescriptorExternalBuilder {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorExternalBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorExternalBuilder.java
index 16ded67141..e45be1e5e0 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorExternalBuilder.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorExternalBuilder.java
@@ -18,6 +18,7 @@ import net.sourceforge.pmd.properties.PropertyDescriptorField;
* @author Clément Fournier
* @since 6.0.0
*/
+@Deprecated
public interface PropertyDescriptorExternalBuilder {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/SingleNumericPropertyBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/SingleNumericPropertyBuilder.java
index 4e4d450aed..78832baf3e 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/SingleNumericPropertyBuilder.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/SingleNumericPropertyBuilder.java
@@ -8,6 +8,7 @@ package net.sourceforge.pmd.properties.builders;
* @author Clément Fournier
* @since 6.0.0
*/
+@Deprecated
public abstract class SingleNumericPropertyBuilder>
extends SingleValuePropertyBuilder {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/SinglePackagedPropertyBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/SinglePackagedPropertyBuilder.java
index 2f7219d14c..85e8e3a272 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/SinglePackagedPropertyBuilder.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/SinglePackagedPropertyBuilder.java
@@ -12,6 +12,7 @@ import java.util.Collection;
* @author Clément Fournier
* @since 6.0.0
*/
+@Deprecated
public abstract class SinglePackagedPropertyBuilder>
extends SingleValuePropertyBuilder {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/EnumeratedPropertyModule.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/EnumeratedPropertyModule.java
index ff78fa232b..9836ceecb6 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/EnumeratedPropertyModule.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/EnumeratedPropertyModule.java
@@ -15,6 +15,7 @@ import net.sourceforge.pmd.util.CollectionUtil;
*
* @author Clément Fournier
*/
+@Deprecated
public class EnumeratedPropertyModule {
private final Map choicesByLabel;
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/MethodPropertyModule.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/MethodPropertyModule.java
index c2b1019055..bbca8d8a02 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/MethodPropertyModule.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/MethodPropertyModule.java
@@ -16,6 +16,7 @@ import net.sourceforge.pmd.util.ClassUtil;
*
* @author Clément Fournier
*/
+@Deprecated
public class MethodPropertyModule extends PackagedPropertyModule {
public static final char CLASS_METHOD_DELIMITER = '#';
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/NumericPropertyModule.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/NumericPropertyModule.java
index e37286f9a1..0b8a26c988 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/NumericPropertyModule.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/NumericPropertyModule.java
@@ -17,6 +17,7 @@ import net.sourceforge.pmd.properties.PropertyDescriptorField;
*
* @author Clément Fournier
*/
+@Deprecated
public class NumericPropertyModule {
private final T lowerLimit;
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/PackagedPropertyModule.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/PackagedPropertyModule.java
index a9c29a0ea6..5e90f6f4cc 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/PackagedPropertyModule.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/PackagedPropertyModule.java
@@ -24,6 +24,7 @@ import net.sourceforge.pmd.properties.PropertyDescriptorField;
*
* @author Clément Fournier
*/
+@Deprecated
public abstract class PackagedPropertyModule {
private static final Pattern PACKAGE_NAME_PATTERN = Pattern.compile("(\\w+)(\\.\\w+)*");
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/TypePropertyModule.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/TypePropertyModule.java
index 183357552e..52e4f5d87f 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/TypePropertyModule.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/modules/TypePropertyModule.java
@@ -12,6 +12,7 @@ import java.util.List;
*
* @author Clément Fournier
*/
+@Deprecated
public class TypePropertyModule extends PackagedPropertyModule {
public TypePropertyModule(String[] legalPackageNames, List defaults) {
From 5c398b825ed44f7aedd1aa8c994d3b27b88e15c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Tue, 30 Oct 2018 09:18:58 +0100
Subject: [PATCH 012/139] Add comments, update release notes
---
docs/pages/release_notes.md | 19 +++++++++++++++++++
.../EnumeratedPropertyDescriptor.java | 2 ++
.../pmd/properties/FileProperty.java | 2 ++
.../pmd/properties/FloatMultiProperty.java | 2 +-
.../pmd/properties/FloatProperty.java | 4 +++-
.../pmd/properties/MethodMultiProperty.java | 1 +
.../pmd/properties/MethodProperty.java | 1 +
.../properties/NumericPropertyDescriptor.java | 2 ++
.../pmd/properties/PropertyDescriptor.java | 2 ++
.../pmd/properties/TypeMultiProperty.java | 2 +-
.../pmd/properties/TypeProperty.java | 2 +-
11 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md
index 89a879949a..4e9f375bc3 100644
--- a/docs/pages/release_notes.md
+++ b/docs/pages/release_notes.md
@@ -21,6 +21,25 @@ This is a {{ site.pmd.release_type }} release.
### API Changes
+* Several classes and interfaces from the properties framework are now deprecated and will be removed with 7.0.0.
+ * MethodProperty, FloatProperty, FileProperty, TypeProperty and their multi-valued counterparts
+ are discontinued for lack of a use-case, and will probably not be replaced with 7.0.0.
+ Users of FloatProperty should consider using a DoubleProperty.
+ * EnumeratedPropertyDescriptor, NumericPropertyDescriptor, PackagedPropertyDescriptor, and the related builders
+ (in net.sourceforge.pmd.properties.builders) will be removed. In the future, these interfaces won't be around
+ but their functionality will, under another form. The related methods `PropertyTypeId#isPropertyNumeric` and
+ `PropertyTypeId#isPropertyPackaged` are also deprecated.
+ * All classes of net.sourceforge.pmd.properties.modules are deprecated and will be removed. They were
+ never intended as public api.
+ * The classes PropertyDescriptorField, PropertyDescriptorBuilderConversionWrapper, and the methods
+ `PropertyDescriptor#attributeValuesById`, `PropertyDescriptor#isDefinedExternally` and `PropertyTypeId#getFactory` are deprecated with no
+ intended replacement. These were used to read and write properties to and from XML, and were never
+ intended as public API.
+ * The class ValueParserConstants is deprecated with no intended replacement, it was not intended as
+ public API.
+ * The method `PropertyDescriptor#preferredRowCount` is deprecated with no intended replacement. It was
+ never implemented, and does not belong in this interface.
+
### External Contributions
{% endtocmaker %}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/EnumeratedPropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/EnumeratedPropertyDescriptor.java
index c069542aac..b8d17f99bd 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/EnumeratedPropertyDescriptor.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/EnumeratedPropertyDescriptor.java
@@ -15,6 +15,8 @@ import java.util.Map;
*
* @author Clément Fournier
* @since 6.0.0
+ * @deprecated Will be removed with 7.0.0. In the future this interface won't exist,
+ * but enumerated properties will still be around
*/
@Deprecated
public interface EnumeratedPropertyDescriptor extends PropertyDescriptor {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/FileProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/FileProperty.java
index 5720929625..7fc043e613 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/FileProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/FileProperty.java
@@ -17,7 +17,9 @@ import net.sourceforge.pmd.properties.builders.SinglePackagedPropertyBuilder;
*
* @author Brian Remedios
* @version Refactored June 2017 (6.0.0)
+ * @deprecated Will be removed with 7.0.0 with no scheduled replacement
*/
+@Deprecated
public final class FileProperty extends AbstractSingleValueProperty {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatMultiProperty.java
index ef8c60ac6b..9a166dc60d 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatMultiProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatMultiProperty.java
@@ -16,7 +16,7 @@ import net.sourceforge.pmd.properties.builders.PropertyDescriptorBuilderConversi
*
* @author Brian Remedios
* @version Refactored June 2017 (6.0.0)
- * @deprecated Use {@link DoubleMultiProperty}
+ * @deprecated Will be removed with 7.0.0 with no scheduled replacement. Users should use {@link DoubleMultiProperty} instead
*/
@Deprecated
public final class FloatMultiProperty extends AbstractMultiNumericProperty {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatProperty.java
index 19ced229aa..9f0990e24f 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/FloatProperty.java
@@ -12,7 +12,9 @@ import net.sourceforge.pmd.properties.builders.SingleNumericPropertyBuilder;
/**
* Defines a property type that supports single float property values within an upper and lower boundary.
- * @deprecated Use {@link DoubleProperty}
+ *
+ *
+ * @deprecated Will be removed with 7.0.0 with no scheduled replacement. Users should use {@link DoubleProperty} instead
* @author Brian Remedios
*/
@Deprecated
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodMultiProperty.java
index 1a0248a07d..8c2c3d2a6e 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodMultiProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodMultiProperty.java
@@ -23,6 +23,7 @@ import net.sourceforge.pmd.properties.modules.MethodPropertyModule;
*
* @author Brian Remedios
* @version Refactored June 2017 (6.0.0)
+ * @deprecated Will be removed with 7.0.0 with no scheduled replacement
*/
@Deprecated
public final class MethodMultiProperty extends AbstractMultiPackagedProperty {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodProperty.java
index 697f4eadb3..f42768eedb 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/MethodProperty.java
@@ -24,6 +24,7 @@ import net.sourceforge.pmd.properties.modules.MethodPropertyModule;
* @deprecated Not useful, will be remove by 7.0.0
* @author Brian Remedios
* @version Refactored June 2017 (6.0.0)
+ * @deprecated Will be removed with 7.0.0 with no scheduled replacement
*/
@Deprecated
public final class MethodProperty extends AbstractPackagedProperty {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericPropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericPropertyDescriptor.java
index 1fdb507fa9..d8b75e4089 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericPropertyDescriptor.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/NumericPropertyDescriptor.java
@@ -9,6 +9,8 @@ package net.sourceforge.pmd.properties;
*
* @param type of the property value
*
+ * @deprecated Will be removed with 7.0.0. In the future this interface won't exist,
+ * but numeric properties will still be around
* @author Brian Remedios
* @author Clément Fournier
*/
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
index a7e7a01552..aa93fb9da3 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
@@ -22,6 +22,8 @@ import net.sourceforge.pmd.annotation.InternalApi;
* Several interfaces further specialize the behaviour of descriptors to accommodate specific types of descriptors,
* see {@link NumericPropertyDescriptor} and {@link EnumeratedPropertyDescriptor}.
*
+ *
Upcoming API changes to the properties framework: see https://github.com/pmd/pmd/issues/1415
+ *
* @param type of the property's value. This is a list type for multi-valued properties.
*
* @author Brian Remedios
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeMultiProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeMultiProperty.java
index f38dbbbf0f..9899e00538 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeMultiProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeMultiProperty.java
@@ -15,7 +15,7 @@ import net.sourceforge.pmd.properties.modules.TypePropertyModule;
* Defines a property that supports multiple class types, even for primitive values!
*
* TODO - untested for array types
- * @deprecated Not useful, will be removed by 7.0.0
+ * @deprecated Will be removed with 7.0.0 with no scheduled replacement yet
* @author Brian Remedios
*/
@Deprecated
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeProperty.java
index ed3f5ca3b8..9b6cfc1113 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/TypeProperty.java
@@ -17,7 +17,7 @@ import net.sourceforge.pmd.properties.modules.TypePropertyModule;
* TODO - untested for array types
*
* @author Brian Remedios
- * @deprecated Not useful, will be removed by 7.0.0
+ * @deprecated Will be removed with 7.0.0 with no scheduled replacement yet
*/
@Deprecated
public final class TypeProperty extends AbstractPackagedProperty {
From a033b27e2e39a82136be893934bddab2890a143a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Mon, 29 Oct 2018 03:31:06 +0100
Subject: [PATCH 013/139] Add pmd 7.0.0 dev page to docs
---
docs/_data/sidebars/pmd_sidebar.yml | 3 +
docs/pages/next_major_development.md | 206 +++++++++++++++++++++++++++
docs/pages/release_notes.md | 2 +
docs/pages/release_notes_old.md | 3 +-
4 files changed, 212 insertions(+), 2 deletions(-)
create mode 100644 docs/pages/next_major_development.md
diff --git a/docs/_data/sidebars/pmd_sidebar.yml b/docs/_data/sidebars/pmd_sidebar.yml
index 7e01f5c0c4..593dc5e9a1 100644
--- a/docs/_data/sidebars/pmd_sidebar.yml
+++ b/docs/_data/sidebars/pmd_sidebar.yml
@@ -25,6 +25,9 @@ entries:
- title: Release notes
url: /pmd_release_notes.html
output: web, pdf
+ - title: PMD 7.0.0 development
+ url: /pmd_next_major_development.html
+ output: web, pdf
- title: Getting help
url: /pmd_about_help.html
output: web, pdf
diff --git a/docs/pages/next_major_development.md b/docs/pages/next_major_development.md
new file mode 100644
index 0000000000..c7abcaa68c
--- /dev/null
+++ b/docs/pages/next_major_development.md
@@ -0,0 +1,206 @@
+---
+title: PMD 7.0.0 development
+permalink: pmd_next_major_development.html
+keywords: changelog, release notes, deprecation, api changes
+---
+
+We're excited to bring you the next major version of PMD! Here are the major features and changes we're working on.
+To give us feedback or to suggest a new feature, drop us a line on [Gitter](https://gitter.im/pmd/pmd)!
+
+## New Features
+
+TODO
+
+## Java grammar changes
+
+{% include note.html content="Current plans are listed [here](https://github.com/pmd/pmd/labels/in%3Aast) and in particular [here](https://github.com/pmd/pmd/issues/1019)" %}
+
+
+
+## New API support guidelines
+
+### What's new
+
+Until now, all released public members and types were implicitly considered part
+of PMD's public API, including inheritance-specific members (protected members, abstract methods).
+We have maintained those APIs with the goal to preserve full binary compatibility between minor releases,
+only breaking those APIs infrequently, for major releases.
+
+In order to allow PMD to move forward at a faster pace, this implicit contract will
+be invalidated with PMD 7.0.0. We now introduce more fine-grained distinctions between
+the type of compatibility support we guarantee for our libraries, and ways to make
+them explicit to clients of PMD.
+
+#### `.internal` packages and `@InternalApi` annotation
+
+*Internal API* is meant for use *only* by the main PMD codebase. Internal types and methods
+may be modified in any way, or even removed, at any time.
+
+Any API in a package that contains an `.internal` segment is considered internal.
+The `@InternalApi` annotation will be used for APIs that have to live outside of
+these packages, e.g. methods of a public type that shouldn't be used outside of PMD (again,
+these can be removed anytime).
+
+#### `@ReservedSubclassing`
+
+Types marked with the `@ReservedSubclassing` annotation are only meant to be subclassed
+by classes within PMD. As such, we may add new abstract methods, or remove protected methods,
+at any time. All published public members remain supported. The annotation is *not* inherited, which
+means a reserved interface doesn't prevent its implementors to be subclassed.
+
+#### `@Experimental`
+
+APIs marked with the `@Experimental` annotation at the class or method level are subject to change.
+They can be modified in any way, or even removed, at any time. You should not use or rely
+ on them in any production code. They are purely to allow broad testing and feedback.
+
+#### `@Deprecated`
+
+APIs marked with the `@Deprecated` annotation at the class or method level will remain supported
+until the next major release but it is recommended to stop using them.
+
+### The transition
+
+*All currently supported APIs will remain so until 7.0.0*. All APIs that are to be moved to
+`.internal` packages or hidden will be tagged `@InternalApi` before that major release, and
+the breaking API changes will be performed in 7.0.0.
+
+## Planned API removals
+
+### List of currently deprecated APIs
+
+{% include warning.html content="This list is not exhaustive. The ultimate reference is whether
+an API is tagged as `@Deprecated` or not in the latest minor release. During the development of 7.0.0,
+we may decide to remove some APIs that were not tagged as deprecated, though we'll try to avoid it." %}
+
+#### 6.8.0
+
+* A couple of methods and fields in `net.sourceforge.pmd.properties.AbstractPropertySource` have been
+ deprecated, as they are replaced by already existing functionality or expose internal implementation
+ details: `propertyDescriptors`, `propertyValuesByDescriptor`,
+ `copyPropertyDescriptors()`, `copyPropertyValues()`, `ignoredProperties()`, `usesDefaultValues()`,
+ `useDefaultValueFor()`.
+
+* Some methods in `net.sourceforge.pmd.properties.PropertySource` have been deprecated as well:
+ `usesDefaultValues()`, `useDefaultValueFor()`, `ignoredProperties()`.
+
+* The class `net.sourceforge.pmd.lang.rule.AbstractDelegateRule` has been deprecated and will
+ be removed with PMD 7.0.0. It is internally only in use by RuleReference.
+
+* The default constructor of `net.sourceforge.pmd.lang.rule.RuleReference` has been deprecated
+ and will be removed with PMD 7.0.0. RuleReferences should only be created by providing a Rule and
+ a RuleSetReference. Furthermore the following methods are deprecated: `setRuleReference()`,
+ `hasOverriddenProperty()`, `usesDefaultValues()`, `useDefaultValueFor()`.
+
+#### 6.7.0
+
+* All classes in the package `net.sourceforge.pmd.lang.dfa.report` have been deprecated and will be removed
+ with PMD 7.0.0. This includes the class `net.sourceforge.pmd.lang.dfa.report.ReportTree`. The reason is,
+ that this class is very specific to Java and not suitable for other languages. It has only been used for
+ `YAHTMLRenderer`, which has been rewritten to work without these classes.
+
+* The nodes RUNSIGNEDSHIFT and RSIGNEDSHIFT are deprecated and will be removed from the AST with PMD 7.0.0.
+ These represented the operator of ShiftExpression in two cases out of three, but they're not needed and
+ make ShiftExpression inconsistent. The operator of a ShiftExpression is now accessible through
+ ShiftExpression#getOperator.
+
+#### 6.5.0
+
+* The utility class `net.sourceforge.pmd.lang.java.ast.CommentUtil` has been deprecated and will be removed
+ with PMD 7.0.0. Its methods have been intended to parse javadoc tags. A more useful solution will be added
+ around the AST node `FormalComment`, which contains as children `JavadocElement` nodes, which in
+ turn provide access to the `JavadocTag`.
+
+ All comment AST nodes (`FormalComment`, `MultiLineComment`, `SingleLineComment`) have a new method
+ `getFilteredComment()` which provide access to the comment text without the leading `/*` markers.
+
+* The method `AbstractCommentRule.tagsIndicesIn()` has been deprecated and will be removed with
+ PMD 7.0.0. It is not very useful, since it doesn't extract the information
+ in a useful way. You would still need check, which tags have been found, and with which
+ data they might be accompanied.
+
+#### 6.4.0
+
+* The following classes in package `net.sourceforge.pmd.benchmark` have been deprecated: `Benchmark`, `Benchmarker`,
+ `BenchmarkReport`, `BenchmarkResult`, `RuleDuration`, `StringBuilderCR` and `TextReport`. Their API is not supported anymore
+ and is disconnected from the internals of PMD. Use the newer API based around `TimeTracker` instead, which can be found
+ in the same package.
+* The class `net.sourceforge.pmd.lang.java.xpath.TypeOfFunction` has been deprecated. Use the newer `TypeIsFunction` in the same package.
+* The `typeof` methods in `net.sourceforge.pmd.lang.java.xpath.JavaFunctions` have been deprecated.
+ Use the newer `typeIs` method in the same class instead..
+* The methods `isA`, `isEither` and `isNeither` of `net.sourceforge.pmd.lang.java.typeresolution.TypeHelper`.
+ Use the new `isExactlyAny` and `isExactlyNone` methods in the same class instead.
+
+#### 6.2.0
+
+* The static method `PMDParameters.transformParametersIntoConfiguration(PMDParameters)` is now deprecated,
+ for removal in 7.0.0. The new instance method `PMDParameters.toConfiguration()` replaces it.
+
+* The method `ASTConstructorDeclaration.getParameters()` has been deprecated in favor of the new method
+ `getFormalParameters()`. This method is available for both `ASTConstructorDeclaration` and
+ `ASTMethodDeclaration`.
+
+#### 6.1.0
+
+* The method `getXPathNodeName` is added to the `Node` interface, which removes the
+use of the `toString` of a node to get its XPath element name (see [#569](https://github.com/pmd/pmd/issues/569)).
+ * The default implementation provided in `AbstractNode`, will
+ be removed with 7.0.0
+ * With 7.0.0, the `Node.toString` method will not necessarily provide its XPath node
+ name anymore.
+
+* The interface `net.sourceforge.pmd.cpd.Renderer` has been deprecated. A new interface
+`net.sourceforge.pmd.cpd.renderer.CPDRenderer` has been introduced to replace it. The main
+difference is that the new interface is meant to render directly to a `java.io.Writer`
+rather than to a String. This allows to greatly reduce the memory footprint of CPD, as on
+large projects, with many duplications, it was causing `OutOfMemoryError`s (see [#795](https://github.com/pmd/pmd/issues/795)).
+
+ `net.sourceforge.pmd.cpd.FileReporter` has also been deprecated as part of this change, as it's no longer needed.
+
+#### 6.0.1
+
+* The constant `net.sourceforge.pmd.PMD.VERSION` has been deprecated and will be removed with PMD 7.0.0.
+ Please use `net.sourceforge.pmd.PMDVersion.VERSION` instead.
+
+### List of currently deprecated rules
+
+* The Java rules {% rule java/codestyle/VariableNamingConventions %}, {% rule java/codestyle/MIsLeadingVariableName %},
+ {% rule java/codestyle/SuspiciousConstantFieldName %}, and {% rule java/codestyle/AvoidPrefixingMethodParameters %} are
+ now deprecated, and will be removed with version 7.0.0. They are replaced by the more general
+ {% rule java/codestyle/FieldNamingConventions %}, {% rule java/codestyle/FormalParameterNamingConventions %}, and
+ {% rule java/codestyle/LocalVariableNamingConventions %}.
+
+* The Java rule {% rule java/codestyle/AbstractNaming %} is deprecated
+ in favour of {% rule java/codestyle/ClassNamingConventions %}.
+
+* The Java rules {% rule java/codestyle/WhileLoopsMustUseBraces %}, {% rule java/codestyle/ForLoopMustUseBraces %}, {% rule java/codestyle/IfStmtMustUseBraces %}, and {% rule java/codestyle/IfElseStmtMustUseBraces %}
+ are deprecated. They will be replaced by the new rule {% rule java/codestyle/ControlStatementBraces %}
+
+* The Java rules {% rule java/codestyle/NcssConstructorCount %}, {% rule java/codestyle/NcssMethodCount %}, and {% rule java/codestyle/NcssTypeCount %} have been
+ deprecated. They will be replaced by the new rule {% rule java/design/NcssCount %} in the category `design`.
+
+* The Java rule `LooseCoupling` in ruleset `java-typeresolution` is deprecated. Use the rule with the same name from category `bestpractices` instead.
+
+* The Java rule `CloneMethodMustImplementCloneable` in ruleset `java-typeresolution` is deprecated. Use the rule with the same name from category `errorprone` instead.
+
+* The Java rule `UnusedImports` in ruleset `java-typeresolution` is deprecated. Use the rule with
+ the same name from category `bestpractices` instead.
+
+* The Java rule `SignatureDeclareThrowsException` in ruleset `java-typeresolution` is deprecated. Use the rule with the same name from category `design` instead.
+
+* The Java rule `EmptyStaticInitializer` in ruleset `java-empty` is deprecated. Use the rule {% rule java/errorprone/EmptyInitializer %}, which covers both static and non-static empty initializers.`
+
+* The Java rules `GuardDebugLogging` (ruleset `java-logging-jakarta-commons`) and `GuardLogStatementJavaUtil`
+ (ruleset `java-logging-java`) have been deprecated. Use the rule {% rule java/bestpractices/GuardLogStatement %}, which covers all cases regardless of the logging framework.
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md
index b8f8783555..8c5a72c673 100644
--- a/docs/pages/release_notes.md
+++ b/docs/pages/release_notes.md
@@ -22,3 +22,5 @@ This is a {{ site.pmd.release_type }} release.
{% endtocmaker %}
+{% include note.html content="The release notes of previous versions are available [here](pmd_release_notes_old.html)" %}
+
diff --git a/docs/pages/release_notes_old.md b/docs/pages/release_notes_old.md
index 3fff802bb5..d7110b6473 100644
--- a/docs/pages/release_notes_old.md
+++ b/docs/pages/release_notes_old.md
@@ -3,8 +3,7 @@ title: Old Release Notes
permalink: pmd_release_notes_old.html
---
-Previous versions of PMD can be downloaded here:
-http://sourceforge.net/projects/pmd/files/pmd/
+Previous versions of PMD can be downloaded here: https://github.com/pmd/pmd/releases
## 28-October-2018 - 6.9.0
From 679eaeb4e5786cb60b61e7e1890ff71e69f7c85e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Fri, 2 Nov 2018 08:11:26 +0100
Subject: [PATCH 014/139] Deprecate Initializer and functions
---
.../main/java/net/sourceforge/pmd/lang/XPathHandler.java | 6 ++++++
.../java/net/sourceforge/pmd/lang/xpath/Initializer.java | 5 +++++
.../net/sourceforge/pmd/lang/xpath/MatchesFunction.java | 3 +++
.../java/net/sourceforge/pmd/lang/xpath/PMDFunctions.java | 5 +++++
.../pmd/lang/java/xpath/GetCommentOnFunction.java | 3 +++
.../net/sourceforge/pmd/lang/java/xpath/JavaFunctions.java | 3 +++
.../net/sourceforge/pmd/lang/java/xpath/MetricFunction.java | 3 +++
.../pmd/lang/java/xpath/TypeIsExactlyFunction.java | 4 ++++
.../net/sourceforge/pmd/lang/java/xpath/TypeIsFunction.java | 4 ++++
9 files changed, 36 insertions(+)
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/XPathHandler.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/XPathHandler.java
index d3d7ca82b6..95728185d7 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/XPathHandler.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/XPathHandler.java
@@ -6,6 +6,7 @@ package net.sourceforge.pmd.lang;
import org.jaxen.Navigator;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.xpath.Initializer;
import net.sf.saxon.sxpath.IndependentContext;
@@ -14,6 +15,8 @@ import net.sf.saxon.sxpath.IndependentContext;
* Interface for performing Language specific XPath handling, such as
* initialization and navigation.
*/
+@InternalApi
+@Deprecated
public interface XPathHandler {
XPathHandler DUMMY = new XPathHandler() {
@@ -48,6 +51,9 @@ public interface XPathHandler {
/**
* Get a Jaxen Navigator for this Language. May return null
if
* there is no Jaxen Navigation for this language.
+ *
+ * @deprecated Support for Jaxen will be removed come 7.0.0
*/
+ @Deprecated
Navigator getNavigator();
}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/Initializer.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/Initializer.java
index 54d28699c6..c73ef828a7 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/Initializer.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/Initializer.java
@@ -4,6 +4,7 @@
package net.sourceforge.pmd.lang.xpath;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.Language;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.LanguageVersion;
@@ -16,7 +17,11 @@ import net.sf.saxon.sxpath.IndependentContext;
* initialization. For example, initializing custom Jaxen Functions.
* Initialization should be performed before any XPath related operations are
* performed.
+ *
+ * @deprecated Is internal API
*/
+@InternalApi
+@Deprecated
public final class Initializer {
private Initializer() { }
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/MatchesFunction.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/MatchesFunction.java
index 67493ca9c5..252ed9bdec 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/MatchesFunction.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/MatchesFunction.java
@@ -14,9 +14,12 @@ import org.jaxen.FunctionCallException;
import org.jaxen.SimpleFunctionContext;
import org.jaxen.XPathFunctionContext;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.xpath.Attribute;
// FIXME Can this function be extended to work on non-AST attributes?
+@InternalApi
+@Deprecated
public class MatchesFunction implements Function {
public static void registerSelfInSimpleContext() {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/PMDFunctions.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/PMDFunctions.java
index 394bd230d1..5a26e7b75c 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/PMDFunctions.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/xpath/PMDFunctions.java
@@ -4,6 +4,11 @@
package net.sourceforge.pmd.lang.xpath;
+import net.sourceforge.pmd.annotation.InternalApi;
+
+
+@InternalApi
+@Deprecated
public final class PMDFunctions {
private PMDFunctions() { }
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/GetCommentOnFunction.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/GetCommentOnFunction.java
index 386798653b..9e79e5328f 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/GetCommentOnFunction.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/GetCommentOnFunction.java
@@ -12,6 +12,7 @@ import org.jaxen.FunctionCallException;
import org.jaxen.SimpleFunctionContext;
import org.jaxen.XPathFunctionContext;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.AbstractNode;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
@@ -24,6 +25,8 @@ import net.sourceforge.pmd.lang.java.ast.Comment;
*
* @author Andy Throgmorton
*/
+@InternalApi
+@Deprecated
public class GetCommentOnFunction implements Function {
public static void registerSelfInSimpleContext() {
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/JavaFunctions.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/JavaFunctions.java
index 35f43e830b..d4242f26e6 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/JavaFunctions.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/JavaFunctions.java
@@ -4,6 +4,7 @@
package net.sourceforge.pmd.lang.java.xpath;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.ast.xpath.saxon.ElementNode;
@@ -12,6 +13,8 @@ import net.sf.saxon.expr.XPathContext;
/**
* Exposes all Java Language specific functions for Saxon use.
*/
+@InternalApi
+@Deprecated
public final class JavaFunctions {
private JavaFunctions() {
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/MetricFunction.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/MetricFunction.java
index 24a1f0a030..29e9c2bb69 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/MetricFunction.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/MetricFunction.java
@@ -15,6 +15,7 @@ import org.jaxen.FunctionCallException;
import org.jaxen.SimpleFunctionContext;
import org.jaxen.XPathFunctionContext;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.java.ast.ASTAnyTypeDeclaration;
import net.sourceforge.pmd.lang.java.ast.MethodLikeNode;
@@ -32,6 +33,8 @@ import net.sourceforge.pmd.lang.java.metrics.api.JavaOperationMetricKey;
* @author Clément Fournier
* @since 6.0.0
*/
+@InternalApi
+@Deprecated
public class MetricFunction implements Function {
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/TypeIsExactlyFunction.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/TypeIsExactlyFunction.java
index e6437fcce3..811afd1525 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/TypeIsExactlyFunction.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/TypeIsExactlyFunction.java
@@ -12,10 +12,14 @@ import org.jaxen.FunctionCallException;
import org.jaxen.SimpleFunctionContext;
import org.jaxen.XPathFunctionContext;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.java.ast.TypeNode;
import net.sourceforge.pmd.lang.java.typeresolution.TypeHelper;
+
+@InternalApi
+@Deprecated
public class TypeIsExactlyFunction implements Function {
public static void registerSelfInSimpleContext() {
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/TypeIsFunction.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/TypeIsFunction.java
index 0c5ecb3c3f..41ac55d5b0 100644
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/TypeIsFunction.java
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/xpath/TypeIsFunction.java
@@ -12,10 +12,14 @@ import org.jaxen.FunctionCallException;
import org.jaxen.SimpleFunctionContext;
import org.jaxen.XPathFunctionContext;
+import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.lang.java.ast.TypeNode;
import net.sourceforge.pmd.lang.java.typeresolution.TypeHelper;
+
+@InternalApi
+@Deprecated
public class TypeIsFunction implements Function {
public static void registerSelfInSimpleContext() {
From e1b5717675646779553cebdfa510dbca17e2a30f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Fri, 2 Nov 2018 09:09:13 +0100
Subject: [PATCH 015/139] Fix #1372
---
.../resources/category/java/codestyle.xml | 6 +++--
.../codestyle/xml/UselessQualifiedThis.xml | 23 +++++++++++++++++++
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/pmd-java/src/main/resources/category/java/codestyle.xml b/pmd-java/src/main/resources/category/java/codestyle.xml
index 3329ce7284..483d2e3a05 100644
--- a/pmd-java/src/main/resources/category/java/codestyle.xml
+++ b/pmd-java/src/main/resources/category/java/codestyle.xml
@@ -1950,7 +1950,9 @@ public class Foo {
message="Useless qualified this usage in the same class."
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_codestyle.html#uselessqualifiedthis">
- Look for qualified this usages in the same class.
+
+ Reports qualified this usages in the same class.
+
3
@@ -1958,7 +1960,7 @@ public class Foo {
+
+
+ False positive for UselessQualifiedThis #1372
+ 0
+
+
+
+
\ No newline at end of file
From 08950c9fbed7f1d365e33eb650b26ae53868f26f Mon Sep 17 00:00:00 2001
From: Will Herrmann
Date: Fri, 2 Nov 2018 16:04:21 -0500
Subject: [PATCH 016/139] Upgrading JCommander from 1.48 to 1.72
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 9f8f1d3050..52722c32d2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -842,7 +842,7 @@ Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code
com.beust
jcommander
- 1.48
+ 1.72
org.ow2.asm
From ddf1347782fd8526dcb4796a17acf35e7d22a0f8 Mon Sep 17 00:00:00 2001
From: Dem Pilafian
Date: Sat, 3 Nov 2018 20:07:34 -0700
Subject: [PATCH 017/139] Who really knows regex?
---
docs/pages/pmd/userdocs/suppressing_warnings.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/pages/pmd/userdocs/suppressing_warnings.md b/docs/pages/pmd/userdocs/suppressing_warnings.md
index 6f59675085..5b19ccab1c 100644
--- a/docs/pages/pmd/userdocs/suppressing_warnings.md
+++ b/docs/pages/pmd/userdocs/suppressing_warnings.md
@@ -175,7 +175,7 @@ are unused:
```
-Note for message based suppression to work, you must know who to write
+Note for message based suppression to work, you must know how to write
a regular expression that matches the message of violations you wish to
suppress. Regular expressions are explained in the JavaDoc for standard
Java class java.util.regex.Pattern.
@@ -203,4 +203,4 @@ For example, to suppress reporting specifically typed parameters which are unuse
Note for XPath based suppression to work, you must know how to write
an XPath query that matches the AST structure of the nodes of the
violations you wish to suppress. XPath queries are explained in
-[XPath Rule tutorial](pmd_userdocs_extending_writing_xpath_rules.html).
\ No newline at end of file
+[XPath Rule tutorial](pmd_userdocs_extending_writing_xpath_rules.html).
From 39d340f431c1101dd6836b3968a2e81196c07cad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Sun, 4 Nov 2018 14:48:35 +0100
Subject: [PATCH 018/139] Update release notes, refs #1430
---
docs/pages/release_notes.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md
index 62caa38f96..bc060c9b9d 100644
--- a/docs/pages/release_notes.md
+++ b/docs/pages/release_notes.md
@@ -25,6 +25,7 @@ This is a {{ site.pmd.release_type }} release.
### External Contributions
* [#1424](https://github.com/pmd/pmd/pull/1424): \[doc] #1341 Updating Regex Values in default Value Property - [avishvat](https://github.com/vishva007)
+* [#1430](https://github.com/pmd/pmd/pull/1430): \[doc] Who really knows regex? - [Dem Pilafian](https://github.com/dpilafian)
{% endtocmaker %}
From 8823ef5356a09c46ba89c30a7199c6371f7cbb56 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Mon, 5 Nov 2018 00:32:18 +0100
Subject: [PATCH 019/139] More deprecations on PropertyDescriptor, relates to
#1432
---
.../AbstractMultiValueProperty.java | 1 +
.../pmd/properties/AbstractProperty.java | 1 +
.../AbstractSingleValueProperty.java | 1 +
.../MultiValuePropertyDescriptor.java | 7 ++++
.../pmd/properties/PropertyDescriptor.java | 39 +++++++++++++------
.../pmd/properties/PropertyTypeId.java | 25 ++++++++++++
.../SingleValuePropertyDescriptor.java | 4 ++
.../builders/MultiValuePropertyBuilder.java | 3 ++
.../builders/PropertyDescriptorBuilder.java | 2 +
.../PropertyDescriptorExternalBuilder.java | 1 +
.../builders/SingleValuePropertyBuilder.java | 3 ++
11 files changed, 76 insertions(+), 11 deletions(-)
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractMultiValueProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractMultiValueProperty.java
index 514ed20003..339a6554c6 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractMultiValueProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractMultiValueProperty.java
@@ -23,6 +23,7 @@ import net.sourceforge.pmd.Rule;
* @author Clément Fournier
* @version 6.0.0
*/
+@Deprecated
/* default */ abstract class AbstractMultiValueProperty extends AbstractProperty>
implements MultiValuePropertyDescriptor {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractProperty.java
index ab1815ddef..f6946437ea 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractProperty.java
@@ -23,6 +23,7 @@ import org.apache.commons.lang3.StringUtils;
* @author Clément Fournier
* @version Refactored June 2017 (6.0.0)
*/
+// @Deprecated // will be replaced by another base class in the next PR
/* default */ abstract class AbstractProperty implements PropertyDescriptor {
private final String name;
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractSingleValueProperty.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractSingleValueProperty.java
index 0864cbaf17..d3908f6c4d 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractSingleValueProperty.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractSingleValueProperty.java
@@ -14,6 +14,7 @@ import net.sourceforge.pmd.Rule;
*
* @author Clément Fournier
*/
+@Deprecated
/* default */ abstract class AbstractSingleValueProperty extends AbstractProperty
implements SingleValuePropertyDescriptor {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/MultiValuePropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/MultiValuePropertyDescriptor.java
index 6d70fd44a7..49d710b40c 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/MultiValuePropertyDescriptor.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/MultiValuePropertyDescriptor.java
@@ -17,13 +17,18 @@ import java.util.List;
*
* @author Clément Fournier
* @since 6.0.0
+ *
+ * @deprecated The hard divide between multi- and single-value properties will be removed with 7.0.0
*/
+@Deprecated
public interface MultiValuePropertyDescriptor extends PropertyDescriptor> {
/** Default delimiter for multi-valued properties other than numeric ones. */
+ @Deprecated
char DEFAULT_DELIMITER = '|';
/** Default delimiter for numeric multi-valued properties. */
+ @Deprecated
char DEFAULT_NUMERIC_DELIMITER = ',';
@@ -33,9 +38,11 @@ public interface MultiValuePropertyDescriptor extends PropertyDescriptor type();
}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
index aa93fb9da3..d25bcba046 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyDescriptor.java
@@ -22,7 +22,7 @@ import net.sourceforge.pmd.annotation.InternalApi;
* Several interfaces further specialize the behaviour of descriptors to accommodate specific types of descriptors,
* see {@link NumericPropertyDescriptor} and {@link EnumeratedPropertyDescriptor}.
*
- *
Upcoming API changes to the properties framework: see https://github.com/pmd/pmd/issues/1415
+ * Upcoming API changes to the properties framework: see wiki
*
* @param type of the property's value. This is a list type for multi-valued properties.
*
@@ -53,7 +53,11 @@ public interface PropertyDescriptor extends Comparable>
* class.
*
* @return Class literal of the value type
+ *
+ * @deprecated This method is mainly used for documentation, but will not prove general enough
+ * to support PMD 7.0.0's improved property types.
*/
+ @Deprecated
Class> type();
@@ -65,7 +69,10 @@ public interface PropertyDescriptor extends Comparable>
* must be used.
*
* @return boolean
+ *
+ * @deprecated The hard divide between multi- and single-value properties will be removed with 7.0.0
*/
+ @Deprecated
boolean isMultiValue();
@@ -85,7 +92,7 @@ public interface PropertyDescriptor extends Comparable>
*
* @return A diagnostic message.
*/
- String errorFor(T value);
+ String errorFor(T value); // TODO Java 1.8 make optional
/**
@@ -93,12 +100,7 @@ public interface PropertyDescriptor extends Comparable>
* edit property values. If the value returned has a non-zero fractional part then this is can be used to place
* adjacent fields on the same row.
*
- * Example:
name -> 0.0 description 1.0 minValue -> 2.0 maxValue -> 2.1
..would have their
- * fields placed like:
- *
- * name: [ ] description: [ ] minimum: [ ] maximum: [ ]
- *
- * @return float
+ * @return The relative order compared to other properties of the same rule
*/
float uiOrder();
@@ -109,8 +111,12 @@ public interface PropertyDescriptor extends Comparable>
* @param propertyString The string to parse
*
* @return The value represented by the string
+ *
* @throws IllegalArgumentException if the given string cannot be parsed
+ * @deprecated PMD 7.0.0 will use a more powerful scheme to represent values than
+ * simple strings, this method won't be general enough
*/
+ @Deprecated
T valueFrom(String propertyString) throws IllegalArgumentException;
@@ -120,7 +126,11 @@ public interface PropertyDescriptor extends Comparable>
* @param value Object
*
* @return String
+ *
+ * @deprecated PMD 7.0.0 will use a more powerful scheme to represent values than
+ * simple strings, this method won't be general enough
*/
+ @Deprecated
String asDelimitedString(T value);
@@ -131,7 +141,11 @@ public interface PropertyDescriptor extends Comparable>
* @param rule Rule
*
* @return String
+ *
+ * @deprecated Used nowhere, and fails if the rule doesn't define the property descriptor
+ * A better solution will be added on property source
*/
+ @Deprecated
String propertyErrorFor(Rule rule);
@@ -139,8 +153,9 @@ public interface PropertyDescriptor extends Comparable>
* If the datatype is a String then return the preferred number of rows to allocate in the text widget, returns a
* value of one for all other types. Useful for multi-line XPATH editors.
*
- * @deprecated Was never implemented, and is none of the descriptor's concern. Will be removed with 7.0.0
* @return int
+ *
+ * @deprecated Was never implemented, and is none of the descriptor's concern. Will be removed with 7.0.0
*/
@Deprecated
int preferredRowCount();
@@ -149,8 +164,9 @@ public interface PropertyDescriptor extends Comparable>
/**
* Returns a map representing all the property attributes of the receiver in string form.
*
- * @deprecated Will be removed with 7.0.0
* @return map
+ *
+ * @deprecated Will be removed with 7.0.0
*/
@Deprecated
Map attributeValuesById();
@@ -161,8 +177,9 @@ public interface PropertyDescriptor extends Comparable>
* to write out the property correctly: if it was defined externally, then its definition must be written out,
* otherwise only its value.
*
- * @deprecated May be removed with 7.0.0
* @return True if the descriptor was defined in xml
+ *
+ * @deprecated May be removed with 7.0.0
*/
@Deprecated
@InternalApi
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyTypeId.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyTypeId.java
index 21b848fde8..4e78fc04c2 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyTypeId.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyTypeId.java
@@ -18,11 +18,21 @@ import net.sourceforge.pmd.properties.builders.PropertyDescriptorExternalBuilder
* of the property that should be built. The mapping between the values of this attribute
* and the concrete property that is built is encoded in the constants of this enum.
*
+ * Properties API changes
This class' API is mainly provided to build GUIs for XPath rules
+ * like the rule designer, so that they have info about the available properties from XML. As such,
+ * the number of clients are probably low. Nevertheless, a bunch of members have been deprecated to
+ * warn about probable upcoming API changes with 7.0.0, but the amount of change may be greater.
+ * See {@link PropertyDescriptor} for more info about property framework changes with 7.0.0.
+ *
* @author Clément Fournier
* @see PropertyDescriptorExternalBuilder
* @since 6.0.0
*/
public enum PropertyTypeId {
+ // These are exclusively used for XPath rules. It would make more sense to model the supported
+ // property types around XML Schema Datatypes (XSD) 1.0 or 1.1 instead of Java datatypes (save for
+ // e.g. the Class type), including the mnemonics (eg. xs:integer instead of Integer)
+
BOOLEAN("Boolean", BooleanProperty.extractor(), ValueParserConstants.BOOLEAN_PARSER),
BOOLEAN_LIST("List[Boolean]", BooleanMultiProperty.extractor(), ValueParserConstants.BOOLEAN_PARSER),
@@ -125,7 +135,10 @@ public enum PropertyTypeId {
* lists of values as its value.
*
* @return whether the property is multivalue
+ *
+ * @deprecated see {@link PropertyDescriptor#isMultiValue()}
*/
+ @Deprecated
public boolean isPropertyMultivalue() {
return factory.isMultiValue();
}
@@ -136,7 +149,10 @@ public enum PropertyTypeId {
* This is the component type of the list if the property is multivalued.
*
* @return The value type of the property
+ *
+ * @deprecated see {@link PropertyDescriptor#type()}
*/
+ @Deprecated
public Class> propertyValueType() {
return factory.valueType();
}
@@ -148,7 +164,10 @@ public enum PropertyTypeId {
* of the list. A list parser can be obtained with {@link ValueParserConstants#multi(ValueParser, char)}.
*
* @return The value parser
+ *
+ * @deprecated see {@link PropertyDescriptor#valueFrom(String)}
*/
+ @Deprecated
public ValueParser> getValueParser() {
return valueParser;
}
@@ -170,7 +189,10 @@ public enum PropertyTypeId {
* @param stringId The identifier of the type
*
* @return The factory used to build new instances of a descriptor
+ *
+ * @deprecated See {@link PropertyDescriptorExternalBuilder}
*/
+ @Deprecated
public static PropertyDescriptorExternalBuilder> factoryFor(String stringId) {
PropertyTypeId cons = CONSTANTS_BY_MNEMONIC.get(stringId);
return cons == null ? null : cons.factory;
@@ -197,7 +219,10 @@ public enum PropertyTypeId {
* @param multiValue Whether the descriptor is multivalued or not
*
* @return The string id
+ *
+ * @deprecated The signature will probably be altered in 7.0.0 but a similar functionality will be available
*/
+ @Deprecated
public static String typeIdFor(Class> valueType, boolean multiValue) {
for (Map.Entry entry : CONSTANTS_BY_MNEMONIC.entrySet()) {
if (entry.getValue().propertyValueType() == valueType
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/SingleValuePropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/SingleValuePropertyDescriptor.java
index e79c28d46c..4ca0ac6337 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/SingleValuePropertyDescriptor.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/SingleValuePropertyDescriptor.java
@@ -12,9 +12,13 @@ package net.sourceforge.pmd.properties;
*
* @author Clément Fournier
* @since 6.0.0
+ *
+ * @deprecated The hard divide between multi- and single-value properties will be removed with 7.0.0
*/
+@Deprecated
public interface SingleValuePropertyDescriptor extends PropertyDescriptor {
@Override
+ @Deprecated
Class type();
}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/MultiValuePropertyBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/MultiValuePropertyBuilder.java
index 6405dd5770..da8f9009a7 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/MultiValuePropertyBuilder.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/MultiValuePropertyBuilder.java
@@ -17,7 +17,10 @@ import net.sourceforge.pmd.properties.MultiValuePropertyDescriptor;
*
* @param Element type of the list
* @param Concrete type of the underlying builder
+ *
*/
+// @Deprecated // will be rewritten in the next PR and placed in the properties package,
+// since there will be no need for a separate package
public abstract class MultiValuePropertyBuilder>
extends PropertyDescriptorBuilder, T> {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorBuilder.java
index 784fe1ff0f..5aa1ef3959 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorBuilder.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorBuilder.java
@@ -19,6 +19,8 @@ import net.sourceforge.pmd.properties.PropertyDescriptor;
* @author Clément Fournier
* @since 6.0.0
*/
+// @Deprecated // will be rewritten in the next PR and placed in the properties package,
+// since there will be no need for a separate package
public abstract class PropertyDescriptorBuilder> {
protected String name;
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorExternalBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorExternalBuilder.java
index e45be1e5e0..9f63bdd3b7 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorExternalBuilder.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/PropertyDescriptorExternalBuilder.java
@@ -17,6 +17,7 @@ import net.sourceforge.pmd.properties.PropertyDescriptorField;
*
* @author Clément Fournier
* @since 6.0.0
+ * @deprecated The property XML API will not need this anymore
*/
@Deprecated
public interface PropertyDescriptorExternalBuilder {
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/SingleValuePropertyBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/SingleValuePropertyBuilder.java
index 4c8edbf11b..cce7692506 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/SingleValuePropertyBuilder.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/builders/SingleValuePropertyBuilder.java
@@ -9,7 +9,10 @@ package net.sourceforge.pmd.properties.builders;
*
* @param Value type of the built descriptor
* @param Concrete type of this builder instance.
+ *
*/
+// @Deprecated // will be rewritten in the next PR and placed in the properties package,
+// since there will be no need for a separate package
public abstract class SingleValuePropertyBuilder>
extends PropertyDescriptorBuilder {
From 972a991cb0cdaffc17ffb92708fa3a698f8296b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Mon, 29 Oct 2018 19:36:56 +0100
Subject: [PATCH 020/139] WIP
---
.../AbstractMultiValuePropertyBuilder.java | 76 ++++++++++++
.../newframework/AbstractPropertyBuilder.java | 91 ++++++++++++++
.../AbstractPropertyDescriptor.java | 76 ++++++++++++
.../AbstractSingleValuePropertyBuilder.java | 65 ++++++++++
.../MultiValuePropertyDescriptor.java | 67 ++++++++++
.../newframework/PropertyDescriptor.java | 116 ++++++++++++++++++
.../newframework/PropertyFactory.java | 59 +++++++++
.../newframework/PropertyValidator.java | 26 ++++
.../SingleValuePropertyDescriptor.java | 54 ++++++++
9 files changed, 630 insertions(+)
create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractMultiValuePropertyBuilder.java
create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyBuilder.java
create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyDescriptor.java
create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractSingleValuePropertyBuilder.java
create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/MultiValuePropertyDescriptor.java
create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyDescriptor.java
create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyFactory.java
create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyValidator.java
create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/SingleValuePropertyDescriptor.java
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractMultiValuePropertyBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractMultiValuePropertyBuilder.java
new file mode 100644
index 0000000000..e94f87b448
--- /dev/null
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractMultiValuePropertyBuilder.java
@@ -0,0 +1,76 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+
+package net.sourceforge.pmd.properties.newframework;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.function.Function;
+
+
+/**
+ * @author Clément Fournier
+ * @since 6.7.0
+ */
+public abstract class AbstractMultiValuePropertyBuilder>, V> extends AbstractPropertyBuilder> {
+ private final Set> componentValidators = new LinkedHashSet<>();
+ private final Function parser;
+ private final Class type;
+
+ private List defaultValues;
+
+
+ AbstractMultiValuePropertyBuilder(String name, Function parser, Class type) {
+ super(name);
+ this.parser = parser;
+ this.type = type;
+ }
+
+
+ /**
+ * Specify a default value.
+ *
+ * @param val List of values
+ *
+ * @return The same builder
+ */
+ @SuppressWarnings("unchecked")
+ public B defaultValues(Collection extends V> val) {
+ this.defaultValues = new ArrayList<>(val);
+ return (B) this;
+ }
+
+
+ /**
+ * Specify default values.
+ *
+ * @param val List of values
+ *
+ * @return The same builder
+ */
+ @SuppressWarnings("unchecked")
+ public B defaultValues(V... val) {
+ this.defaultValues = Arrays.asList(val);
+ return (B) this;
+ }
+
+
+ @Override
+ public PropertyDescriptor> build() {
+ return new MultiValuePropertyDescriptor<>(
+ name,
+ description,
+ uiOrder,
+ defaultValues,
+ validators,
+ componentValidators,
+ parser,
+ type
+ );
+ }
+}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyBuilder.java
new file mode 100644
index 0000000000..e31bdb73e3
--- /dev/null
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyBuilder.java
@@ -0,0 +1,91 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+
+package net.sourceforge.pmd.properties.newframework;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang3.StringUtils;
+
+
+/**
+ * @author Clément Fournier
+ * @since 6.7.0
+ */
+public abstract class AbstractPropertyBuilder, T> {
+ private static final Pattern NAME_PATTERN = Pattern.compile("[a-zA-Z][\\w-]*");
+ protected final Set> validators = new LinkedHashSet<>();
+ protected String name;
+ protected String description;
+ protected float uiOrder = 0f;
+
+
+ public AbstractPropertyBuilder(String name) {
+ if (StringUtils.isBlank(name)) {
+ throw new IllegalArgumentException("Name must be provided");
+ } else if (!NAME_PATTERN.matcher(name).matches()) {
+ throw new IllegalArgumentException("Invalid name '" + name + "'");
+ }
+ this.name = name;
+ }
+
+
+ /**
+ * Specify the description of the property.
+ *
+ * @param desc The description
+ *
+ * @return The same builder
+ */
+ @SuppressWarnings("unchecked")
+ public B desc(String desc) {
+ if (StringUtils.isBlank(desc)) {
+ throw new IllegalArgumentException("Description must be provided");
+ }
+ this.description = desc;
+ return (B) this;
+ }
+
+
+ /**
+ * Specify the UI order of the property.
+ *
+ * @param f The UI order
+ *
+ * @return The same builder
+ */
+ @SuppressWarnings("unchecked")
+ public B uiOrder(float f) {
+ this.uiOrder = f;
+ return (B) this;
+ }
+
+
+ @SuppressWarnings("unchecked")
+ protected B addValidator(Predicate pred, String errorMessage) {
+ validators.add(PropertyValidator.fromPredicate(pred, errorMessage));
+ return (B) this;
+ }
+
+
+ /**
+ * Builds the descriptor and returns it.
+ *
+ * @return The built descriptor
+ *
+ * @throws IllegalArgumentException if parameters are incorrect
+ */
+ public abstract PropertyDescriptor build();
+
+
+ /**
+ * Returns the name of the property to be built.
+ */
+ public String getName() {
+ return name;
+ }
+}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyDescriptor.java
new file mode 100644
index 0000000000..96e44ca073
--- /dev/null
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyDescriptor.java
@@ -0,0 +1,76 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+
+package net.sourceforge.pmd.properties.newframework;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+
+/**
+ * @author Clément Fournier
+ * @since 6.7.0
+ */
+public abstract class AbstractPropertyDescriptor implements PropertyDescriptor {
+
+ private final String name;
+ private final String description;
+ private final float uiOrder;
+ private final Set> validators;
+ private final Class> type;
+
+
+ protected AbstractPropertyDescriptor(String name,
+ String description,
+ float uiOrder,
+ Set> validators, Class> type) {
+ this.name = name;
+ this.description = description;
+ this.uiOrder = uiOrder;
+ this.validators = validators;
+ this.type = type;
+ }
+
+
+ @Override
+ public final String getName() {
+ return name;
+ }
+
+
+ @Override
+ public final String getDescription() {
+ return description;
+ }
+
+
+ @Override
+ public final Class> getType() {
+ return type;
+ }
+
+
+ @Override
+ public List getErrorMessagesFor(T value) {
+ return validators.stream()
+ .map(validator -> validator.validate(value))
+ .filter(Optional::isPresent)
+ .map(Optional::get)
+ .collect(Collectors.toList());
+ }
+
+
+ @Override
+ public final float getUiOrder() {
+ return uiOrder;
+ }
+
+
+ @Override
+ public final int compareTo(PropertyDescriptor> o) {
+ return Float.compare(getUiOrder(), o.getUiOrder());
+ }
+}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractSingleValuePropertyBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractSingleValuePropertyBuilder.java
new file mode 100644
index 0000000000..5d90a8fbc3
--- /dev/null
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractSingleValuePropertyBuilder.java
@@ -0,0 +1,65 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+
+package net.sourceforge.pmd.properties.newframework;
+
+import java.util.function.Function;
+
+
+/**
+ * @author Clément Fournier
+ * @since 6.7.0
+ */
+public abstract class AbstractSingleValuePropertyBuilder, T> extends AbstractPropertyBuilder {
+
+
+ private final Function parser;
+ private final Class type;
+
+ private T defaultValue;
+
+
+ AbstractSingleValuePropertyBuilder(String name, Function parser, Class type) {
+ super(name);
+ this.parser = parser;
+ this.type = type;
+ }
+
+
+ @Override
+ public PropertyDescriptor build() {
+ return new SingleValuePropertyDescriptor<>(
+ name,
+ description,
+ uiOrder,
+ defaultValue,
+ validators,
+ parser,
+ type
+ );
+ }
+
+
+ /**
+ * Specify a default value.
+ *
+ * @param val Value
+ *
+ * @return The same builder
+ */
+ @SuppressWarnings("unchecked")
+ public B defaultValue(T val) {
+ this.defaultValue = val;
+ return (B) this;
+ }
+
+
+ /**
+ * Returns the name of the property to be built.
+ */
+ @Override
+ public String getName() {
+ return name;
+ }
+}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/MultiValuePropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/MultiValuePropertyDescriptor.java
new file mode 100644
index 0000000000..440f7ae762
--- /dev/null
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/MultiValuePropertyDescriptor.java
@@ -0,0 +1,67 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+
+package net.sourceforge.pmd.properties.newframework;
+
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+
+/**
+ * @author Clément Fournier
+ * @since 6.7.0
+ */
+final class MultiValuePropertyDescriptor extends AbstractPropertyDescriptor> {
+
+
+ private final List defaultValue;
+ private final Set> componentValidators;
+ private final Function parser;
+
+
+ MultiValuePropertyDescriptor(String name, String description, float uiOrder,
+ List defaultValue,
+ Set>> listValidators,
+ Set> componentValidators,
+ Function parser,
+ Class type) {
+ super(name, description, uiOrder, listValidators, type);
+ this.defaultValue = defaultValue;
+ this.componentValidators = componentValidators;
+ this.parser = parser;
+ }
+
+
+ @Override
+ public boolean isMultiValue() {
+ return true;
+ }
+
+
+ @Override
+ public List getDefaultValue() {
+ return defaultValue;
+ }
+
+
+ @Override
+ public List valueFrom(List propertyString) throws IllegalArgumentException {
+ return propertyString.stream().map(parser).collect(Collectors.toList());
+ }
+
+
+ @Override
+ public List getErrorMessagesFor(List value) {
+ List listErrorMessages = super.getErrorMessagesFor(value);
+ return listErrorMessages.isEmpty() ? listErrorMessages
+ : componentValidators.stream()
+ .flatMap(validator -> value.stream().map(validator::validate))
+ .filter(Optional::isPresent)
+ .map(Optional::get)
+ .collect(Collectors.toList());
+ }
+}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyDescriptor.java
new file mode 100644
index 0000000000..4af7654f1f
--- /dev/null
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyDescriptor.java
@@ -0,0 +1,116 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+
+package net.sourceforge.pmd.properties.newframework;
+
+import java.util.List;
+
+import net.sourceforge.pmd.properties.EnumeratedPropertyDescriptor;
+import net.sourceforge.pmd.properties.MultiValuePropertyDescriptor;
+import net.sourceforge.pmd.properties.NumericPropertyDescriptor;
+import net.sourceforge.pmd.properties.SingleValuePropertyDescriptor;
+
+
+/**
+ * Property value descriptor that defines the use & requirements for setting property values for use within PMD and
+ * any associated GUIs. While concrete descriptor instances are static and immutable they provide validation,
+ * serialization, and default values for any specific datatypes.
+ *
+ * This interface is primarily specialized according to whether the property is multi-valued or single-valued, see
+ * {@link SingleValuePropertyDescriptor} and {@link MultiValuePropertyDescriptor}.
+ *
+ *
Several interfaces further specialize the behaviour of descriptors to accommodate specific types of descriptors,
+ * see {@link NumericPropertyDescriptor} and {@link EnumeratedPropertyDescriptor}.
+ *
+ * @param type of the property's value. This is a list type for multi-valued properties.
+ *
+ * @author Brian Remedios
+ * @author Clément Fournier
+ * @version Refactored June 2017 (6.0.0)
+ */
+public interface PropertyDescriptor extends Comparable> {
+
+ /**
+ * The name of the property without spaces as it serves as the key into the property map.
+ *
+ * @return String
+ */
+ String getName();
+
+
+ /**
+ * Describes the property and the role it plays within the rule it is specified for. Could be used in a tooltip.
+ *
+ * @return String
+ */
+ String getDescription();
+
+
+ /**
+ * Returns whether the property is multi-valued, i.e. an array of strings,
+ *
+ * As unary property rule properties will return a value of one, you must use the get/setProperty accessors when
+ * working with the actual values. When working with multi-value properties then the get/setProperties accessors
+ * must be used.
+ *
+ * @return boolean
+ */
+ boolean isMultiValue();
+
+
+ /**
+ * Default value to use when the user hasn't specified one or when they wish to revert to a known-good state.
+ *
+ * @return Object
+ */
+ T getDefaultValue();
+
+
+ /**
+ * Denotes the value datatype. For multi-value properties, this is not the List class but the
+ * list's component class.
+ *
+ * @return Class literal of the value type
+ */
+ Class> getType();
+
+ /**
+ * Validation function that returns a diagnostic error message for a sample property value. Returns null if the
+ * value is acceptable.
+ *
+ * @param value The value to check.
+ *
+ * @return A diagnostic message.
+ */
+ List getErrorMessagesFor(T value);
+
+
+ /**
+ * Denotes the relative order the property field should occupy if we are using an auto-generated UI to display and
+ * edit property values. If the value returned has a non-zero fractional part then this is can be used to place
+ * adjacent fields on the same row.
+ *
+ * Example:
name -> 0.0 description 1.0 minValue -> 2.0 maxValue -> 2.1
..would have their
+ * fields placed like:
+ *
+ * {@code name: [ ] description: [ ] minimum: [ ] maximum: [ ]}
+ *
+ * @return float
+ */
+ float getUiOrder();
+
+
+ /**
+ * Returns the value represented by this string.
+ *
+ * @param propertyString The string to parse
+ *
+ * @return The value represented by the string
+ *
+ * @throws IllegalArgumentException if the given string cannot be parsed
+ */
+ T valueFrom(List propertyString) throws IllegalArgumentException;
+
+
+}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyFactory.java
new file mode 100644
index 0000000000..0f41476d16
--- /dev/null
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyFactory.java
@@ -0,0 +1,59 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+
+package net.sourceforge.pmd.properties.newframework;
+
+import java.util.function.Function;
+
+import org.apache.commons.lang3.EnumUtils;
+
+
+/**
+ * @author Clément Fournier
+ * @since 6.7.0
+ */
+public final class PropertyFactory {
+
+ private PropertyFactory() {
+
+ }
+
+
+ public static NumericPropertyBuilder intProperty(String name) {
+ return new NumericPropertyBuilder<>(name, Integer::valueOf, Integer.class);
+ }
+
+ // TODO need a way to document the possible values
+ public static > GenericPBuilder enumProperty(String name, Class enumClass) {
+ return new GenericPBuilder<>(name, s ->
+ EnumUtils.getEnumList(enumClass).stream()
+ .filter(e -> e.name().equalsIgnoreCase(s))
+ .findFirst()
+ .orElseThrow(() -> new IllegalArgumentException("The name '" + s + "' doesn't correspond to any constant in the enum '" + enumClass.getName() + "'"))
+ , enumClass);
+ }
+
+
+ // removes the other type parameter
+ public static class GenericPBuilder extends AbstractSingleValuePropertyBuilder, T> {
+
+ GenericPBuilder(String name, Function parser, Class type) {
+ super(name, parser, type);
+ }
+ }
+
+ public static class NumericPropertyBuilder extends AbstractSingleValuePropertyBuilder, N> {
+
+ NumericPropertyBuilder(String name, Function parser, Class type) {
+ super(name, parser, type);
+ }
+
+
+ public NumericPropertyBuilder requirePositive() {
+ return addValidator(n -> n.intValue() > 0, "Expected a positive number");
+ }
+ }
+
+
+}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyValidator.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyValidator.java
new file mode 100644
index 0000000000..f97bb3d8fb
--- /dev/null
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyValidator.java
@@ -0,0 +1,26 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+
+package net.sourceforge.pmd.properties.newframework;
+
+import java.util.Optional;
+import java.util.function.Predicate;
+
+
+/**
+ * @author Clément Fournier
+ * @since 6.7.0
+ */
+@FunctionalInterface
+public interface PropertyValidator {
+
+ Optional validate(T value);
+
+
+ static PropertyValidator fromPredicate(Predicate pred, String failureMessage) {
+ return u -> pred.test(u) ? Optional.empty() : Optional.of(failureMessage);
+ }
+
+
+}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/SingleValuePropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/SingleValuePropertyDescriptor.java
new file mode 100644
index 0000000000..12eebe7acd
--- /dev/null
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/SingleValuePropertyDescriptor.java
@@ -0,0 +1,54 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+
+package net.sourceforge.pmd.properties.newframework;
+
+import java.util.List;
+import java.util.Set;
+import java.util.function.Function;
+
+
+/**
+ * @author Clément Fournier
+ * @since 6.7.0
+ */
+final class SingleValuePropertyDescriptor extends AbstractPropertyDescriptor {
+
+
+ private final T defaultValue;
+ private final Function parser;
+
+
+ SingleValuePropertyDescriptor(String name, String description, float uiOrder,
+ T defaultValue,
+ Set> validators,
+ Function parser,
+ Class type) {
+ super(name, description, uiOrder, validators, type);
+ this.defaultValue = defaultValue;
+ this.parser = parser;
+ }
+
+
+ @Override
+ public boolean isMultiValue() {
+ return false;
+ }
+
+
+ @Override
+ public T getDefaultValue() {
+ return defaultValue;
+ }
+
+
+ @Override
+ public T valueFrom(List valuesList) throws IllegalArgumentException {
+ if (valuesList.size() != 1) {
+ throw new IllegalArgumentException("This property can only handle a single value, but " + valuesList.size() + " was supplied");
+ }
+
+ return parser.apply(valuesList.get(0));
+ }
+}
From b9a15b405a73e2501501dfa4d92e9878f73c66a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Mon, 29 Oct 2018 22:49:37 +0100
Subject: [PATCH 021/139] Move towards java7 compat
---
.../rule/design/CyclomaticComplexityRule.java | 6 +-
...=> AbstractGenericPropertyDescriptor.java} | 20 +-
.../AbstractMultiValuePropertyBuilder.java | 76 --------
.../newframework/AbstractPropertyBuilder.java | 176 +++++++++++++++++-
.../AbstractSingleValuePropertyBuilder.java | 65 -------
... GenericMultiValuePropertyDescriptor.java} | 21 +--
.../GenericPropertyDescriptor.java | 49 +++++
.../newframework/PropertyFactory.java | 35 ++--
.../newframework/PropertyValidator.java | 30 ++-
.../SingleValuePropertyDescriptor.java | 54 ------
.../properties/newframework/Validators.java | 70 +++++++
11 files changed, 361 insertions(+), 241 deletions(-)
rename pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/{AbstractPropertyDescriptor.java => AbstractGenericPropertyDescriptor.java} (70%)
delete mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractMultiValuePropertyBuilder.java
delete mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractSingleValuePropertyBuilder.java
rename pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/{MultiValuePropertyDescriptor.java => GenericMultiValuePropertyDescriptor.java} (68%)
create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/GenericPropertyDescriptor.java
delete mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/SingleValuePropertyDescriptor.java
create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/Validators.java
diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java
index 08b6c567c5..e8d6b6a450 100644
--- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java
+++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java
@@ -16,6 +16,8 @@ import net.sourceforge.pmd.lang.apex.metrics.api.ApexOperationMetricKey;
import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule;
import net.sourceforge.pmd.lang.metrics.ResultOption;
import net.sourceforge.pmd.properties.IntegerProperty;
+import net.sourceforge.pmd.properties.newframework.PropertyDescriptor;
+import net.sourceforge.pmd.properties.newframework.PropertyFactory;
/**
@@ -25,8 +27,8 @@ import net.sourceforge.pmd.properties.IntegerProperty;
*/
public class CyclomaticComplexityRule extends AbstractApexRule {
- private static final IntegerProperty CLASS_LEVEL_DESCRIPTOR
- = IntegerProperty.named("classReportLevel")
+ private static final PropertyDescriptor CLASS_LEVEL_DESCRIPTOR
+ = PropertyFactory.intProperty("classReportLevel")
.desc("Total class complexity reporting threshold")
.range(1, 200)
.defaultValue(40)
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractGenericPropertyDescriptor.java
similarity index 70%
rename from pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyDescriptor.java
rename to pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractGenericPropertyDescriptor.java
index 96e44ca073..947ad61145 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyDescriptor.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractGenericPropertyDescriptor.java
@@ -14,8 +14,9 @@ import java.util.stream.Collectors;
* @author Clément Fournier
* @since 6.7.0
*/
-public abstract class AbstractPropertyDescriptor implements PropertyDescriptor {
+abstract class AbstractGenericPropertyDescriptor implements PropertyDescriptor {
+ protected final T defaultValue;
private final String name;
private final String description;
private final float uiOrder;
@@ -23,13 +24,16 @@ public abstract class AbstractPropertyDescriptor implements PropertyDescripto
private final Class> type;
- protected AbstractPropertyDescriptor(String name,
- String description,
- float uiOrder,
- Set> validators, Class> type) {
+ protected AbstractGenericPropertyDescriptor(String name,
+ String description,
+ float uiOrder,
+ T defaultValue,
+ Set> validators,
+ Class> type) {
this.name = name;
this.description = description;
this.uiOrder = uiOrder;
+ this.defaultValue = defaultValue;
this.validators = validators;
this.type = type;
}
@@ -53,6 +57,12 @@ public abstract class AbstractPropertyDescriptor implements PropertyDescripto
}
+ @Override
+ public T getDefaultValue() {
+ return defaultValue;
+ }
+
+
@Override
public List getErrorMessagesFor(T value) {
return validators.stream()
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractMultiValuePropertyBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractMultiValuePropertyBuilder.java
deleted file mode 100644
index e94f87b448..0000000000
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractMultiValuePropertyBuilder.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
- */
-
-package net.sourceforge.pmd.properties.newframework;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.function.Function;
-
-
-/**
- * @author Clément Fournier
- * @since 6.7.0
- */
-public abstract class AbstractMultiValuePropertyBuilder>, V> extends AbstractPropertyBuilder> {
- private final Set> componentValidators = new LinkedHashSet<>();
- private final Function parser;
- private final Class type;
-
- private List defaultValues;
-
-
- AbstractMultiValuePropertyBuilder(String name, Function parser, Class type) {
- super(name);
- this.parser = parser;
- this.type = type;
- }
-
-
- /**
- * Specify a default value.
- *
- * @param val List of values
- *
- * @return The same builder
- */
- @SuppressWarnings("unchecked")
- public B defaultValues(Collection extends V> val) {
- this.defaultValues = new ArrayList<>(val);
- return (B) this;
- }
-
-
- /**
- * Specify default values.
- *
- * @param val List of values
- *
- * @return The same builder
- */
- @SuppressWarnings("unchecked")
- public B defaultValues(V... val) {
- this.defaultValues = Arrays.asList(val);
- return (B) this;
- }
-
-
- @Override
- public PropertyDescriptor> build() {
- return new MultiValuePropertyDescriptor<>(
- name,
- description,
- uiOrder,
- defaultValues,
- validators,
- componentValidators,
- parser,
- type
- );
- }
-}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyBuilder.java
index e31bdb73e3..4010bfaeec 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyBuilder.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyBuilder.java
@@ -4,27 +4,40 @@
package net.sourceforge.pmd.properties.newframework;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Set;
-import java.util.function.Predicate;
+import java.util.function.Function;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
+import net.sourceforge.pmd.properties.ValueParser;
+
/**
+ * Base class for generic property builders.
+ *
+ * @param Concrete type of this builder instance
+ * @param Type of values the property handles
+ *
* @author Clément Fournier
* @since 6.7.0
*/
public abstract class AbstractPropertyBuilder, T> {
private static final Pattern NAME_PATTERN = Pattern.compile("[a-zA-Z][\\w-]*");
- protected final Set> validators = new LinkedHashSet<>();
- protected String name;
- protected String description;
- protected float uiOrder = 0f;
+ private final Set> validators = new LinkedHashSet<>();
+ private String name;
+ private String description;
+ private float uiOrder = 0f;
+ private T defaultValue;
- public AbstractPropertyBuilder(String name) {
+ AbstractPropertyBuilder(String name) {
+
if (StringUtils.isBlank(name)) {
throw new IllegalArgumentException("Name must be provided");
} else if (!NAME_PATTERN.matcher(name).matches()) {
@@ -34,6 +47,26 @@ public abstract class AbstractPropertyBuilder> getValidators() {
+ return validators;
+ }
+
+
+ String getDescription() {
+ return description;
+ }
+
+
+ float getUiOrder() {
+ return uiOrder;
+ }
+
+
+ T getDefaultValue() {
+ return defaultValue;
+ }
+
+
/**
* Specify the description of the property.
*
@@ -66,8 +99,22 @@ public abstract class AbstractPropertyBuilder pred, String errorMessage) {
- validators.add(PropertyValidator.fromPredicate(pred, errorMessage));
+ B addValidator(PropertyValidator validator) {
+ validators.add(validator);
+ return (B) this;
+ }
+
+
+ /**
+ * Specify a default value.
+ *
+ * @param val Value
+ *
+ * @return The same builder
+ */
+ @SuppressWarnings("unchecked")
+ public B defaultValue(T val) {
+ this.defaultValue = val;
return (B) this;
}
@@ -88,4 +135,117 @@ public abstract class AbstractPropertyBuilderThis class is abstract because the B type parameter
+ * prevents it to be instantiated anyway. That type parameter
+ * is of use to more refined concrete subclasses.
+ *
+ * @param Concrete type of this builder instance
+ * @param Type of values the property handles
+ *
+ * @author Clément Fournier
+ * @since 6.7.0
+ */
+ public abstract static class GenericPropertyBuilder, T> extends AbstractPropertyBuilder {
+
+
+ private final ValueParser parser;
+ private final Class type;
+
+
+ GenericPropertyBuilder(String name, ValueParser parser, Class type) {
+ super(name);
+ this.parser = parser;
+ this.type = type;
+ }
+
+
+ @Override
+ public PropertyDescriptor build() {
+ return new GenericPropertyDescriptor<>(
+ getName(),
+ getDescription(),
+ getUiOrder(),
+ getDefaultValue(),
+ getValidators(),
+ parser,
+ type
+ );
+ }
+
+
+ }
+
+ /**
+ * Builder for a generic multi-value property.
+ *
+ * This class is abstract because the B type parameter
+ * prevents it to be instantiated anyway. That type parameter
+ * is of use to more refined concrete subclasses.
+ *
+ * @param Concrete type of this builder instance
+ * @param Type of values the property handles. This is the component type of the list
+ *
+ * @author Clément Fournier
+ * @since 6.7.0
+ */
+ public abstract static class AbstractGenericMultiPropertyBuilder>, V> extends AbstractPropertyBuilder> {
+ private final Set> componentValidators = new LinkedHashSet<>();
+ private final Function parser;
+ private final Class type;
+
+
+ AbstractGenericMultiPropertyBuilder(String name, Function parser, Class type) {
+ super(name);
+ this.parser = parser;
+ this.type = type;
+ }
+
+
+ /**
+ * Specify a default value.
+ *
+ * @param val List of values
+ *
+ * @return The same builder
+ */
+ @SuppressWarnings("unchecked")
+ public B defaultValues(Collection extends V> val) {
+ super.defaultValue(new ArrayList<>(val));
+ return (B) this;
+ }
+
+
+ /**
+ * Specify default values.
+ *
+ * @param val List of values
+ *
+ * @return The same builder
+ */
+ @SuppressWarnings("unchecked")
+ public B defaultValues(V... val) {
+ super.defaultValue(Arrays.asList(val));
+ return (B) this;
+ }
+
+
+ @Override
+ public PropertyDescriptor> build() {
+ return new GenericMultiValuePropertyDescriptor<>(
+ getName(),
+ getDescription(),
+ getUiOrder(),
+ getDefaultValue(),
+ getValidators(),
+ componentValidators,
+ parser,
+ type
+ );
+ }
+ }
}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractSingleValuePropertyBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractSingleValuePropertyBuilder.java
deleted file mode 100644
index 5d90a8fbc3..0000000000
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractSingleValuePropertyBuilder.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
- */
-
-package net.sourceforge.pmd.properties.newframework;
-
-import java.util.function.Function;
-
-
-/**
- * @author Clément Fournier
- * @since 6.7.0
- */
-public abstract class AbstractSingleValuePropertyBuilder, T> extends AbstractPropertyBuilder {
-
-
- private final Function parser;
- private final Class type;
-
- private T defaultValue;
-
-
- AbstractSingleValuePropertyBuilder(String name, Function parser, Class type) {
- super(name);
- this.parser = parser;
- this.type = type;
- }
-
-
- @Override
- public PropertyDescriptor build() {
- return new SingleValuePropertyDescriptor<>(
- name,
- description,
- uiOrder,
- defaultValue,
- validators,
- parser,
- type
- );
- }
-
-
- /**
- * Specify a default value.
- *
- * @param val Value
- *
- * @return The same builder
- */
- @SuppressWarnings("unchecked")
- public B defaultValue(T val) {
- this.defaultValue = val;
- return (B) this;
- }
-
-
- /**
- * Returns the name of the property to be built.
- */
- @Override
- public String getName() {
- return name;
- }
-}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/MultiValuePropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/GenericMultiValuePropertyDescriptor.java
similarity index 68%
rename from pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/MultiValuePropertyDescriptor.java
rename to pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/GenericMultiValuePropertyDescriptor.java
index 440f7ae762..f90db3cdc3 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/MultiValuePropertyDescriptor.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/GenericMultiValuePropertyDescriptor.java
@@ -4,6 +4,7 @@
package net.sourceforge.pmd.properties.newframework;
+import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Set;
@@ -15,22 +16,20 @@ import java.util.stream.Collectors;
* @author Clément Fournier
* @since 6.7.0
*/
-final class MultiValuePropertyDescriptor extends AbstractPropertyDescriptor> {
+final class GenericMultiValuePropertyDescriptor extends AbstractGenericPropertyDescriptor> {
- private final List defaultValue;
private final Set> componentValidators;
private final Function parser;
- MultiValuePropertyDescriptor(String name, String description, float uiOrder,
- List defaultValue,
- Set>> listValidators,
- Set> componentValidators,
- Function parser,
- Class type) {
- super(name, description, uiOrder, listValidators, type);
- this.defaultValue = defaultValue;
+ GenericMultiValuePropertyDescriptor(String name, String description, float uiOrder,
+ List defaultValue,
+ Set>> listValidators,
+ Set> componentValidators,
+ Function parser,
+ Class type) {
+ super(name, description, uiOrder, defaultValue, listValidators, type);
this.componentValidators = componentValidators;
this.parser = parser;
}
@@ -44,7 +43,7 @@ final class MultiValuePropertyDescriptor extends AbstractPropertyDescriptor getDefaultValue() {
- return defaultValue;
+ return Collections.unmodifiableList(defaultValue);
}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/GenericPropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/GenericPropertyDescriptor.java
new file mode 100644
index 0000000000..6037ccf4ce
--- /dev/null
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/GenericPropertyDescriptor.java
@@ -0,0 +1,49 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+
+package net.sourceforge.pmd.properties.newframework;
+
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.pmd.properties.ValueParser;
+
+
+/**
+ * @author Clément Fournier
+ * @since 6.7.0
+ */
+final class GenericPropertyDescriptor extends AbstractGenericPropertyDescriptor {
+
+
+ private final ValueParser parser;
+
+
+ GenericPropertyDescriptor(String name,
+ String description,
+ float uiOrder,
+ T defaultValue,
+ Set> validators,
+ ValueParser parser,
+ Class type) {
+ super(name, description, uiOrder, defaultValue, validators, type);
+ this.parser = parser;
+ }
+
+
+ @Override
+ public boolean isMultiValue() {
+ return false;
+ }
+
+
+ @Override
+ public T valueFrom(List valuesList) throws IllegalArgumentException {
+ if (valuesList.size() != 1) {
+ throw new IllegalArgumentException("This property can only handle a single value, but " + valuesList.size() + " was supplied");
+ }
+
+ return parser.valueOf(valuesList.get(0));
+ }
+}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyFactory.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyFactory.java
index 0f41476d16..85b70d5fed 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyFactory.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyFactory.java
@@ -4,10 +4,11 @@
package net.sourceforge.pmd.properties.newframework;
-import java.util.function.Function;
-
import org.apache.commons.lang3.EnumUtils;
+import net.sourceforge.pmd.properties.ValueParser;
+import net.sourceforge.pmd.properties.newframework.AbstractPropertyBuilder.GenericPropertyBuilder;
+
/**
* @author Clément Fournier
@@ -20,38 +21,42 @@ public final class PropertyFactory {
}
+ private static > T enumConstantFromEnum(Class enumClass, String name) {
+ return EnumUtils.getEnumList(enumClass).stream()
+ .filter(e -> e.name().equalsIgnoreCase(name))
+ .findFirst()
+ .orElseThrow(() -> new IllegalArgumentException("The name '" + name + "' doesn't correspond to any constant in the enum '" + enumClass.getName() + "'"));
+ }
+
+
public static NumericPropertyBuilder intProperty(String name) {
return new NumericPropertyBuilder<>(name, Integer::valueOf, Integer.class);
}
- // TODO need a way to document the possible values
+
public static > GenericPBuilder enumProperty(String name, Class enumClass) {
- return new GenericPBuilder<>(name, s ->
- EnumUtils.getEnumList(enumClass).stream()
- .filter(e -> e.name().equalsIgnoreCase(s))
- .findFirst()
- .orElseThrow(() -> new IllegalArgumentException("The name '" + s + "' doesn't correspond to any constant in the enum '" + enumClass.getName() + "'"))
- , enumClass);
+ return new GenericPBuilder<>(name, s -> enumConstantFromEnum(enumClass, s), enumClass);
}
// removes the other type parameter
- public static class GenericPBuilder extends AbstractSingleValuePropertyBuilder, T> {
+ public static class GenericPBuilder extends GenericPropertyBuilder, T> {
- GenericPBuilder(String name, Function parser, Class type) {
+ GenericPBuilder(String name, ValueParser parser, Class type) {
super(name, parser, type);
}
}
- public static class NumericPropertyBuilder extends AbstractSingleValuePropertyBuilder, N> {
+ public static class NumericPropertyBuilder extends GenericPropertyBuilder, N> {
- NumericPropertyBuilder(String name, Function parser, Class type) {
+ NumericPropertyBuilder(String name, ValueParser parser, Class type) {
super(name, parser, type);
}
- public NumericPropertyBuilder requirePositive() {
- return addValidator(n -> n.intValue() > 0, "Expected a positive number");
+ // TODO rename
+ public NumericPropertyBuilder range(N min, N max) {
+ return addValidator(Validators.rangeValidator(min, max));
}
}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyValidator.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyValidator.java
index f97bb3d8fb..e42349b1d5 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyValidator.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyValidator.java
@@ -5,22 +5,42 @@
package net.sourceforge.pmd.properties.newframework;
import java.util.Optional;
-import java.util.function.Predicate;
/**
+ * Validates the value of a property.
+ *
+ * @param Type of value to handle
+ *
* @author Clément Fournier
* @since 6.7.0
*/
-@FunctionalInterface
public interface PropertyValidator {
+ /**
+ * Returns a diagnostic message if the value
+ * has a problem. Otherwise returns an empty
+ * optional.
+ *
+ * @param value The value to validate
+ *
+ * @return An optional diagnostic message
+ */
Optional validate(T value);
- static PropertyValidator fromPredicate(Predicate pred, String failureMessage) {
- return u -> pred.test(u) ? Optional.empty() : Optional.of(failureMessage);
- }
+ /**
+ * Returns a description of the constraint
+ * imposed by this validator on the values.
+ * E.g. "The value should be positive", or
+ * "The value should be one of A | B | C."
+ *
+ * @return A description of the constraint
+ */
+ String getConstraintDescription();
+
+
+ // TODO Java 8 move PropertyFactory#fromPredicate here
}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/SingleValuePropertyDescriptor.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/SingleValuePropertyDescriptor.java
deleted file mode 100644
index 12eebe7acd..0000000000
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/SingleValuePropertyDescriptor.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
- */
-
-package net.sourceforge.pmd.properties.newframework;
-
-import java.util.List;
-import java.util.Set;
-import java.util.function.Function;
-
-
-/**
- * @author Clément Fournier
- * @since 6.7.0
- */
-final class SingleValuePropertyDescriptor extends AbstractPropertyDescriptor {
-
-
- private final T defaultValue;
- private final Function parser;
-
-
- SingleValuePropertyDescriptor(String name, String description, float uiOrder,
- T defaultValue,
- Set> validators,
- Function parser,
- Class type) {
- super(name, description, uiOrder, validators, type);
- this.defaultValue = defaultValue;
- this.parser = parser;
- }
-
-
- @Override
- public boolean isMultiValue() {
- return false;
- }
-
-
- @Override
- public T getDefaultValue() {
- return defaultValue;
- }
-
-
- @Override
- public T valueFrom(List valuesList) throws IllegalArgumentException {
- if (valuesList.size() != 1) {
- throw new IllegalArgumentException("This property can only handle a single value, but " + valuesList.size() + " was supplied");
- }
-
- return parser.apply(valuesList.get(0));
- }
-}
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/Validators.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/Validators.java
new file mode 100644
index 0000000000..bfe5848a86
--- /dev/null
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/Validators.java
@@ -0,0 +1,70 @@
+/**
+ * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
+ */
+
+package net.sourceforge.pmd.properties.newframework;
+
+import java.util.Optional;
+
+
+/**
+ * Transitional class to make up for the absence of lambdas until we move to Java 8.
+ *
+ * @author Clément Fournier
+ * @since 6.7.0
+ */
+final class Validators {
+
+ private Validators() {
+
+ }
+
+
+ public static PropertyValidator rangeValidator(T min, T max) {
+ return fromPredicate(new Predicate() {
+ @Override
+ public boolean test(T t) {
+ return min.doubleValue() < t.doubleValue() && max.doubleValue() > t.doubleValue();
+ }
+ },
+ "Should be between " + min + " and " + max
+ );
+ }
+
+
+ /**
+ * Builds a new validator from a predicate,
+ * and documentation messages.
+ *
+ * @param pred The predicate. If it returns
+ * false on a value, then the
+ * value is deemed to have a
+ * problem and the failureMessage
+ * will be transmitted.
+ * @param constraintDescription Description of the constraint,
+ * see {@link PropertyValidator#getConstraintDescription()}.
+ * @param Type of value to validate
+ *
+ * @return A new validator
+ */
+ private static PropertyValidator fromPredicate(Predicate pred, String constraintDescription) {
+ return new PropertyValidator() {
+ @Override
+ public Optional validate(U value) {
+ return pred.test(value) ? Optional.empty() : Optional.of("Constraint violated on value '" + value + "' (" + constraintDescription + ")");
+ }
+
+
+ @Override
+ public String getConstraintDescription() {
+ return constraintDescription;
+ }
+ };
+ }
+
+
+ // Until we have Java 8
+ interface Predicate {
+ boolean test(T t);
+ }
+}
From de176384f773996db15474f2672dcc1df850c06e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?=
Date: Mon, 29 Oct 2018 23:10:14 +0100
Subject: [PATCH 022/139] Try to integrate in current framework
---
.../rule/design/CyclomaticComplexityRule.java | 2 +-
.../AbstractPropertyBuilder.java | 23 ++--
.../GenericMultiValuePropertyDescriptor.java | 71 +++++++++++
.../properties/GenericPropertyDescriptor.java | 45 +++++++
.../{newframework => }/PropertyFactory.java | 20 ++-
.../{newframework => }/PropertyValidator.java | 10 +-
.../{newframework => }/Validators.java | 9 +-
.../AbstractGenericPropertyDescriptor.java | 86 -------------
.../GenericMultiValuePropertyDescriptor.java | 66 ----------
.../GenericPropertyDescriptor.java | 49 --------
.../newframework/PropertyDescriptor.java | 116 ------------------
11 files changed, 153 insertions(+), 344 deletions(-)
rename pmd-core/src/main/java/net/sourceforge/pmd/properties/{newframework => }/AbstractPropertyBuilder.java (89%)
create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/GenericMultiValuePropertyDescriptor.java
create mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/GenericPropertyDescriptor.java
rename pmd-core/src/main/java/net/sourceforge/pmd/properties/{newframework => }/PropertyFactory.java (68%)
rename pmd-core/src/main/java/net/sourceforge/pmd/properties/{newframework => }/PropertyValidator.java (83%)
rename pmd-core/src/main/java/net/sourceforge/pmd/properties/{newframework => }/Validators.java (86%)
delete mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractGenericPropertyDescriptor.java
delete mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/GenericMultiValuePropertyDescriptor.java
delete mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/GenericPropertyDescriptor.java
delete mode 100644 pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/PropertyDescriptor.java
diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java
index e8d6b6a450..f3fda24a87 100644
--- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java
+++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/rule/design/CyclomaticComplexityRule.java
@@ -17,7 +17,7 @@ import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule;
import net.sourceforge.pmd.lang.metrics.ResultOption;
import net.sourceforge.pmd.properties.IntegerProperty;
import net.sourceforge.pmd.properties.newframework.PropertyDescriptor;
-import net.sourceforge.pmd.properties.newframework.PropertyFactory;
+import net.sourceforge.pmd.properties.PropertyFactory;
/**
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyBuilder.java b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractPropertyBuilder.java
similarity index 89%
rename from pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyBuilder.java
rename to pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractPropertyBuilder.java
index 4010bfaeec..7ba53b4c08 100644
--- a/pmd-core/src/main/java/net/sourceforge/pmd/properties/newframework/AbstractPropertyBuilder.java
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/properties/AbstractPropertyBuilder.java
@@ -2,7 +2,7 @@
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
-package net.sourceforge.pmd.properties.newframework;
+package net.sourceforge.pmd.properties;
import java.util.ArrayList;
import java.util.Arrays;
@@ -10,13 +10,10 @@ import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
-import java.util.function.Function;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
-import net.sourceforge.pmd.properties.ValueParser;
-
/**
* Base class for generic property builders.
@@ -155,12 +152,14 @@ public abstract class AbstractPropertyBuilder parser;
private final Class type;
+ private final boolean isDefinedExternally;
- GenericPropertyBuilder(String name, ValueParser parser, Class type) {
+ GenericPropertyBuilder(String name, ValueParser parser, Class type, boolean isDefinedExternally) {
super(name);
this.parser = parser;
this.type = type;
+ this.isDefinedExternally = isDefinedExternally;
}
@@ -173,7 +172,8 @@ public abstract class AbstractPropertyBuilder>, V> extends AbstractPropertyBuilder> {
private final Set> componentValidators = new LinkedHashSet<>();
- private final Function parser;
+ private final ValueParser parser;
private final Class type;
+ private final boolean isDefinedExternally;
- AbstractGenericMultiPropertyBuilder(String name, Function parser, Class type) {
+ AbstractGenericMultiPropertyBuilder(String name, ValueParser parser, Class type, boolean isDefinedExternally) {
super(name);
this.parser = parser;
this.type = type;
+ this.isDefinedExternally = isDefinedExternally;
}
@@ -236,7 +238,7 @@ public abstract class AbstractPropertyBuilder> build() {
- return new GenericMultiValuePropertyDescriptor<>(
+ return new GenericMultiValuePropertyDescriptor(
getName(),
getDescription(),
getUiOrder(),
@@ -244,7 +246,8 @@ public abstract class AbstractPropertyBuilder extends AbstractMultiValueProperty