dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.09k stars 1.56k forks source link

Could the various Lint related classes in package:analyzer be made public? #50986

Open rrousselGit opened 1 year ago

rrousselGit commented 1 year ago

Hello!

I am working on enabling the implementation of custom lint rules in a syntax similar to how the Dart SDK defines them.
And while investigating how the SDK handles lints, I realized a large amount of classes related to them are private.

Here's a non-exhaustive of potential classes that I feel would be valuable if made public:

and their equally valuable dependencies, such as InterfaceManagger3, LinterVisitor, ...

All of these combined contain a large number of valuable utilities. Yet these objects aren't easily extractable out of the SDK. They are often entangled with the implementation classes of other aspects of the analyzer.

srawlins commented 1 year ago

CC @pq @scheglov @bwilkerson

I think I agree. It would be perfectly reasonable to use these while writing a diagnostic in a plugin, right?

rrousselGit commented 1 year ago

On that note, ErrorReporter is public and has a public constructor which accepts a Source. But Source isn't public

I believe Source is also available on various other places (Element)

rrousselGit commented 1 year ago

Some equally valuable utilities to expose would be the fixes / CorrectionProducers

There's a large amount of them, and diagnostic plugins would otherwise have to reimplement them for their use-case.

bwilkerson commented 1 year ago

It's my opinion that we don't want to commit to supporting the lint related classes as part of the public API for the analyzer package, or to make CorrectionProducer public, until we have resolved the issue of whether and how to support plugins.

srawlins commented 3 months ago

We've got working designs for how to support plugins using LintRule, LintCode, CorrectionProducer, et al, so I will start working to make the necessary lint-related classes public. CC @pq

rrousselGit commented 3 months ago

This is hype! I'll definitely try this whenever it's available :)