Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: pkg/front_end/lib/src/fasta/loader.dart

Issue 2938573002: Improve recovery from compile-time errors. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_target.dart ('k') | pkg/front_end/test/fasta/compile.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/loader.dart
diff --git a/pkg/front_end/lib/src/fasta/loader.dart b/pkg/front_end/lib/src/fasta/loader.dart
index 61e908c65d0d015ec4599ba949a2048a7bdba048..5a8e64a29cca8dee39fbd3039dad53a614c9ae65 100644
--- a/pkg/front_end/lib/src/fasta/loader.dart
+++ b/pkg/front_end/lib/src/fasta/loader.dart
@@ -25,7 +25,19 @@ abstract class Loader<L> {
final TargetImplementation target;
- final List<InputError> errors = <InputError>[];
+ /// List of all handled compile-time errors seen so far by libraries loaded
+ /// by this loader.
+ ///
+ /// A handled error is an error that has been added to the generated AST
+ /// already, for example, as a throw expression.
+ final List<InputError> handledErrors = <InputError>[];
+
+ /// List of all unhandled compile-time errors seen so far by libraries loaded
+ /// by this loader.
+ ///
+ /// An unhandled error is an error that hasn't been handled, see
+ /// [handledErrors].
+ final List<InputError> unhandledErrors = <InputError>[];
LibraryBuilder coreLibrary;
@@ -85,9 +97,8 @@ abstract class Loader<L> {
uri.scheme == "dart" &&
uri.path.startsWith("_") &&
accessor.uri.scheme != "dart") {
- const String message = "Can't access platform private library.";
- printUnexpected(accessor.fileUri, charOffset, message);
- errors.add(new InputError(accessor.fileUri, charOffset, message));
+ accessor.addCompileTimeError(
+ charOffset, "Can't access platform private library.");
}
return builder;
}
@@ -146,14 +157,20 @@ ${format(ms / libraryCount, 3, 12)} ms/compilation unit.""");
/// Builds all the method bodies found in the given [library].
Future<Null> buildBody(covariant LibraryBuilder library);
- List<InputError> collectCompileTimeErrors() {
- List<InputError> errors = <InputError>[]..addAll(this.errors);
- for (LibraryBuilder library in builders.values) {
- if (library.loader == this) {
- errors.addAll(library.compileTimeErrors);
- }
+ /// Register [message] as a compile-time error.
+ ///
+ /// If [silent] is true, no error is printed as it is assumed the error has
+ /// been previously reported.
+ ///
+ /// If [wasHandled] is true, this error is added to [handledErrors],
+ /// otherwise it is added to [unhandledErrors].
+ void addCompileTimeError(Uri fileUri, int charOffset, Object message,
+ {bool silent: false, bool wasHandled: false}) {
+ if (!silent) {
+ printUnexpected(fileUri, charOffset, message);
}
- return errors;
+ (wasHandled ? handledErrors : unhandledErrors)
+ .add(new InputError(fileUri, charOffset, message));
}
Builder getAbstractClassInstantiationError() {
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/kernel_target.dart ('k') | pkg/front_end/test/fasta/compile.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698