Skip to content

[core] Analysis listeners#3692

Merged
adangel merged 108 commits into
pmd:pmd/7.0.xfrom
oowekyala:analysis-listener
Feb 16, 2022
Merged

[core] Analysis listeners#3692
adangel merged 108 commits into
pmd:pmd/7.0.xfrom
oowekyala:analysis-listener

Conversation

@oowekyala

@oowekyala oowekyala commented Dec 16, 2021

Copy link
Copy Markdown
Member

Describe the PR

This is a pretty old PR of mine which refactors the high-level execution logic of PMD. The new abstraction GlobalAnalysisListener (and its helper FileAnalysisListener) implements the listener pattern for an analysis. Violations and errors are the kinds of events that are forwarded to this listener. Renderers now use this API to receive these events and produce a report or output it it. With this design analysis does not necessarily produce a Report object, if that's not needed. I expect this is might be useful for IDE integrations.

SourceCodeProcessor is removed and its functionality merged into PmdRunnable. RuleContext is not analysis-global anymore, instead it provides API for rules to report violations on. Eventually I want rule implementations to have type-safe access to a RuleContext object, eg by making them implement AstVisitor<RuleContext, Void>.

This is part of a pretty long chain of local branches (first PR was #3085), which aim to

  • replace PMD's DataSource and CPD's SourceCode with a new TextDocument abstraction
  • make parsing and text manipulation in rules more efficient by using TextDocument
  • improve error reporting APIs, for instance by introducing a class to reify text locations. It will become possible to report errors on a specific token for instance.
  • improve the classes that represent code comments
  • simplify PMD internals (mostly just this PR)

These branches currently culminate with the implementation of a Javadoc parser using these new APIs. Using TextDocuments we can also eventually support #693, and I actually have an ugly prototype in my branches. Another cool thing I've been working on is copy-paste detection based not on tokens but on ASTs, which gives much more precise results as CPD and could possibly be part of pmd 7 as a new PMD rule.

Related issues

Ready?

  • Deprecations for PMD 6
  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

@adangel adangel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@adangel adangel merged commit 18779ea into pmd:pmd/7.0.x Feb 16, 2022
@oowekyala oowekyala deleted the analysis-listener branch February 16, 2022 20:07
@adangel adangel mentioned this pull request Jan 23, 2023
55 tasks
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.

2 participants