Currently Linter::lint_program does too much - it is meant to lint a single file. However it also creates Context, filters the diagnostics and returns them.
Instead this method should take a &mut FileContext , run any necessary rules and return. FileContext should contain Arc<Mutex<LintContext>> and have relevant method that would add diagnostics to the LintContext. Then filtering should be done in by the caller.
Currently
Linter::lint_program
does too much - it is meant to lint a single file. However it also createsContext
, filters the diagnostics and returns them.Instead this method should take a
&mut FileContext
, run any necessary rules and return.FileContext
should containArc<Mutex<LintContext>>
and have relevant method that would add diagnostics to theLintContext
. Then filtering should be done in by the caller.This is a prerequisite for a plugin system.