getPathsForName method
Implementation
Iterable<String> getPathsForName(PubspecConfig pubspecConfig, String name) {
if (TypeChecker.isKnownDartType(name)) return [];
final foundModel = models.firstWhereOrNull((model) => model.name == name);
if (foundModel == null) {
//Maybe a generic
final dartType = DartType(name);
if (dartType.generics.isEmpty) {
throw Exception(
'getPathForName is null: because `$name` was not added to the config file');
}
final paths = <String>{};
dartType.generics.forEach((element) {
paths.addAll(getPathsForName(pubspecConfig, element.toString()));
});
return paths;
} else {
final baseDirectory =
foundModel.baseDirectory ?? pubspecConfig.baseDirectory;
final path = foundModel.path;
if (path == null) {
return ['$baseDirectory'];
} else if (path.startsWith('package:')) {
return [path];
} else {
return ['$baseDirectory/$path'];
}
}
}