OLD | NEW |
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 'elements.dart'; | 7 import 'elements.dart'; |
8 import '../helpers/helpers.dart'; // Included for debug helpers. | 8 import '../helpers/helpers.dart'; // Included for debug helpers. |
9 import '../tree/tree.dart'; | 9 import '../tree/tree.dart'; |
10 import '../util/util.dart'; | 10 import '../util/util.dart'; |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 import '../scanner/scannerlib.dart' show | 32 import '../scanner/scannerlib.dart' show |
33 EOF_TOKEN, | 33 EOF_TOKEN, |
34 ErrorToken, | 34 ErrorToken, |
35 Token; | 35 Token; |
36 | 36 |
37 import '../ordered_typeset.dart' show OrderedTypeSet; | 37 import '../ordered_typeset.dart' show OrderedTypeSet; |
38 | 38 |
39 import 'visitor.dart' show ElementVisitor; | 39 import 'visitor.dart' show ElementVisitor; |
40 | 40 |
| 41 abstract class DeclarationSite { |
| 42 } |
| 43 |
41 abstract class ElementX extends Element { | 44 abstract class ElementX extends Element { |
42 static int elementHashCode = 0; | 45 static int elementHashCode = 0; |
43 | 46 |
44 final String name; | 47 final String name; |
45 final ElementKind kind; | 48 final ElementKind kind; |
46 final Element enclosingElement; | 49 final Element enclosingElement; |
47 final int hashCode = ++elementHashCode; | 50 final int hashCode = ++elementHashCode; |
48 Link<MetadataAnnotation> metadata = const Link<MetadataAnnotation>(); | 51 Link<MetadataAnnotation> metadata = const Link<MetadataAnnotation>(); |
49 | 52 |
50 ElementX(this.name, this.kind, this.enclosingElement) { | 53 ElementX(this.name, this.kind, this.enclosingElement) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 257 |
255 bool get hasTreeElements => analyzableElement.hasTreeElements; | 258 bool get hasTreeElements => analyzableElement.hasTreeElements; |
256 | 259 |
257 TreeElements get treeElements => analyzableElement.treeElements; | 260 TreeElements get treeElements => analyzableElement.treeElements; |
258 | 261 |
259 AnalyzableElement get analyzableElement { | 262 AnalyzableElement get analyzableElement { |
260 Element element = outermostEnclosingMemberOrTopLevel; | 263 Element element = outermostEnclosingMemberOrTopLevel; |
261 if (element.isAbstractField || element.isPrefix) return element.library; | 264 if (element.isAbstractField || element.isPrefix) return element.library; |
262 return element; | 265 return element; |
263 } | 266 } |
| 267 |
| 268 DeclarationSite get declarationSite => null; |
264 } | 269 } |
265 | 270 |
266 class ErroneousElementX extends ElementX implements ErroneousElement { | 271 class ErroneousElementX extends ElementX implements ErroneousElement { |
267 final MessageKind messageKind; | 272 final MessageKind messageKind; |
268 final Map messageArguments; | 273 final Map messageArguments; |
269 | 274 |
270 ErroneousElementX(this.messageKind, this.messageArguments, | 275 ErroneousElementX(this.messageKind, this.messageArguments, |
271 String name, Element enclosing) | 276 String name, Element enclosing) |
272 : super(name, ElementKind.ERROR, enclosing); | 277 : super(name, ElementKind.ERROR, enclosing); |
273 | 278 |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 | 1078 |
1074 accept(ElementVisitor visitor) => visitor.visitTypedefElement(this); | 1079 accept(ElementVisitor visitor) => visitor.visitTypedefElement(this); |
1075 | 1080 |
1076 // A typedef cannot be patched therefore defines itself. | 1081 // A typedef cannot be patched therefore defines itself. |
1077 AstElement get definingElement => this; | 1082 AstElement get definingElement => this; |
1078 } | 1083 } |
1079 | 1084 |
1080 // This class holds common information for a list of variable or field | 1085 // This class holds common information for a list of variable or field |
1081 // declarations. It contains the node, and the type. A [VariableElementX] | 1086 // declarations. It contains the node, and the type. A [VariableElementX] |
1082 // forwards its [computeType] and [parseNode] methods to this class. | 1087 // forwards its [computeType] and [parseNode] methods to this class. |
1083 class VariableList { | 1088 class VariableList implements DeclarationSite { |
1084 VariableDefinitions definitions; | 1089 VariableDefinitions definitions; |
1085 DartType type; | 1090 DartType type; |
1086 final Modifiers modifiers; | 1091 final Modifiers modifiers; |
1087 Link<MetadataAnnotation> metadata = const Link<MetadataAnnotation>(); | 1092 Link<MetadataAnnotation> metadata = const Link<MetadataAnnotation>(); |
1088 | 1093 |
1089 VariableList(Modifiers this.modifiers); | 1094 VariableList(Modifiers this.modifiers); |
1090 | 1095 |
1091 VariableList.node(VariableDefinitions node, this.type) | 1096 VariableList.node(VariableDefinitions node, this.type) |
1092 : this.definitions = node, | 1097 : this.definitions = node, |
1093 this.modifiers = node.modifiers { | 1098 this.modifiers = node.modifiers { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 return variables.type; | 1207 return variables.type; |
1203 } | 1208 } |
1204 | 1209 |
1205 bool get isInstanceMember => isClassMember && !isStatic; | 1210 bool get isInstanceMember => isClassMember && !isStatic; |
1206 | 1211 |
1207 // Note: cachedNode.beginToken will not be correct in all | 1212 // Note: cachedNode.beginToken will not be correct in all |
1208 // cases, for example, for function typed parameters. | 1213 // cases, for example, for function typed parameters. |
1209 Token get position => token; | 1214 Token get position => token; |
1210 | 1215 |
1211 accept(ElementVisitor visitor) => visitor.visitVariableElement(this); | 1216 accept(ElementVisitor visitor) => visitor.visitVariableElement(this); |
| 1217 |
| 1218 DeclarationSite get declarationSite => variables; |
1212 } | 1219 } |
1213 | 1220 |
1214 class LocalVariableElementX extends VariableElementX | 1221 class LocalVariableElementX extends VariableElementX |
1215 implements LocalVariableElement { | 1222 implements LocalVariableElement { |
1216 LocalVariableElementX(String name, | 1223 LocalVariableElementX(String name, |
1217 ExecutableElement enclosingElement, | 1224 ExecutableElement enclosingElement, |
1218 VariableList variables, | 1225 VariableList variables, |
1219 Token token) | 1226 Token token) |
1220 : super(name, ElementKind.VARIABLE, enclosingElement, variables, token) { | 1227 : super(name, ElementKind.VARIABLE, enclosingElement, variables, token) { |
1221 createDefinitions(variables.definitions); | 1228 createDefinitions(variables.definitions); |
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2694 AstElement get definingElement; | 2701 AstElement get definingElement; |
2695 | 2702 |
2696 bool get hasResolvedAst => definingElement.hasTreeElements; | 2703 bool get hasResolvedAst => definingElement.hasTreeElements; |
2697 | 2704 |
2698 ResolvedAst get resolvedAst { | 2705 ResolvedAst get resolvedAst { |
2699 return new ResolvedAst(declaration, | 2706 return new ResolvedAst(declaration, |
2700 definingElement.node, definingElement.treeElements); | 2707 definingElement.node, definingElement.treeElements); |
2701 } | 2708 } |
2702 | 2709 |
2703 } | 2710 } |
OLD | NEW |