Deprecate ASTPackageDeclaration#getPackageNameImage

This commit is contained in:
Clément Fournier
2020-10-31 15:18:19 +01:00
parent 2b9e3057a7
commit bc9557830a
2 changed files with 17 additions and 1 deletions

View File

@@ -72,7 +72,7 @@ public class ASTCompilationUnit extends AbstractJavaTypeNode implements RootNode
// @NonNull
public String getPackageName() {
ASTPackageDeclaration pdecl = getPackageDeclaration();
return pdecl == null ? "" : pdecl.getPackageNameImage();
return pdecl == null ? "" : pdecl.getName();
}
@InternalApi

View File

@@ -5,6 +5,7 @@
package net.sourceforge.pmd.lang.java.ast;
import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.xpath.internal.DeprecatedAttribute;
public class ASTPackageDeclaration extends AbstractJavaAnnotatableNode {
@@ -25,7 +26,22 @@ public class ASTPackageDeclaration extends AbstractJavaAnnotatableNode {
return visitor.visit(this, data);
}
/**
* @deprecated Use {@link #getName()}
*/
@Deprecated
@DeprecatedAttribute(replaceWith = "@Name")
public String getPackageNameImage() {
return getName();
}
/**
* Returns the name of the package.
*
* @since 6.30.0
*/
public String getName() {
return ((ASTName) getChild(this.getNumChildren() - 1)).getImage();
}
}