Skip to content

[apex] Summit-AST Apex module - Part 2 - expression nodes#4151

Merged
adangel merged 22 commits into
pmd:experimental-apex-parserfrom
aaronhurst-google:experimental-apex-parser
Oct 20, 2022
Merged

[apex] Summit-AST Apex module - Part 2 - expression nodes#4151
adangel merged 22 commits into
pmd:experimental-apex-parserfrom
aaronhurst-google:experimental-apex-parser

Conversation

@aaronhurst-google

@aaronhurst-google aaronhurst-google commented Oct 11, 2022

Copy link
Copy Markdown
Contributor

Second part of Summit-AST-based Apex module.

Changes

  • Build expression nodes

    • 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 (where PMD node does not correspond to Summit Node)
    • Implement AbstractApexNode.getDefiningType
  • Implement reference types

    • Implement ASTReferenceExpression.isSObjectType
    • Implement ASTReferenceExpression.hasRealLoc
    • Fix ASTEmptyReferenceExpression.getDefiningType
  • Miscellaneous

    • Implement ASTMethodCallExpression.getFullMethodName
    • Update ASTLiteralExpression.getImage
    • Replace Triple with data class
    • Fix BITWISE_XOR
    • Replace Identifier.asCodeString with getString
    • Fix ASTLiteralExpression.getImage
    • Updated Summit-AST to released version (1.0.0)

Related issues:

eklimo and others added 20 commits August 11, 2022 11:10
- Remove Jorje dependencies
- Add temporary local jar dependency for Summit-AST
- 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
- Split `setParent` call from main `build` function into new
  `buildAndSetParent`
- Remove list-based `build` function to decrease complexity
- Improve documentation
* 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`
…arser

Change-Id: If0e9011847b2fa515faaacc631c0876ac0683d2a
Update summit-ast dependency to latest release.

Change-Id: I14cb01fe198c6fc78dcd90b1f23c44e42c573bba
@aaronhurst-google

aaronhurst-google commented Oct 11, 2022

Copy link
Copy Markdown
Contributor Author

(Test failures in this experimental branch continue to be expected until the AST is fully translated.)

@aaronhurst-google aaronhurst-google changed the title Summit-AST Apex module - Part 2 - expression nodes [apex] Summit-AST Apex module - Part 2 - expression nodes Oct 12, 2022
@adangel adangel self-requested a review October 14, 2022 07:27

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

Thanks! LGTM

Comment thread pmd-apex/pom.xml Outdated
Comment thread pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ast/ASTMethod.java Outdated
* Removed Kotlin compiler version in submodule pom.xml
* Package-private AST node constructors
* Constructor method naming for getImage and getCanonicalName

Change-Id: I4b2cd2ca0437c480e5fc52cf3147be7a2336f6f7
Change-Id: I715bc3729d7c631993cfcfb6c6f503b959ce4340
@adangel adangel merged commit 815b796 into pmd:experimental-apex-parser Oct 20, 2022
@adangel adangel added this to the 7.0.0 milestone Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants