Skip to content

[core] refactor: Make the children array never null#1823

Merged
oowekyala merged 1 commit into
pmd:pmd/7.0.xfrom
adangel:pmd7-ast-children-non-null
May 18, 2019
Merged

[core] refactor: Make the children array never null#1823
oowekyala merged 1 commit into
pmd:pmd/7.0.xfrom
adangel:pmd7-ast-children-non-null

Conversation

@adangel

@adangel adangel commented May 11, 2019

Copy link
Copy Markdown
Member

Changes:

  • The children array in AbstractNode is now initialized with an empty array.
  • This means, it is now never null, thus the null checks can be removed.
  • The only change to the children array is, when adding a new child (jjtAddChild), or removing a child (removeChildAtIndex).

Future:

  • the children array is protected. This means, sub classes could assign null to it... do we really need field available in subclasses? I'd assume, the already available methods are enough. -> this is something for defining a general AST API (which methods should be package private only, as they are only used by the parser, which methods define the API, when do we implement iterator, etc..)

@adangel adangel added the in:pmd-internals Affects PMD's internals label May 11, 2019
@adangel adangel added this to the 7.0.0 milestone May 11, 2019
@ghost

ghost commented May 11, 2019

Copy link
Copy Markdown
1 Message
📖 No java rules are changed!

Generated by 🚫 Danger

@oowekyala oowekyala merged commit 113ad74 into pmd:pmd/7.0.x May 18, 2019
oowekyala added a commit that referenced this pull request May 18, 2019
From PR #1823

* This PR is for PMD 7.
* It's extracted from #1759

Changes:
* The children array in AbstractNode is now initialized with an empty
* array.
* This means, it is now never null, thus the null checks can be removed.
* The only change to the children array is, when adding a new child
* (`jjtAddChild`), or removing a child (`removeChildAtIndex`).

Future:
* the children array is protected. This means, sub classes could assign
* null to it... do we really need field available in subclasses? I'd
* assume, the already available methods are enough. -> this is something
* for defining a general AST API (which methods should be package
* private only, as they are only used by the parser, which methods
* define the API, when do we implement iterator, etc..)
@adangel adangel deleted the pmd7-ast-children-non-null branch May 26, 2019 10:30
@adangel adangel changed the title refactor: Make the children array never null [core] refactor: Make the children array never null Jan 7, 2023
@adangel adangel mentioned this pull request Jan 23, 2023
55 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:pmd-internals Affects PMD's internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants