Skip to content

[java] Add void type node to replace ResultType#2715

Merged
oowekyala merged 2 commits into
pmd:java-grammarfrom
oowekyala:grammar-void-type
Aug 23, 2020
Merged

[java] Add void type node to replace ResultType#2715
oowekyala merged 2 commits into
pmd:java-grammarfrom
oowekyala:grammar-void-type

Conversation

@oowekyala

Copy link
Copy Markdown
Member

Describe the PR

Add a VoidType node to replace ResultType. This means we don't need the ResultType wrapper when the method is not void, and the result type node is never null:

CodeOld ASTNew AST
void foo();
└─ MethodDeclaration
   └─ ResultType[@Void=true()]
   └─ MethodDeclarator
      └─ FormalParameters
└─ MethodDeclaration
   └─ ModifierList
   └─ VoidType
   └─ FormalParameters

int foo();
└─ MethodDeclaration
   └─ ResultType[@Void=false()]
      └─ Type
         └─ PrimitiveType
   └─ MethodDeclarator
      └─ FormalParameters
└─ MethodDeclaration
   └─ ModifierList
   └─ PrimitiveType
   └─ FormalParameters

This also makes the qualifier of a ClassLiteral non-null, which removes the inconsistency between void.class and T.class:

CodeCurrent java-grammarAfter this PR
void.class
ClassLiteral[@Void=true()]
└─ ClassLiteral
   └─ VoidType
int.class
└─ ClassLiteral
   └─ PrimitiveType
└─ ClassLiteral
   └─ PrimitiveType

(this change description is relative to java-grammar as ASTClassLiteral does not exist on master, so we don't have to put it into the clean release notes).

Related issues

  • Fixes #

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by travis)
  • Added (in-code) documentation (if needed)

@oowekyala oowekyala added the in:ast About the AST structure or API, the parsing step label Aug 14, 2020
@oowekyala oowekyala added this to the 7.0.0 milestone Aug 14, 2020
@ghost

ghost commented Aug 14, 2020

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

Generated by 🚫 Danger

@adangel adangel 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.

@oowekyala oowekyala merged commit 29482a1 into pmd:java-grammar Aug 23, 2020
@oowekyala oowekyala deleted the grammar-void-type branch August 23, 2020 18:50
@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.

2 participants