resolveUnitAt method
Future<ResolvedUnitResult>
resolveUnitAt(
- Uri uri
)
Implementation
Future<ResolvedUnitResult> resolveUnitAt(Uri uri) async {
assert(FileSystemEntity.isFileSync(
uri.toFilePath(windows: Platform.isWindows)));
for (final ctx in contexts.contexts) {
final path = getPath(uri);
if (_resolvedAsts.containsKey(path)) {
return _resolvedAsts[path]! as ResolvedUnitResult;
}
final output =
await ctx.currentSession.getResolvedUnit2(path) as ResolvedUnitResult;
if (output.state == ResultState.VALID) {
return _resolvedAsts[path] = output;
}
}
throw ArgumentError("'uri' could not be resolved (contexts: "
"${contexts.contexts.map((c) => c.contextRoot.root.toUri()).join(", ")})");
}