Chromium Code Reviews| Index: pkg/analyzer/lib/src/task/dart.dart |
| diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart |
| index c8b108bdf2c8dfbd742d35d681eacce96080422c..4dcc1c97df683b6bfc4e32033a2e952efe204382 100644 |
| --- a/pkg/analyzer/lib/src/task/dart.dart |
| +++ b/pkg/analyzer/lib/src/task/dart.dart |
| @@ -6443,8 +6443,38 @@ class VerifyUnitTask extends SourceBasedAnalysisTask { |
| } |
| } |
| StringLiteral uriLiteral = directive.uri; |
| - errorReporter.reportErrorForNode(CompileTimeErrorCode.URI_DOES_NOT_EXIST, |
| - uriLiteral, [directive.uriContent]); |
| + CompileTimeErrorCode errorCode = CompileTimeErrorCode.URI_DOES_NOT_EXIST; |
| + if (_isGenerated(source)) { |
| + errorCode = CompileTimeErrorCode.URI_HAS_NOT_BEEN_GENERATED; |
| + } |
| + errorReporter |
| + .reportErrorForNode(errorCode, uriLiteral, [directive.uriContent]); |
| + } |
| + |
| + /** |
| + * Return `true` if the given [source] refers to a file that is assumed to be |
| + * generated. |
| + */ |
| + bool _isGenerated(Source source) { |
| + if (source == null) { |
| + return false; |
| + } |
| + // TODO(brianwilkerson) Generalize this mechanism. |
| + List<String> suffixes = <String>[ |
|
scheglov
2016/08/10 19:12:15
const const
Brian Wilkerson
2016/08/10 19:42:02
Done
|
| + '.g.dart', |
| + '.pb.dart', |
| + '.pbenum.dart', |
| + '.pbserver.dart', |
| + '.pbjson.dart', |
| + '.template.dart' |
| + ]; |
| + String fullName = source.fullName; |
| + for (String suffix in suffixes) { |
| + if (fullName.endsWith(suffix)) { |
| + return true; |
| + } |
| + } |
| + return false; |
| } |
| /** |