mirror of
https://github.com/flutter/flutter
synced 2024-10-13 19:52:53 +00:00
Add a diagnostic message for malformed imports in analyze.dart (#38355)
This commit is contained in:
parent
1df6e2af5d
commit
d291de086c
|
@ -435,6 +435,22 @@ Future<void> verifyNoBadImportsInFlutter(String workingDirectory) async {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (final String key in dependencyMap.keys) {
|
||||
for (final String dependency in dependencyMap[key]) {
|
||||
if (dependencyMap[dependency] != null)
|
||||
continue;
|
||||
// Sanity check before performing _deepSearch, to ensure there's no rogue
|
||||
// dependencies.
|
||||
final String validFilenames = dependencyMap.keys.map((String name) => name + '.dart').join(', ');
|
||||
errors.add(
|
||||
'$key imported package:flutter/$dependency.dart '
|
||||
'which is not one of the valid exports { $validFilenames }.\n'
|
||||
'Consider changing $dependency.dart to one of them.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (final String package in dependencyMap.keys) {
|
||||
final List<String> loop = _deepSearch<String>(dependencyMap, package);
|
||||
if (loop != null) {
|
||||
|
@ -1180,6 +1196,9 @@ Set<String> _findFlutterDependencies(String srcPath, List<String> errors, { bool
|
|||
}
|
||||
|
||||
List<T> _deepSearch<T>(Map<T, Set<T>> map, T start, [ Set<T> seen ]) {
|
||||
if (map[start] == null)
|
||||
return null; // We catch these separately.
|
||||
|
||||
for (final T key in map[start]) {
|
||||
if (key == start)
|
||||
continue; // we catch these separately
|
||||
|
|
Loading…
Reference in a new issue