This repository was archived by the owner on Mar 24, 2026. It is now read-only.
Replies: 2 comments 13 replies
|
You're not meant to access the ResolvedUnit directly. Instead use context.registry to listen to what you care about. This is a much more efficient way of listening to AstNodes. |
7 replies
|
Somewhat related question - you said e.g. Is this not a correct way to add a lint error? context.registry.addMethodInvocation((final node) {
final name = node.toString();
if (regex.hasMatch(name)) {
reporter.reportErrorForNode(code, node);
}
}); |
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I don't see that there's any way to access the resolved the unit in an individual lint rule.
rundoesn't return a future, so I can't awaitresolver.getResolvedUnitResult()without getting a bunch of errors (and no linting). The best I can do seems to be overridestartupand copyDartLintRule's startup into my rule (including_stateKey), then setting its resolvedunitto a class field. Then I can access the resolved unit just fine inrun. However, this also requires me to use custom_lint_core'sLinterVisitorandcontext.registry.nodeLintRegistrywhich are both supposed to be internal to the package.Overall the goal is to run a regex on a whole file to pull out some very specific cases that I can't find any other way to cover.
All reactions