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

Side by Side Diff: pkg/front_end/lib/src/fasta/fasta_codes.dart

Issue 2965393002: Use FastaMessage instead of String. Part 1. (Closed)
Patch Set: Add type variable to Code. 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 unified diff | Download patch
OLDNEW
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 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/compiler_command_line.dart ('k') | pkg/front_end/lib/src/fasta/fasta_codes_generated.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698