resolve method
Returns the absolute path wrt. to the given environment or null, if the import could not be resolved.
Implementation
@override
String? resolve(String scriptUri) {
final uri = Uri.parse(scriptUri);
if (uri.scheme == 'dart') {
// Ignore the SDK
return null;
}
if (uri.scheme == 'package') {
// TODO(cbracken) belongs in a Bazel package
return _resolveBazelPackage(uri.pathSegments);
}
if (uri.scheme == 'file') {
final runfilesPathSegment =
'.runfiles/$workspacePath'.replaceAll(RegExp(r'/*$'), '/');
final runfilesPos = uri.path.indexOf(runfilesPathSegment);
if (runfilesPos >= 0) {
final pathStart = runfilesPos + runfilesPathSegment.length;
return uri.path.substring(pathStart);
}
return null;
}
if (uri.scheme == 'https' || uri.scheme == 'http') {
return _extractHttpPath(uri);
}
// We cannot deal with anything else.
failed.add('$uri');
return null;
}