[java] Remove deprecated classes and methods
AbstractPackageNameModuleDirective#getImage AbstractTypeDeclaration#getImage ASTAnnotation#getAnnotationName ASTClassType#ASTClassType(String) ASTClassType#getImage ASTClassType#isReferenceToClassSameCompilationUnit ASTFieldDeclaration#getVariableName ASTLiteral#is_xxx_Literal ASTMethodDeclaration#getMethodName ASTMethodReference#getImage ASTModuleName#getImage ASTPrimitiveType#getImage ASTType#getTypeImage ASTType#getArrayDepth ASTType#isPrimitiveType #isArrayType #isClassOrInterfaceType ASTTypeDeclaration#getImage ASTUnaryExpression#isPrefix ASTVariableId#getImage ASTVariableId#getVariableName JavaComment#getImage JavaNode#jjtAccept JavaParserVisitor JavaParserVisitorAdapter ModifierOwner#isFinal #isAbstract ... #isPublic ... TypeNode#getType
This commit is contained in:
@ -297,6 +297,68 @@ The following previously deprecated rules have been finally removed:
|
||||
* {%jdoc !!apex::lang.apex.ast.ASTPrefixExpression %} - method `getOperator()` removed.
|
||||
Use {%jdoc apex::lang.apex.ast.ASTPrefixExpression#getOp() %} instead.
|
||||
* `net.sourceforge.pmd.lang.apex.rule.security.Helper` removed. This was actually internal API.
|
||||
* pmd-java
|
||||
* {%jdoc !!java::lang.java.ast.AbstractPackageNameModuleDirective %} - method `getImage()` has been removed.
|
||||
Use {%jdoc java::lang.java.ast.AbstractPackageNameModuleDirective#getPackageName() %} instead.
|
||||
* {%jdoc !!java::lang.java.ast.AbstractTypeDeclaration %} - method `getImage()` has been removed.
|
||||
Use {%jdoc java::lang.java.ast.AbstractTypeDeclaration#getSimpleName() %} instead.
|
||||
* {%jdoc !!java::lang.java.ast.ASTAnnotation %} - method `getAnnotationName()` has been removed.
|
||||
* {%jdoc !!java::lang.java.ast.ASTClassType %}
|
||||
* constructor `ASTClassType(java.lang.String)` has been removed.
|
||||
* method `getImage()` has been removed.
|
||||
* method `isReferenceToClassSameCompilationUnit()` has been removed.
|
||||
* {%jdoc !!java::lang.java.ast.ASTFieldDeclaration %} - method `getVariableName()` has been removed.
|
||||
* {%jdoc !!java::lang.java.ast.ASTLiteral %} - the following methods have been removed:
|
||||
* `isStringLiteral()` - use `node instanceof ASTStringLiteral` instead.
|
||||
* `isCharLiteral()` - use `node instanceof ASTCharLiteral` instead.
|
||||
* `isNullLiteral()` - use `node instanceof ASTNullLiteral` instead.
|
||||
* `isBooleanLiteral()` - use `node instanceof ASTBooleanLiteral` instead.
|
||||
* `isNumericLiteral()` - use `node instanceof ASTNumericLiteral` instead.
|
||||
* `isIntLiteral()` - use {%jdoc lang.java.ast.ASTNumericLiteral#isIntLiteral() %} instead.
|
||||
* `isLongLiteral()` - use {%jdoc lang.java.ast.ASTNumericLiteral#isLongLiteral() %} instead.
|
||||
* `isFloatLiteral()` - use {%jdoc lang.java.ast.ASTNumericLiteral#isFloatLiteral() %} instead.
|
||||
* `isDoubleLiteral()` - use {%jdoc lang.java.ast.ASTNumericLiteral#isDoubleLiteral() %} instead.
|
||||
* {%jdoc !!java::lang.java.ast.ASTMethodDeclaration %} - methods `getImage()` and `getMethodName()` have been removed.
|
||||
Use {%jdoc java::lang.java.ast.ASTMethodDeclaration#getName() %} instead.
|
||||
* {%jdoc !!java::lang.java.ast.ASTMethodReference %} - method `getImage()` has been removed.
|
||||
* {%jdoc !!java::lang.java.ast.ASTModuleName %} - method `getImage()` has been removed.
|
||||
* {%jdoc !!java::lang.java.ast.ASTPrimitiveType %} - method `getImage()` has been removed.
|
||||
* {%jdoc !!java::lang.java.ast.ASTType %}
|
||||
* `getTypeImage()` has been removed.
|
||||
* `getArrayDepth()` has been removed. It's only available for arrays: {%jdoc java::lang.java.ast.ASTArrayType#getArrayDepth() %}.
|
||||
* `isPrimitiveType()` - use `node instanceof ASTPrimitiveType` instead.
|
||||
* `isArrayType()` - use `node instanceof ASTArrayType` instead.
|
||||
* `isClassOrInterfaceType()` - use `node instanceof ASTClassType` instead.
|
||||
* {%jdoc !!java::lang.java.ast.ASTTypeDeclaration %} - method `getImage()` has been removed.
|
||||
* {%jdoc !!java::lang.java.ast.ASTUnaryExpression %} - method `isPrefix()` has been removed.
|
||||
Use {%jdoc java::lang.java.ast.ASTUnaryExpression#getOperator() %}`.isPrefix()` instead.
|
||||
* {%jdoc !!java::lang.java.ast.ASTVariableId %} - methods `getImage()` and `getVariableName()` have been removed.
|
||||
Use {%jdoc java::lang.java.ast.ASTVariableId#getName() %} instead.
|
||||
* {%jdoc !!java::lang.java.ast.JavaComment %} - method `getImage()` has been removed.
|
||||
Use {%jdoc java::lang.java.ast.JavaComment#getText() %} instead.
|
||||
* {%jdoc !!java::lang.java.ast.JavaNode %} - method `jjtAccept()` has been removed.
|
||||
Use {%jdoc core::lang.ast.Node#acceptVisitor(core::lang.ast.AstVisitor,P) %} instead.
|
||||
* `net.sourceforge.pmd.lang.java.ast.JavaParserVisitor`
|
||||
Use {%jdoc java::lang.java.ast.JavaVisitor %} or {%jdoc java::lang.java.ast.JavaVisitorBase %} instead.
|
||||
* `net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter`
|
||||
* {%jdoc !!java::lang.java.ast.ModifierOwner %}
|
||||
* `isFinal()` - This is still available in various subtypes, where it makes sense, e.g. {%jdoc java::lang.java.ast.ASTLocalVariableDeclaration#isFinal() %}.
|
||||
* `isAbstract()` - This is still available in subtypes, e.g. {%jdoc java::lang.java.ast.ASTTypeDeclaration#isAbstract() %}.
|
||||
* `isStrictfp()` - Use {%jdoc java::lang.java.ast.ModifierOwner#hasModifiers(java::lang.java.ast.JModifier,java::lang.java.ast.JModifier...) %} instead, e.g. `hasModifiers(STRICTFP)`.
|
||||
* `isSynchronized()` - Use {%jdoc java::lang.java.ast.ModifierOwner#hasModifiers(java::lang.java.ast.JModifier,java::lang.java.ast.JModifier...) %} instead, e.g. `hasModifiers(SYNCHRONIZED)`.
|
||||
* `isNative()` - Use {%jdoc java::lang.java.ast.ModifierOwner#hasModifiers(java::lang.java.ast.JModifier,java::lang.java.ast.JModifier...) %} instead, e.g. `hasModifiers(NATIVE)`.
|
||||
* `isStatic()` - This is still available in subtypes, e.g. {%jdoc java::lang.java.ast.ASTMethodDeclaration#isStatic() %}.
|
||||
* `isVolatile()` - Use {%jdoc java::lang.java.ast.ModifierOwner#hasModifiers(java::lang.java.ast.JModifier,java::lang.java.ast.JModifier...) %} instead, e.g. `hasModifiers(VOLATILE)`.
|
||||
* `isTransient()` - Use {%jdoc java::lang.java.ast.ModifierOwner#hasModifiers(java::lang.java.ast.JModifier,java::lang.java.ast.JModifier...) %} instead, e.g. `hasModifiers(TRANSIENT)`.
|
||||
* `isPrivate()` - Use {%jdoc java::lang.java.ast.ModifierOwner#getVisibility() %} instead, e.g. `getVisibility() == Visibility.V_PRIVATE`.
|
||||
* `isPublic()` - Use {%jdoc java::lang.java.ast.ModifierOwner#getVisibility() %} instead, e.g. `getVisibility() == Visibility.V_PUBLIC`.
|
||||
* `isProtected()` - Use {%jdoc java::lang.java.ast.ModifierOwner#getVisibility() %} instead, e.g. `getVisibility() == Visibility.V_PROTECTED`.
|
||||
* `isPackagePrivate()` - Use {%jdoc java::lang.java.ast.ModifierOwner#getVisibility() %} instead, e.g. `getVisibility() == Visibility.V_PACKAGE`.
|
||||
* `isSyntacticallyAbstract()` - Use {%jdoc java::lang.java.ast.ModifierOwner#hasExplicitModifiers(java::lang.java.ast.JModifier,java::lang.java.ast.JModifier...) %} instead, e.g. `hasExplicitModifiers(ABSTRACT)`.
|
||||
* `isSyntacticallyPublic()` - Use {%jdoc java::lang.java.ast.ModifierOwner#hasExplicitModifiers(java::lang.java.ast.JModifier,java::lang.java.ast.JModifier...) %} instead, e.g. `hasExplicitModifiers(PUBLIC)`.
|
||||
* `isSyntacticallyStatic()` - Use {%jdoc java::lang.java.ast.ModifierOwner#hasExplicitModifiers(java::lang.java.ast.JModifier,java::lang.java.ast.JModifier...) %} instead, e.g. `hasExplicitModifiers(STATIC)`.
|
||||
* `isSyntacticallyFinal()` - Use {%jdoc java::lang.java.ast.ModifierOwner#hasExplicitModifiers(java::lang.java.ast.JModifier,java::lang.java.ast.JModifier...) %} instead, e.g. `hasExplicitModifiers(FINAL)`.
|
||||
* {%jdoc !!java::lang.java.ast.TypeNode %} - method `getType()` has been removed. Use {%jdoc java::lang.java.ast.TypeNode#getTypeMirror() %} instead.
|
||||
* pmd-javascript
|
||||
* {%jdoc javascript::lang.ecmascript.ast.AbstractEcmascriptNode %} - method `getNode()` has been removed.
|
||||
AST nodes still have access to the underlying Rhino node via the protected property `node`.
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.rule;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -21,12 +22,14 @@ import net.sourceforge.pmd.RuleContext;
|
||||
import net.sourceforge.pmd.annotation.DeprecatedUntil700;
|
||||
import net.sourceforge.pmd.lang.LanguageProcessor;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.Attribute;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.PmdXPathException;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.XPathVersion;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.internal.DeprecatedAttrLogger;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.internal.SaxonXPathRuleQuery;
|
||||
import net.sourceforge.pmd.properties.PropertyDescriptor;
|
||||
import net.sourceforge.pmd.properties.PropertyFactory;
|
||||
import net.sourceforge.pmd.util.IteratorUtil;
|
||||
|
||||
|
||||
/**
|
||||
@ -130,10 +133,26 @@ public final class XPathRule extends AbstractRule {
|
||||
}
|
||||
|
||||
for (Node nodeWithViolation : nodesWithViolation) {
|
||||
ctx.addViolation(nodeWithViolation, nodeWithViolation.getImage());
|
||||
// see Deprecate getImage/@Image #4787 https://github.com/pmd/pmd/issues/4787
|
||||
String messageArg = nodeWithViolation.getImage();
|
||||
// Nodes might already have been refactored to not use getImage anymore.
|
||||
// Therefore, try several other common names
|
||||
if (messageArg == null) {
|
||||
messageArg = getFirstMessageArgFromNode(nodeWithViolation, "Name", "SimpleName", "MethodName");
|
||||
}
|
||||
ctx.addViolation(nodeWithViolation, messageArg);
|
||||
}
|
||||
}
|
||||
|
||||
private String getFirstMessageArgFromNode(Node node, String... attributeNames) {
|
||||
List<String> nameList = Arrays.asList(attributeNames);
|
||||
return IteratorUtil.toStream(node.getXPathAttributesIterator())
|
||||
.filter(a -> nameList.contains(a.getName()))
|
||||
.findFirst()
|
||||
.map(Attribute::getStringValue)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private ContextedRuntimeException addExceptionContext(PmdXPathException e) {
|
||||
return e.addRuleName(getName());
|
||||
}
|
||||
|
@ -1254,7 +1254,7 @@ void ClassOrInterfaceDeclaration() #ClassDeclaration:
|
||||
{}
|
||||
{
|
||||
( "class" | "interface" { jjtThis.setInterface(); } )
|
||||
<IDENTIFIER> { setLastTokenImage(jjtThis); }
|
||||
<IDENTIFIER> { jjtThis.setSimpleName(getToken(0).getImage()); }
|
||||
[ TypeParameters() ]
|
||||
[ ExtendsList() ]
|
||||
[ ImplementsList() ]
|
||||
@ -1288,7 +1288,7 @@ void EnumDeclaration():
|
||||
{}
|
||||
{
|
||||
softKeyword("enum")
|
||||
<IDENTIFIER> {setLastTokenImage(jjtThis);}
|
||||
<IDENTIFIER> { jjtThis.setSimpleName(getToken(0).getImage()); }
|
||||
[ ImplementsList() ]
|
||||
EnumBody()
|
||||
}
|
||||
@ -1313,7 +1313,7 @@ void RecordDeclaration():
|
||||
{}
|
||||
{
|
||||
softKeyword("record")
|
||||
<IDENTIFIER> {setLastTokenImage(jjtThis);}
|
||||
<IDENTIFIER> { jjtThis.setSimpleName(getToken(0).getImage()); }
|
||||
[ TypeParameters() ]
|
||||
RecordHeader()
|
||||
[ ImplementsList() ]
|
||||
@ -1422,13 +1422,13 @@ void VariableDeclarator() :
|
||||
void VariableDeclaratorId() #VariableId:
|
||||
{}
|
||||
{
|
||||
<IDENTIFIER> { setLastTokenImage(jjtThis); }
|
||||
<IDENTIFIER> { jjtThis.setName(getToken(0).getImage()); }
|
||||
}
|
||||
|
||||
void VariableIdWithDims() #VariableId :
|
||||
{}
|
||||
{
|
||||
<IDENTIFIER> { setLastTokenImage(jjtThis); }
|
||||
<IDENTIFIER> { jjtThis.setName(getToken(0).getImage()); }
|
||||
[ Dims() ]
|
||||
}
|
||||
|
||||
@ -1458,7 +1458,7 @@ void MethodDeclaration() :
|
||||
{
|
||||
[ TypeParameters() ]
|
||||
ResultType()
|
||||
<IDENTIFIER> { setLastTokenImage(jjtThis); }
|
||||
<IDENTIFIER> { jjtThis.setName(getToken(0).getImage()); }
|
||||
FormalParameters()
|
||||
[ Dims() ]
|
||||
[ ThrowsList() ]
|
||||
@ -1693,7 +1693,7 @@ void ClassOrInterfaceType() #void:
|
||||
// a type name, otherwise it wouldn't have compiled. So it's not ambiguous and we can
|
||||
// start fresh: "@B Map.Entry" will be unambiguously [[@B Map].Entry]
|
||||
|
||||
(<IDENTIFIER> {setLastTokenImage(jjtThis);} [ TypeArguments() ]) #ClassType
|
||||
(<IDENTIFIER> { jjtThis.setSimpleName(getToken(0).getImage()); } [ TypeArguments() ]) #ClassType
|
||||
|
|
||||
|
||||
|
||||
@ -1705,7 +1705,7 @@ void ClassOrInterfaceType() #void:
|
||||
AmbiguousName()
|
||||
[ TypeArguments() #ClassType(2) ]
|
||||
{
|
||||
// At this point the first ClassOrInterfaceType may be on top of the stack,
|
||||
// At this point the first ClassType may be on top of the stack,
|
||||
// but its image is not set. If it is on the stack we need to shrink the bounds
|
||||
// of the ambiguous name, or delete it.
|
||||
Node first = jjtree.peekNode();
|
||||
@ -1735,7 +1735,7 @@ private void ClassTypeSegment() #ClassType(jjtree.nodeArity() + 1):
|
||||
TypeAnnotListNoInject()
|
||||
<IDENTIFIER>
|
||||
// We'll enclose the previous segment
|
||||
{ setLastTokenImage(jjtThis); }
|
||||
{ jjtThis.setSimpleName(getToken(0).getImage()); }
|
||||
[ TypeArguments() ]
|
||||
}
|
||||
|
||||
@ -2263,7 +2263,7 @@ void MethodReference() #MethodReference(jjtree.nodeArity() + 1): // LHS is injec
|
||||
{
|
||||
"::"
|
||||
[TypeArguments()]
|
||||
( "new" | <IDENTIFIER> ) {setLastTokenImage(jjtThis);}
|
||||
( "new" | <IDENTIFIER> ) { jjtThis.setMethodName(getToken(0).getImage()); }
|
||||
{/* empty, to set the image before jjtClose */}
|
||||
}
|
||||
|
||||
@ -2984,7 +2984,7 @@ void TypeAnnotation() #void:
|
||||
void AnnotationTypeDeclaration():
|
||||
{}
|
||||
{
|
||||
"@" "interface" <IDENTIFIER> { setLastTokenImage(jjtThis); }
|
||||
"@" "interface" <IDENTIFIER> { jjtThis.setSimpleName(getToken(0).getImage()); }
|
||||
AnnotationTypeBody()
|
||||
}
|
||||
|
||||
@ -3019,7 +3019,7 @@ void AnnotationMethodDeclaration() #MethodDeclaration:
|
||||
{}
|
||||
{
|
||||
Type()
|
||||
<IDENTIFIER> { setLastTokenImage(jjtThis); }
|
||||
<IDENTIFIER> { jjtThis.setName(getToken(0).getImage()); }
|
||||
("(" ")") #FormalParameters
|
||||
[ Dims() ]
|
||||
[ DefaultValue() ] ";"
|
||||
@ -3061,7 +3061,7 @@ void ModuleDirective() #void:
|
||||
void ModuleName():
|
||||
{ String name; }
|
||||
{
|
||||
name=VoidNameNoLookahead() { jjtThis.setImage(name); }
|
||||
name=VoidNameNoLookahead() { jjtThis.setName(name); }
|
||||
}
|
||||
|
||||
void AmbiguousName():
|
||||
|
@ -197,14 +197,23 @@ public final class ASTAmbiguousName extends AbstractJavaExpr implements ASTRefer
|
||||
// this reference and the lambdas can be optimised to a singleton
|
||||
shrinkOneSegment(
|
||||
simpleName -> {
|
||||
String simpleNameImage = simpleName.getFirstToken().getImage();
|
||||
AbstractJavaNode parent = (AbstractJavaNode) simpleName.getParent();
|
||||
parent.setImage(simpleName.getFirstToken().getImage());
|
||||
if (parent instanceof ASTClassType) {
|
||||
((ASTClassType) parent).setSimpleName(simpleNameImage);
|
||||
} else {
|
||||
parent.setImage(simpleName.getFirstToken().getImage());
|
||||
}
|
||||
parent.removeChildAtIndex(simpleName.getIndexInParent());
|
||||
return null;
|
||||
},
|
||||
(ambig, simpleName) -> {
|
||||
AbstractJavaNode parent = (AbstractJavaNode) ambig.getParent();
|
||||
parent.setImage(simpleName);
|
||||
if (parent instanceof ASTClassType) {
|
||||
((ASTClassType) parent).setSimpleName(simpleName);
|
||||
} else {
|
||||
parent.setImage(simpleName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
);
|
||||
|
@ -9,7 +9,6 @@ import java.util.Iterator;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import net.sourceforge.pmd.annotation.DeprecatedUntil700;
|
||||
import net.sourceforge.pmd.lang.ast.NodeStream;
|
||||
import net.sourceforge.pmd.lang.java.types.JClassType;
|
||||
|
||||
@ -41,18 +40,6 @@ public final class ASTAnnotation extends AbstractJavaTypeNode implements TypeNod
|
||||
return (JClassType) super.getTypeMirror();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the annotation as it is used,
|
||||
* eg {@code java.lang.Override} or {@code Override}.
|
||||
*
|
||||
* @deprecated Use {@link #getTypeMirror()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@DeprecatedUntil700
|
||||
public String getAnnotationName() {
|
||||
return getTypeNode().getText().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the simple name of the annotation.
|
||||
*/
|
||||
|
@ -36,7 +36,6 @@ public final class ASTArrayType extends AbstractJavaTypeNode implements ASTRefer
|
||||
return (ASTType) getChild(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArrayDepth() {
|
||||
return getDimensions().size();
|
||||
}
|
||||
|
@ -88,7 +88,6 @@ public final class ASTCatchParameter extends AbstractJavaNode
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return hasModifiers(JModifier.FINAL);
|
||||
}
|
||||
|
@ -48,28 +48,18 @@ public final class ASTClassType extends AbstractJavaTypeNode implements ASTRefer
|
||||
assert lhs != null : "Null LHS";
|
||||
|
||||
this.addChild(lhs, 0);
|
||||
this.simpleName = simpleName;
|
||||
assertSimpleNameOk();
|
||||
this.setSimpleName(simpleName);
|
||||
}
|
||||
|
||||
|
||||
ASTClassType(ASTAmbiguousName simpleName) {
|
||||
super(JavaParserImplTreeConstants.JJTCLASSTYPE);
|
||||
this.simpleName = simpleName.getFirstToken().getImage();
|
||||
|
||||
assertSimpleNameOk();
|
||||
}
|
||||
|
||||
// Just for one usage in Symbol table
|
||||
@Deprecated
|
||||
public ASTClassType(String simpleName) {
|
||||
super(JavaParserImplTreeConstants.JJTCLASSTYPE);
|
||||
this.simpleName = simpleName;
|
||||
this.setSimpleName(simpleName.getFirstToken().getImage());
|
||||
}
|
||||
|
||||
ASTClassType(@Nullable ASTClassType lhs, boolean isFqcn, JavaccToken firstToken, JavaccToken identifier) {
|
||||
super(JavaParserImplTreeConstants.JJTCLASSTYPE);
|
||||
this.setImage(identifier.getImage());
|
||||
this.setSimpleName(identifier.getImage());
|
||||
this.isFqcn = isFqcn;
|
||||
if (lhs != null) {
|
||||
this.addChild(lhs, 0);
|
||||
@ -83,25 +73,6 @@ public final class ASTClassType extends AbstractJavaTypeNode implements ASTRefer
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setImage(String image) {
|
||||
this.simpleName = image;
|
||||
assertSimpleNameOk();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public String getImage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void assertSimpleNameOk() {
|
||||
assert this.simpleName != null
|
||||
&& this.simpleName.indexOf('.') < 0
|
||||
&& AssertionUtil.isJavaIdentifier(this.simpleName)
|
||||
: "Invalid simple name '" + this.simpleName + "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the type was written with a full package qualification.
|
||||
* For example, {@code java.lang.Override}. For nested types, only the
|
||||
@ -160,6 +131,18 @@ public final class ASTClassType extends AbstractJavaTypeNode implements ASTRefer
|
||||
}
|
||||
|
||||
|
||||
void setSimpleName(String simpleName) {
|
||||
this.simpleName = simpleName;
|
||||
assertSimpleNameOk();
|
||||
}
|
||||
|
||||
private void assertSimpleNameOk() {
|
||||
assert this.simpleName != null
|
||||
&& this.simpleName.indexOf('.') < 0
|
||||
&& AssertionUtil.isJavaIdentifier(this.simpleName)
|
||||
: "Invalid simple name '" + this.simpleName + "'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the simple name of this type. Use the {@linkplain #getReferencedSym() symbol}
|
||||
* to get more information.
|
||||
@ -168,32 +151,6 @@ public final class ASTClassType extends AbstractJavaTypeNode implements ASTRefer
|
||||
return simpleName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the type this node is referring to is declared within the
|
||||
* same compilation unit - either a class/interface or a enum type. You want
|
||||
* to check this, if {@link #getType()} is null.
|
||||
*
|
||||
* @return {@code true} if this node referencing a type in the same
|
||||
* compilation unit, {@code false} otherwise.
|
||||
*
|
||||
* @deprecated This may be removed once type resolution is afoot
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isReferenceToClassSameCompilationUnit() {
|
||||
ASTCompilationUnit root = ancestors(ASTCompilationUnit.class).first();
|
||||
for (ASTClassDeclaration c : root.descendants(ASTClassDeclaration.class).crossFindBoundaries()) {
|
||||
if (c.hasImageEqualTo(getImage())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (ASTEnumDeclaration e : root.descendants(ASTEnumDeclaration.class).crossFindBoundaries()) {
|
||||
if (e.hasImageEqualTo(getImage())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void setFullyQualified() {
|
||||
this.isFqcn = true;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public final class ASTEnumConstant extends AbstractJavaTypeNode
|
||||
|
||||
@Override
|
||||
public String getImage() {
|
||||
return getVarId().getImage();
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,7 +64,7 @@ public final class ASTEnumConstant extends AbstractJavaTypeNode
|
||||
* Returns the name of the enum constant.
|
||||
*/
|
||||
public String getName() {
|
||||
return getImage();
|
||||
return getVarId().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,7 +65,6 @@ public interface ASTExecutableDeclaration
|
||||
* standard reflection API.
|
||||
*/
|
||||
// TODO is this relevant?
|
||||
@Override
|
||||
default boolean isAbstract() {
|
||||
return hasModifiers(JModifier.ABSTRACT);
|
||||
}
|
||||
|
@ -76,7 +76,6 @@ public final class ASTFieldDeclaration extends AbstractJavaNode
|
||||
/**
|
||||
* Returns true if this field is static.
|
||||
*/
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
return hasModifiers(JModifier.STATIC);
|
||||
}
|
||||
|
@ -91,7 +91,6 @@ public final class ASTFormalParameter extends AbstractJavaNode
|
||||
return getVarId().getTypeMirror(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return hasModifiers(JModifier.FINAL);
|
||||
}
|
||||
|
@ -62,7 +62,6 @@ public final class ASTLambdaParameter extends AbstractJavaTypeNode
|
||||
return firstChild(ASTType.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return hasModifiers(JModifier.FINAL);
|
||||
}
|
||||
|
@ -21,90 +21,6 @@ import net.sourceforge.pmd.lang.document.Chars;
|
||||
* </pre>
|
||||
*/
|
||||
public interface ASTLiteral extends ASTPrimaryExpression {
|
||||
|
||||
// Those methods are deprecated as they're not so useful, and introduce
|
||||
// unwanted XPath attributes
|
||||
|
||||
/**
|
||||
* Returns true if this is a {@linkplain ASTStringLiteral string literal}.
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean isStringLiteral() {
|
||||
return this instanceof ASTStringLiteral;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this is a {@linkplain ASTCharLiteral character literal}.
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean isCharLiteral() {
|
||||
return this instanceof ASTCharLiteral;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this is the {@linkplain ASTNullLiteral null literal}.
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean isNullLiteral() {
|
||||
return this instanceof ASTNullLiteral;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this is a {@linkplain ASTBooleanLiteral boolean literal}.
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean isBooleanLiteral() {
|
||||
return this instanceof ASTBooleanLiteral;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this is a {@linkplain ASTNumericLiteral numeric literal}
|
||||
* of any kind.
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean isNumericLiteral() {
|
||||
return this instanceof ASTNumericLiteral;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this is an {@linkplain ASTNumericLiteral integer literal}.
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean isIntLiteral() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this is a {@linkplain ASTNumericLiteral long integer literal}.
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean isLongLiteral() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this is a {@linkplain ASTNumericLiteral float literal}.
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean isFloatLiteral() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this is a {@linkplain ASTNumericLiteral double literal}.
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean isDoubleLiteral() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the text of the literal in the source file. Note that
|
||||
* {@link #getText()} may include parentheses.
|
||||
|
@ -76,7 +76,6 @@ public final class ASTLocalVariableDeclaration extends AbstractJavaNode
|
||||
return firstChild(ASTType.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return hasModifiers(JModifier.FINAL);
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import net.sourceforge.pmd.lang.java.symbols.JMethodSymbol;
|
||||
import net.sourceforge.pmd.lang.java.types.JMethodSig;
|
||||
import net.sourceforge.pmd.lang.java.types.TypeSystem;
|
||||
import net.sourceforge.pmd.lang.java.types.TypeTestUtil;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.DeprecatedAttribute;
|
||||
|
||||
|
||||
/**
|
||||
@ -44,6 +43,8 @@ import net.sourceforge.pmd.lang.rule.xpath.DeprecatedAttribute;
|
||||
*/
|
||||
public final class ASTMethodDeclaration extends AbstractExecutableDeclaration<JMethodSymbol> {
|
||||
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Populated by {@link OverrideResolutionPass}.
|
||||
*/
|
||||
@ -89,24 +90,15 @@ public final class ASTMethodDeclaration extends AbstractExecutableDeclaration<JM
|
||||
return ident.getReportLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the simple name of the method.
|
||||
*
|
||||
* @deprecated Use {@link #getName()}
|
||||
*/
|
||||
@Deprecated
|
||||
@DeprecatedAttribute(replaceWith = "@Name")
|
||||
public String getMethodName() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
|
||||
/** Returns the simple name of the method. */
|
||||
@Override
|
||||
public String getName() {
|
||||
return getImage();
|
||||
return name;
|
||||
}
|
||||
|
||||
void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this method declaration is an explicit record component accessor,
|
||||
@ -133,12 +125,10 @@ public final class ASTMethodDeclaration extends AbstractExecutableDeclaration<JM
|
||||
}
|
||||
|
||||
/** Returns true if this method is static. */
|
||||
@Override
|
||||
public boolean isStatic() {
|
||||
return hasModifiers(JModifier.STATIC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return hasModifiers(JModifier.FINAL);
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ public final class ASTMethodReference extends AbstractJavaExpr
|
||||
private JMethodSig functionalMethod;
|
||||
private JMethodSig compileTimeDecl;
|
||||
|
||||
private String methodName;
|
||||
|
||||
ASTMethodReference(int id) {
|
||||
super(id);
|
||||
}
|
||||
@ -97,13 +99,12 @@ public final class ASTMethodReference extends AbstractJavaExpr
|
||||
*/
|
||||
@Override
|
||||
public @NonNull String getMethodName() {
|
||||
return super.getImage();
|
||||
assert methodName != null : "method name was null";
|
||||
return methodName;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public @Nullable String getImage() {
|
||||
return null;
|
||||
void setMethodName(String methodName) {
|
||||
this.methodName = methodName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -9,6 +9,7 @@ package net.sourceforge.pmd.lang.java.ast;
|
||||
* {@code java.base}.
|
||||
*/
|
||||
public final class ASTModuleName extends AbstractJavaNode {
|
||||
private String name;
|
||||
|
||||
ASTModuleName(int id) {
|
||||
super(id);
|
||||
@ -20,18 +21,15 @@ public final class ASTModuleName extends AbstractJavaNode {
|
||||
return visitor.visit(this, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getImage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the declared module. Module names look
|
||||
* like package names, eg {@code java.base}.
|
||||
*/
|
||||
public String getName() {
|
||||
return super.getImage();
|
||||
return name;
|
||||
}
|
||||
|
||||
void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
@ -89,22 +89,18 @@ public final class ASTNumericLiteral extends AbstractLiteral implements ASTLiter
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isIntLiteral() {
|
||||
return isIntegral && !is64bits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLongLiteral() {
|
||||
return isIntegral && is64bits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFloatLiteral() {
|
||||
return !isIntegral && !is64bits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDoubleLiteral() {
|
||||
return !isIntegral && is64bits;
|
||||
}
|
||||
|
@ -37,12 +37,6 @@ public final class ASTPrimitiveType extends AbstractJavaTypeNode implements ASTT
|
||||
return kind;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getImage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <P, R> R acceptVisitor(JavaVisitor<? super P, ? extends R> visitor, P data) {
|
||||
return visitor.visit(this, data);
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.java.ast;
|
||||
|
||||
import net.sourceforge.pmd.lang.java.ast.internal.PrettyPrintingUtil;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.NoAttribute;
|
||||
|
||||
|
||||
@ -27,30 +26,7 @@ import net.sourceforge.pmd.lang.rule.xpath.NoAttribute;
|
||||
*/
|
||||
public interface ASTType extends TypeNode, Annotatable, LeftRecursiveNode {
|
||||
|
||||
// these are noAttribute so they don't end up in the tree dump tests
|
||||
|
||||
/**
|
||||
* For now this returns the name of the type with all the segments,
|
||||
* without annotations, array dimensions, or type parameters. Experimental
|
||||
* because we need to specify it, eg it would be more useful to have
|
||||
* a method return a qualified name with help of the symbol table.
|
||||
*
|
||||
* @deprecated This is not meaningful. Use {@link PrettyPrintingUtil}
|
||||
*/
|
||||
@Deprecated
|
||||
default String getTypeImage() {
|
||||
return PrettyPrintingUtil.prettyPrintType(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of array dimensions of this type.
|
||||
* This is 0 unless this node is {@linkplain ASTArrayType}.
|
||||
*/
|
||||
@Deprecated
|
||||
default int getArrayDepth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// these are NoAttribute, so they don't end up in the tree dump tests
|
||||
|
||||
/**
|
||||
* Returns true if this is the "void" pseudo-type, ie an {@link ASTVoidType}.
|
||||
@ -59,24 +35,4 @@ public interface ASTType extends TypeNode, Annotatable, LeftRecursiveNode {
|
||||
default boolean isVoid() {
|
||||
return this instanceof ASTVoidType;
|
||||
}
|
||||
|
||||
// TODO remove that, there's enough on JTypeMirror
|
||||
|
||||
@Deprecated
|
||||
default boolean isPrimitiveType() {
|
||||
return this instanceof ASTPrimitiveType;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
default boolean isArrayType() {
|
||||
return this instanceof ASTArrayType;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
default boolean isClassOrInterfaceType() {
|
||||
return this instanceof ASTClassType;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import net.sourceforge.pmd.lang.ast.NodeStream;
|
||||
import net.sourceforge.pmd.lang.java.symbols.JClassSymbol;
|
||||
import net.sourceforge.pmd.lang.java.types.JClassType;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.DeprecatedAttribute;
|
||||
|
||||
|
||||
/**
|
||||
@ -63,19 +62,7 @@ public interface ASTTypeDeclaration
|
||||
* empty string if this is an anonymous class declaration.
|
||||
*/
|
||||
@NonNull
|
||||
default String getSimpleName() {
|
||||
return getImage();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getSimpleName()}
|
||||
*/
|
||||
@Deprecated
|
||||
@DeprecatedAttribute(replaceWith = "@SimpleName")
|
||||
@Override
|
||||
String getImage();
|
||||
|
||||
String getSimpleName();
|
||||
|
||||
/**
|
||||
* Returns the name of the package in which this class is declared.
|
||||
@ -132,7 +119,6 @@ public interface ASTTypeDeclaration
|
||||
* Returns true if this is an abstract type. Interfaces and annotations
|
||||
* types are implicitly abstract.
|
||||
*/
|
||||
@Override
|
||||
default boolean isAbstract() {
|
||||
return hasModifiers(ABSTRACT);
|
||||
}
|
||||
@ -140,12 +126,10 @@ public interface ASTTypeDeclaration
|
||||
/**
|
||||
* Returns true if this type is static. Only inner types can be static.
|
||||
*/
|
||||
@Override
|
||||
default boolean isStatic() {
|
||||
return hasModifiers(JModifier.STATIC);
|
||||
}
|
||||
|
||||
@Override
|
||||
default boolean isFinal() {
|
||||
return hasModifiers(JModifier.FINAL);
|
||||
}
|
||||
|
@ -41,16 +41,6 @@ public final class ASTUnaryExpression extends AbstractJavaExpr {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if this is a prefix expression.
|
||||
*
|
||||
* @deprecated XPath-attribute only, use {@code getOperator().isPrefix()} in java code.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isPrefix() {
|
||||
return getOperator().isPrefix();
|
||||
}
|
||||
|
||||
/** Returns the constant representing the operator of this expression. */
|
||||
public UnaryOp getOperator() {
|
||||
return operator;
|
||||
|
@ -15,7 +15,6 @@ import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.java.ast.ASTAssignableExpr.ASTNamedReferenceExpr;
|
||||
import net.sourceforge.pmd.lang.java.symbols.JVariableSymbol;
|
||||
import net.sourceforge.pmd.lang.java.types.JTypeMirror;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.DeprecatedAttribute;
|
||||
|
||||
// @formatter:off
|
||||
/**
|
||||
@ -46,6 +45,7 @@ import net.sourceforge.pmd.lang.rule.xpath.DeprecatedAttribute;
|
||||
// @formatter:on
|
||||
public final class ASTVariableId extends AbstractTypedSymbolDeclarator<JVariableSymbol> implements ModifierOwner, SymbolDeclaratorNode {
|
||||
|
||||
private String name;
|
||||
private List<ASTNamedReferenceExpr> usages = Collections.emptyList();
|
||||
|
||||
ASTVariableId(int id) {
|
||||
@ -94,7 +94,6 @@ public final class ASTVariableId extends AbstractTypedSymbolDeclarator<JVariable
|
||||
return getModifierOwnerParent().getModifiers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinal() {
|
||||
return hasModifiers(JModifier.FINAL);
|
||||
}
|
||||
@ -114,19 +113,13 @@ public final class ASTVariableId extends AbstractTypedSymbolDeclarator<JVariable
|
||||
return (ModifierOwner) parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getName()}
|
||||
*/
|
||||
@Override
|
||||
@DeprecatedAttribute(replaceWith = "@Name")
|
||||
@Deprecated
|
||||
public String getImage() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
/** Returns the name of the variable. */
|
||||
public String getName() {
|
||||
return super.getImage();
|
||||
return name;
|
||||
}
|
||||
|
||||
void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -220,16 +213,6 @@ public final class ASTVariableId extends AbstractTypedSymbolDeclarator<JVariable
|
||||
return getParent() instanceof ASTEnumConstant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the variable.
|
||||
*
|
||||
* @deprecated Use {@link #getName()}
|
||||
*/
|
||||
@Deprecated
|
||||
@DeprecatedAttribute(replaceWith = "@Name")
|
||||
public String getVariableName() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this declarator id declares a resource in a try-with-resources statement.
|
||||
|
@ -6,21 +6,17 @@ package net.sourceforge.pmd.lang.java.ast;
|
||||
|
||||
public abstract class AbstractPackageNameModuleDirective extends ASTModuleDirective {
|
||||
|
||||
private String packageName;
|
||||
|
||||
AbstractPackageNameModuleDirective(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public final String getPackageName() {
|
||||
return super.getImage();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final String getImage() {
|
||||
return null;
|
||||
return packageName;
|
||||
}
|
||||
|
||||
final void setPackageName(String name) {
|
||||
super.setImage(name);
|
||||
packageName = name;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.document.FileLocation;
|
||||
import net.sourceforge.pmd.lang.java.symbols.JClassSymbol;
|
||||
import net.sourceforge.pmd.lang.java.types.JClassType;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.DeprecatedAttribute;
|
||||
|
||||
|
||||
/**
|
||||
@ -22,6 +21,7 @@ abstract class AbstractTypeDeclaration extends AbstractTypedSymbolDeclarator<JCl
|
||||
|
||||
private String binaryName;
|
||||
private @Nullable String canonicalName;
|
||||
private String simpleName;
|
||||
|
||||
AbstractTypeDeclaration(int i) {
|
||||
super(i);
|
||||
@ -37,21 +37,15 @@ abstract class AbstractTypeDeclaration extends AbstractTypedSymbolDeclarator<JCl
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getSimpleName()}
|
||||
*/
|
||||
@Deprecated
|
||||
@DeprecatedAttribute(replaceWith = "@SimpleName")
|
||||
@Override
|
||||
public String getImage() {
|
||||
return getSimpleName();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getSimpleName() {
|
||||
assert super.getImage() != null : "Null simple name";
|
||||
return super.getImage();
|
||||
assert simpleName != null : "Null simple name";
|
||||
return simpleName;
|
||||
}
|
||||
|
||||
final void setSimpleName(String simpleName) {
|
||||
this.simpleName = simpleName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,13 +52,6 @@ public final class InternalApiBridge {
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static ASTVariableId newVarId(String image) {
|
||||
ASTVariableId varid = new ASTVariableId(JavaParserImplTreeConstants.JJTVARIABLEID);
|
||||
varid.setImage(image);
|
||||
return varid;
|
||||
}
|
||||
|
||||
public static void setSymbol(SymbolDeclaratorNode node, JElementSymbol symbol) {
|
||||
if (node instanceof ASTMethodDeclaration) {
|
||||
((ASTMethodDeclaration) node).setSymbol((JMethodSymbol) symbol);
|
||||
|
@ -37,14 +37,6 @@ public class JavaComment implements Reportable {
|
||||
return getToken().getReportLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getText()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getImage() {
|
||||
return getToken().getImage();
|
||||
}
|
||||
|
||||
/** The token underlying this comment. */
|
||||
public final JavaccToken getToken() {
|
||||
return token;
|
||||
|
@ -7,8 +7,6 @@ package net.sourceforge.pmd.lang.java.ast;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import net.sourceforge.pmd.annotation.DeprecatedUntil700;
|
||||
import net.sourceforge.pmd.lang.ast.AstVisitor;
|
||||
import net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeNode;
|
||||
import net.sourceforge.pmd.lang.java.symbols.table.JSymbolTable;
|
||||
import net.sourceforge.pmd.lang.java.types.TypeSystem;
|
||||
@ -19,21 +17,6 @@ import net.sourceforge.pmd.lang.java.types.TypeSystem;
|
||||
*/
|
||||
public interface JavaNode extends JjtreeNode<JavaNode> {
|
||||
|
||||
/**
|
||||
* Calls back the visitor's visit method corresponding to the runtime type of this Node.
|
||||
*
|
||||
* @param visitor Visitor to dispatch
|
||||
* @param data Visit data
|
||||
*
|
||||
* @deprecated Use {@link #acceptVisitor(AstVisitor, Object)}
|
||||
*/
|
||||
@Deprecated
|
||||
@DeprecatedUntil700
|
||||
default Object jjtAccept(JavaParserVisitor visitor, Object data) {
|
||||
return acceptVisitor(visitor, data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the node representing the type declaration this node is
|
||||
* found in. The type of that node is the type of the {@code this}
|
||||
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.java.ast;
|
||||
|
||||
import net.sourceforge.pmd.annotation.DeprecatedUntil700;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
|
||||
/**
|
||||
* Backwards-compatibility only.
|
||||
*
|
||||
* @deprecated Use {@link JavaVisitor}
|
||||
*/
|
||||
@Deprecated
|
||||
@DeprecatedUntil700
|
||||
public interface JavaParserVisitor extends JavaVisitor<Object, Object> {
|
||||
|
||||
@Override
|
||||
default Object visitNode(Node node, Object param) {
|
||||
for (Node child: node.children()) {
|
||||
child.acceptVisitor(this, param);
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
// REMOVE ME
|
||||
// deprecated stuff kept for compatibility with existing visitors, not matched by anything
|
||||
|
||||
@Deprecated
|
||||
default Object visit(ASTExpression node, Object data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
default Object visit(ASTLiteral node, Object data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
default Object visit(ASTType node, Object data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
default Object visit(ASTReferenceType node, Object data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
default Object visit(ASTStatement node, Object data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
default Object visit(ASTPrimaryExpression node, Object data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user