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

Unified Diff: pkg/front_end/lib/src/fasta/kernel/verifier.dart

Issue 2979623002: Use messages for (some) public API errors (Closed)
Patch Set: cl comments Created 3 years, 5 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
Index: pkg/front_end/lib/src/fasta/kernel/verifier.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/verifier.dart b/pkg/front_end/lib/src/fasta/kernel/verifier.dart
index c98e6bc03d7f476857f514e92e19fc0e82f17588..7d4ed01d9b6dfaba797cc7014addba7da276d4a8 100644
--- a/pkg/front_end/lib/src/fasta/kernel/verifier.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/verifier.dart
@@ -24,13 +24,14 @@ import 'package:kernel/verifier.dart' show VerificationError, VerifyingVisitor;
import '../deprecated_problems.dart' show deprecated_printUnexpected;
+import '../fasta_codes.dart';
+
import 'redirecting_factory_body.dart' show RedirectingFactoryBody;
-List<VerificationError> verifyProgram(Program program,
- {bool isOutline: false}) {
+List<LocatedMessage> verifyProgram(Program program, {bool isOutline: false}) {
FastaVerifyingVisitor verifier = new FastaVerifyingVisitor(isOutline);
program.accept(verifier);
- return verifier.errors;
+ return verifier.errors.map(convertError).toList();
}
class FastaVerifyingVisitor extends VerifyingVisitor
@@ -106,3 +107,13 @@ class FastaVerifyingVisitor extends VerifyingVisitor
problem(null, "Unexpected appearance of the unknown type.");
}
}
+
+LocatedMessage convertError(VerificationError error) {
+ var node = error.node ?? error.context;
+ int offset = node?.fileOffset ?? -1;
+ var file = node?.location?.file;
+ Uri uri = file == null ? null : Uri.parse(file);
+ return templateInternalVerificationError
+ .withArguments(error.details)
+ .withLocation(uri, offset);
+}

Powered by Google App Engine
This is Rietveld 408576698