269 update to apex parser 40 for corrections to trigger parsing #270
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.
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.