Description
Splitting this out of #55281 (comment) so it doesn't get lost.
This lint reads the content in a way that appears that it can hit the disk and can be quite slow when analyzing a lot of files (or a large library):
One simple option suggested by @bwilkerson was:
var unitContext =
context.allUnits.firstWhereOrNull((unit) => unit.unit == node);
var content = unitContext.content;
And @scheglov:
And yes, I think
registerNodeProcessors()
should have access to the currentLintRuleUnitContext
instance. Currently it knows all units of the library, and its defining unit, but not the current.
I had a quick look at this, but I am a little confused by LinterContext.definedUnit
because it seems like there is code that passes each individual unit in for it. For example this call here happens inside a loop for all units within a library (called currentUnit
):
And then currentUnit
is passed as definingUnit
:
So I wonder whether definingUnit
could just be rename and repurposed as currentUnit
or whether any lints really do need/want the defining unit?