Remove pkg/dart_messages

Not used

Fixes https://github.com/dart-lang/sdk/issues/27832

Change-Id: Ia1e00fc8be2c904f21a95e89640099fa900a15a5
Reviewed-on: https://dart-review.googlesource.com/74461
Reviewed-by: Peter von der Ahé <ahe@google.com>
This commit is contained in:
Kevin Moore 2018-09-11 16:20:06 +00:00
parent d35c18999f
commit 0f1fa9eeae
10 changed files with 0 additions and 1904 deletions

View file

@ -30,7 +30,6 @@ csslib:third_party/pkg/csslib/lib
dart2js_info:third_party/pkg/dart2js_info/lib
dart2js_tools:pkg/dart2js_tools/lib
dart_internal:pkg/dart_internal/lib
dart_messages:pkg/dart_messages/lib
dart_style:third_party/pkg_tested/dart_style/lib
dartdoc:third_party/pkg/dartdoc/lib
dev_compiler:pkg/dev_compiler/lib

View file

@ -1,2 +0,0 @@
analyzer:
strong-mode: true

View file

@ -1,35 +0,0 @@
// Copyright (c) 2015, 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.
import 'dart:math' as math;
import 'package:dart_messages/shared_messages.dart' as shared_messages;
math.Random random = new math.Random();
const idLength = 6;
final $A = "A".codeUnitAt(0);
final $Z = "Z".codeUnitAt(0);
String computeId() {
List<int> charCodes = [];
for (int i = 0; i < idLength; i++) {
charCodes.add($A + random.nextInt($Z - $A));
}
return new String.fromCharCodes(charCodes);
}
/// Computes a random message ID that hasn't been used before.
void main() {
var usedIds =
shared_messages.MESSAGES.values.map((entry) => entry.id).toSet();
print("${usedIds.length} existing ids");
var newId;
do {
newId = computeId();
} while (usedIds.contains(newId));
print("Available id: $newId");
}

View file

@ -1,251 +0,0 @@
// Copyright (c) 2015, 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.
import 'dart:convert';
import 'dart:io' as io;
import 'package:dart_messages/shared_messages.dart';
const String jsonPath = '../lib/generated/shared_messages.json';
const String dart2jsPath =
'../../compiler/lib/src/diagnostics/generated/shared_messages.dart';
const String analyzerPath =
'../../analyzer/lib/src/generated/generated/shared_messages.dart';
final String dontEditWarning = """
/*
DON'T EDIT. GENERATED. DON'T EDIT.
This file has been generated by 'publish.dart' in the dart_messages package.
Messages are maintained in `lib/shared_messages.dart` of that same package.
After any change to that file, run `bin/publish.dart` to generate a new version
of the json, dart2js and analyzer representations.
*/""";
const String copyrightHeader = '''
// Copyright (c) 2015, 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.''';
void markAsReadonly(String path) {
// TODO(15078): mark as read-only. Currently not possible:
// http://dartbug.com/15078.
}
void emitJson() {
var input = MESSAGES;
var outPath = io.Platform.script.resolve(jsonPath).toFilePath();
print("Emitting JSON:");
print(" Input: ${input.length} entries");
print(" Output: $outPath");
new io.File(outPath).writeAsStringSync(messagesAsJson);
print("Emitting JSON done.");
}
/// Escapes the given string [str].
///
/// The parameter [str] may be `null` in which case the result is "null".
String escapeString(String str) {
return jsonEncode(str);
}
/// Emits the messages in dart2js format.
///
/// The dart2js-format consists of two entities:
/// 1. the `MessageKind` enum, and
/// 2. the MessageKind-to-Template map `TEMPLATES`.
///
/// The template is an instance of MessageTemplate:
///
/// const MessageTemplate(
/// this.kind,
/// this.template,
/// {this.howToFix,
/// this.examples,
/// this.options: const <String>[]});
///
/// A sample output thus looks as follows:
///
/// enum MessageKind {
/// EXAMPLE_MESSAGE,
/// }
///
/// const Map<MessageKind, MessageTemplate> {
/// EXAMPLE_MESSAGE: const MessageTemplate(
/// EXAMPLE_MESSAGE,
/// "Don't use #foo with #bar",
/// howToFix: "Just don't do it",
/// options: const ['--some-flag']),
/// examples: const ['''
/// some example with bad code;'''],
/// };
void emitDart2js() {
var input = MESSAGES;
var outPath = io.Platform.script.resolve(dart2jsPath).toFilePath();
print("Emitting dart2js:");
print(" Input: ${input.length} entries");
print(" Output: $outPath");
StringBuffer out = new StringBuffer();
out.writeln(copyrightHeader);
out.writeln(dontEditWarning);
out.writeln("import '../messages.dart' show MessageKind, MessageTemplate;");
out.writeln();
out.writeln("const Map<MessageKind, MessageTemplate> TEMPLATES = "
"const <MessageKind, MessageTemplate>{ ");
input.forEach((name, message) {
if (!message.usedBy.contains(Platform.dart2js)) return;
out.writeln(" MessageKind.$name: const MessageTemplate(");
// TODO(floitsch): include id.
out.writeln(" MessageKind.$name,");
out.write(" ");
out.write(escapeString(message.template));
if (message.howToFix != null) {
out.write(",\n howToFix: ${escapeString(message.howToFix)}");
}
if (message.options != null) {
out.write(",\n options: const [");
out.write(message.options.map(escapeString).join(","));
out.writeln("]");
}
if (message.examples != null) {
out.writeln(",\n examples: const [");
String escapeExampleContent(String content) {
if (content.contains("\n") || content.contains('"')) {
return 'r"""\n$content"""';
} else if (content.contains("\\")) {
return 'r"$content"';
}
return '"$content"';
}
for (var example in message.examples) {
if (example is String) {
out.write(" ");
out.write(escapeExampleContent(example));
} else if (example is Map) {
out.writeln(" const {");
example.forEach((fileName, content) {
out.writeln(" '$fileName': ");
out.write(escapeExampleContent(content));
out.writeln(",");
});
out.write(" }");
}
out.writeln(",");
}
out.writeln(" ]");
}
out.writeln(" ), // Generated. Don't edit.");
});
out.writeln("};");
new io.File(outPath).writeAsStringSync(out.toString());
print("Emitting dart2js done.");
}
String convertToAnalyzerTemplate(String template, holeOrder) {
var holeMap;
if (holeOrder != null) {
holeMap = {};
for (int i = 0; i < holeOrder.length; i++) {
holeMap[holeOrder[i]] = i;
}
}
int seenHoles = 0;
return template.replaceAllMapped(new RegExp(r"#\w+|#{\w+}"), (Match match) {
if (holeMap != null) {
String matchedString = match[0];
String holeName = matchedString.startsWith("#{")
? matchedString.substring(2, matchedString.length - 1)
: matchedString.substring(1);
int index = holeMap[holeName];
if (index == null) {
throw "Couldn't find hole-position for $holeName $holeMap";
}
return "{$index}";
} else {
return "{${seenHoles++}}";
}
});
}
String camlToAllCaps(String input) {
StringBuffer out = new StringBuffer();
for (int i = 0; i < input.length; i++) {
String c = input[i];
if (c.toUpperCase() == c) {
out.write("_$c");
} else {
out.write(c.toUpperCase());
}
}
return out.toString();
}
/// Emits the messages in analyzer format.
///
/// Messages are encoded as instances of `ErrorCode` classes where the
/// corresponding class is given by the `category` field of the Message.
///
/// All instances are stored as top-level const variables.
///
/// A sample output looks as follows:
///
/// const FooCategoryErrorCode EXAMPLE_MESSAGE = const FooCategoryErrorCode(
/// "EXAMPLE_MESSAGE",
/// "Don't use {0} with {1}",
/// "Just don't do it");
void emitAnalyzer() {
var input = MESSAGES;
var outPath = io.Platform.script.resolve(analyzerPath).toFilePath();
print("Emitting analyzer:");
print(" Input: ${input.length} entries");
print(" Output: $outPath");
StringBuffer out = new StringBuffer();
out.writeln(copyrightHeader);
out.writeln(dontEditWarning);
out.writeln("import 'package:analyzer/src/generated/error.dart';");
out.writeln("import 'package:analyzer/src/generated/parser.dart' "
"show ParserErrorCode;");
input.forEach((name, message) {
if (!message.usedBy.contains(Platform.analyzer)) return;
List<Category> categories = message.categories;
bool hasMultipleCategories = categories.length != 1;
for (Category category in categories) {
String className = category.name + "Code";
String analyzerName =
hasMultipleCategories ? "$name${camlToAllCaps(category.name)}" : name;
out.writeln();
out.writeln("const $className $analyzerName = const $className(");
out.writeln(" '$name',");
String template = message.template;
List holeOrder = message.templateHoleOrder;
String analyzerTemplate = convertToAnalyzerTemplate(template, holeOrder);
out.write(" ");
out.write(escapeString(analyzerTemplate));
out.write(",\n ");
out.write(escapeString(message.howToFix));
out.writeln("); // Generated. Don't edit.");
}
});
new io.File(outPath).writeAsStringSync(out.toString());
print("Emitting analyzer done.");
}
/// Translates the shared messages in `../lib/shared_messages.dart` to JSON,
/// dart2js, and analyzer formats.
///
/// Emits the json-output to [jsonPath], the dart2js-output to [dart2jsPath],
/// and the analyzer-output to [analyzerPath].
void main() {
emitJson();
emitDart2js();
emitAnalyzer();
}

