-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[java] Updates to AST nodes #4768
Conversation
Only on ASTMethodDeclaration, ASTFieldDeclaration and ASTAnyTypeDeclaration. This makes it possible to remove it from AccessNode.
Deprecate ASTClassOrInterfaceDeclaration#isPackagePrivate(). Use #hasVisibility(Visibility) instead, which can correctly differentiate between local and package private classes.
Generated by 🚫 Danger |
Thanks for starting this! I would also suggest renaming VariableDeclaratorId to VariableId since it's used relatively often in the codebase. |
a3a19eb
to
e79e840
Compare
I guess, we should also rename ASTClassOrInterfaceBody to ASTClassBody. It looks odd, if we leave ASTClassOrInterfaceBody... (it's the only one with "ClassOrInterface") |
Also rename AbstractAnyTypeDeclaration to AbstractTypeDeclaration
…ration Also rename AbstractMethodOrConstructorDeclaration to AbstractExecutableDeclaration
- getName() instead of getMethodName() or getVariableName() - firstChild() instead of getFirstChildOfType() - getRoot() instead of getFirstParentOfType(ASTCompilationUnit.class) - children() instead of findChildrenOfType() - no more addRuleChainVisit() - ancestors() instead of getNthParent() - descendants() instead of findDescendantsOfType()
- firstChild() instead of getFirstChildOfType() - descendants() instead of findDescendantsOfType() - ancestors() instead of getFirstParentOfType()
- This improves ASTLiteral implementation - Adds ASTLiteral#getLiteralText() - not yet exposed as XPath attribute Co-authored-by: Clément Fournier <clement.fournier76@gmail.com>
- taken from pmd#4352 (avoid getImage()) - Exposes @LiteralText for ASTLiteral Co-authored-by: Clément Fournier <clement.fournier76@gmail.com>
I think, this is ready now. Many deprecated API usages are resolved. I integrated parts of #4352 (ASTLiteral improvements, XPath Attribute improvements).
Deleting deprecations needs to be done in a separate PR (I don't want to make this even bigger).
|
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.
Thanks, this looks good
pmd-java/src/main/java/net/sourceforge/pmd/lang/java/ast/internal/PrettyPrintingUtil.java
Outdated
Show resolved
Hide resolved
…nal/PrettyPrintingUtil.java Co-authored-by: Clément Fournier <clement.fournier@tu-dresden.de>
Describe the PR
Finish the remaining open tasks for Java (#1307, #3751).
Note: I don't want to remove any methods for now, just deprecate them, if not already. I think, we should remove the deprecated methods only after a RC5, to have some deprecation notice. However, renaming classes definitely breaks...Not sure, if it's worth to wait. I'll see, once I proceed with this PR.
In this case, I decided now to remove the method ASTClassDeclaration#isPackagePrivate since we renamed the class from ASTClassOrInterfaceDeclaration. So, deprecating isn't that helpful.
Tasks:
Long.parseUnsignedLong
rather than a custom implementation.@LiteralText
is availableRelated issues
Ready?
./mvnw clean verify
passes (checked automatically by github actions)