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

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

Issue 1417103002: Add ElementKind for factory constructors. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 5 years, 2 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 | « pkg/compiler/lib/src/elements/common.dart ('k') | pkg/compiler/lib/src/elements/modelx.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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; 5 library elements;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/resolution.dart' show 8 import '../common/resolution.dart' show
9 Resolution; 9 Resolution;
10 import '../compiler.dart' show 10 import '../compiler.dart' show
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Parameters in constructors that directly initialize fields. For example: 77 // Parameters in constructors that directly initialize fields. For example:
78 // [:A(this.field):]. 78 // [:A(this.field):].
79 static const ElementKind INITIALIZING_FORMAL = 79 static const ElementKind INITIALIZING_FORMAL =
80 const ElementKind('initializing_formal', ElementCategory.VARIABLE); 80 const ElementKind('initializing_formal', ElementCategory.VARIABLE);
81 static const ElementKind FUNCTION = 81 static const ElementKind FUNCTION =
82 const ElementKind('function', ElementCategory.FUNCTION); 82 const ElementKind('function', ElementCategory.FUNCTION);
83 static const ElementKind CLASS = 83 static const ElementKind CLASS =
84 const ElementKind('class', ElementCategory.CLASS); 84 const ElementKind('class', ElementCategory.CLASS);
85 static const ElementKind GENERATIVE_CONSTRUCTOR = 85 static const ElementKind GENERATIVE_CONSTRUCTOR =
86 const ElementKind('generative_constructor', ElementCategory.FACTORY); 86 const ElementKind('generative_constructor', ElementCategory.FACTORY);
87 static const ElementKind FACTORY_CONSTRUCTOR =
88 const ElementKind('factory_constructor', ElementCategory.FACTORY);
87 static const ElementKind FIELD = 89 static const ElementKind FIELD =
88 const ElementKind('field', ElementCategory.VARIABLE); 90 const ElementKind('field', ElementCategory.VARIABLE);
89 static const ElementKind FIELD_LIST = 91 static const ElementKind FIELD_LIST =
90 const ElementKind('field_list', ElementCategory.NONE); 92 const ElementKind('field_list', ElementCategory.NONE);
91 static const ElementKind GENERATIVE_CONSTRUCTOR_BODY = 93 static const ElementKind GENERATIVE_CONSTRUCTOR_BODY =
92 const ElementKind('generative_constructor_body', ElementCategory.NONE); 94 const ElementKind('generative_constructor_body', ElementCategory.NONE);
93 static const ElementKind COMPILATION_UNIT = 95 static const ElementKind COMPILATION_UNIT =
94 const ElementKind('compilation_unit', ElementCategory.NONE); 96 const ElementKind('compilation_unit', ElementCategory.NONE);
95 static const ElementKind GETTER = 97 static const ElementKind GETTER =
96 const ElementKind('getter', ElementCategory.NONE); 98 const ElementKind('getter', ElementCategory.NONE);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 207
206 /// `true` if this element is a type variable declaration. 208 /// `true` if this element is a type variable declaration.
207 bool get isTypeVariable; 209 bool get isTypeVariable;
208 210
209 /// `true` if this element is a typedef declaration. 211 /// `true` if this element is a typedef declaration.
210 bool get isTypedef; 212 bool get isTypedef;
211 213
212 /// `true` if this element is a top level function, static or instance 214 /// `true` if this element is a top level function, static or instance
213 /// method, local function or closure defined by a function expression. 215 /// method, local function or closure defined by a function expression.
214 /// 216 ///
215 /// This property is `true` for operator methods and factory constructors but 217 /// This property is `true` for operator methods but `false` for getter and
216 /// `false` for getter and setter methods, and generative constructors. 218 /// setter methods, and generative and factory constructors.
217 /// 219 ///
218 /// See also [isConstructor], [isGenerativeConstructor], and 220 /// See also [isConstructor], [isGenerativeConstructor], and
219 /// [isFactoryConstructor] for constructor properties, and [isAccessor], 221 /// [isFactoryConstructor] for constructor properties, and [isAccessor],
220 /// [isGetter] and [isSetter] for getter/setter properties. 222 /// [isGetter] and [isSetter] for getter/setter properties.
221 bool get isFunction; 223 bool get isFunction;
222 224
223 /// `true` if this element is an operator method. 225 /// `true` if this element is an operator method.
224 bool get isOperator; 226 bool get isOperator;
225 227
226 /// `true` if this element is an accessor, that is either an explicit 228 /// `true` if this element is an accessor, that is either an explicit
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 } 494 }
493 495
494 static bool isStaticOrTopLevelField(Element element) { 496 static bool isStaticOrTopLevelField(Element element) {
495 return isStaticOrTopLevel(element) 497 return isStaticOrTopLevel(element)
496 && (identical(element.kind, ElementKind.FIELD) 498 && (identical(element.kind, ElementKind.FIELD)
497 || identical(element.kind, ElementKind.GETTER) 499 || identical(element.kind, ElementKind.GETTER)
498 || identical(element.kind, ElementKind.SETTER)); 500 || identical(element.kind, ElementKind.SETTER));
499 } 501 }
500 502
501 static bool isStaticOrTopLevelFunction(Element element) { 503 static bool isStaticOrTopLevelFunction(Element element) {
502 return isStaticOrTopLevel(element) 504 return isStaticOrTopLevel(element) && element.isFunction;
503 && (identical(element.kind, ElementKind.FUNCTION));
504 } 505 }
505 506
506 static bool isInstanceMethod(Element element) { 507 static bool isInstanceMethod(Element element) {
507 return !Elements.isUnresolved(element) 508 return !Elements.isUnresolved(element)
508 && element.isInstanceMember 509 && element.isInstanceMember
509 && (identical(element.kind, ElementKind.FUNCTION)); 510 && (identical(element.kind, ElementKind.FUNCTION));
510 } 511 }
511 512
512 /// Also returns true for [ConstructorBodyElement]s and getters/setters. 513 /// Also returns true for [ConstructorBodyElement]s and getters/setters.
513 static bool isNonAbstractInstanceMember(Element element) { 514 static bool isNonAbstractInstanceMember(Element element) {
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 bool get isDeclaredByField; 1711 bool get isDeclaredByField;
1711 1712
1712 /// Returns `true` if this member is abstract. 1713 /// Returns `true` if this member is abstract.
1713 bool get isAbstract; 1714 bool get isAbstract;
1714 1715
1715 /// If abstract, [implementation] points to the overridden concrete member, 1716 /// If abstract, [implementation] points to the overridden concrete member,
1716 /// if any. Otherwise [implementation] points to the member itself. 1717 /// if any. Otherwise [implementation] points to the member itself.
1717 Member get implementation; 1718 Member get implementation;
1718 } 1719 }
1719 1720
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/elements/common.dart ('k') | pkg/compiler/lib/src/elements/modelx.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698