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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/elements/modelx.dart

Issue 18072002: Fix Element.findMyName for named constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/compiler/dart2js/find_my_name_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 elements.modelx; 5 library elements.modelx;
6 6
7 import 'dart:collection' show LinkedHashMap; 7 import 'dart:collection' show LinkedHashMap;
8 8
9 import 'elements.dart'; 9 import 'elements.dart';
10 import '../../compiler.dart' as api; 10 import '../../compiler.dart' as api;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 169
170 bool isAssignable() { 170 bool isAssignable() {
171 if (modifiers.isFinalOrConst()) return false; 171 if (modifiers.isFinalOrConst()) return false;
172 if (isFunction() || isGenerativeConstructor()) return false; 172 if (isFunction() || isGenerativeConstructor()) return false;
173 return true; 173 return true;
174 } 174 }
175 175
176 Token position() => null; 176 Token position() => null;
177 177
178 Token findMyName(Token token) { 178 Token findMyName(Token token) {
179 for (Token t = token; !identical(t.kind, EOF_TOKEN); t = t.next) { 179 // We search for the token that has the name of this element.
180 if (t.value == name) return t; 180 // For constructors, that doesn't work because they may have
181 // named formed out of multiple tokens (named constructors) so
182 // for those we search for the class name instead.
183 String needle = isConstructor() ? enclosingElement.name : name;
184 for (Token t = token; EOF_TOKEN != t.kind; t = t.next) {
185 if (needle == t.value) return t;
181 } 186 }
182 return token; 187 return token;
183 } 188 }
184 189
185 CompilationUnitElement getCompilationUnit() { 190 CompilationUnitElement getCompilationUnit() {
186 Element element = this; 191 Element element = this;
187 while (!element.isCompilationUnit()) { 192 while (!element.isCompilationUnit()) {
188 element = element.enclosingElement; 193 element = element.enclosingElement;
189 } 194 }
190 return element; 195 return element;
(...skipping 2012 matching lines...) Expand 10 before | Expand all | Expand 10 after
2203 2208
2204 MetadataAnnotation ensureResolved(Compiler compiler) { 2209 MetadataAnnotation ensureResolved(Compiler compiler) {
2205 if (resolutionState == STATE_NOT_STARTED) { 2210 if (resolutionState == STATE_NOT_STARTED) {
2206 compiler.resolver.resolveMetadataAnnotation(this); 2211 compiler.resolver.resolveMetadataAnnotation(this);
2207 } 2212 }
2208 return this; 2213 return this;
2209 } 2214 }
2210 2215
2211 String toString() => 'MetadataAnnotation($value, $resolutionState)'; 2216 String toString() => 'MetadataAnnotation($value, $resolutionState)';
2212 } 2217 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/find_my_name_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698