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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/warnings.dart

Issue 675113002: Support async/await in the dart2js frontend. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update unittests Created 6 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart2js; 5 part of dart2js;
6 6
7 const DONT_KNOW_HOW_TO_FIX = ""; 7 const DONT_KNOW_HOW_TO_FIX = "";
8 8
9 /** 9 /**
10 * The messages in this file should meet the following guide lines: 10 * The messages in this file should meet the following guide lines:
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 /** 75 /**
76 * Examples will be checked by 76 * Examples will be checked by
77 * tests/compiler/dart2js/message_kind_test.dart. 77 * tests/compiler/dart2js/message_kind_test.dart.
78 * 78 *
79 * An example is either a String containing the example source code or a Map 79 * An example is either a String containing the example source code or a Map
80 * from filenames to source code. In the latter case, the filename for the 80 * from filenames to source code. In the latter case, the filename for the
81 * main library code must be 'main.dart'. 81 * main library code must be 'main.dart'.
82 */ 82 */
83 final List examples; 83 final List examples;
84 84
85 const MessageKind(this.template, {this.howToFix, this.examples}); 85 /// Additional options needed for the examples to work.
86 final List<String> options;
87
88 const MessageKind(this.template,
89 {this.howToFix,
90 this.examples,
91 this.options: const <String>[]});
86 92
87 /// Do not use this. It is here for legacy and debugging. It violates item 4 93 /// Do not use this. It is here for legacy and debugging. It violates item 4
88 /// above. 94 /// above.
89 static const MessageKind GENERIC = const MessageKind('#{text}'); 95 static const MessageKind GENERIC = const MessageKind('#{text}');
90 96
91 static const MessageKind NOT_ASSIGNABLE = const MessageKind( 97 static const MessageKind NOT_ASSIGNABLE = const MessageKind(
92 "'#{fromType}' is not assignable to '#{toType}'."); 98 "'#{fromType}' is not assignable to '#{toType}'.");
93 99
94 static const MessageKind VOID_EXPRESSION = const MessageKind( 100 static const MessageKind VOID_EXPRESSION = const MessageKind(
95 "Expression does not yield a value."); 101 "Expression does not yield a value.");
(...skipping 1873 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 "#{warnings} warning(s) suppressed in #{uri}."); 1975 "#{warnings} warning(s) suppressed in #{uri}.");
1970 1976
1971 static const MessageKind HIDDEN_HINTS = const MessageKind( 1977 static const MessageKind HIDDEN_HINTS = const MessageKind(
1972 "#{hints} hint(s) suppressed in #{uri}."); 1978 "#{hints} hint(s) suppressed in #{uri}.");
1973 1979
1974 static const MessageKind PREAMBLE = const MessageKind( 1980 static const MessageKind PREAMBLE = const MessageKind(
1975 "When run on the command-line, the compiled output might" 1981 "When run on the command-line, the compiled output might"
1976 " require a preamble file located in:\n" 1982 " require a preamble file located in:\n"
1977 " <sdk>/lib/_internal/compiler/js_lib/preambles."); 1983 " <sdk>/lib/_internal/compiler/js_lib/preambles.");
1978 1984
1985
1986 static const MessageKind EXPERIMENTAL_ASYNC_AWAIT = const MessageKind(
1987 "Experimental language feature 'async/await' is not supported.");
1988
1989 static const MessageKind INVALID_STARRED_KEYWORD = const MessageKind(
1990 "Invalid '#{keyword}' keyword.",
1991 options: const ['--enable-async'],
1992 howToFix: "Try removing whitespace between '#{keyword}' and '*'.",
1993 examples: const [
1994 "main() async * {}",
1995 "main() sync * {}",
1996 "main() async* { yield * 0; }"
1997 ]);
1998
1999 static const MessageKind INVALID_SYNC_MODIFIER = const MessageKind(
2000 "Invalid modifier 'sync'.",
2001 options: const ['--enable-async'],
2002 howToFix: "Try replacing 'sync' with 'sync*'.",
2003 examples: const [
2004 "main() sync {}"
2005 ]);
2006
2007 static const MessageKind INVALID_AWAIT_FOR = const MessageKind(
2008 "'await' is only supported on for-in loops.",
2009 options: const ['--enable-async'],
2010 howToFix: "Try rewriting the loop as a for-in loop or removing the "
2011 "'await' keyword.",
2012 examples: const ["""
2013 main() async* {
2014 await for (int i = 0; i < 10; i++) {}
2015 }
2016 """]);
2017
2018 static const MessageKind ASYNC_MODIFIER_ON_ABSTRACT_METHOD =
2019 const MessageKind(
2020 "The modifier '#{modifier}' is not allowed on an abstract method.",
2021 options: const ['--enable-async'],
2022 howToFix: "Try removing the '#{modifier}' modifier or adding a "
2023 "body to the method.",
2024 examples: const ["""
2025 abstract class A {
2026 method() async;
2027 }
2028 class B extends A {
2029 method() {}
2030 }
2031 main() {
2032 A a = new B();
2033 a.method();
2034 }
2035 """]);
2036
2037 static const MessageKind ASYNC_MODIFIER_ON_CONSTRUCTOR =
2038 const MessageKind(
2039 "The modifier '#{modifier}' is not allowed on constructors.",
2040 options: const ['--enable-async'],
2041 howToFix: "Try removing the '#{modifier}' modifier.",
2042 examples: const ["""
2043 class A {
2044 A() async;
2045 }
2046 main() => new A();""",
2047
2048 """
2049 class A {
2050 A();
2051 factory A.a() async* => new A();
2052 }
2053 main() => new A.a();"""]);
2054
2055 static const MessageKind YIELDING_MODIFIER_ON_ARROW_BODY =
2056 const MessageKind(
2057 "The modifier '#{modifier}' is not allowed on methods implemented "
2058 "using '=>'.",
2059 options: const ['--enable-async'],
2060 howToFix: "Try removing the '#{modifier}' modifier or implementing "
2061 "the method body using a block: '{ ... }'.",
2062 examples: const ["main() sync* => null;", "main() async* => null;"]);
2063
2064 // TODO(johnniwinther): Check for 'async' as identifier.
2065 static const MessageKind ASYNC_KEYWORD_AS_IDENTIFIER = const MessageKind(
2066 "'#{keyword}' cannot be used as an identifier in a function body marked "
2067 "with '#{modifier}'.",
2068 options: const ['--enable-async'],
2069 howToFix: "Try removing the '#{modifier}' modifier or renaming the "
2070 "identifier.",
2071 examples: const ["""
2072 main() async {
2073 var await;
2074 }""",
2075 """
2076 main() async* {
2077 var yield;
2078 }""",
2079 """
2080 main() sync* {
2081 var yield;
2082 }"""]);
2083
1979 ////////////////////////////////////////////////////////////////////////////// 2084 //////////////////////////////////////////////////////////////////////////////
1980 // Patch errors start. 2085 // Patch errors start.
1981 ////////////////////////////////////////////////////////////////////////////// 2086 //////////////////////////////////////////////////////////////////////////////
1982 2087
1983 static const MessageKind PATCH_RETURN_TYPE_MISMATCH = const MessageKind( 2088 static const MessageKind PATCH_RETURN_TYPE_MISMATCH = const MessageKind(
1984 "Patch return type '#{patchReturnType}' does not match " 2089 "Patch return type '#{patchReturnType}' does not match "
1985 "'#{originReturnType}' on origin method '#{methodName}'."); 2090 "'#{originReturnType}' on origin method '#{methodName}'.");
1986 2091
1987 static const MessageKind PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH = 2092 static const MessageKind PATCH_REQUIRED_PARAMETER_COUNT_MISMATCH =
1988 const MessageKind( 2093 const MessageKind(
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2129 static String convertToString(value) { 2234 static String convertToString(value) {
2130 if (value is ErrorToken) { 2235 if (value is ErrorToken) {
2131 // Shouldn't happen. 2236 // Shouldn't happen.
2132 return value.assertionMessage; 2237 return value.assertionMessage;
2133 } else if (value is Token) { 2238 } else if (value is Token) {
2134 value = value.value; 2239 value = value.value;
2135 } 2240 }
2136 return '$value'; 2241 return '$value';
2137 } 2242 }
2138 } 2243 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698