[apex] Use apex-parser and Summit AST#4806
Merged
Merged
Conversation
- Remove Jorje dependencies - Add temporary local jar dependency for Summit-AST - Comment out code until compilation succeeds
Operators - Create operator enums to wrap internal Jorje operators. - Create getters returning new operator enums in operator-expression nodes. Deprecate old getters. - Refactor metrics classes to use new operator enums. Tests - Remove references to internal Jorje nodes.
- Replace `ApexNode` type arguments with `Void` - Remove `ApexNode.getNode` - Remove `ASTCommentContainer` type parameter - Deprecate `ASTUserClassOrInterface` type parameter
Remove `node` field from `AbstractApexNode` to remove restriction of wrapping a single node. Create `AbstractApexNode.Single` subclass that wraps a single node. Other subclasses can be created as needed for common cases, or `AbstractApexNode` can be extended directly in irregular cases.
- Add call to `SummitAST` in `ApexParser` - Fix NPE involving `suppressMap` to allow `ApexTreeBuilder` to run - Remove unused `TopLevelVisitor`
Replace `CompilationUnit` with `TypeDeclaration` as the top-level node to match the AST produced by Jorje.
- Replace `ApexTreeBuilder.java` with `ApexTreeBuilder.kt` - Set up tree builder foundation - Build `TypeDeclaration` nodes
- Add `AbstractApexNode.Many`
- Add `buildChildren` function to tree builder
- Split `setParent` call from main `build` function into new `buildAndSetParent` - Remove list-based `build` function to decrease complexity - Improve documentation
- Remove Jorje dependencies - Add Summit-AST dependency - Comment out code until compilation succeeds
- Replace `ApexNode` type arguments with `Void` - Remove `ApexNode.getNode` - Remove `ASTCommentContainer` type parameter - Deprecate `ASTUserClassOrInterface` type parameter
Remove `node` field from `AbstractApexNode` to remove restriction of wrapping a single node. Create `AbstractApexNode.Single` subclass that wraps a single node. Other subclasses can be created as needed for common cases, or `AbstractApexNode` can be extended directly in irregular cases.
- Add call to `SummitAST` in `ApexParser` - Fix NPE involving `suppressMap` to allow `ApexTreeBuilder` to run - Remove unused `TopLevelVisitor`
Replace `CompilationUnit` with `TypeDeclaration` as the top-level node to match the AST produced by Jorje.
- Replace `ApexTreeBuilder.java` with `ApexTreeBuilder.kt` - Set up tree builder foundation - Build `TypeDeclaration` nodes
- Add `AbstractApexNode.Many`
- Add `buildChildren` function to tree builder
* Build expression statements ** Build assignment expressions ** Build array expressions ** Build literal expressions ** Build cast expressions ** Build operator expressions ** Build `this`/`super` expressions ** Build type reference expressions ** Build field/variable expressions ** Build method call expressions * Build ternary expressions * Refactor `AbstractApexNode` ** Add default implementations for some methods ** Add empty constructor ** Implement `AbstractApexNode.getDefiningType` * Fix `ASTLiteralExpression.getImage` * Implement reference types ** Implement `ASTReferenceExpression.isSObjectType` ** Implement `ASTReferenceExpression.hasRealLoc` ** Fix `ASTEmptyReferenceExpression.getDefiningType` * Implement `ASTMethodCallExpression.getFullMethodName` * Update `ASTLiteralExpression.getImage` * Replace `Triple` with `data class` * Fix `BITWISE_XOR` * Replace `Identifier.asCodeString` with `getString` * Fix call expressions ** Only the `receiver` of `CallExpression`s should be flattened * Fix `referenceTypeOf` Reference type should only be `STORE` when the variable is the target of assignment. * Rename `ASTMethodCallExpression.components`
… part-1 Change-Id: I254208dd5d1b9dbf5335a59a51372ec1d55f8535
adangel
commented
Feb 9, 2024
Also simplify ApexCRUDViolationRule Fixes TODO(b/239648780)
2 tasks
- keep CONSTRUCTOR_ID and STATIC_INIT_ID private - update migration documentation
…IfPrimitive These are helper methods to be used only inside the ast package.
- removed method getContext() - always returned null Fixes TODO(b/243906211) - Verify that getReferenceType() returns the correct values Fixes TODO(b/239648780)
Fixes TODO(b/239648780)
This was testing a deprecated XPath attribute, but that attribute was already removed.
Fixes TODO(b/243905954)
Update release notes/migration guide
adangel
added a commit
that referenced
this pull request
Feb 22, 2024
[apex] Use apex-parser and Summit AST #4806
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Describe the PR
These are all the current changes on the branch
experimental-apex-parserthat need to be reviewed once more.As far as I know, the rules all work the same, so function-wise this is ready.
Ideally, this will be part of PMD 7.0.0.
Possible open tasks (to be checked):
Related issues
Ready?
./mvnw clean verifypasses (checked automatically by github actions)