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

Side by Side Diff: pkg/compiler/lib/src/elements/modelx.dart

Issue 2619243002: Make .enclosingClass always return the declaration (Closed)
Patch Set: Updated cf. comments Created 3 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/inferrer/inferrer_engine.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 '../common.dart'; 7 import '../common.dart';
8 import '../common/names.dart' show Identifiers; 8 import '../common/names.dart' show Identifiers;
9 import '../common/resolution.dart' show Resolution, ParsingContext; 9 import '../common/resolution.dart' show Resolution, ParsingContext;
10 import '../compiler.dart' show Compiler; 10 import '../compiler.dart' show Compiler;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 LibraryElement get implementationLibrary { 156 LibraryElement get implementationLibrary {
157 Element element = this; 157 Element element = this;
158 while (!identical(element.kind, ElementKind.LIBRARY)) { 158 while (!identical(element.kind, ElementKind.LIBRARY)) {
159 element = element.enclosingElement; 159 element = element.enclosingElement;
160 } 160 }
161 return element; 161 return element;
162 } 162 }
163 163
164 ClassElement get enclosingClass { 164 ClassElement get enclosingClass {
165 for (Element e = this; e != null; e = e.enclosingElement) { 165 for (Element e = this; e != null; e = e.enclosingElement) {
166 if (e.isClass) return e; 166 if (e.isClass) return e.declaration;
167 } 167 }
168 return null; 168 return null;
169 } 169 }
170 170
171 /** 171 /**
172 * Creates the scope for this element. 172 * Creates the scope for this element.
173 */ 173 */
174 Scope buildScope() => enclosingElement.buildScope(); 174 Scope buildScope() => enclosingElement.buildScope();
175 175
176 String toString() { 176 String toString() {
(...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after
2350 message: 'Malformedness has not yet been computed for $this.')); 2350 message: 'Malformedness has not yet been computed for $this.'));
2351 return _isEffectiveTargetMalformed == true; 2351 return _isEffectiveTargetMalformed == true;
2352 } 2352 }
2353 2353
2354 accept(ElementVisitor visitor, arg) { 2354 accept(ElementVisitor visitor, arg) {
2355 return visitor.visitConstructorElement(this, arg); 2355 return visitor.visitConstructorElement(this, arg);
2356 } 2356 }
2357 2357
2358 ConstructorElement get definingConstructor => null; 2358 ConstructorElement get definingConstructor => null;
2359 2359
2360 ClassElement get enclosingClass => enclosingElement; 2360 ClassElement get enclosingClass => enclosingElement.declaration;
2361 } 2361 }
2362 2362
2363 class DeferredLoaderGetterElementX extends GetterElementX 2363 class DeferredLoaderGetterElementX extends GetterElementX
2364 implements GetterElement { 2364 implements GetterElement {
2365 final PrefixElement prefix; 2365 final PrefixElement prefix;
2366 2366
2367 DeferredLoaderGetterElementX(PrefixElement prefix) 2367 DeferredLoaderGetterElementX(PrefixElement prefix)
2368 : this.prefix = prefix, 2368 : this.prefix = prefix,
2369 super(Identifiers.loadLibrary, Modifiers.EMPTY, prefix, false) { 2369 super(Identifiers.loadLibrary, Modifiers.EMPTY, prefix, false) {
2370 functionSignature = 2370 functionSignature =
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after
3421 body = node.asFunctionExpression().body; 3421 body = node.asFunctionExpression().body;
3422 } 3422 }
3423 return new ParsedResolvedAst( 3423 return new ParsedResolvedAst(
3424 declaration, 3424 declaration,
3425 node, 3425 node,
3426 body, 3426 body,
3427 definingElement.treeElements, 3427 definingElement.treeElements,
3428 definingElement.compilationUnit.script.resourceUri); 3428 definingElement.compilationUnit.script.resourceUri);
3429 } 3429 }
3430 } 3430 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/inferrer/inferrer_engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698