Abstract toString into AbstractNode, deprecate the implementation
Log that the default implementation will be removed
This commit is contained in:
@ -130,14 +130,12 @@ public abstract class AbstractApexNode<T extends AstNode> extends AbstractNode i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getXPathNodeName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final String getXPathNodeName() {
|
public final String getXPathNodeName() {
|
||||||
|
new ASTMapEntryNode(null).toString();
|
||||||
return this.getClass().getSimpleName().replaceFirst("^AST", "");
|
return this.getClass().getSimpleName().replaceFirst("^AST", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ package net.sourceforge.pmd.lang.ast;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
@ -18,12 +18,16 @@ import org.jaxen.JaxenException;
|
|||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import net.sourceforge.pmd.PMDVersion;
|
||||||
import net.sourceforge.pmd.lang.ast.xpath.Attribute;
|
import net.sourceforge.pmd.lang.ast.xpath.Attribute;
|
||||||
import net.sourceforge.pmd.lang.ast.xpath.DocumentNavigator;
|
import net.sourceforge.pmd.lang.ast.xpath.DocumentNavigator;
|
||||||
import net.sourceforge.pmd.lang.dfa.DataFlowNode;
|
import net.sourceforge.pmd.lang.dfa.DataFlowNode;
|
||||||
|
|
||||||
public abstract class AbstractNode implements Node {
|
public abstract class AbstractNode implements Node {
|
||||||
|
|
||||||
|
private static final Logger LOG = Logger.getLogger(AbstractNode.class.getName());
|
||||||
|
|
||||||
|
|
||||||
protected Node parent;
|
protected Node parent;
|
||||||
protected Node[] children;
|
protected Node[] children;
|
||||||
protected int childIndex;
|
protected int childIndex;
|
||||||
@ -448,6 +452,23 @@ public abstract class AbstractNode implements Node {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getXPathNodeName() {
|
public String getXPathNodeName() {
|
||||||
|
LOG.warning("getXPathNodeName should be overriden in classes derived from AbstractNode. " +
|
||||||
|
"The implementation is provided for compatibility with existing implementors," +
|
||||||
|
"but could be declared abstract as soon as release " + PMDVersion.getNextMajorRelease()
|
||||||
|
+ ".");
|
||||||
return toString();
|
return toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*
|
||||||
|
* @deprecated The equivalence between toString and a node's name could be broken as soon as release 7.0.0.
|
||||||
|
* Use getXPathNodeName for that purpose. The use for debugging purposes is not deprecated.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getXPathNodeName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ public class MatchesFunctionTest {
|
|||||||
super(1);
|
super(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MyNode";
|
return "MyNode";
|
||||||
|
@ -9,6 +9,7 @@ public class DummyNode extends AbstractNode {
|
|||||||
super(id);
|
super(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "dummyNode";
|
return "dummyNode";
|
||||||
|
@ -78,10 +78,7 @@ public abstract class AbstractJavaNode extends AbstractNode implements JavaNode
|
|||||||
return comment;
|
return comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getXPathNodeName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final String getXPathNodeName() {
|
public final String getXPathNodeName() {
|
||||||
|
@ -23,6 +23,7 @@ public abstract class Comment extends AbstractNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getImage();
|
return getImage();
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,7 @@ public class JavadocElement extends AbstractNode {
|
|||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getXPathNodeName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -68,10 +68,7 @@ public abstract class AbstractEcmascriptNode<T extends AstNode> extends Abstract
|
|||||||
return node.hasSideEffects();
|
return node.hasSideEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getXPathNodeName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,9 +56,7 @@ public abstract class AbstractJspNode extends AbstractNode implements JspNode {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return getXPathNodeName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,9 +77,7 @@ public abstract class AbstractPLSQLNode extends net.sourceforge.pmd.lang.ast.Abs
|
|||||||
* otherwise overriding toString() is probably all you need to do.
|
* otherwise overriding toString() is probably all you need to do.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return getXPathNodeName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString(String prefix) {
|
public String toString(String prefix) {
|
||||||
return prefix + toString();
|
return prefix + toString();
|
||||||
|
@ -11,6 +11,7 @@ public class DummyNode extends AbstractNode {
|
|||||||
super(id);
|
super(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "dummyNode";
|
return "dummyNode";
|
||||||
|
@ -56,9 +56,7 @@ public abstract class AbstractVFNode extends AbstractNode implements VfNode {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return getXPathNodeName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,6 +81,7 @@ public class ASTDirective extends AbstractVmNode {
|
|||||||
/**
|
/**
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this).appendSuper(super.toString()).append("directiveName", getDirectiveName())
|
return new ToStringBuilder(this).appendSuper(super.toString()).append("directiveName", getDirectiveName())
|
||||||
|
@ -134,9 +134,7 @@ public class AbstractVmNode extends AbstractNode implements VmNode {
|
|||||||
* otherwise overriding toString() is probably all you need to do.
|
* otherwise overriding toString() is probably all you need to do.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return getXPathNodeName();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param prefix
|
* @param prefix
|
||||||
|
Reference in New Issue
Block a user