View file

@ -1,687 +0,0 @@
{
"exampleMessage": {
"id": "use an Id generated by bin/message_id.dart",
"subId": 0,
"categories": [
"AnalysisOptionsError"
],
"template": "#use #named #arguments",
"templateHoleOrder": [
"arguments",
"named",
"use"
],
"howToFix": "an explanation on how to fix things",
"options": null,
"usedBy": [],
"examples": [
" Some multiline example;\n That generates the bug.",
{
"fileA.dart": " or a map from file to content.\n again multiline",
"fileB.dart": " with possibly multiple files.\n muliline too"
}
]
},
"CONST_CONSTRUCTOR_WITH_BODY": {
"id": "LGJGHW",
"subId": 0,
"categories": [
"ParserError"
],
"template": "Const constructor can't have a body.",
"templateHoleOrder": null,
"howToFix": "Try removing the 'const' keyword or the body.",
"options": null,
"usedBy": [
"Platform.analyzer",
"Platform.dart2js"
],
"examples": [
" class C {\n const C() {}\n }\n\n main() => new C();"
]
},
"CONST_FACTORY": {
"id": "LGJGHW",
"subId": 1,
"categories": [
"ParserError"
],
"template": "Only redirecting factory constructors can be declared to be 'const'.",
"templateHoleOrder": null,
"howToFix": "Try removing the 'const' keyword or replacing the body with '=' followed by a valid target.",
"options": null,
"usedBy": [
"Platform.analyzer",
"Platform.dart2js"
],
"examples": [
" class C {\n const factory C() {}\n }\n\n main() => new C();"
]
},
"EXTRANEOUS_MODIFIER": {
"id": "GRKIQE",
"subId": 0,
"categories": [
"ParserError"
],
"template": "Can't have modifier '#{modifier}' here.",
"templateHoleOrder": null,
"howToFix": "Try removing '#{modifier}'.",
"options": null,
"usedBy": [
"Platform.dart2js"
],
"examples": [
"var String foo; main(){}",
"var set foo; main(){}",
"var final foo; main(){}",
"var var foo; main(){}",
"var const foo; main(){}",
"var abstract foo; main(){}",
"var static foo; main(){}",
"var external foo; main(){}",
"final var foo; main(){}",
"var var foo; main(){}",
"const var foo; main(){}",
"abstract var foo; main(){}",
"static var foo; main(){}",
"external var foo; main(){}"
]
},
"EXTRANEOUS_MODIFIER_REPLACE": {
"id": "GRKIQE",
"subId": 1,
"categories": [
"ParserError"
],
"template": "Can't have modifier '#{modifier}' here.",
"templateHoleOrder": null,
"howToFix": "Try replacing modifier '#{modifier}' with 'var', 'final', or a type.",
"options": null,
"usedBy": [
"Platform.dart2js"
],
"examples": [
"set foo; main(){}",
"abstract foo; main(){}",
"static foo; main(){}",
"external foo; main(){}"
]
},
"CONST_CLASS": {
"id": "GRKIQE",
"subId": 2,
"categories": [
"ParserError"
],
"template": "Classes can't be declared to be 'const'.",
"templateHoleOrder": null,
"howToFix": "Try removing the 'const' keyword or moving to the class' constructor(s).",
"options": null,
"usedBy": [
"Platform.analyzer"
],
"examples": [
" const class C {}\n\n main() => new C();\n "
]
},
"CONST_METHOD": {
"id": "GRKIQE",
"subId": 3,
"categories": [
"ParserError"
],
"template": "Getters, setters and methods can't be declared to be 'const'.",
"templateHoleOrder": null,
"howToFix": "Try removing the 'const' keyword.",
"options": null,
"usedBy": [
"Platform.analyzer"
],
"examples": [
"const int foo() => 499; main() {}",
"const int get foo => 499; main() {}",
"const set foo(v) => 499; main() {}",
"class A { const int foo() => 499; } main() { new A(); }",
"class A { const int get foo => 499; } main() { new A(); }",
"class A { const set foo(v) => 499; } main() { new A(); }"
]
},
"CONST_ENUM": {
"id": "GRKIQE",
"subId": 4,
"categories": [
"ParserError"
],
"template": "Enums can't be declared to be 'const'.",
"templateHoleOrder": null,
"howToFix": "Try removing the 'const' keyword.",
"options": null,
"usedBy": [
"Platform.analyzer"
],
"examples": [
"const enum Foo { x } main() {}"
]
},
"CONST_TYPEDEF": {
"id": "GRKIQE",
"subId": 5,
"categories": [
"ParserError"
],
"template": "Type aliases can't be declared to be 'const'.",
"templateHoleOrder": null,
"howToFix": "Try removing the 'const' keyword.",
"options": null,
"usedBy": [
"Platform.analyzer"
],
"examples": [
"const typedef void Foo(); main() {}"
]
},
"CONST_AND_FINAL": {
"id": "GRKIQE",
"subId": 6,
"categories": [
"ParserError"
],
"template": "Members can't be declared to be both 'const' and 'final'.",
"templateHoleOrder": null,
"howToFix": "Try removing either the 'const' or 'final' keyword.",
"options": null,
"usedBy": [
"Platform.analyzer"
],
"examples": [
"final const int x = 499; main() {}",
"const final int x = 499; main() {}",
"class A { static final const int x = 499; } main() {}",
"class A { static const final int x = 499; } main() {}"
]
},
"CONST_AND_VAR": {
"id": "GRKIQE",
"subId": 7,
"categories": [
"ParserError"
],
"template": "Members can't be declared to be both 'const' and 'var'.",
"templateHoleOrder": null,
"howToFix": "Try removing either the 'const' or 'var' keyword.",
"options": null,
"usedBy": [
"Platform.analyzer"
],
"examples": [
"var const x = 499; main() {}",
"const var x = 499; main() {}",
"class A { var const x = 499; } main() {}",
"class A { const var x = 499; } main() {}"
]
},
"CLASS_IN_CLASS": {
"id": "DOTHQH",
"subId": 0,
"categories": [
"ParserError"
],
"template": "Classes can't be declared inside other classes.",
"templateHoleOrder": null,
"howToFix": "Try moving the class to the top-level.",
"options": null,
"usedBy": [
"Platform.analyzer"
],
"examples": [
"class A { class B {} } main() { new A(); }"
]
},
"CONSTRUCTOR_WITH_RETURN_TYPE": {
"id": "VOJBWY",
"subId": 0,
"categories": [
"ParserError"
],
"template": "Constructors can't have a return type.",
"templateHoleOrder": null,
"howToFix": "Try removing the return type.",
"options": null,
"usedBy": [
"Platform.analyzer",
"Platform.dart2js"
],
"examples": [
"class A { int A() {} } main() { new A(); }"
]
},
"MISSING_EXPRESSION_IN_THROW": {
"id": "FTGGMJ",
"subId": 0,
"categories": [
"ParserError"
],
"template": "Missing expression after 'throw'.",
"templateHoleOrder": null,
"howToFix": "Did you mean 'rethrow'?",
"options": null,
"usedBy": [
"Platform.analyzer",
"Platform.dart2js"
],
"examples": [
"main() { throw; }",
"main() { try { throw 0; } catch(e) { throw; } }"
]
},
"RETHROW_OUTSIDE_CATCH": {
"id": "MWETLC",
"subId": 0,
"categories": [
"CompileTimeError"
],
"template": "Rethrow must be inside of catch clause.",
"templateHoleOrder": null,
"howToFix": "Try moving the expression into a catch clause, or using a 'throw' expression.",
"options": null,
"usedBy": [
"Platform.analyzer",
"Platform.dart2js"
],
"examples": [
"main() { rethrow; }"
]
},
"RETURN_IN_GENERATIVE_CONSTRUCTOR": {
"id": "UOTDQH",
"subId": 0,
"categories": [
"CompileTimeError"
],
"template": "Constructors can't return values.",
"templateHoleOrder": null,
"howToFix": "Try removing the return statement or using a factory constructor.",
"options": null,
"usedBy": [
"Platform.analyzer",
"Platform.dart2js"
],
"examples": [
" class C {\n C() {\n return 1;\n }\n }\n\n main() => new C();"
]
},
"RETURN_IN_GENERATOR": {
"id": "JRUTUQ",
"subId": 0,
"categories": [
"CompileTimeError"
],
"template": "Can't return a value from a generator function (using the '#{modifier}' modifier).",
"templateHoleOrder": null,
"howToFix": "Try removing the value, replacing 'return' with 'yield' or changing the method body modifier.",
"options": null,
"usedBy": [
"Platform.analyzer",
"Platform.dart2js"
],
"examples": [
" foo() async* { return 0; }\n main() => foo();\n ",
" foo() sync* { return 0; }\n main() => foo();\n "
]
},
"NOT_ASSIGNABLE": {
"id": "FYQYXB",
"subId": 0,
"categories": [
"StaticTypeWarning"
],
"template": "'#{fromType}' is not assignable to '#{toType}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.dart2js"
],
"examples": null
},
"FORIN_NOT_ASSIGNABLE": {
"id": "FYQYXB",
"subId": 1,
"categories": [
"Hint"
],
"template": "The element type '#{currentType}' of '#{expressionType}' is not assignable to '#{elementType}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.dart2js"
],
"examples": [
" main() {\n List<int> list = <int>[1, 2];\n for (String x in list) x;\n }\n "
]
},
"RETURN_OF_INVALID_TYPE": {
"id": "FYQYXB",
"subId": 2,
"categories": [
"StaticTypeWarning"
],
"template": "The return type '#{fromType}' is not a '#{toType}', as defined by the method '#{method}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.analyzer"
],
"examples": [
"int foo() => 'foo'; main() { foo(); }"
]
},
"ARGUMENT_TYPE_NOT_ASSIGNABLE": {
"id": "FYQYXB",
"subId": 3,
"categories": [
"Hint",
"StaticWarning"
],
"template": "The argument type '#{fromType}' cannot be assigned to the parameter type '#{toType}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.analyzer"
],
"examples": [
"foo(int x) => x; main() { foo('bar'); }"
]
},
"CANNOT_RESOLVE": {
"id": "ERUSKD",
"subId": 0,
"categories": [
"StaticTypeWarning"
],
"template": "Can't resolve '#{name}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.dart2js"
],
"examples": null
},
"UNDEFINED_METHOD": {
"id": "ERUSKD",
"subId": 1,
"categories": [
"StaticTypeWarning",
"Hint"
],
"template": "The method '#{memberName}' is not defined for the class '#{className}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.dart2js",
"Platform.analyzer"
],
"examples": [
" class A {\n foo() { bar(); }\n }\n main() { new A().foo(); }\n "
]
},
"UNDEFINED_METHOD_WITH_CONSTRUCTOR": {
"id": "ERUSKD",
"subId": 2,
"categories": [
"StaticTypeWarning"
],
"template": "The method '#{memberName}' is not defined for the class '#{className}', but a constructor with that name is defined.",
"templateHoleOrder": null,
"howToFix": "Try adding 'new' or 'const' to invoke the constructor, or change the method name.",
"options": null,
"usedBy": [
"Platform.analyzer"
],
"examples": [
" class A {\n A.bar() {}\n }\n main() { A.bar(); }\n "
]
},
"UNDEFINED_GETTER": {
"id": "ERUSKD",
"subId": 3,
"categories": [
"StaticTypeWarning",
"StaticWarning",
"Hint"
],
"template": "The getter '#{memberName}' is not defined for the class '#{className}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.dart2js",
"Platform.analyzer"
],
"examples": [
"class A {} main() { new A().x; }",
"class A {} main() { A.x; }"
]
},
"UNDEFINED_ENUM_CONSTANT": {
"id": "ERUSKD",
"subId": 4,
"categories": [
"StaticTypeWarning"
],
"template": "There is no constant named '#{memberName}' in '#{className}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.analyzer"
],
"examples": [
" enum E { ONE }\n E e() { return E.TWO; }\n main() { e(); }\n "
]
},
"UNDEFINED_INSTANCE_GETTER_BUT_SETTER": {
"id": "ERUSKD",
"subId": 5,
"categories": [
"StaticTypeWarning"
],
"template": "The setter '#{memberName}' in class '#{className}' can not be used as a getter.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.dart2js"
],
"examples": [
"class A { set x(y) {} } main() { new A().x; }"
]
},
"UNDEFINED_OPERATOR": {
"id": "ERUSKD",
"subId": 6,
"categories": [
"StaticTypeWarning",
"Hint"
],
"template": "The operator '#{memberName}' is not defined for the class '#{className}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.dart2js",
"Platform.analyzer"
],
"examples": [
"class A {} main() { new A() + 3; }"
]
},
"UNDEFINED_SETTER": {
"id": "ERUSKD",
"subId": 7,
"categories": [
"StaticTypeWarning",
"StaticWarning",
"Hint"
],
"template": "The setter '#{memberName}' is not defined for the class '#{className}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.dart2js",
"Platform.analyzer"
],
"examples": [
"class A {} main() { new A().x = 499; }"
]
},
"NO_SUCH_SUPER_MEMBER": {
"id": "ERUSKD",
"subId": 8,
"categories": [
"StaticTypeWarning"
],
"template": "Can't resolve '#{memberName}' in a superclass of '#{className}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.dart2js"
],
"examples": null
},
"UNDEFINED_SUPER_GETTER": {
"id": "ERUSKD",
"subId": 9,
"categories": [
"StaticTypeWarning",
"StaticWarning"
],
"template": "The getter '#{memberName}' is not defined in a superclass of '#{className}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.analyzer"
],
"examples": [
" class A {}\n class B extends A {\n foo() => super.x;\n }\n main() { new B().foo(); }\n "
]
},
"UNDEFINED_SUPER_METHOD": {
"id": "ERUSKD",
"subId": 10,
"categories": [
"StaticTypeWarning"
],
"template": "The method '#{memberName}' is not defined in a superclass of '#{className}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.analyzer"
],
"examples": [
" class A {}\n class B extends A {\n foo() => super.x();\n }\n main() { new B().foo(); }\n "
]
},
"UNDEFINED_SUPER_OPERATOR": {
"id": "ERUSKD",
"subId": 11,
"categories": [
"StaticTypeWarning"
],
"template": "The operator '#{memberName}' is not defined in a superclass of '#{className}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.analyzer"
],
"examples": [
" class A {}\n class B extends A {\n foo() => super + 499;\n }\n main() { new B().foo(); }\n "
]
},
"UNDEFINED_SUPER_SETTER": {
"id": "ERUSKD",
"subId": 12,
"categories": [
"StaticTypeWarning",
"StaticWarning"
],
"template": "The setter '#{memberName}' is not defined in a superclass of '#{className}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.analyzer",
"Platform.dart2js"
],
"examples": [
" class A {}\n class B extends A {\n foo() { super.x = 499; }\n }\n main() { new B().foo(); }\n "
]
},
"UNDEFINED_FUNCTION": {
"id": "ERUSKD",
"subId": 13,
"categories": [
"StaticTypeWarning"
],
"template": "The function '#{memberName}' is not defined.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.analyzer"
],
"examples": [
"main() { foo(); }"
]
},
"UNDEFINED_STATIC_GETTER_BUT_SETTER": {
"id": "ERUSKD",
"subId": 14,
"categories": [
"StaticTypeWarning"
],
"template": "Cannot resolve getter '#{name}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.dart2js"
],
"examples": [
"set foo(x) {} main() { foo; }"
]
},
"UNDEFINED_STATIC_SETTER_BUT_GETTER": {
"id": "ERUSKD",
"subId": 15,
"categories": [
"StaticTypeWarning"
],
"template": "Cannot resolve setter '#{name}'.",
"templateHoleOrder": null,
"howToFix": null,
"options": null,
"usedBy": [
"Platform.dart2js"
],
"examples": [
" main() {\n final x = 1;\n x = 2;\n }",
" main() {\n const x = 1;\n x = 2;\n }\n ",
" final x = 1;\n main() { x = 3; }\n ",
" const x = 1;\n main() { x = 3; }\n ",
"get foo => null main() { foo = 5; }",
"const foo = 0 main() { foo = 5; }"
]
}
}

