Skip to content

[core] Add getXPathNodeName to the Node interface#879

Merged
jsotuyod merged 7 commits into
pmd:masterfrom
oowekyala:xpath-tostring
Jan 25, 2018
Merged

[core] Add getXPathNodeName to the Node interface#879
jsotuyod merged 7 commits into
pmd:masterfrom
oowekyala:xpath-tostring

Conversation

@oowekyala

Copy link
Copy Markdown
Member

A default implementation is available in AbstractNode to preserve compatibility with the previous way, which
used Object.toString.

Fixes #569

A default implementation is available in AbstractNode
to preserve compatibility with the previous way, which
used Object.toString.

Fixes pmd#569
@@ -132,9 +132,16 @@ protected boolean hasRealLoc() {

@Override
public String toString() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably @Deprecated this implementation to be removed in PMD 7.0.0

* <p>Please override it. It may be removed in a future major version.
*/
@Override
public String getXPathNodeName() {

@jsotuyod jsotuyod Jan 25, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd have this method at least log on WARNING to have people override this method. You can use the new PMDVersion.getNextMajor() to tell people to do so before 7.0.0 is out. We should also flag this method for removal on such release


@Override
public String toString() {
return getXPathNodeName();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this method. We would inherit it from AbstractNode and still want to kill it eventually

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, it went right over my head lol


@Override
public String toString() {
return getXPathNodeName();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

}

public String toString() {
return getXPathNodeName();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto


public String toString() {
return PLSQLParserTreeConstants.jjtNodeName[id];
return getXPathNodeName();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

}

public String toString() {
return getXPathNodeName();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto


public String toString() {
return VmParserTreeConstants.jjtNodeName[id];
return getXPathNodeName();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@jsotuyod jsotuyod added this to the 6.1.0 milestone Jan 25, 2018
@jsotuyod jsotuyod self-assigned this Jan 25, 2018
@jsotuyod jsotuyod added an:enhancement An improvement on existing features / rules in:pmd-internals Affects PMD's internals labels Jan 25, 2018

@jsotuyod jsotuyod left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking very neat. Kudos for taking the time to tackle it, and to @gibarsin and @MatiasComercio for coming up with the idea of decoupling these

import net.sourceforge.pmd.lang.ast.AbstractNode;

public class AbstractJspNode extends AbstractNode implements JspNode {
public abstract class AbstractJspNode extends AbstractNode implements JspNode {

@jsotuyod jsotuyod Jan 25, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding this abstract is a breaking API change. Even though I agree it makes perfect sense to have it, we can't break this API until PMD 7.0.0. We should revert this particular change. We could make a reminder ticket like we did with #463 for 6.0.0

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, it's in #881

import net.sourceforge.pmd.lang.ast.AbstractNode;

public class AbstractVFNode extends AbstractNode implements VfNode {
public abstract class AbstractVFNode extends AbstractNode implements VfNode {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@oowekyala oowekyala mentioned this pull request Jan 25, 2018
64 tasks
@jsotuyod jsotuyod merged commit b1c5e3d into pmd:master Jan 25, 2018
@oowekyala oowekyala deleted the xpath-tostring branch January 25, 2018 13:14
@oowekyala oowekyala added the in:xpath Relating to xpath support at large, eg Jaxen / Saxon, custom functions, attribute resolution label May 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

an:enhancement An improvement on existing features / rules in:pmd-internals Affects PMD's internals in:xpath Relating to xpath support at large, eg Jaxen / Saxon, custom functions, attribute resolution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants