GeezerVison is showing github.com — [java] Align method and constructor declaration grammar by oowekyala · Pull Request #2034 · pmd/pmd
Conversation
oowekyala
commented
Sep 27, 2019
•
edited by adangel
Loading
Uh oh!
There was an error while loading. Please reload this page.
This fleshes out ASTMethodOrConstructorDeclaration to abstract what can be abstracted, and align their grammar more closely
Grammar changes
- Merge ASTAnnotationMethodDeclaration into ASTMethodDeclaration. I don't see the point of having two separate nodes, the only API difference is that annotation methods may have a default value.
- The removed node had no MethodDeclarator, or FormalParameters, which just introduced more nullability in the API
- Add an ASTBlock as a child of ASTConstructorDeclaration -> was just inconsistent
- Replace NameList with ThrowsList
- Remove MethodDeclarator, former children are direct children of the method declaration. This node just introduced inconsistencies (ConstructorDeclaration didn't have it) and an unnecessary level of nesting.
- Add many useful methods to ASTMethodOrConstructorDeclaration
API changes
- Add JavaNode#getEnclosingType, ASTCompilationUnit#{getPackageName, getTypeDeclarations}
- Rename ASTMethodDeclaration#getBlock to getBody, now shared by constructor declarations
- Rename ASTConstructorDeclaration#getParameterCount to getArity, now shared by method declarations
Internal changes
- Reimplement the name fetching routines of JavaRuleViolation so that they don't use the old symbol table anymore. That was completely unnecessary and the old symbol table is broken a bit more by this PR.
TODO on master
- Deprecate AbstractJavaRule#getDeclaringType (replaced by JavaNode#getEnclosingType)
- Backport
JavaNode#getEnclosingType to master
AbstractJavaRule#getDeclaringType is useless, it only cares for class or interface types, it returns a simple string, even though the enclosing type may be anonymous...
- The new method returns the node instead, and is available everywhere
- -> a12afd1
- 04e5619 Deprecate ASTMethodDeclaration#getMethodDeclarator - the methods "getFormalParameters()", "getMethodName()" should be used directly instead.
- also add "getParameterCount()"/"getArity()" to ASTMethodDeclaration
- introduce the new aliases for the other renamed methods on master and deprecate the old ones (like what was done for getFormalParameters)
- ASTMethodDeclaration#getBlock -> getBody
- ASTConstructorDeclaration#getParameterCount -> getArity
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…aration
* Remove ASTConstructorDeclaration::getParameters -> use getFormalParameters
* Remove ASTConstructorDeclaration::getParameterCount -> use getArity
* Remove MethodDeclarator from MethodDeclaration grammar, deprecate node class
* Add an ASTBlock to ASTConstructorDeclaration grammar and
ASTMethodOrConstructorDeclaration::getBody
* Remove ASTMethodDeclaration::getBlock in favour of getBody
Make JavaRuleViolation not depend on the old symbol table
|
1 Message
|
| 📖 |
No java rules are changed! |
Generated by 🚫 Danger
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to do the deprecations on master first?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Maybe, introduce the new aliases for the other renamed methods on master and deprecate the
old ones (like what was done for getFormalParameters)
Which ones do you mean?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Which ones do you mean?
ASTMethodDeclaration#getBlock -> getBody
ASTConstructorDeclaration#getParameterCount -> getArity
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
oowekyala
added a commit
that referenced
this pull request
Oct 5, 2019
Also, replace deprecated method usages
Reviewers
adangel
adangel left review comments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
in:ast
About the AST structure or API, the parsing step
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|