From 2a59be965a879b1b924db9be4c2aac1aec703379 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Fri, 2 Feb 2024 12:42:26 +0100 Subject: [PATCH] [visualforce] Remove deprecated classes/methods --- docs/pages/release_notes.md | 8 ++++ .../net/sourceforge/pmd/lang/vf/DataType.java | 38 ------------------- .../sourceforge/pmd/lang/vf/ast/VfNode.java | 14 ------- .../pmd/lang/vf/ast/VfParserVisitor.java | 19 ---------- .../lang/vf/ast/VfParserVisitorAdapter.java | 13 ------- .../pmd/lang/vf/rule/AbstractVfRule.java | 10 ++++- .../sourceforge/pmd/lang/vf/DataTypeTest.java | 11 ------ 7 files changed, 16 insertions(+), 97 deletions(-) delete mode 100644 pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfParserVisitor.java delete mode 100644 pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfParserVisitorAdapter.java diff --git a/docs/pages/release_notes.md b/docs/pages/release_notes.md index 5608db7951..fca52bee88 100644 --- a/docs/pages/release_notes.md +++ b/docs/pages/release_notes.md @@ -251,6 +251,14 @@ The following previously deprecated classes have been removed: * Method `getNode()` has been removed. The underlying node is only available in AST nodes, but not in rule implementations. * {%jdoc !!scala::lang.scala.ast.AbstractScalaNode %} - method `getNode()` has been removed. AST nodes still have access to the underlying Scala node via the protected property `node`. +* pmd-visualforce + * {%jdoc !!visualforce::lang.vf.ast.VfNode %} - method `jjtAccept()` has been removed. + Use {%jdoc core::lang.ast.Node#acceptVisitor(core::lang.ast.AstVisitor,P) %} instead. + * `net.sourceforge.pmd.lang.vf.ast.VfParserVisitor` + Use {%jdoc visualforce::lang.vf.ast.VfVisitor %} or {%jdoc visualforce::lang.vf.ast.VfVisitorBase %} instead. + * `net.sourceforge.pmd.lang.vf.ast.VfParserVisitorAdapter` + * {%jdoc !!visualforce::lang.vf.DataType %} - method `fromBasicType(BasicType)` has been removed. + Use {%jdoc visualforce::lang.vf.DataType#fromTypeName(java.lang.String) %} instead. * pmd-vm * {%jdoc !!vm::lang.vm.ast.VmNode %} - method `jjtAccept()` has been removed. Use {%jdoc core::lang.ast.Node#acceptVisitor(core::lang.ast.AstVisitor,P) %} instead. diff --git a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/DataType.java b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/DataType.java index 5d800ec6ca..a4cb3a2a62 100644 --- a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/DataType.java +++ b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/DataType.java @@ -14,8 +14,6 @@ import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import apex.jorje.semantic.symbol.type.BasicType; - /** * Represents all data types that can be referenced from a Visualforce page. This enum consolidates the data types * available to CustomFields and Apex. It uses the naming convention of CustomFields. @@ -106,42 +104,6 @@ public enum DataType { return dataType; } - /** - * Map to correct instance, returns {@code Unknown} if the value can't be mapped. - * - * @deprecated Use {@link #fromTypeName(String)} instead. - */ - @Deprecated - public static DataType fromBasicType(BasicType value) { - if (value != null) { - switch (value) { - case BOOLEAN: - return Checkbox; - case CURRENCY: - return Currency; - case DATE: - return Date; - case DATE_TIME: - return DateTime; - case ID: - return Lookup; - case DECIMAL: - case DOUBLE: - case INTEGER: - case LONG: - return Number; - case STRING: - return Text; - case TIME: - return Time; - default: - break; - } - } - LOG.debug("Unable to determine DataType of {}", value); - return Unknown; - } - /** * Map to correct instance, returns {@code Unknown} if the value can't be mapped. */ diff --git a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfNode.java b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfNode.java index ec46775e6e..b8cc32a2c2 100644 --- a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfNode.java +++ b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfNode.java @@ -4,21 +4,7 @@ package net.sourceforge.pmd.lang.vf.ast; -import net.sourceforge.pmd.annotation.DeprecatedUntil700; -import net.sourceforge.pmd.lang.ast.AstVisitor; import net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeNode; public interface VfNode extends JjtreeNode { - - /** - * Accept the visitor. - * - * @deprecated Use {@link #acceptVisitor(AstVisitor, Object)} - */ - @Deprecated - @DeprecatedUntil700 - default Object jjtAccept(VfParserVisitor visitor, Object data) { - return acceptVisitor(visitor, data); - } - } diff --git a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfParserVisitor.java b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfParserVisitor.java deleted file mode 100644 index c6f71a377a..0000000000 --- a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfParserVisitor.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -package net.sourceforge.pmd.lang.vf.ast; - -import net.sourceforge.pmd.annotation.DeprecatedUntil700; -import net.sourceforge.pmd.lang.ast.Node; - -@Deprecated -@DeprecatedUntil700 -public interface VfParserVisitor extends VfVisitor { - - @Override - default Object visitNode(Node node, Object param) { - node.children().forEach(it -> it.acceptVisitor(this, param)); - return param; - } -} diff --git a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfParserVisitorAdapter.java b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfParserVisitorAdapter.java deleted file mode 100644 index 154df0f261..0000000000 --- a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/ast/VfParserVisitorAdapter.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - -package net.sourceforge.pmd.lang.vf.ast; - -import net.sourceforge.pmd.annotation.DeprecatedUntil700; - -@Deprecated -@DeprecatedUntil700 -public class VfParserVisitorAdapter extends VfVisitorBase implements VfParserVisitor { - -} diff --git a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/rule/AbstractVfRule.java b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/rule/AbstractVfRule.java index 4fb6e82f79..fc6d427773 100644 --- a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/rule/AbstractVfRule.java +++ b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/rule/AbstractVfRule.java @@ -7,12 +7,18 @@ package net.sourceforge.pmd.lang.vf.rule; import net.sourceforge.pmd.RuleContext; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.rule.AbstractRule; -import net.sourceforge.pmd.lang.vf.ast.VfParserVisitor; +import net.sourceforge.pmd.lang.vf.ast.VfVisitor; -public abstract class AbstractVfRule extends AbstractRule implements VfParserVisitor { +public abstract class AbstractVfRule extends AbstractRule implements VfVisitor { @Override public void apply(Node target, RuleContext ctx) { target.acceptVisitor(this, ctx); } + + @Override + public Object visitNode(Node node, Object param) { + node.children().forEach(n -> n.acceptVisitor(this, param)); + return param; + } } diff --git a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/DataTypeTest.java b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/DataTypeTest.java index fbf9da60fd..22e0de81c0 100644 --- a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/DataTypeTest.java +++ b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/DataTypeTest.java @@ -10,8 +10,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; -import apex.jorje.semantic.symbol.type.BasicType; - class DataTypeTest { @Test void testFromString() { @@ -33,15 +31,6 @@ class DataTypeTest { assertEquals(DataType.Unknown, DataType.fromTypeName(null)); } - @Test - void testDeprecatedFromBasicType() { - assertEquals(DataType.Checkbox, DataType.fromBasicType(BasicType.BOOLEAN)); - assertEquals(DataType.Number, DataType.fromBasicType(BasicType.DECIMAL)); - assertEquals(DataType.Number, DataType.fromBasicType(BasicType.DOUBLE)); - assertEquals(DataType.Unknown, DataType.fromBasicType(BasicType.APEX_OBJECT)); - assertEquals(DataType.Unknown, DataType.fromBasicType(null)); - } - @Test void testRequiresEncoding() { assertFalse(DataType.AutoNumber.requiresEscaping);