View file

@ -1,860 +0,0 @@
// Copyright (c) 2015, 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.
/// An update to this file must be followed by regenerating the corresponding
/// json, dart2js and analyzer file. Use `publish.dart` in the bin directory.
///
/// Every message in this file must have an id. Use `message_id.dart` in the
/// bin directory to generate a fresh one.
///
/// The messages in this file should follow the [Guide for Writing
/// Diagnostics](../../front_end/lib/src/fasta/diagnostics.md).
import 'dart:convert';
/// Encodes the category of the message.
///
/// This is currently only used in the analyzer.
// TODO(floitsch): encode severity and type in the category, so we can generate
// the corresponding ErrorCode subclasses.
class Category {
static final analysisOptionsError = new Category("AnalysisOptionsError");
static final analysisOptionsWarning = new Category("AnalysisOptionsWarning");
static final checkedModeCompileTimeError =
new Category("CheckedModeCompileTimeError");
static final parserError = new Category("ParserError");
static final compileTimeError = new Category("CompileTimeError");
static final staticTypeWarning = new Category("StaticTypeWarning");
static final staticWarning = new Category("StaticWarning");
static final hint = new Category("Hint");
final String name;
Category(this.name);
}
enum Platform {
dart2js,
analyzer,
}
const dart2js = Platform.dart2js;
const analyzer = Platform.analyzer;
class Message {
/// Generic id for this message.
///
/// This id should be shared by all errors that fall into the same category.
/// In particular, we want errors of the same category to share the same
/// explanation page, and want to disable warnings of the same category
/// with just one line.
final String id;
/// The sub-id of the error.
///
/// This id just needs to be unique within the same [id].
final int subId;
/// The error of which this message is a specialization.
///
/// For example, "Const is not allowed on getters" may be a specialization of
/// "The 'const' keyword is not allowed here".
///
/// Examples of the specialized message, should trigger for the more generic
/// message, when the platform doesn't support the more specialized message.
///
/// Specializations must have the same error-id (but not sub-id) as the more
/// generic message.
final String specializationOf;
/// The categories of this message.
///
/// The same message can be used in multiple categories, for example, as
/// hint and warning.
final List<Category> categories;
final String template;
// The analyzer fills holes positionally (and not named). The following field
// overrides the order of the holes.
// For example the template "The argument #field in #cls is bad", could have
// the order `["cls", "field"]', which means that the analyzer would first
// provide the class `cls` and then only `field`.
// This list is generally `null`, but when it is provided it must contain all
// holes.
final List<String> templateHoleOrder;
final String howToFix;
final List<String> options;
final List examples;
final List<Platform> usedBy;
Message(
{this.id,
this.subId: 0,
this.specializationOf: null,
this.categories,
this.template,
this.templateHoleOrder,
this.howToFix,
this.options,
this.usedBy: const [],
this.examples});
}
String get messagesAsJson {
var jsonified = {};
MESSAGES.forEach((String name, Message message) {
jsonified[name] = {
'id': message.id,
'subId': message.subId,
'categories':
message.categories.map((category) => category.name).toList(),
'template': message.template,
'templateHoleOrder': message.templateHoleOrder,
'howToFix': message.howToFix,
'options': message.options,
'usedBy': message.usedBy.map((platform) => platform.toString()).toList(),
'examples': message.examples,
};
});
return new JsonEncoder.withIndent(' ').convert(jsonified);
}
final Map<String, Message> MESSAGES = {
'exampleMessage': new Message(
id: 'use an Id generated by bin/message_id.dart',
categories: [Category.analysisOptionsError],
template: "#use #named #arguments",
templateHoleOrder: ["arguments", "named", "use"],
howToFix: "an explanation on how to fix things",
examples: [
r'''
Some multiline example;
That generates the bug.''',
{
'fileA.dart': '''
or a map from file to content.
again multiline''',
'fileB.dart': '''
with possibly multiple files.
muliline too'''
}
]),
// Const constructors may not have a body.
'CONST_CONSTRUCTOR_WITH_BODY': new Message(
id: 'LGJGHW',
subId: 0,
categories: [Category.parserError],
template: "Const constructor can't have a body.",
howToFix: "Try removing the 'const' keyword or the body.",
usedBy: [analyzer, dart2js],
examples: const [
r"""
class C {
const C() {}
}
main() => new C();"""
]),
// Const constructor factories may only redirect (and must not have a body).
'CONST_FACTORY': new Message(
id: 'LGJGHW',
subId: 1,
categories: [Category.parserError],
template: "Only redirecting factory constructors can be declared to "
"be 'const'.",
howToFix: "Try removing the 'const' keyword or replacing the body with "
"'=' followed by a valid target.",
usedBy: [analyzer, dart2js],
examples: const [
r"""
class C {
const factory C() {}
}
main() => new C();"""
]),
'EXTRANEOUS_MODIFIER': new Message(
id: 'GRKIQE',
subId: 0,
categories: [Category.parserError],
template: "Can't have modifier '#{modifier}' here.",
howToFix: "Try removing '#{modifier}'.",
usedBy: [dart2js],
examples: const [
"var String foo; main(){}",
// "var get foo; main(){}",
"var set foo; main(){}",
"var final foo; main(){}",
"var var foo; main(){}",
"var const foo; main(){}",
"var abstract foo; main(){}",
"var static foo; main(){}",
"var external foo; main(){}",
"final var foo; main(){}",
"var var foo; main(){}",
"const var foo; main(){}",
"abstract var foo; main(){}",
"static var foo; main(){}",
"external var foo; main(){}"
]),
'EXTRANEOUS_MODIFIER_REPLACE': new Message(
id: 'GRKIQE',
subId: 1,
categories: [Category.parserError],
template: "Can't have modifier '#{modifier}' here.",
howToFix: "Try replacing modifier '#{modifier}' with 'var', 'final', "
"or a type.",
usedBy: [dart2js],
examples: const [
// "get foo; main(){}",
"set foo; main(){}",
"abstract foo; main(){}",
"static foo; main(){}",
"external foo; main(){}"
]),
'CONST_CLASS': new Message(
id: 'GRKIQE',
subId: 2,
// The specialization could also be 'EXTRANEOUS_MODIFIER_REPLACE', but the
// example below triggers 'EXTRANEOUS_MODIFIER'.
specializationOf: 'EXTRANEOUS_MODIFIER',
categories: [Category.parserError],
template: "Classes can't be declared to be 'const'.",
howToFix: "Try removing the 'const' keyword or moving to the class'"
" constructor(s).",
usedBy: [analyzer],
examples: const [
r"""
const class C {}
main() => new C();
"""
]),
'CONST_METHOD': new Message(
id: 'GRKIQE',
subId: 3,
// The specialization could also be 'EXTRANEOUS_MODIFIER_REPLACE', but the
// example below triggers 'EXTRANEOUS_MODIFIER'.
specializationOf: 'EXTRANEOUS_MODIFIER',
categories: [Category.parserError],
template: "Getters, setters and methods can't be declared to be 'const'.",
howToFix: "Try removing the 'const' keyword.",
usedBy: [analyzer],
examples: const [
"const int foo() => 499; main() {}",
"const int get foo => 499; main() {}",
"const set foo(v) => 499; main() {}",
"class A { const int foo() => 499; } main() { new A(); }",
"class A { const int get foo => 499; } main() { new A(); }",
"class A { const set foo(v) => 499; } main() { new A(); }",
]),
'CONST_ENUM': new Message(
id: 'GRKIQE',
subId: 4,
// The specialization could also be 'EXTRANEOUS_MODIFIER_REPLACE', but the
// example below triggers 'EXTRANEOUS_MODIFIER'.
specializationOf: 'EXTRANEOUS_MODIFIER',
categories: [Category.parserError],
template: "Enums can't be declared to be 'const'.",
howToFix: "Try removing the 'const' keyword.",
usedBy: [analyzer],
examples: const [
"const enum Foo { x } main() {}",
]),
'CONST_TYPEDEF': new Message(
id: 'GRKIQE',
subId: 5,
// The specialization could also be 'EXTRANEOUS_MODIFIER_REPLACE', but the
// example below triggers 'EXTRANEOUS_MODIFIER'.
specializationOf: 'EXTRANEOUS_MODIFIER',
categories: [Category.parserError],
template: "Type aliases can't be declared to be 'const'.",
howToFix: "Try removing the 'const' keyword.",
usedBy: [analyzer],
examples: const [
"const typedef void Foo(); main() {}",
]),
'CONST_AND_FINAL': new Message(
id: 'GRKIQE',
subId: 6,
// The specialization could also be 'EXTRANEOUS_MODIFIER_REPLACE', but the
// example below triggers 'EXTRANEOUS_MODIFIER'.
specializationOf: 'EXTRANEOUS_MODIFIER',
categories: [Category.parserError],
template: "Members can't be declared to be both 'const' and 'final'.",
howToFix: "Try removing either the 'const' or 'final' keyword.",
usedBy: [analyzer],
examples: const [
"final const int x = 499; main() {}",
"const final int x = 499; main() {}",
"class A { static final const int x = 499; } main() {}",
"class A { static const final int x = 499; } main() {}",
]),
'CONST_AND_VAR': new Message(
id: 'GRKIQE',
subId: 7,
// The specialization could also be 'EXTRANEOUS_MODIFIER_REPLACE', but the
// example below triggers 'EXTRANEOUS_MODIFIER'.
specializationOf: 'EXTRANEOUS_MODIFIER',
categories: [Category.parserError],
template: "Members can't be declared to be both 'const' and 'var'.",
howToFix: "Try removing either the 'const' or 'var' keyword.",
usedBy: [analyzer],
examples: const [
"var const x = 499; main() {}",
"const var x = 499; main() {}",
"class A { var const x = 499; } main() {}",
"class A { const var x = 499; } main() {}",
]),
'CLASS_IN_CLASS': new Message(
// Dart2js currently reports this as an EXTRANEOUS_MODIFIER error.
// TODO(floitsch): make dart2js use this error instead.
id: 'DOTHQH',
categories: [Category.parserError],
template: "Classes can't be declared inside other classes.",
howToFix: "Try moving the class to the top-level.",
usedBy: [analyzer],
examples: const [
"class A { class B {} } main() { new A(); }",
]),
'CONSTRUCTOR_WITH_RETURN_TYPE': new Message(
id: 'VOJBWY',
categories: [Category.parserError],
template: "Constructors can't have a return type.",
howToFix: "Try removing the return type.",
usedBy: [analyzer, dart2js],
examples: const [
"class A { int A() {} } main() { new A(); }",
]),
'MISSING_EXPRESSION_IN_THROW': new Message(
id: 'FTGGMJ',
subId: 0,
categories: [Category.parserError],
template: "Missing expression after 'throw'.",
howToFix: "Did you mean 'rethrow'?",
usedBy: [analyzer, dart2js],
examples: const [
'main() { throw; }',
'main() { try { throw 0; } catch(e) { throw; } }'
]),
/**
* 12.8.1 Rethrow: It is a compile-time error if an expression of the form
* <i>rethrow;</i> is not enclosed within a on-catch clause.
*/
'RETHROW_OUTSIDE_CATCH': new Message(
id: 'MWETLC',
categories: [Category.compileTimeError],
template: 'Rethrow must be inside of catch clause.',
howToFix: "Try moving the expression into a catch clause, or "
"using a 'throw' expression.",
usedBy: [analyzer, dart2js],
examples: const ["main() { rethrow; }"]),
/**
* 13.12 Return: It is a compile-time error if a return statement of the form
* <i>return e;</i> appears in a generative constructor.
*/
'RETURN_IN_GENERATIVE_CONSTRUCTOR': new Message(
id: 'UOTDQH',
categories: [Category.compileTimeError],
template: "Constructors can't return values.",
howToFix:
"Try removing the return statement or using a factory constructor.",
usedBy: [analyzer, dart2js],
examples: const [
"""
class C {
C() {
return 1;
}
}
main() => new C();"""
]),
/**
* 13.12 Return: It is a compile-time error if a return statement of the form
* <i>return e;</i> appears in a generator function.
*/
'RETURN_IN_GENERATOR': new Message(
id: 'JRUTUQ',
subId: 0,
categories: [Category.compileTimeError],
template: "Can't return a value from a generator function "
"(using the '#{modifier}' modifier).",
howToFix: "Try removing the value, replacing 'return' with 'yield' or"
" changing the method body modifier.",
usedBy: [analyzer, dart2js],
examples: const [
"""
foo() async* { return 0; }
main() => foo();
""",
"""
foo() sync* { return 0; }
main() => foo();
"""
]),
'NOT_ASSIGNABLE': new Message(
id: 'FYQYXB',
subId: 0,
categories: [Category.staticTypeWarning],
template: "'#{fromType}' is not assignable to '#{toType}'.",
usedBy: [dart2js]),
'FORIN_NOT_ASSIGNABLE': new Message(
id: 'FYQYXB',
subId: 1,
categories: [Category.hint],
template: "The element type '#{currentType}' of '#{expressionType}' "
"is not assignable to '#{elementType}'.",
usedBy: [dart2js],
examples: const [
"""
main() {
List<int> list = <int>[1, 2];
for (String x in list) x;
}
"""
]),
/**
* 13.11 Return: It is a static type warning if the type of <i>e</i> may not
* be assigned to the declared return type of the immediately enclosing
* function.
*/
'RETURN_OF_INVALID_TYPE': new Message(
id: 'FYQYXB',
subId: 2,
specializationOf: 'NOT_ASSIGNABLE',
categories: [Category.staticTypeWarning],
template: "The return type '#{fromType}' is not a '#{toType}', as "
"defined by the method '#{method}'.",
usedBy: [analyzer],
examples: const ["int foo() => 'foo'; main() { foo(); }"]),
/**
* 12.11.1 New: It is a static warning if the static type of <i>a<sub>i</sub>,
* 1 &lt;= i &lt;= n+ k</i> may not be assigned to the type of the
* corresponding formal parameter of the constructor <i>T.id</i> (respectively
* <i>T</i>).
*
* 12.11.2 Const: It is a static warning if the static type of
* <i>a<sub>i</sub>, 1 &lt;= i &lt;= n+ k</i> may not be assigned to the type
* of the corresponding formal parameter of the constructor <i>T.id</i>
* (respectively <i>T</i>).
*
* 12.14.2 Binding Actuals to Formals: Let <i>T<sub>i</sub></i> be the static
* type of <i>a<sub>i</sub></i>, let <i>S<sub>i</sub></i> be the type of
* <i>p<sub>i</sub>, 1 &lt;= i &lt;= n+k</i> and let <i>S<sub>q</sub></i> be
* the type of the named parameter <i>q</i> of <i>f</i>. It is a static
* warning if <i>T<sub>j</sub></i> may not be assigned to <i>S<sub>j</sub>, 1
* &lt;= j &lt;= m</i>.
*
* 12.14.2 Binding Actuals to Formals: Furthermore, each <i>q<sub>i</sub>, 1
* &lt;= i &lt;= l</i>, must have a corresponding named parameter in the set
* <i>{p<sub>n+1</sub>, &hellip; p<sub>n+k</sub>}</i> or a static warning
* occurs. It is a static warning if <i>T<sub>m+j</sub></i> may not be
* assigned to <i>S<sub>r</sub></i>, where <i>r = q<sub>j</sub>, 1 &lt;= j
* &lt;= l</i>.
*/
'ARGUMENT_TYPE_NOT_ASSIGNABLE': new Message(
id: 'FYQYXB',
subId: 3,
specializationOf: 'NOT_ASSIGNABLE',
categories: [Category.hint, Category.staticWarning],
template: "The argument type '#{fromType}' cannot be assigned to the "
"parameter type '#{toType}'.",
usedBy: [analyzer],
// TODO(floitsch): support hint warnings and ways to specify which
// category an example should trigger for.
examples: const ["foo(int x) => x; main() { foo('bar'); }"]),
'CANNOT_RESOLVE': new Message(
id: 'ERUSKD',
subId: 0,
categories: [Category.staticTypeWarning],
template: "Can't resolve '#{name}'.",
usedBy: [dart2js]),
/**
* 12.15.1 Ordinary Invocation: Let <i>T</i> be the static type of <i>o</i>.
* It is a static type warning if <i>T</i> does not have an accessible
* instance member named <i>m</i>.
*/
'UNDEFINED_METHOD': new Message(
id: 'ERUSKD',
subId: 1,
categories: [Category.staticTypeWarning, Category.hint],
template: "The method '#{memberName}' is not defined for the class"
" '#{className}'.",
usedBy: [dart2js, analyzer],
examples: const [
"""
class A {
foo() { bar(); }
}
main() { new A().foo(); }
""",
]),
/**
* 12.15.1 Ordinary Invocation: Let <i>T</i> be the static type of <i>o</i>.
* It is a static type warning if <i>T</i> does not have an accessible
* instance member named <i>m</i>.
*/
'UNDEFINED_METHOD_WITH_CONSTRUCTOR': new Message(
id: 'ERUSKD',
subId: 2,
specializationOf: "UNDEFINED_METHOD",
categories: [Category.staticTypeWarning],
template: "The method '#{memberName}' is not defined for the class"
" '#{className}', but a constructor with that name is defined.",
howToFix: "Try adding 'new' or 'const' to invoke the constructor, or "
"change the method name.",
usedBy: [analyzer],
examples: const [
"""
class A {
A.bar() {}
}
main() { A.bar(); }
""",
]),
/**
* 12.17 Getter Invocation: Let <i>T</i> be the static type of <i>e</i>. It is
* a static type warning if <i>T</i> does not have a getter named <i>m</i>.
*/
'UNDEFINED_GETTER': new Message(
id: 'ERUSKD',
subId: 3,
categories: [
Category.staticTypeWarning,
Category.staticWarning,
Category.hint
],
template: "The getter '#{memberName}' is not defined for the "
"class '#{className}'.",
usedBy: [dart2js, analyzer],
examples: const [
"class A {} main() { new A().x; }",
"class A {} main() { A.x; }"
]),
/**
* 12.17 Getter Invocation: It is a static warning if there is no class
* <i>C</i> in the enclosing lexical scope of <i>i</i>, or if <i>C</i> does
* not declare, implicitly or explicitly, a getter named <i>m</i>.
*/
'UNDEFINED_ENUM_CONSTANT': new Message(
id: 'ERUSKD',
subId: 4,
specializationOf: 'UNDEFINED_GETTER',
categories: [Category.staticTypeWarning],
template: "There is no constant named '#{memberName}' in '#{className}'.",
usedBy: [analyzer],
examples: const [
"""
enum E { ONE }
E e() { return E.TWO; }
main() { e(); }
"""
]),
'UNDEFINED_INSTANCE_GETTER_BUT_SETTER': new Message(
id: 'ERUSKD',
subId: 5,
specializationOf: 'UNDEFINED_GETTER',
categories: [
Category.staticTypeWarning,
],
template: "The setter '#{memberName}' in class '#{className}' can"
" not be used as a getter.",
usedBy: [dart2js],
examples: const [
"class A { set x(y) {} } main() { new A().x; }",
]),
/**
* 12.18 Assignment: Evaluation of an assignment of the form
* <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] = <i>e<sub>3</sub></i> is
* equivalent to the evaluation of the expression (a, i, e){a.[]=(i, e);
* return e;} (<i>e<sub>1</sub></i>, <i>e<sub>2</sub></i>,
* <i>e<sub>2</sub></i>).
*
* 12.29 Assignable Expressions: An assignable expression of the form
* <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] is evaluated as a method
* invocation of the operator method [] on <i>e<sub>1</sub></i> with argument
* <i>e<sub>2</sub></i>.
*
* 12.15.1 Ordinary Invocation: Let <i>T</i> be the static type of <i>o</i>.
* It is a static type warning if <i>T</i> does not have an accessible
* instance member named <i>m</i>.
*/
'UNDEFINED_OPERATOR': new Message(
id: 'ERUSKD',
subId: 6,
categories: [Category.staticTypeWarning, Category.hint],
template: "The operator '#{memberName}' is not defined for the "
"class '#{className}'.",
usedBy: [dart2js, analyzer],
examples: const [
"class A {} main() { new A() + 3; }",
]),
/**
* 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>.
* It is a static type warning if <i>T</i> does not have an accessible
* instance setter named <i>v=</i>.
*
* 12.18 Assignment: It is as static warning if an assignment of the form
* <i>v = e</i> occurs inside a top level or static function (be it function,
* method, getter, or setter) or variable initializer and there is no
* declaration <i>d</i> with name <i>v=</i> in the lexical scope enclosing the
* assignment.
*
* 12.18 Assignment: It is a static warning if there is no class <i>C</i> in
* the enclosing lexical scope of the assignment, or if <i>C</i> does not
* declare, implicitly or explicitly, a setter <i>v=</i>.
*/
'UNDEFINED_SETTER': new Message(
id: 'ERUSKD',
subId: 7,
categories: [
Category.staticTypeWarning,
Category.staticWarning,
Category.hint
],
template: "The setter '#{memberName}' is not defined for the "
"class '#{className}'.",
usedBy: [dart2js, analyzer],
// TODO(eernst): When this.x access is available, add examples here,
// e.g., "class A { var x; A(this.x) : x = 3; } main() => new A(2);"
examples: const [
"class A {} main() { new A().x = 499; }",
]),
'NO_SUCH_SUPER_MEMBER': new Message(
id: 'ERUSKD',
subId: 8,
categories: [Category.staticTypeWarning],
template:
"Can't resolve '#{memberName}' in a superclass of '#{className}'.",
usedBy: [dart2js]),
/**
* 12.17 Getter Invocation: Let <i>T</i> be the static type of <i>e</i>. It is
* a static type warning if <i>T</i> does not have a getter named <i>m</i>.
*
* 12.17 Getter Invocation: It is a static warning if there is no class
* <i>C</i> in the enclosing lexical scope of <i>i</i>, or if <i>C</i> does
* not declare, implicitly or explicitly, a getter named <i>m</i>.
*/
'UNDEFINED_SUPER_GETTER': new Message(
id: 'ERUSKD',
subId: 9,
specializationOf: 'NO_SUCH_SUPER_MEMBER',
categories: [Category.staticTypeWarning, Category.staticWarning],
template: "The getter '#{memberName}' is not defined in a superclass "
"of '#{className}'.",
usedBy: [analyzer],
examples: const [
"""
class A {}
class B extends A {
foo() => super.x;
}
main() { new B().foo(); }
"""
]),
/**
* 12.15.4 Super Invocation: A super method invocation <i>i</i> has the form
* <i>super.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub>:
* a<sub>n+1</sub>, &hellip; x<sub>n+k</sub>: a<sub>n+k</sub>)</i>. It is a
* static type warning if <i>S</i> does not have an accessible instance member
* named <i>m</i>.
*/
'UNDEFINED_SUPER_METHOD': new Message(
id: 'ERUSKD',
subId: 10,
specializationOf: 'NO_SUCH_SUPER_MEMBER',
categories: [Category.staticTypeWarning],
template: "The method '#{memberName}' is not defined in a superclass "
"of '#{className}'.",
usedBy: [analyzer],
examples: const [
"""
class A {}
class B extends A {
foo() => super.x();
}
main() { new B().foo(); }
"""
]),
/**
* 12.18 Assignment: Evaluation of an assignment of the form
* <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] = <i>e<sub>3</sub></i> is
* equivalent to the evaluation of the expression (a, i, e){a.[]=(i, e);
* return e;} (<i>e<sub>1</sub></i>, <i>e<sub>2</sub></i>,
* <i>e<sub>2</sub></i>).
*
* 12.29 Assignable Expressions: An assignable expression of the form
* <i>e<sub>1</sub></i>[<i>e<sub>2</sub></i>] is evaluated as a method
* invocation of the operator method [] on <i>e<sub>1</sub></i> with argument
* <i>e<sub>2</sub></i>.
*
* 12.15.1 Ordinary Invocation: Let <i>T</i> be the static type of <i>o</i>.
* It is a static type warning if <i>T</i> does not have an accessible
* instance member named <i>m</i>.
*/
'UNDEFINED_SUPER_OPERATOR': new Message(
id: 'ERUSKD',
subId: 11,
specializationOf: 'NO_SUCH_SUPER_MEMBER',
categories: [Category.staticTypeWarning],
template: "The operator '#{memberName}' is not defined in a superclass "
"of '#{className}'.",
usedBy: [analyzer],
examples: const [
"""
class A {}
class B extends A {
foo() => super + 499;
}
main() { new B().foo(); }
"""
]),
/**
* 12.18 Assignment: Let <i>T</i> be the static type of <i>e<sub>1</sub></i>.
* It is a static type warning if <i>T</i> does not have an accessible
* instance setter named <i>v=</i>.
*
* 12.18 Assignment: It is as static warning if an assignment of the form
* <i>v = e</i> occurs inside a top level or static function (be it function,
* method, getter, or setter) or variable initializer and there is no
* declaration <i>d</i> with name <i>v=</i> in the lexical scope enclosing the
* assignment.
*
* 12.18 Assignment: It is a static warning if there is no class <i>C</i> in
* the enclosing lexical scope of the assignment, or if <i>C</i> does not
* declare, implicitly or explicitly, a setter <i>v=</i>.
*/
'UNDEFINED_SUPER_SETTER': new Message(
id: 'ERUSKD',
subId: 12,
categories: [Category.staticTypeWarning, Category.staticWarning],
template: "The setter '#{memberName}' is not defined in a superclass "
"of '#{className}'.",
usedBy: [
analyzer,
dart2js,
],
examples: const [
"""
class A {}
class B extends A {
foo() { super.x = 499; }
}
main() { new B().foo(); }
""",
// TODO(floitsch): reenable this test.
/*
"""
main() => new B().m();
class A {
get x => 1;
}
class B extends A {
m() { super.x = 2; }
}
"""
*/
]),
/**
* 12.15.3 Unqualified Invocation: If there exists a lexically visible
* declaration named <i>id</i>, let <i>f<sub>id</sub></i> be the innermost
* such declaration. Then: [skip]. Otherwise, <i>f<sub>id</sub></i> is
* considered equivalent to the ordinary method invocation
* <b>this</b>.<i>id</i>(<i>a<sub>1</sub></i>, ..., <i>a<sub>n</sub></i>,
* <i>x<sub>n+1</sub></i> : <i>a<sub>n+1</sub></i>, ...,
* <i>x<sub>n+k</sub></i> : <i>a<sub>n+k</sub></i>).
*/
'UNDEFINED_FUNCTION': new Message(
id: 'ERUSKD',
subId: 13,
specializationOf: 'CANNOT_RESOLVE',
categories: [Category.staticTypeWarning],
template: "The function '#{memberName}' is not defined.",
usedBy: [analyzer],
examples: const [
"main() { foo(); }",
]),
'UNDEFINED_STATIC_GETTER_BUT_SETTER': new Message(
id: 'ERUSKD',
subId: 14,
specializationOf: 'CANNOT_RESOLVE',
categories: [Category.staticTypeWarning],
template: "Cannot resolve getter '#{name}'.",
usedBy: [dart2js],
examples: const [
"set foo(x) {} main() { foo; }",
]),
'UNDEFINED_STATIC_SETTER_BUT_GETTER': new Message(
id: 'ERUSKD',
subId: 15,
specializationOf: 'CANNOT_RESOLVE',
categories: [Category.staticTypeWarning],
template: "Cannot resolve setter '#{name}'.",
usedBy: [dart2js],
examples: const [
"""
main() {
final x = 1;
x = 2;
}""",
"""
main() {
const x = 1;
x = 2;
}
""",
"""
final x = 1;
main() { x = 3; }
""",
"""
const x = 1;
main() { x = 3; }
""",
"get foo => null main() { foo = 5; }",
"const foo = 0 main() { foo = 5; }",
]),
};

