| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 library fasta.codes; | 5 library fasta.codes; |
| 6 | 6 |
| 7 import 'package:front_end/src/scanner/token.dart' show Token; | 7 import 'package:front_end/src/scanner/token.dart' show Token; |
| 8 | 8 |
| 9 part 'fasta_codes_generated.dart'; | 9 part 'fasta_codes_generated.dart'; |
| 10 | 10 |
| 11 class FastaCode<T> { | 11 class Code<T> { |
| 12 final String name; | 12 final String name; |
| 13 | 13 |
| 14 final String template; | 14 final Template<T> template; |
| 15 | |
| 16 final String tip; | |
| 17 | 15 |
| 18 final String analyzerCode; | 16 final String analyzerCode; |
| 19 | 17 |
| 20 final String dart2jsCode; | 18 final String dart2jsCode; |
| 21 | 19 |
| 22 final T format; | 20 const Code(this.name, this.template, {this.analyzerCode, this.dart2jsCode}); |
| 23 | |
| 24 const FastaCode(this.name, | |
| 25 {this.template, | |
| 26 this.tip, | |
| 27 this.analyzerCode, | |
| 28 this.dart2jsCode, | |
| 29 this.format}); | |
| 30 | 21 |
| 31 String toString() => name; | 22 String toString() => name; |
| 32 } | 23 } |
| 33 | 24 |
| 34 class FastaMessage { | 25 class Message { |
| 35 final Uri uri; | 26 final Code code; |
| 36 | |
| 37 final int charOffset; | |
| 38 | 27 |
| 39 final String message; | 28 final String message; |
| 40 | 29 |
| 41 final String tip; | 30 final String tip; |
| 42 | 31 |
| 43 final FastaCode code; | |
| 44 | |
| 45 final Map<String, dynamic> arguments; | 32 final Map<String, dynamic> arguments; |
| 46 | 33 |
| 47 const FastaMessage(this.uri, this.charOffset, this.code, | 34 const Message(this.code, {this.message, this.tip, this.arguments}); |
| 48 {this.message, this.tip, this.arguments}); | 35 |
| 36 LocatedMessage withLocation(Uri uri, int charOffset) { |
| 37 return new LocatedMessage(uri, charOffset, this); |
| 38 } |
| 49 } | 39 } |
| 40 |
| 41 class MessageCode extends Code<Null> implements Message { |
| 42 final String message; |
| 43 |
| 44 final String tip; |
| 45 |
| 46 const MessageCode(String name, |
| 47 {String analyzerCode, String dart2jsCode, this.message, this.tip}) |
| 48 : super(name, null, analyzerCode: analyzerCode, dart2jsCode: dart2jsCode); |
| 49 |
| 50 Map<String, dynamic> get arguments => const <String, dynamic>{}; |
| 51 |
| 52 Code get code => this; |
| 53 |
| 54 LocatedMessage withLocation(Uri uri, int charOffset) { |
| 55 return new LocatedMessage(uri, charOffset, this); |
| 56 } |
| 57 } |
| 58 |
| 59 class Template<T> { |
| 60 final String messageTemplate; |
| 61 |
| 62 final String tipTemplate; |
| 63 |
| 64 final T withArguments; |
| 65 |
| 66 const Template({this.messageTemplate, this.tipTemplate, this.withArguments}); |
| 67 } |
| 68 |
| 69 class LocatedMessage { |
| 70 final Uri uri; |
| 71 |
| 72 final int charOffset; |
| 73 |
| 74 final Message messageObject; |
| 75 |
| 76 const LocatedMessage(this.uri, this.charOffset, this.messageObject); |
| 77 |
| 78 Code get code => messageObject.code; |
| 79 |
| 80 String get message => messageObject.message; |
| 81 |
| 82 String get tip => messageObject.tip; |
| 83 |
| 84 Map<String, dynamic> get arguments => messageObject.arguments; |
| 85 } |
| OLD | NEW |