Skip to content
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

269 update to apex parser 40 for corrections to trigger parsing #270

Conversation

nawforce
Copy link
Contributor

@nawforce nawforce commented Apr 1, 2024

This changes the CST construction for the extra details supported for triggers in apex-parser 4.0.0. The support supplied here is only partial as the PR is getting big. Essentially we support statements and fields in triggers but ignore other declarations such as for properties or inner classes which matches current behaviour.

So for example, you should no longer get an error declaring a method but you will see an error if you try to invoke it as the method is not yet visible in the CST. Supporting FieldDeclaration was a bit tricky, if you test these in a trigger you will see they scope like local variables. Arguably we could have not allowed FieldDeclarations in triggers and let the parser treat them as LocalVariableDeclarations but that would not help with PropertyDeclarations which we will need to support later. Instead I have transformed fields into LocalVariableDeclarations, see constructTriggerVar() and we can the same with properties.

To get better support I think we need to make TriggerDeclaration inherit from FullDeclaration so that we can piggy-back on the existing support for the other types of declarations you can use in a trigger. That change is fairly easy to make but I would expect we might need to correct handling in quite a number of uses.

I have tested the apex-samples locally as this branch requires apex-parser 4.0.0 to be released for the CI to run.

@nawforce nawforce linked an issue Apr 1, 2024 that may be closed by this pull request
@nawforce nawforce requested a review from pwrightcertinia April 1, 2024 17:22
@pwrightcertinia pwrightcertinia merged commit 0861c0c into main Apr 24, 2024
1 check passed
@pwrightcertinia pwrightcertinia deleted the 269-update-to-apex-parser-40-for-corrections-to-trigger-parsing branch April 24, 2024 11:58
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.

Update to apex-parser 4.0 for corrections to trigger parsing
2 participants