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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/scanner/class_element_parser.dart

Issue 20742002: Clean up error handling. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added documentation guide lines. Created 7 years, 4 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 part of scanner; 5 part of scanner;
6 6
7 class ClassElementParser extends PartialParser { 7 class ClassElementParser extends PartialParser {
8 ClassElementParser(Listener listener) : super(listener); 8 ClassElementParser(Listener listener) : super(listener);
9 9
10 Token parseClassBody(Token token) => fullParseClassBody(token); 10 Token parseClassBody(Token token) => fullParseClassBody(token);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 Identifier selector = send.selector.asIdentifier(); 97 Identifier selector = send.selector.asIdentifier();
98 Operator operator = selector.asOperator(); 98 Operator operator = selector.asOperator();
99 if (operator != null) { 99 if (operator != null) {
100 assert(identical(receiver.source.stringValue, 'operator')); 100 assert(identical(receiver.source.stringValue, 'operator'));
101 // TODO(ahe): It is a hack to compare to ')', but it beats 101 // TODO(ahe): It is a hack to compare to ')', but it beats
102 // parsing the node. 102 // parsing the node.
103 bool isUnary = identical(operator.token.next.next.stringValue, ')'); 103 bool isUnary = identical(operator.token.next.next.stringValue, ')');
104 return Elements.constructOperatorName(operator.source, isUnary); 104 return Elements.constructOperatorName(operator.source, isUnary);
105 } else { 105 } else {
106 if (receiver == null || receiver.source != enclosingElement.name) { 106 if (receiver == null || receiver.source != enclosingElement.name) {
107 listener.reportErrorCode(send.receiver, 107 listener.reportError(send.receiver,
108 MessageKind.INVALID_CONSTRUCTOR_NAME, 108 MessageKind.INVALID_CONSTRUCTOR_NAME,
109 {'name': enclosingElement.name}); 109 {'name': enclosingElement.name});
110 } 110 }
111 return selector.source; 111 return selector.source;
112 } 112 }
113 } 113 }
114 114
115 void endMethod(Token getOrSet, Token beginToken, Token endToken) { 115 void endMethod(Token getOrSet, Token beginToken, Token endToken) {
116 super.endMethod(getOrSet, beginToken, endToken); 116 super.endMethod(getOrSet, beginToken, endToken);
117 FunctionExpression method = popNode(); 117 FunctionExpression method = popNode();
(...skipping 17 matching lines...) Expand all
135 } 135 }
136 136
137 void endFactoryMethod(Token beginToken, Token endToken) { 137 void endFactoryMethod(Token beginToken, Token endToken) {
138 super.endFactoryMethod(beginToken, endToken); 138 super.endFactoryMethod(beginToken, endToken);
139 FunctionExpression method = popNode(); 139 FunctionExpression method = popNode();
140 pushNode(null); 140 pushNode(null);
141 SourceString name = getMethodNameHack(method.name); 141 SourceString name = getMethodNameHack(method.name);
142 Identifier singleIdentifierName = method.name.asIdentifier(); 142 Identifier singleIdentifierName = method.name.asIdentifier();
143 if (singleIdentifierName != null && singleIdentifierName.source == name) { 143 if (singleIdentifierName != null && singleIdentifierName.source == name) {
144 if (name != enclosingElement.name) { 144 if (name != enclosingElement.name) {
145 listener.reportErrorCode(singleIdentifierName, 145 listener.reportError(singleIdentifierName,
146 MessageKind.INVALID_UNNAMED_CONSTRUCTOR_NAME, 146 MessageKind.INVALID_UNNAMED_CONSTRUCTOR_NAME,
147 {'name': enclosingElement.name}); 147 {'name': enclosingElement.name});
148 } 148 }
149 } 149 }
150 ElementKind kind = ElementKind.FUNCTION; 150 ElementKind kind = ElementKind.FUNCTION;
151 Element memberElement = 151 Element memberElement =
152 new PartialFunctionElement(name, beginToken, null, endToken, 152 new PartialFunctionElement(name, beginToken, null, endToken,
153 kind, method.modifiers, enclosingElement); 153 kind, method.modifiers, enclosingElement);
154 addMember(memberElement); 154 addMember(memberElement);
155 } 155 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 void endMetadata(Token beginToken, Token periodBeforeName, Token endToken) { 190 void endMetadata(Token beginToken, Token periodBeforeName, Token endToken) {
191 popNode(); // Discard arguments. 191 popNode(); // Discard arguments.
192 if (periodBeforeName != null) { 192 if (periodBeforeName != null) {
193 popNode(); // Discard name. 193 popNode(); // Discard name.
194 } 194 }
195 popNode(); // Discard node (Send or Identifier). 195 popNode(); // Discard node (Send or Identifier).
196 pushMetadata(new PartialMetadataAnnotation(beginToken, endToken)); 196 pushMetadata(new PartialMetadataAnnotation(beginToken, endToken));
197 } 197 }
198 } 198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698