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

Side by Side Diff: frog/leg/warnings.dart

Issue 9166010: Implement super calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 class MessageKind { 5 class MessageKind {
6 final String template; 6 final String template;
7 const MessageKind(this.template); 7 const MessageKind(this.template);
8 8
9 static final GENERIC = const MessageKind('#{1}'); 9 static final GENERIC = const MessageKind('#{1}');
10 10
(...skipping 26 matching lines...) Expand all
37 'not all paths lead to a return or throw statement'); 37 'not all paths lead to a return or throw statement');
38 38
39 static final CANNOT_RESOLVE = const MessageKind( 39 static final CANNOT_RESOLVE = const MessageKind(
40 'cannot resolve #{1}'); 40 'cannot resolve #{1}');
41 static final CANNOT_RESOLVE_TYPE = const MessageKind( 41 static final CANNOT_RESOLVE_TYPE = const MessageKind(
42 'cannot resolve type #{1}'); 42 'cannot resolve type #{1}');
43 static final DUPLICATE_DEFINITION = const MessageKind( 43 static final DUPLICATE_DEFINITION = const MessageKind(
44 'duplicate definition of #{1}'); 44 'duplicate definition of #{1}');
45 static final NOT_A_TYPE = const MessageKind( 45 static final NOT_A_TYPE = const MessageKind(
46 '#{1} is not a type'); 46 '#{1} is not a type');
47 static final NO_SUPER_IN_OBJECT = const MessageKind(
48 '\'Object\' does not have a superclass');
47 static final CANNOT_FIND_CONSTRUCTOR = const MessageKind( 49 static final CANNOT_FIND_CONSTRUCTOR = const MessageKind(
48 'cannot find constructor #{1}'); 50 'cannot find constructor #{1}');
49 static final INVALID_RECEIVER_IN_INITIALIZER = const MessageKind( 51 static final INVALID_RECEIVER_IN_INITIALIZER = const MessageKind(
50 'field initializer expected'); 52 'field initializer expected');
51 static final NO_THIS_IN_STATIC = const MessageKind( 53 static final NO_THIS_IN_STATIC = const MessageKind(
52 '\'this\' is only available in instance methods'); 54 '\'this\' is only available in instance methods');
55 static final NO_SUPER_IN_STATIC = const MessageKind(
56 '\'super\' is only available in instance methods');
53 static final DUPLICATE_INITIALIZER = const MessageKind( 57 static final DUPLICATE_INITIALIZER = const MessageKind(
54 'field #{1} is initialized more than once'); 58 'field #{1} is initialized more than once');
55 static final ALREADY_INITIALIZED = const MessageKind( 59 static final ALREADY_INITIALIZED = const MessageKind(
56 '#{1} was already initialized here'); 60 '#{1} was already initialized here');
57 static final INIT_STATIC_FIELD = const MessageKind( 61 static final INIT_STATIC_FIELD = const MessageKind(
58 'cannot initialize static field #{1}'); 62 'cannot initialize static field #{1}');
59 static final NOT_A_FIELD = const MessageKind( 63 static final NOT_A_FIELD = const MessageKind(
60 '#{1} is not a field'); 64 '#{1} is not a field');
61 65
62 toString() => template; 66 toString() => template;
63 } 67 }
64 68
65 class Message { 69 class Message {
66 final kind; 70 final kind;
67 final List arguments; 71 final List arguments;
68 String message; 72 String message;
69 73
70 Message(this.kind, this.arguments); 74 Message(this.kind, this.arguments);
71 75
72 String toString() { 76 String toString() {
73 if (message === null) { 77 if (message === null) {
74 message = kind.template; 78 message = kind.template;
75 int position = 1; 79 int position = 1;
76 for (var argument in arguments) { 80 for (var argument in arguments) {
77 message = message.replaceAll('#{${position++}}', 81 message = message.replaceAll('#{${position++}}', argument.toString());
78 argument.toString());
79 } 82 }
80 } 83 }
81 return message; 84 return message;
82 } 85 }
83 86
84 bool operator==(other) { 87 bool operator==(other) {
85 if (other is !Message) return false; 88 if (other is !Message) return false;
86 return (kind == other.kind) && (toString() == other.toString()); 89 return (kind == other.kind) && (toString() == other.toString());
87 } 90 }
88 } 91 }
(...skipping 14 matching lines...) Expand all
103 String toString() => message.toString(); 106 String toString() => message.toString();
104 } 107 }
105 108
106 class ResolutionWarning { 109 class ResolutionWarning {
107 final Message message; 110 final Message message;
108 ResolutionWarning.message(this.message); 111 ResolutionWarning.message(this.message);
109 ResolutionWarning(MessageKind kind, List<Type> arguments) 112 ResolutionWarning(MessageKind kind, List<Type> arguments)
110 : message = new Message(kind, arguments); 113 : message = new Message(kind, arguments);
111 String toString() => message.toString(); 114 String toString() => message.toString();
112 } 115 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698