GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — [core] Cleanup Node and AbstractNode by oowekyala · Pull Request #2447 · pmd/pmd Conversation
|
Generated by 🚫 Danger |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the huge cleanup!
Consider my comments as food for thought 😄
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * | ||
| * @param image The image to check | ||
| */ | ||
| default boolean hasImageEqualTo(String image) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Once we removed the generic "getImage" method in favor of more specific methods likes "getName" etc., this method also doesn't make sense and should be removed
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * @param child The child to add | ||
| * @param index The index to which the child will be added | ||
| */ | ||
| protected void addChild(final B child, final int index) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Do we need three different ways to add children? (addChild, insertChild, setChildren)
Can we reduce this maybe?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
setChildren in used only in tests AFAIK so could be pulled down to DummyNode.
I think addChild is a bit unsafe/hard to use:
addChild(child, 42), and leave 42 null slots in the array (which breaks the contract of the class)...n children performs n array resizesOTOH I can't see another way to improve it right now apart from documentation
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * | ||
| * @param index the child index | ||
| */ | ||
| protected void setChildIndex(final int index) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is this needed as a protected method? It looks error prone, if this is ever forgotten to be called. And it probably shouldn't needed to be called -> addChild etc. should automatically make sure, the tree is consistent.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I'll look into whether we can remove it
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| /** | ||
| * Interface that binds the return type of some node methods to a type | ||
| * parameter. This enforces that eg all children of such a node are from |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I guess, we should demand that all language impls use this interface. Maybe that's just in the documentation then?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * it must be set to some value that depends on the node type, not some | ||
| * arbitrary "1" or "2", and not necessarily a unique value. | ||
| */ | ||
| protected AbstractJjtreeNode(int id) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can name the "id" something like "productionId" or "jjtNodeNameIndex", to avoid the misinterpretation of "unique id"...
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| import net.sourceforge.pmd.lang.ast.AbstractNode; | ||
| import net.sourceforge.pmd.lang.ast.Node; | ||
| import net.sourceforge.pmd.lang.ast.impl.AbstractNode; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
In theory, AbstractNode should be irrelevant in this context - AbstractNode should only help to implement the Node API, but should not add to the API... (so no additional methods).
Maybe we don't need the NoAttrScope at all? If a intermediate (abstract) class adds a public method, it is public API... so why not expose it as XPath attribute?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| public void setImage(String image) { | ||
| super.setImage(image); | ||
| } | ||
|
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Hm... why do we have a "DummyJavaNode" in src/main? Looks like, this should have gone into src/test....
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I recall it's still in main because some rules about imports create dummy nodes for ImportWrapper... Hopefully those rules may be rewritten with the newer symbol table and ImportWrapper can be nuked
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * Normally this is uppercase, unless the names is quoted ("name"). | ||
| * </p> | ||
| */ | ||
| default String getCanonicalImage() { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
hm...yes, these methods are not ideal, too generic like "getImage". but this time on plsql...
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.