runWidget method
Future<void>
runWidget(
- FileSystemEntity file,
- AnalysisContextCollection collection,
- DartServerRepository dartServerRepository,
- TestRunInfo testRunInfo,
Implementation
Future<void> runWidget(
FileSystemEntity file,
AnalysisContextCollection collection,
DartServerRepository dartServerRepository,
TestRunInfo testRunInfo,
) async {
try {
final resolvedUnit = await file.resolveFile(collection);
CompilationUnit unit = resolvedUnit.unit;
final widgetGenerator = WidgetGenerator(
dartServerRepository: dartServerRepository,
cacheManager: CacheManager(),
);
widgetGenerator.init();
for (var declaration in unit.declarations) {
if (declaration is ClassDeclaration) {
final element = declaration.declaredElement!;
if (!element.checkIfAWidgetOrState) continue;
if (!isAnnotationPresent(element)) continue;
await widgetGenerator.generateForWidget(
classDeclaration: declaration,
compilationUnit: unit,
subjectFile: file.path,
testRunInfo: testRunInfo);
}
}
} catch (e, stackTrace) {
wtTelemetry.trackError(
severity: Severity.error, error: e, stackTrace: stackTrace);
wtLog.error('Unable to resolve file ${file.path}', verbose: true);
}
}