Skip to content

[java] Simplify array allocation expressions#1981

Merged
oowekyala merged 3 commits into
pmd:java-grammarfrom
oowekyala:grammar-array-dims
Sep 27, 2019
Merged

[java] Simplify array allocation expressions#1981
oowekyala merged 3 commits into
pmd:java-grammarfrom
oowekyala:grammar-array-dims

Conversation

@oowekyala

Copy link
Copy Markdown
Member

This is a minor simplification of the grammar of array allocation expressions.

  • ArrayAllocation nodes now have an ArrayType as a child,instead of a type + ArrayAllocationDims. This allows sharing the API and is overall less surprising (you'd expect an array allocation expression to have an array type node somewhere)
  • ArrayTypeDims is renamed to ArrayDimensions (it's tricky to spot the extra s)
  • ArrayDimExpr extends ArrayTypeDim. So ArrayAllocationDims can be removed, since ArrayDimensions collects all dimensions, whether they're initialized with a length expression (ArrayDimExpr) or not.

I'm not sure we really need an ArrayDimExpr node, ArrayTypeDim could as well have an optional child for the expression, but I'm concerned the API of that node would be more complex.

This prepares for fixing #997. We now have a single node type for array dimensions. We can add it in VariableDeclaratorId and MethodDeclaration, and get rid of Dimensionable. This fix has to wait for #1980 because both touch the VariableDeclaratorId production

This simplifies the grammar of allocation expressions,
they now have an array type as a child
@oowekyala oowekyala added the in:ast About the AST structure or API, the parsing step label Aug 15, 2019
@oowekyala oowekyala added this to the 7.0.0 milestone Aug 15, 2019
@ghost

ghost commented Sep 25, 2019

Copy link
Copy Markdown
1 Warning
⚠️ This PR cannot be merged yet.

Generated by 🚫 Danger

@oowekyala oowekyala merged commit 6a04f6a into pmd:java-grammar Sep 27, 2019
@oowekyala oowekyala deleted the grammar-array-dims branch October 1, 2019 08:52
@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:ast About the AST structure or API, the parsing step

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant