Repository navigation
Fix #6655: Deprecate antlr4 generated lexers - #7172
Conversation
|
Compared to main: (comment created at 2026-11-12 10:31:57+00:00 for 67ea287) |
|
Thanks for the heads-up! I've been thinking about what this actually means for the pmd-kotlin module. I assume the intent of keeping And even deprecating only the outer On the other hand, backwards compatibility is probably hardly an issue for Kotlin: there are about 40 XPath-based Kotlin rules, and close to zero Java-based ones I know of. XPath-based rules only depend on node names, not on Java class names. So we have some freedom here. Just to brainstorm, one possible path could be:
There may well be other or better options, e.g. keeping the parser public but marking its internals as internal API, which is less work but leaves more ANTLR details in the public API. What do you think? Happy to open an issue to work this out further. |
|
Oops. I completely missed these inner classes in KotlinParser and SwiftParser. I'll need to think more about this, but in the meantime, I'll mark this as draft so it doesn't get merged. |
6b89bda to
c5f18bd
Compare
|
I've undeprecated KotlinParser and SwiftParser for now. KotlinParser has >100 inner classes. Extracting those into separate files feels like it's worth a separate PR. |
Update deprecation versions and release notes.
c5f18bd to
e0fa95d
Compare
There was a problem hiding this comment.
Thanks for working on this.
I'll change the description of #6655 to only concentrate on lexer and leave out parser.
In general: public API would be
- net.sourceforge.pmd.lang.swift.ast.PmdSwiftParser and all the AST nodes (which are in reality not AST nodes but parse rule context). The parser itself (net.sourceforge.pmd.lang.swift.ast.SwiftParser) would be package-private.
As it is right now, we shouldn't deprecate this outer class, as it creates a mess with the inner classes (we would get a deprecation warning depending on IDE although technically only the outer class would be deprecated).- Update: the generated visitor classes are public API as well, as they are used for writing rules
- net.sourceforge.pmd.lang.swift.cpd.SwiftCpdLexer and the implementation net.sourceforge.pmd.lang.swift.ast.SwiftLexer is package-private. This PR solves that by deprecating it.
For the parser: Moving the inner classes out will be a breaking, incompatible change. Can't do for PMD 7. We might do it for PMD 8, if it is worth (added to #5703). Note, that this circles back to the original problem, that antlr does not generate an AST, but a parse tree (see #4337).
|
Should we create a follow-up issue for what is left to do? |
It's already tracked in #5703. |
Describe the PR
This PR deprecates all antlr4 generated
FooLexer,,FooParserFooBaseListenerandFooListenerclasses (where Foo is a language name). It does not deprecateKotlinVisitorandSwiftVisitor, as they are needed to create custom rules.Related issues
Ready?
./mvnw clean verifypasses (checked automatically by github actions)