Format constants and remove dart2jsCode

Change-Id: Ia04066782292f0c49a56689056c69b0481f3aacb
Reviewed-on: https://dart-review.googlesource.com/72021
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
This commit is contained in:
Peter von der Ahé 2018-08-30 08:05:31 +00:00 committed by commit-bot@chromium.org
parent f45ca5c4ac
commit fa14dbcdfc
9 changed files with 245 additions and 829 deletions

View file

@ -78,7 +78,6 @@ class _CompilerFileSystemEntity implements fe.FileSystemEntity {
/// [DiagnosticReporter].
void reportFrontEndMessage(
DiagnosticReporter reporter, fe.CompilationMessage message) {
// TODO(sigmund): translate message kinds using message.dart2jsCode
MessageKind kind = MessageKind.GENERIC;
Spannable span;
if (message.span != null) {

View file

@ -34,8 +34,4 @@ abstract class CompilationMessage {
/// The corresponding analyzer error code, or null if there is no
/// corresponding message in analyzer.
String get analyzerCode;
/// The corresponding dart2js error code, or null if there is no corresponding
/// message in dart2js.
String get dart2jsCode;
}

View file

@ -689,8 +689,6 @@ class _CompilationMessage implements CompilationMessage {
String get analyzerCode => _original.code.analyzerCode;
String get dart2jsCode => _original.code.dart2jsCode;
SourceSpan get span {
var uri = _original.uri;
var offset = _original.charOffset;

View file

@ -25,12 +25,9 @@ class Code<T> {
final String analyzerCode;
final String dart2jsCode;
final Severity severity;
const Code(this.name, this.template,
{this.analyzerCode, this.dart2jsCode, this.severity});
const Code(this.name, this.template, {this.analyzerCode, this.severity});
String toString() => name;
}
@ -61,15 +58,8 @@ class MessageCode extends Code<Null> implements Message {
final String tip;
const MessageCode(String name,
{String analyzerCode,
String dart2jsCode,
Severity severity,
this.message,
this.tip})
: super(name, null,
analyzerCode: analyzerCode,
dart2jsCode: dart2jsCode,
severity: severity);
{String analyzerCode, Severity severity, this.message, this.tip})
: super(name, null, analyzerCode: analyzerCode, severity: severity);
Map<String, dynamic> get arguments => const <String, dynamic>{};

File diff suppressed because it is too large Load diff

View file

@ -33,7 +33,6 @@ CantInferPackagesFromManyInputs/analyzerCode: Fail
CantInferPackagesFromManyInputs/example: Fail
CantInferPackagesFromPackageUri/analyzerCode: Fail
CantInferPackagesFromPackageUri/example: Fail
CantInferTypeDueToCircularity/dart2jsCode: Fail
CantInferTypeDueToCircularity/example: Fail
CantInferTypeDueToInconsistentOverrides/example: Fail
CantUseSuperBoundedTypeForInstanceCreation/analyzerCode: Fail
@ -56,27 +55,19 @@ ConstConstructorRedirectionToNonConst/analyzerCode: Fail # The analyzer doesn't
ConstConstructorWithNonConstSuper/example: Fail
ConstEvalContext/analyzerCode: Fail # This is just used for displaying the context.
ConstEvalContext/example: Fail # This is just used for displaying the context.
ConstEvalDuplicateKey/dart2jsCode: Fail
ConstEvalDuplicateKey/example: Fail
ConstEvalFailedAssertion/dart2jsCode: Fail
ConstEvalFailedAssertion/example: Fail
ConstEvalFailedAssertionWithMessage/dart2jsCode: Fail
ConstEvalFailedAssertionWithMessage/example: Fail
ConstEvalInvalidBinaryOperandType/analyzerCode: Fail # CONST_EVAL_TYPE_NUM / CONST_EVAL_TYPE_BOOL
ConstEvalInvalidBinaryOperandType/example: Fail
ConstEvalInvalidMethodInvocation/dart2jsCode: Fail
ConstEvalInvalidMethodInvocation/example: Fail
ConstEvalInvalidStaticInvocation/dart2jsCode: Fail
ConstEvalInvalidStaticInvocation/example: Fail
ConstEvalInvalidStringInterpolationOperand/dart2jsCode: Fail
ConstEvalInvalidStringInterpolationOperand/example: Fail
ConstEvalInvalidType/analyzerCode: Fail # CONST_CONSTRUCTOR_FIELD_TYPE_MISMATCH / CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH / CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH / ...
ConstEvalInvalidType/example: Fail
ConstEvalNegativeShift/analyzerCode: Fail # http://dartbug.com/33481
ConstEvalNegativeShift/example: Fail
ConstEvalNonConstantLiteral/dart2jsCode: Fail
ConstEvalNonConstantLiteral/example: Fail
ConstEvalNonConstantVariableGet/dart2jsCode: Fail
ConstEvalNonConstantVariableGet/example: Fail
ConstEvalZeroDivisor/example: Fail
ConstFieldWithoutInitializer/example: Fail
@ -185,7 +176,6 @@ ForInLoopWithConstVariable/example: Fail
FunctionTypeDefaultValue/example: Fail
FunctionTypedParameterVar/script1: Fail
GeneratorReturnsValue/example: Fail
GetterNotFound/dart2jsCode: Fail
GetterNotFound/example: Fail
GetterWithFormals/example: Fail
IllegalAssignmentToNonAssignable/script1: Fail
@ -231,7 +221,6 @@ MapLiteralTypeArgumentMismatch/example: Fail
MemberWithSameNameAsClass/analyzerCode: Fail
MemberWithSameNameAsClass/example: Fail
MetadataTypeArguments/example: Fail
MethodNotFound/dart2jsCode: Fail
MethodNotFound/example: Fail
MissingArgumentList/analyzerCode: Fail
MissingArgumentList/example: Fail
@ -241,7 +230,6 @@ MissingInput/analyzerCode: Fail
MissingInput/example: Fail
MissingMain/analyzerCode: Fail
MissingMain/example: Fail
MissingPartOf/dart2jsCode: Fail
MissingPrefixInDeferredImport/example: Fail
MixinInferenceNoMatchingClass/example: Fail
MultipleExtends/script: Fail
@ -280,14 +268,9 @@ OverrideTypeMismatchReturnType/example: Fail
OverrideTypeVariablesMismatch/example: Fail
PackageNotFound/analyzerCode: Fail
PackageNotFound/example: Fail
PartOfLibraryNameMismatch/dart2jsCode: Fail
PartOfLibraryNameMismatch/example: Fail
PartOfSelf/dart2jsCode: Fail
PartOfUriMismatch/dart2jsCode: Fail
PartOfUriMismatch/example: Fail
PartOfUseUri/dart2jsCode: Fail
PartOfUseUri/example: Fail
PartTwice/dart2jsCode: Fail
PatchClassTypeVariablesMismatch/analyzerCode: Fail
PatchClassTypeVariablesMismatch/example: Fail
PatchDeclarationMismatch/analyzerCode: Fail
@ -314,7 +297,6 @@ SdkSpecificationNotFound/analyzerCode: Fail
SdkSpecificationNotFound/example: Fail
SdkSummaryNotFound/analyzerCode: Fail
SdkSummaryNotFound/example: Fail
SetterNotFound/dart2jsCode: Fail
SetterNotFound/example: Fail
SetterNotSync/example: Fail
SetterWithWrongNumberOfFormals/example: Fail
@ -328,10 +310,8 @@ SuperAsExpression/example: Fail
SuperAsIdentifier/example: Fail
SuperNullAware/example: Fail
SuperclassHasNoDefaultConstructor/example: Fail
SuperclassHasNoGetter/dart2jsCode: Fail
SuperclassHasNoGetter/example: Fail
SuperclassHasNoMethod/example: Fail
SuperclassHasNoSetter/dart2jsCode: Fail
SuperclassHasNoSetter/example: Fail
SuperclassMethodArgumentMismatch/analyzerCode: Fail
SuperclassMethodArgumentMismatch/example: Fail

File diff suppressed because it is too large Load diff

View file

@ -90,7 +90,6 @@ class MessageTestSuite extends ChainContext {
String externalTest;
bool frontendInternal = false;
String analyzerCode;
String dart2jsCode;
Severity severity;
YamlNode badSeverity;
@ -117,10 +116,6 @@ class MessageTestSuite extends ChainContext {
analyzerCode = value;
break;
case "dart2jsCode":
dart2jsCode = value;
break;
case "bytes":
YamlList list = node;
if (list.first is List) {
@ -260,17 +255,6 @@ class MessageTestSuite extends ChainContext {
" on an example to find the code."
" The code is printed just before the file name."
: null);
yield createDescription(
"dart2jsCode",
null,
exampleAndAnalyzerCodeRequired &&
!frontendInternal &&
analyzerCode != null &&
dart2jsCode == null
? "No dart2js code for $name."
" Try using *ignored* or *fatal*"
: null);
}
}

View file

@ -56,7 +56,7 @@ part of fasta.codes;
throw "No 'template:' in key $name.";
}
sb.writeln(compileTemplate(name, map['template'], map['tip'],
map['analyzerCode'], map['dart2jsCode'], map['severity']));
map['analyzerCode'], map['severity']));
}
return new DartFormatter().format("$sb");
@ -66,7 +66,7 @@ final RegExp placeholderPattern =
new RegExp("#\([-a-zA-Z0-9_]+\)(?:%\([0-9]*\)\.\([0-9]+\))?");
String compileTemplate(String name, String template, String tip,
String analyzerCode, String dart2jsCode, String severity) {
String analyzerCode, String severity) {
if (template == null) {
print('Error: missing template for message: $name');
exitCode = 1;
@ -79,6 +79,15 @@ String compileTemplate(String name, String template, String tip,
var parameters = new Set<String>();
var conversions = new Set<String>();
var arguments = new Set<String>();
bool hasNameSystem = false;
void ensureNameSystem() {
if (hasNameSystem) return;
conversions.add(r"""
NameSystem nameSystem = new NameSystem();
StringBuffer buffer;""");
hasNameSystem = true;
}
for (Match match in placeholderPattern.allMatches("$template${tip ?? ''}")) {
String name = match[1];
String padding = match[2];
@ -161,9 +170,9 @@ String compileTemplate(String name, String template, String tip,
case "type":
parameters.add("DartType _type");
ensureNameSystem();
conversions.add(r"""
NameSystem nameSystem = new NameSystem();
StringBuffer buffer = new StringBuffer();
buffer = new StringBuffer();
new Printer(buffer, syntheticNames: nameSystem).writeNode(_type);
String type = '$buffer';
""");
@ -172,6 +181,7 @@ String type = '$buffer';
case "type2":
parameters.add("DartType _type2");
ensureNameSystem();
conversions.add(r"""
buffer = new StringBuffer();
new Printer(buffer, syntheticNames: nameSystem).writeNode(_type2);
@ -209,8 +219,16 @@ String type2 = '$buffer';
break;
case "constant":
parameters.add("Constant constant");
arguments.add("'constant': constant");
parameters.add("Constant _constant");
ensureNameSystem();
conversions.add(r"""
buffer = new StringBuffer();
new Printer(buffer, syntheticNames: nameSystem).writeNode(_constant);
String constant = '$buffer';
""");
arguments.add("'constant': _constant");
break;
case "num1":
@ -247,9 +265,6 @@ String type2 = '$buffer';
if (analyzerCode != null) {
codeArguments.add('analyzerCode: "$analyzerCode"');
}
if (dart2jsCode != null) {
codeArguments.add('dart2jsCode: "$dart2jsCode"');
}
if (severity != null) {
String severityEnumName = severityEnumNames[severity];
if (severityEnumName == null) {