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

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

Issue 2975823002: Remove all deprecated fasta message methods from analyzer. (Closed)
Patch Set: 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
« no previous file with comments | « pkg/front_end/lib/src/fasta/fasta_codes_generated.dart ('k') | pkg/front_end/messages.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/problems.dart
diff --git a/pkg/front_end/lib/src/fasta/problems.dart b/pkg/front_end/lib/src/fasta/problems.dart
new file mode 100644
index 0000000000000000000000000000000000000000..71b21bc1c5f5f58249d2ec22b3a6ad1c61319804
--- /dev/null
+++ b/pkg/front_end/lib/src/fasta/problems.dart
@@ -0,0 +1,50 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library fasta.problems;
+
+import 'messages.dart'
+ show
+ Message,
+ deprecated_format,
+ templateUnexpected,
+ templateUnhandled,
+ templateUnimplemented,
+ templateUnsupported;
+
+/// Used to report an internal error.
+///
+/// Internal errors should be avoided as best as possible, but are preferred
+/// over assertion failures. The message should contain a short description
+/// that may help a developer debug the issue. This method should be called
+/// instead of using `throw`, as this allows us to ensure that there are no
+/// throws anywhere else in the codebase.
+dynamic internalProblem(Message message, int charOffset, Uri uri) {
+ String text = "Internal problem: ${message.message}";
+ if (uri == null && charOffset == -1) {
+ throw text;
+ } else {
+ throw deprecated_format(uri, charOffset, text);
+ }
+}
+
+dynamic unimplemented(String what, int charOffset, Uri uri) {
+ return internalProblem(
+ templateUnimplemented.withArguments(what), charOffset, uri);
+}
+
+dynamic unhandled(String what, String where, int charOffset, Uri uri) {
+ return internalProblem(
+ templateUnhandled.withArguments(what, where), charOffset, uri);
+}
+
+dynamic unexpected(String expected, String actual, int charOffset, Uri uri) {
+ return internalProblem(
+ templateUnexpected.withArguments(expected, actual), charOffset, uri);
+}
+
+dynamic unsupported(String operation, int charOffset, Uri uri) {
+ return internalProblem(
+ templateUnsupported.withArguments(operation), charOffset, uri);
+}
« no previous file with comments | « pkg/front_end/lib/src/fasta/fasta_codes_generated.dart ('k') | pkg/front_end/messages.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698