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

[core] Clarify API for ANTLR based languages #2500

Closed
5 tasks done
Tracked by #3898
adangel opened this issue May 20, 2020 · 1 comment · Fixed by #4471
Closed
5 tasks done
Tracked by #3898

[core] Clarify API for ANTLR based languages #2500

adangel opened this issue May 20, 2020 · 1 comment · Fixed by #4471
Assignees
Milestone

Comments

@adangel
Copy link
Member

adangel commented May 20, 2020

Part of #2499

  • We should not expose antlr specific API into the PMD's node API (this is addressed by [core,swift] Refactor antlr implementation #2463)

  • AntlrTokenizer is internal but should be impl, because it is needed to implement a language
    based on antlr - at least AntlrTokenizer.getCharStreamFromSourceCode

  • AntlrBaseRule uses already a different concept than JavaccBasedRules
    (where is the visitor or is the rule a visitor?). This indicates missing work on API design
    in general.

    • Those rules use a visitor instead of being a visitor. Having Javacc rules implement the interface is the bad design, which led to duplication of thousands of lines:

    //
    // The following APIs are identical to those in JavaParserVisitorAdapter.
    // Due to Java single inheritance, it preferred to extend from the more
    // complex Rule base class instead of from relatively simple Visitor.
    //

    Note that because of [core] Add generic visitor interface in pmd-core #2589, we don't actually need language-specific base rule classes anymore. We could just have an AbstractVisitorRule on the model of the Antlr one (the antlr one doesn't need to exist), with a buildVisitor() method that returns an AstVisitor<RuleContext, ?>.

  • Open question: How can we extend the Antlr nodes (e.g. adding additional getters/attributes to expose some information for XPath)? The issue is, that they're all generated into the same file...

  • How does the impl API look like for Antlr-based languages? -> that leads to the documentation

  • This task probably depends on PMD 7.0.0 API

  • This task creates another refactoring task (implementing the proposed API).

@adangel

This comment was marked as resolved.

@adangel adangel mentioned this issue Jan 23, 2023
55 tasks
@adangel adangel self-assigned this Apr 13, 2023
@adangel adangel mentioned this issue Apr 13, 2023
4 tasks
@adangel adangel changed the title [core] Clarify API for Antlr based languages [core] Clarify API for ANTLR based languages Apr 14, 2023
adangel added a commit to adangel/pmd that referenced this issue Apr 14, 2023
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 a pull request may close this issue.

1 participant