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

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: 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 abstract class FastaCode<T> {
Siggi Cherem (dart-lang) 2017/07/07 21:17:08 seems you can drop the T here now.
ahe 2017/07/10 13:43:50 Actually, T was essential for ensuring type safety
Siggi Cherem (dart-lang) 2017/07/10 16:19:47 BTW - I was suggesting it when you didn't have any
ahe 2017/07/10 16:57:26 I know that nothing was depending on it, but for t
12 final String name; 12 final String name;
13 13
14 final String template; 14 final String template;
15 15
16 final String tip; 16 final String tip;
17 17
18 final String analyzerCode; 18 final String analyzerCode;
19 19
20 final String dart2jsCode; 20 final String dart2jsCode;
21 21
22 final T format;
23
24 const FastaCode(this.name, 22 const FastaCode(this.name,
25 {this.template, 23 {this.template, this.tip, this.analyzerCode, this.dart2jsCode});
26 this.tip,
27 this.analyzerCode,
28 this.dart2jsCode,
29 this.format});
30 24
31 String toString() => name; 25 String toString() => name;
32 } 26 }
33 27
28 class UnboundFastaCode<T> extends FastaCode<T> {
29 final T bind;
30
31 const UnboundFastaCode(String name,
32 {String template,
33 String tip,
34 String analyzerCode,
35 String dart2jsCode,
36 this.bind})
37 : super(name,
38 template: template,
39 tip: tip,
40 analyzerCode: analyzerCode,
41 dart2jsCode: dart2jsCode);
42 }
43
44 class BoundFastaCode extends FastaCode<BoundFastaCode> {
ahe 2017/07/07 15:25:42 I'm thinking about renaming this to NoArgumentsFas
Siggi Cherem (dart-lang) 2017/07/07 21:17:08 +1 on doing some renames. Some alternative sugges
ahe 2017/07/10 13:43:50 I did something like that.
45 const BoundFastaCode(String name,
46 {String template, String tip, String analyzerCode, String dart2jsCode})
47 : super(name,
48 template: template,
49 tip: tip,
50 analyzerCode: analyzerCode,
51 dart2jsCode: dart2jsCode);
52
53 FastaMessage call(Uri uri, int charOffset) {
54 return new FastaMessage(uri, charOffset, this,
55 message: template, tip: tip, arguments: const <String, dynamic>{});
56 }
57 }
58
34 class FastaMessage { 59 class FastaMessage {
35 final Uri uri; 60 final Uri uri;
36 61
37 final int charOffset; 62 final int charOffset;
38 63
39 final String message; 64 final String message;
40 65
41 final String tip; 66 final String tip;
Siggi Cherem (dart-lang) 2017/07/07 21:17:08 could we turn this into: String get tip => code.t
ahe 2017/07/10 13:43:50 No, the tip is also subject to template expansion.
42 67
43 final FastaCode code; 68 final FastaCode code;
44 69
45 final Map<String, dynamic> arguments; 70 final Map<String, dynamic> arguments;
46 71
47 const FastaMessage(this.uri, this.charOffset, this.code, 72 const FastaMessage(this.uri, this.charOffset, this.code,
48 {this.message, this.tip, this.arguments}); 73 {this.message, this.tip, this.arguments});
49 } 74 }
75
76 typedef BoundFastaMessage = FastaMessage Function(Uri, int);
ahe 2017/07/07 15:25:41 I'm thinking about renaming this to BoundCode.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698