From 34693e4ca0b39be284d65824fbfae8994f5fe144 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Tue, 19 Dec 2023 20:44:42 +0100 Subject: [PATCH] [scala] Avoid using @Image --- .../java/net/sourceforge/pmd/lang/scala/ast/ASTLitBoolean.java | 3 +-- .../java/net/sourceforge/pmd/lang/scala/ast/ASTLitByte.java | 3 +-- .../java/net/sourceforge/pmd/lang/scala/ast/ASTLitChar.java | 3 +-- .../java/net/sourceforge/pmd/lang/scala/ast/ASTLitDouble.java | 3 +-- .../java/net/sourceforge/pmd/lang/scala/ast/ASTLitFloat.java | 3 +-- .../java/net/sourceforge/pmd/lang/scala/ast/ASTLitInt.java | 3 +-- .../java/net/sourceforge/pmd/lang/scala/ast/ASTLitLong.java | 3 +-- .../java/net/sourceforge/pmd/lang/scala/ast/ASTLitNull.java | 3 +-- .../java/net/sourceforge/pmd/lang/scala/ast/ASTLitShort.java | 3 +-- .../java/net/sourceforge/pmd/lang/scala/ast/ASTLitString.java | 3 +-- .../java/net/sourceforge/pmd/lang/scala/ast/ASTLitSymbol.java | 3 +-- .../java/net/sourceforge/pmd/lang/scala/ast/ASTLitUnit.java | 3 +-- .../net/sourceforge/pmd/lang/scala/ast/ASTNameAnonymous.java | 3 +-- .../sourceforge/pmd/lang/scala/ast/ASTNameIndeterminate.java | 3 +-- .../java/net/sourceforge/pmd/lang/scala/ast/ASTTermName.java | 3 +-- .../java/net/sourceforge/pmd/lang/scala/ast/ASTTypeName.java | 3 +-- .../net/sourceforge/pmd/lang/scala/rule/ScalaRuleTest.java | 2 +- .../net/sourceforge/pmd/lang/scala/rule/XPathRuleTest.java | 2 +- 18 files changed, 18 insertions(+), 34 deletions(-) diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitBoolean.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitBoolean.java index e15ba1e3d5..a3b490f86e 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitBoolean.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitBoolean.java @@ -20,8 +20,7 @@ public final class ASTLitBoolean extends AbstractScalaNode { return visitor.visit(this, data); } - @Override - public String getImage() { + public String getValue() { return String.valueOf(node.value()); } } diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitByte.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitByte.java index 8c8e4d73ba..9dbfcd6ae9 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitByte.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitByte.java @@ -20,8 +20,7 @@ public final class ASTLitByte extends AbstractScalaNode { return visitor.visit(this, data); } - @Override - public String getImage() { + public String getValue() { return String.valueOf(node.value()); } } diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitChar.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitChar.java index 85ea9ae940..6288fe52da 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitChar.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitChar.java @@ -20,8 +20,7 @@ public final class ASTLitChar extends AbstractScalaNode { return visitor.visit(this, data); } - @Override - public String getImage() { + public String getValue() { return String.valueOf(node.value()); } } diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitDouble.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitDouble.java index bcc328db61..52330775e9 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitDouble.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitDouble.java @@ -20,8 +20,7 @@ public final class ASTLitDouble extends AbstractScalaNode { return visitor.visit(this, data); } - @Override - public String getImage() { + public String getValue() { return String.valueOf(node.value()); } } diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitFloat.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitFloat.java index 8a58620747..ff59afff3d 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitFloat.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitFloat.java @@ -20,8 +20,7 @@ public final class ASTLitFloat extends AbstractScalaNode { return visitor.visit(this, data); } - @Override - public String getImage() { + public String getValue() { return String.valueOf(node.value()); } } diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitInt.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitInt.java index 8dc3cde2d1..02b1c284c6 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitInt.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitInt.java @@ -20,8 +20,7 @@ public final class ASTLitInt extends AbstractScalaNode { return visitor.visit(this, data); } - @Override - public String getImage() { + public String getValue() { return String.valueOf(node.value()); } } diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitLong.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitLong.java index 7fc2a5cea8..bbf3144378 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitLong.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitLong.java @@ -20,8 +20,7 @@ public final class ASTLitLong extends AbstractScalaNode { return visitor.visit(this, data); } - @Override - public String getImage() { + public String getValue() { return String.valueOf(node.value()); } } diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitNull.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitNull.java index dc966c9b97..ce6c705b6a 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitNull.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitNull.java @@ -20,8 +20,7 @@ public final class ASTLitNull extends AbstractScalaNode { return visitor.visit(this, data); } - @Override - public String getImage() { + public String getValue() { return String.valueOf(node.value()); } } diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitShort.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitShort.java index 22d7e3d898..9dc01d2252 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitShort.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitShort.java @@ -20,8 +20,7 @@ public final class ASTLitShort extends AbstractScalaNode { return visitor.visit(this, data); } - @Override - public String getImage() { + public String getValue() { return String.valueOf(node.value()); } } diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitString.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitString.java index fd55565cd4..e001f3a953 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitString.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitString.java @@ -20,8 +20,7 @@ public final class ASTLitString extends AbstractScalaNode { return visitor.visit(this, data); } - @Override - public String getImage() { + public String getValue() { return String.valueOf(node.value()); } } diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitSymbol.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitSymbol.java index 113560d02b..d4a308d171 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitSymbol.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitSymbol.java @@ -20,8 +20,7 @@ public final class ASTLitSymbol extends AbstractScalaNode { return visitor.visit(this, data); } - @Override - public String getImage() { + public String getValue() { return String.valueOf(node.value()); } } diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitUnit.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitUnit.java index 559e902a57..877bff747b 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitUnit.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTLitUnit.java @@ -20,8 +20,7 @@ public final class ASTLitUnit extends AbstractScalaNode { return visitor.visit(this, data); } - @Override - public String getImage() { + public String getValue() { return String.valueOf(node.value()); } } diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTNameAnonymous.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTNameAnonymous.java index c35925b927..eaecb9506d 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTNameAnonymous.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTNameAnonymous.java @@ -20,8 +20,7 @@ public final class ASTNameAnonymous extends AbstractScalaNode { return visitor.visit(this, data); } - @Override - public String getImage() { + public String getValue() { return node.value(); } } diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTNameIndeterminate.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTNameIndeterminate.java index 5aa220a8a1..56a472bd38 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTNameIndeterminate.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTNameIndeterminate.java @@ -20,8 +20,7 @@ public final class ASTNameIndeterminate extends AbstractScalaNode { return visitor.visit(this, data); } - @Override - public String getImage() { + public String getValue() { return node.value(); } } diff --git a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTypeName.java b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTypeName.java index ad2df50de4..66f866fed5 100644 --- a/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTypeName.java +++ b/pmd-scala-modules/pmd-scala-common/src/main/java/net/sourceforge/pmd/lang/scala/ast/ASTTypeName.java @@ -20,8 +20,7 @@ public final class ASTTypeName extends AbstractScalaNode { return visitor.visit(this, data); } - @Override - public String getImage() { + public String getValue() { return node.value(); } } diff --git a/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/ScalaRuleTest.java b/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/ScalaRuleTest.java index 144593dfef..fbf65864c7 100644 --- a/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/ScalaRuleTest.java +++ b/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/ScalaRuleTest.java @@ -49,7 +49,7 @@ class ScalaRuleTest extends BaseScalaTest { @Override public RuleContext visit(ASTTermApply node, RuleContext data) { ASTTermName child = node.getFirstChildOfType(ASTTermName.class); - if (child != null && child.hasImageEqualTo("println")) { + if (child != null && "println".equals(child.getValue())) { addViolation(data, node); } return data; diff --git a/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/XPathRuleTest.java b/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/XPathRuleTest.java index 303040dc59..8b3ae58acd 100644 --- a/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/XPathRuleTest.java +++ b/pmd-scala-modules/pmd-scala-common/src/test/java/net/sourceforge/pmd/lang/scala/rule/XPathRuleTest.java @@ -19,7 +19,7 @@ class XPathRuleTest extends BaseScalaTest { @Test void testPrintHelloWorld() { - Report report = evaluate(SCALA_TEST, "//TermApply/TermName[@Image=\"println\"]"); + Report report = evaluate(SCALA_TEST, "//TermApply/TermName[@Value=\"println\"]"); RuleViolation rv = report.getViolations().get(0); assertEquals(2, rv.getBeginLine()); }