View file

@ -1,4 +0,0 @@
# This package is not intended to be published.
name: dart_messages
#version: do-not-upload
dependencies:

View file

@ -1,57 +0,0 @@
// Copyright (c) 2015, 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.
import 'dart:io' as io;
import 'package:dart_messages/shared_messages.dart';
void testJsonIsUpdated() {
var packageRoot = io.Platform.packageRoot;
if (packageRoot == null || packageRoot == "") {
throw new UnsupportedError("This test requires a package root.");
}
var jsonUri = Uri
.parse(packageRoot)
.resolve('dart_messages/generated/shared_messages.json');
var jsonPath = jsonUri.toFilePath();
var content = new io.File(jsonPath).readAsStringSync();
if (messagesAsJson != content) {
print("The content of the Dart messages and the corresponding JSON file");
print("is not the same.");
print("Please run bin/publish.dart to update the JSON file.");
throw "Content is not the same";
}
}
void testIdsAreUnique() {
var usedIds = new Set();
for (var entry in MESSAGES.values) {
var id = "${entry.id}-${entry.subId}";
if (!usedIds.add(id)) {
throw "Id appears twice: $id";
}
}
}
void testSpecializationsAreOfSameId() {
for (var entry in MESSAGES.values) {
var specializationOf = entry.specializationOf;
if (specializationOf == null) continue;
var generic = MESSAGES[specializationOf];
if (generic == null) {
throw "More generic message doesn't exist: $specializationOf";
}
if (generic.id != entry.id) {
var id = "${entry.id}-${entry.subId}";
var genericId = "${generic.id}-${generic.subId}";
throw "Specialization doesn't have same id: $id - $genericId";
}
}
}
void main() {
testJsonIsUpdated();
testIdsAreUnique();
testSpecializationsAreOfSameId();
}

