GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [java] Grammar type expr by oowekyala · Pull Request #2039 · pmd/pmd

Conversation

@oowekyala

@oowekyala oowekyala commented Sep 28, 2019

Copy link
Copy Markdown
Member

Grammar changes

  • Introduce TypeExpression, a node type that wraps a Type node but is an ASTExpression

    • This allows us to treat instanceof expressions as infix expressions (which they are, syntactically), and fix the weird inconsistency, that instanceof is in the middle of the precedence hierarchy of infix operators, yet is not itself an ASTInfixExpression. Now it has its own constant in BinaryOp, and ASTInstanceOfExpression extends ASTInfixExpression (its XPath name is InfixExpression too).
    • This also simplifies the qualifier of method call, method references, and field accesses. Previously it could have been a type, an expression, or an AmbiguousName (which implements both interfaces). Now we can use the single interface ASTExpression to unify them, and merge the methods getLhsType, getLhsExpression, getAmbiguousLhs (which were inconsistently defined anyway).
    • This is what Spoon does
  • Cleanup inconsistencies in the API of many nodes

    • align the API of ASTAssignmentExpression on that of ASTInfixExpression
    • rename the methods of ASTConditionalExpression to a simpler scheme (I'd like ASTIfStatement to have the same names)
    • Fix many doc comments or simplify them
      • In particular, fix many comments specifying that some node is a PrimaryExpression, or a node with a specific precedence. Since parentheses are flattened, any expression may appear there (even those that have a lower precedence, provided they were parenthesized). There were quite a few bugs where eg getLhsExpression expects an ASTPrimaryExpression even though anything can be there.

TBH ASTPrimaryExpression is not useful in the API since #1872, and we should probably scrap it entirely.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
oowekyala added 9 commits September 26, 2019 05:53
@oowekyala
Correct documentation
90f645f
@oowekyala
Treat instanceof expression as an infix expression
d4b0440
@oowekyala
Same for qualifiable exprs
1e81957
@oowekyala
Simplify doc comments
163d1be
@oowekyala
Fix tests
f777e3b
@oowekyala
Rename to getQualifier
e20c1fe
@oowekyala
Uniformise some method names
49d5da5
@oowekyala
Use imports to reduce merge conflicts
b4d188a
@oowekyala
Fix qualifier being ASTExpression
9451961
Since parentheses are flattened, any expression may be in any position
(which is good tbh, the API is simpler, and the AST is uniform)
@oowekyala oowekyala added the in:ast About the AST structure or API, the parsing step label Sep 28, 2019
@oowekyala oowekyala added this to the 7.0.0 milestone Sep 28, 2019
@oowekyala
Suppress PMD warnings
8b4e308
@ghost

ghost commented Sep 29, 2019

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

Generated by 🚫 Danger

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@adangel adangel changed the title Grammar type expr [java] Grammar type expr Sep 29, 2019
adangel
adangel reviewed Sep 29, 2019
View reviewed changes
Comment thread pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAssignmentExpression.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTAssignmentExpression.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTConstructorCall.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTExplicitConstructorInvocation.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTInfixExpression.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/ASTInstanceOfExpression.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/AbstractJavaNode.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalInterfaces.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/InternalInterfaces.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

oowekyala added 5 commits September 30, 2019 11:36
@oowekyala
PR review comments
43a8c6d
* Don't abbreviate getLhs/getRhs
* Make ExplicitConstructorInvocation implement QualifierOwner
@oowekyala
Remove InstanceOfExpression, use regular InfixExpression
341a833
@oowekyala
Remove JSingleChildNode
420cc4d
See pmd#2039 (comment)
@oowekyala
Fix compilation
60aaaff
Use AtLeastOneChild to remove nullability warnings.
@oowekyala
Merge branch 'java-grammar' into grammar-type-expr
d56f61b
adangel
adangel approved these changes Sep 30, 2019
View reviewed changes
@oowekyala oowekyala self-assigned this Oct 5, 2019
@oowekyala
oowekyala merged commit d56f61b into pmd:java-grammar Oct 5, 2019
@oowekyala
oowekyala deleted the grammar-type-expr branch October 5, 2019 12:58
@adangel adangel mentioned this pull request Jan 23, 2023
PMD 7 Tracking Issue #3898
Closed
55 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@adangel adangel adangel approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@oowekyala oowekyala

Labels

in:ast About the AST structure or API, the parsing step

Projects

None yet

Milestone

7.0.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@oowekyala @adangel
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.