testRun method
- @visibleForTesting
- ResolvedUnitResult result,
- AnalysisError analysisError,
- List<
AnalysisError> others, { - Pubspec? pubspec,
Runs this fix in test mode.
The result will contain all the changes that would have been applied by run.
The parameter pubspec
can be used to simulate a pubspec file which will
be passed to CustomLintContext.pubspec.
By default, an empty pubspec with the name test_project
will be used.
Implementation
@visibleForTesting
Future<List<PrioritizedSourceChange>> testRun(
ResolvedUnitResult result,
AnalysisError analysisError,
List<AnalysisError> others, {
Pubspec? pubspec,
}) async {
final registry = LintRuleNodeRegistry(
NodeLintRegistry(LintRegistry(), enableTiming: false),
'unknown',
);
final postRunCallbacks = <void Function()>[];
final context = CustomLintContext(
registry,
postRunCallbacks.add,
{},
pubspec,
);
final resolver = CustomLintResolverImpl(
() => Future.value(result),
lineInfo: result.lineInfo,
path: result.path,
source: result.libraryElement.source,
);
final reporter = ChangeReporterImpl(result.session, resolver);
await startUp(resolver, context);
run(resolver, reporter, context, analysisError, others);
runPostRunCallbacks(postRunCallbacks);
return reporter.waitForCompletion();
}