Merge pull request #4792 from adangel:undeprecate-node-getImage

[core] Undeprecate Node::getImage() in PMD 7 #4792
This commit is contained in:
Andreas Dangel
2024-02-02 19:49:26 +01:00
9 changed files with 15 additions and 22 deletions

View File

@ -23,7 +23,6 @@ public final class ASTAnnotation extends AbstractApexNode<Annotation> {
}
@Override
@Deprecated
public String getImage() {
return getName();
}

View File

@ -38,7 +38,6 @@ public final class ASTAnnotationParameter extends AbstractApexNode<AnnotationPar
}
@Override
@Deprecated
public String getImage() {
return getValue();
}

View File

@ -4,8 +4,6 @@
package net.sourceforge.pmd.lang.apex.ast;
import net.sourceforge.pmd.annotation.DeprecatedUntil700;
import apex.jorje.semantic.ast.compilation.Compilation;
abstract class BaseApexClass<T extends Compilation> extends AbstractApexNode<T> implements ASTUserClassOrInterface<T> {
@ -21,12 +19,7 @@ abstract class BaseApexClass<T extends Compilation> extends AbstractApexNode<T>
return true;
}
/**
* @deprecated Use {@link #getSimpleName()}
*/
@Override
@Deprecated
@DeprecatedUntil700
public String getImage() {
return getSimpleName();
}

View File

@ -72,11 +72,12 @@ public interface Node extends Reportable {
* node. This is usually an identifier, but you should check that using the Designer. On most nodes though, this
* method returns {@code null}.
*
* @deprecated Should be replaced with methods that have more specific
* names in node classes.
* <p><strong>Note:</strong>
* This method will be deprecated in the future (<a href="https://github.com/pmd/pmd/issues/4787">#4787</a>).
* It will be replaced with methods that have more specific names in node classes. In some cases, there
* are already alternatives available that should be used.</p>
*/
@Deprecated
@DeprecatedUntil700
// @Deprecated // todo deprecate (#4787)
default String getImage() {
return null;
}
@ -85,12 +86,13 @@ public interface Node extends Reportable {
/**
* Returns true if this node's image is equal to the given string.
*
* <p><strong>Note:</strong>
* This method will be deprecated in the future (<a href="https://github.com/pmd/pmd/issues/4787">#4787</a>).
* See {@link #getImage()}.
* </p>
* @param image The image to check
*
* @deprecated See {@link #getImage()}
*/
@Deprecated
@DeprecatedUntil700
// @Deprecated // todo deprecate (#4787)
default boolean hasImageEqualTo(String image) {
return Objects.equals(getImage(), image);
}

View File

@ -38,7 +38,7 @@ public abstract class AbstractJjtreeNode<B extends AbstractJjtreeNode<B, N>, N e
}
@Override
// @Deprecated // todo deprecate, will change tree dump tests
// @Deprecated // todo deprecate, will change tree dump tests (#4787)
public String getImage() {
return image;
}

View File

@ -71,7 +71,7 @@ public interface ASTTypeDeclaration
/**
* @deprecated Use {@link #getSimpleName()}
*/
@Deprecated
@Deprecated // note: already deprecated in 6.55.0
@DeprecatedAttribute(replaceWith = "@SimpleName")
@Override
String getImage();

View File

@ -119,7 +119,7 @@ public final class ASTVariableId extends AbstractTypedSymbolDeclarator<JVariable
*/
@Override
@DeprecatedAttribute(replaceWith = "@Name")
@Deprecated
@Deprecated // note: already deprecated in 6.55.0
public String getImage() {
return getName();
}

View File

@ -40,7 +40,7 @@ abstract class AbstractTypeDeclaration extends AbstractTypedSymbolDeclarator<JCl
/**
* @deprecated Use {@link #getSimpleName()}
*/
@Deprecated
@Deprecated // note: already deprecated in 6.55.0
@DeprecatedAttribute(replaceWith = "@SimpleName")
@Override
public String getImage() {

View File

@ -42,7 +42,7 @@ public class JavaComment implements Reportable {
*/
@Deprecated
public String getImage() {
return getToken().getImage();
return getText().toString();
}
/** The token underlying this comment. */