View file

@ -26,7 +26,6 @@ analyzer/test/src/summary/resynthesize_kernel_test: Slow, Pass
analyzer/test/src/task/strong/checker_test: Slow, Pass
analyzer_plugin/test/plugin/folding_mixin_test: Slow, Pass
analyzer_plugin/tool/spec/check_all_test: Skip # Issue 29133
dart_messages/test/dart_messages_test: Skip # Requires a package root.
dev_compiler/test/options/*: Skip # test needs fixes
dev_compiler/test/sourcemap/*: SkipByDesign # Skip sourcemap tests
dev_compiler/test/sourcemap/testfiles/*: SkipByDesign # Skip dev_compiler codegen tests
@ -151,7 +150,6 @@ analyzer/tool/summary/check_test: SkipByDesign # Uses dart:io.
analyzer/tool/task_dependency_graph/check_test: SkipByDesign # Uses dart:io.
analyzer_cli/*: SkipByDesign # Uses dart:io.
compiler/tool/*: SkipByDesign # Only meant to run on vm
dart_messages/test/dart_messages_test: Skip # Uses dart:io.
front_end/tool/*: SkipByDesign # Only meant to run on vm
http_server/test/*: Fail, OK # Uses dart:io.
kernel/test/*: SkipByDesign # Uses dart:io and bigints.

View file

@ -1752,11 +1752,6 @@
"script": "out/ReleaseX64/dart-sdk/bin/dartanalyzer",
"arguments": ["--fatal-warnings", "pkg/dart_internal"]
},
{
"name": "analyze pkg/dart_messages",
"script": "out/ReleaseX64/dart-sdk/bin/dartanalyzer",
"arguments": ["--fatal-warnings", "pkg/dart_messages"]
},
{
"name": "analyze pkg/dev_compiler",
"script": "out/ReleaseX64/dart-sdk/bin/dartanalyzer",