getResolvedUnit method
Safely resolves the unit at filePath.
Returns null if the result is not a ResolvedUnitResult, the file
does not exist, or the file is not part of an active analysis context.
Implementation
Future<ResolvedUnitResult?> getResolvedUnit(String filePath) async {
try {
final absPath = p.normalize(p.absolute(filePath));
final context = collection.contextFor(absPath);
final unitResult = await context.currentSession.getResolvedUnit(absPath);
if (unitResult is ResolvedUnitResult && unitResult.exists) {
return unitResult;
}
return null;
} catch (_) {
return null;
}
}