PMD utilizes the Apex Jorje library to parse Apex source and generate an AST. The fact that this library is closed-source introduces two major headaches for us:
I can't imagine it's particularly pleasant to develop on top of an undocumented API. Or to slice-and-dice and integrate new versions.
Describe the solution you'd likeI'd like to explore (and contribute to) the transition to a fully open-source Apex front-end.
In my organization, we're using @nawforce's Apex grammar to parse almost 1MLoC, now with zero issues. Built on top of this, we've got an implementation to convert the resulting parse tree to an abstract syntax tree data structure-- excluding the SOQL query syntax, which isn't relevant here. This is not yet open-sourced, but that is obviously a prerequisite to move forward.
The integration of this code ought to be fairly mechanical, to translate this AST data structure to the existing PMD AST. If there are any gaps or incompatibilities, I guess I'm volunteering to accommodate the requested modifications. Validating the semantic equivalence of the representation is a little trickier, but my sense is that this wouldn't be a big hurdle.
The biggest risk is likely in swapping out one parser for another, and that the tool no longer parses an Apex file that it previously accepted. OTOH, any of these issues could actually be fixed upstream, which is not currently a possibility.
So... that's the idea and the offer... wanted to gauge your interest and gather your concerns.
The chosen open source front-end: Summit AST... is Summit AST
Maven Repo for Snapshots: https://google.oss.sonatype.org/content/repositories/snapshots/com/google/summit/summit-ast/
Releases: https://central.sonatype.dev/artifact/com.google.summit/summit-ast/1.0.0/overview
https://repo1.maven.org/maven2/com/google/summit/summit-ast/
Note: All PRs are merged into branch https://github.com/pmd/pmd/tree/experimental-apex-parser
ast
package #4081RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4