OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.src.dart.element.element; | 5 library analyzer.src.dart.element.element; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:math' show min; | 8 import 'dart:math' show min; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 this._fields = fields; | 109 this._fields = fields; |
110 } | 110 } |
111 | 111 |
112 @override | 112 @override |
113 bool get isEnum; | 113 bool get isEnum; |
114 | 114 |
115 @override | 115 @override |
116 ElementKind get kind => ElementKind.CLASS; | 116 ElementKind get kind => ElementKind.CLASS; |
117 | 117 |
118 @override | 118 @override |
119 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 119 T accept<T>(ElementVisitor<T> visitor) => visitor.visitClassElement(this); |
120 visitor.visitClassElement(this); | |
121 | 120 |
122 @override | 121 @override |
123 NamedCompilationUnitMember computeNode() { | 122 NamedCompilationUnitMember computeNode() { |
124 if (isEnum) { | 123 if (isEnum) { |
125 return getNodeMatching((node) => node is EnumDeclaration); | 124 return getNodeMatching((node) => node is EnumDeclaration); |
126 } else { | 125 } else { |
127 return getNodeMatching( | 126 return getNodeMatching( |
128 (node) => node is ClassDeclaration || node is ClassTypeAlias); | 127 (node) => node is ClassDeclaration || node is ClassTypeAlias); |
129 } | 128 } |
130 } | 129 } |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 void visitChildren(ElementVisitor visitor) { | 251 void visitChildren(ElementVisitor visitor) { |
253 super.visitChildren(visitor); | 252 super.visitChildren(visitor); |
254 safelyVisitChildren(accessors, visitor); | 253 safelyVisitChildren(accessors, visitor); |
255 safelyVisitChildren(fields, visitor); | 254 safelyVisitChildren(fields, visitor); |
256 } | 255 } |
257 | 256 |
258 /** | 257 /** |
259 * Return the first element from the given [iterable], or `null` if the | 258 * Return the first element from the given [iterable], or `null` if the |
260 * iterable is empty. | 259 * iterable is empty. |
261 */ | 260 */ |
262 Object/*=E*/ _first/*<E>*/(Iterable/*<E>*/ iterable) { | 261 E _first<E>(Iterable<E> iterable) { |
263 if (iterable.isEmpty) { | 262 if (iterable.isEmpty) { |
264 return null; | 263 return null; |
265 } | 264 } |
266 return iterable.first; | 265 return iterable.first; |
267 } | 266 } |
268 | 267 |
269 /** | 268 /** |
270 * Return an iterable containing all of the implementations of a getter with | 269 * Return an iterable containing all of the implementations of a getter with |
271 * the given [getterName] that are defined in this class any any superclass of | 270 * the given [getterName] that are defined in this class any any superclass of |
272 * this class (but not in interfaces). | 271 * this class (but not in interfaces). |
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1605 } | 1604 } |
1606 } | 1605 } |
1607 this._types = types; | 1606 this._types = types; |
1608 } | 1607 } |
1609 | 1608 |
1610 @override | 1609 @override |
1611 bool operator ==(Object object) => | 1610 bool operator ==(Object object) => |
1612 object is CompilationUnitElementImpl && source == object.source; | 1611 object is CompilationUnitElementImpl && source == object.source; |
1613 | 1612 |
1614 @override | 1613 @override |
1615 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 1614 T accept<T>(ElementVisitor<T> visitor) => |
1616 visitor.visitCompilationUnitElement(this); | 1615 visitor.visitCompilationUnitElement(this); |
1617 | 1616 |
1618 /** | 1617 /** |
1619 * This method is invoked after this unit was incrementally resolved. | 1618 * This method is invoked after this unit was incrementally resolved. |
1620 */ | 1619 */ |
1621 void afterIncrementalResolution() { | 1620 void afterIncrementalResolution() { |
1622 _offsetToElementMap.clear(); | 1621 _offsetToElementMap.clear(); |
1623 } | 1622 } |
1624 | 1623 |
1625 @override | 1624 @override |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2160 @override | 2159 @override |
2161 FunctionType get type { | 2160 FunctionType get type { |
2162 return _type ??= new FunctionTypeImpl(this); | 2161 return _type ??= new FunctionTypeImpl(this); |
2163 } | 2162 } |
2164 | 2163 |
2165 void set type(FunctionType type) { | 2164 void set type(FunctionType type) { |
2166 assert(false); | 2165 assert(false); |
2167 } | 2166 } |
2168 | 2167 |
2169 @override | 2168 @override |
2170 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 2169 T accept<T>(ElementVisitor<T> visitor) => |
2171 visitor.visitConstructorElement(this); | 2170 visitor.visitConstructorElement(this); |
2172 | 2171 |
2173 @override | 2172 @override |
2174 void appendTo(StringBuffer buffer) { | 2173 void appendTo(StringBuffer buffer) { |
2175 if (enclosingElement == null) { | 2174 if (enclosingElement == null) { |
2176 String message; | 2175 String message; |
2177 String name = displayName; | 2176 String name = displayName; |
2178 if (name != null && !name.isEmpty) { | 2177 if (name != null && !name.isEmpty) { |
2179 message = | 2178 message = |
2180 'Found constructor element named $name with no enclosing element'; | 2179 'Found constructor element named $name with no enclosing element'; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2427 * through the method [instance]. | 2426 * through the method [instance]. |
2428 */ | 2427 */ |
2429 DynamicElementImpl() : super(Keyword.DYNAMIC.lexeme, -1) { | 2428 DynamicElementImpl() : super(Keyword.DYNAMIC.lexeme, -1) { |
2430 setModifier(Modifier.SYNTHETIC, true); | 2429 setModifier(Modifier.SYNTHETIC, true); |
2431 } | 2430 } |
2432 | 2431 |
2433 @override | 2432 @override |
2434 ElementKind get kind => ElementKind.DYNAMIC; | 2433 ElementKind get kind => ElementKind.DYNAMIC; |
2435 | 2434 |
2436 @override | 2435 @override |
2437 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => null; | 2436 T accept<T>(ElementVisitor<T> visitor) => null; |
2438 } | 2437 } |
2439 | 2438 |
2440 /** | 2439 /** |
2441 * A concrete implementation of an [ElementAnnotation]. | 2440 * A concrete implementation of an [ElementAnnotation]. |
2442 */ | 2441 */ |
2443 class ElementAnnotationImpl implements ElementAnnotation { | 2442 class ElementAnnotationImpl implements ElementAnnotation { |
2444 /** | 2443 /** |
2445 * The name of the top-level variable used to mark a method parameter as | 2444 * The name of the top-level variable used to mark a method parameter as |
2446 * covariant. | 2445 * covariant. |
2447 */ | 2446 */ |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3018 AstNode computeNode() => getNodeMatching((node) => node is AstNode); | 3017 AstNode computeNode() => getNodeMatching((node) => node is AstNode); |
3019 | 3018 |
3020 /** | 3019 /** |
3021 * Set this element as the enclosing element for given [element]. | 3020 * Set this element as the enclosing element for given [element]. |
3022 */ | 3021 */ |
3023 void encloseElement(ElementImpl element) { | 3022 void encloseElement(ElementImpl element) { |
3024 element.enclosingElement = this; | 3023 element.enclosingElement = this; |
3025 } | 3024 } |
3026 | 3025 |
3027 @override | 3026 @override |
3028 Element/*=E*/ getAncestor/*<E extends Element >*/( | 3027 E getAncestor<E extends Element>(Predicate<Element> predicate) { |
3029 Predicate<Element> predicate) { | |
3030 Element ancestor = _enclosingElement; | 3028 Element ancestor = _enclosingElement; |
3031 while (ancestor != null && !predicate(ancestor)) { | 3029 while (ancestor != null && !predicate(ancestor)) { |
3032 ancestor = ancestor.enclosingElement; | 3030 ancestor = ancestor.enclosingElement; |
3033 } | 3031 } |
3034 return ancestor as Element/*=E*/; | 3032 return ancestor as E; |
3035 } | 3033 } |
3036 | 3034 |
3037 /** | 3035 /** |
3038 * Return the child of this element that is uniquely identified by the given | 3036 * Return the child of this element that is uniquely identified by the given |
3039 * [identifier], or `null` if there is no such child. | 3037 * [identifier], or `null` if there is no such child. |
3040 */ | 3038 */ |
3041 ElementImpl getChild(String identifier) => null; | 3039 ElementImpl getChild(String identifier) => null; |
3042 | 3040 |
3043 @override | 3041 @override |
3044 String getExtendedDisplayName(String shortName) { | 3042 String getExtendedDisplayName(String shortName) { |
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4158 return super.uriOffset; | 4156 return super.uriOffset; |
4159 } | 4157 } |
4160 | 4158 |
4161 @override | 4159 @override |
4162 void set uriOffset(int uriOffset) { | 4160 void set uriOffset(int uriOffset) { |
4163 _assertNotResynthesized(_unlinkedExportNonPublic); | 4161 _assertNotResynthesized(_unlinkedExportNonPublic); |
4164 super.uriOffset = uriOffset; | 4162 super.uriOffset = uriOffset; |
4165 } | 4163 } |
4166 | 4164 |
4167 @override | 4165 @override |
4168 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 4166 T accept<T>(ElementVisitor<T> visitor) => visitor.visitExportElement(this); |
4169 visitor.visitExportElement(this); | |
4170 | 4167 |
4171 @override | 4168 @override |
4172 void appendTo(StringBuffer buffer) { | 4169 void appendTo(StringBuffer buffer) { |
4173 buffer.write("export "); | 4170 buffer.write("export "); |
4174 LibraryElementImpl.getImpl(exportedLibrary).appendTo(buffer); | 4171 LibraryElementImpl.getImpl(exportedLibrary).appendTo(buffer); |
4175 } | 4172 } |
4176 } | 4173 } |
4177 | 4174 |
4178 /** | 4175 /** |
4179 * A concrete implementation of a [FieldElement]. | 4176 * A concrete implementation of a [FieldElement]. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4255 setModifier(Modifier.STATIC, isStatic); | 4252 setModifier(Modifier.STATIC, isStatic); |
4256 } | 4253 } |
4257 | 4254 |
4258 @override | 4255 @override |
4259 bool get isVirtual => true; | 4256 bool get isVirtual => true; |
4260 | 4257 |
4261 @override | 4258 @override |
4262 ElementKind get kind => ElementKind.FIELD; | 4259 ElementKind get kind => ElementKind.FIELD; |
4263 | 4260 |
4264 @override | 4261 @override |
4265 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 4262 T accept<T>(ElementVisitor<T> visitor) => visitor.visitFieldElement(this); |
4266 visitor.visitFieldElement(this); | |
4267 | 4263 |
4268 @override | 4264 @override |
4269 AstNode computeNode() { | 4265 AstNode computeNode() { |
4270 if (isEnumConstant) { | 4266 if (isEnumConstant) { |
4271 return getNodeMatching((node) => node is EnumConstantDeclaration); | 4267 return getNodeMatching((node) => node is EnumConstantDeclaration); |
4272 } else { | 4268 } else { |
4273 return getNodeMatching((node) => node is VariableDeclaration); | 4269 return getNodeMatching((node) => node is VariableDeclaration); |
4274 } | 4270 } |
4275 } | 4271 } |
4276 } | 4272 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4339 return super.type; | 4335 return super.type; |
4340 } | 4336 } |
4341 | 4337 |
4342 @override | 4338 @override |
4343 void set type(DartType type) { | 4339 void set type(DartType type) { |
4344 _assertNotResynthesized(_unlinkedParam); | 4340 _assertNotResynthesized(_unlinkedParam); |
4345 _type = type; | 4341 _type = type; |
4346 } | 4342 } |
4347 | 4343 |
4348 @override | 4344 @override |
4349 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 4345 T accept<T>(ElementVisitor<T> visitor) => |
4350 visitor.visitFieldFormalParameterElement(this); | 4346 visitor.visitFieldFormalParameterElement(this); |
4351 } | 4347 } |
4352 | 4348 |
4353 /** | 4349 /** |
4354 * A concrete implementation of a [FunctionElement]. | 4350 * A concrete implementation of a [FunctionElement]. |
4355 */ | 4351 */ |
4356 class FunctionElementImpl extends ExecutableElementImpl | 4352 class FunctionElementImpl extends ExecutableElementImpl |
4357 implements FunctionElement { | 4353 implements FunctionElement { |
4358 /** | 4354 /** |
4359 * The offset to the beginning of the visible range for this element. | 4355 * The offset to the beginning of the visible range for this element. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4441 return new SourceRange(serializedExecutable.visibleOffset, | 4437 return new SourceRange(serializedExecutable.visibleOffset, |
4442 serializedExecutable.visibleLength); | 4438 serializedExecutable.visibleLength); |
4443 } | 4439 } |
4444 if (_visibleRangeLength < 0) { | 4440 if (_visibleRangeLength < 0) { |
4445 return null; | 4441 return null; |
4446 } | 4442 } |
4447 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); | 4443 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); |
4448 } | 4444 } |
4449 | 4445 |
4450 @override | 4446 @override |
4451 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 4447 T accept<T>(ElementVisitor<T> visitor) => visitor.visitFunctionElement(this); |
4452 visitor.visitFunctionElement(this); | |
4453 | 4448 |
4454 @override | 4449 @override |
4455 void appendTo(StringBuffer buffer) { | 4450 void appendTo(StringBuffer buffer) { |
4456 String name = displayName; | 4451 String name = displayName; |
4457 if (name != null) { | 4452 if (name != null) { |
4458 buffer.write(name); | 4453 buffer.write(name); |
4459 } | 4454 } |
4460 super.appendTo(buffer); | 4455 super.appendTo(buffer); |
4461 } | 4456 } |
4462 | 4457 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4763 (typeParameter as TypeParameterElementImpl).enclosingElement = this; | 4758 (typeParameter as TypeParameterElementImpl).enclosingElement = this; |
4764 } | 4759 } |
4765 this._typeParameterElements = typeParameters; | 4760 this._typeParameterElements = typeParameters; |
4766 } | 4761 } |
4767 | 4762 |
4768 @override | 4763 @override |
4769 List<UnlinkedTypeParam> get unlinkedTypeParams => | 4764 List<UnlinkedTypeParam> get unlinkedTypeParams => |
4770 _unlinkedTypedef?.typeParameters; | 4765 _unlinkedTypedef?.typeParameters; |
4771 | 4766 |
4772 @override | 4767 @override |
4773 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 4768 T accept<T>(ElementVisitor<T> visitor) => |
4774 visitor.visitFunctionTypeAliasElement(this); | 4769 visitor.visitFunctionTypeAliasElement(this); |
4775 | 4770 |
4776 @override | 4771 @override |
4777 void appendTo(StringBuffer buffer) { | 4772 void appendTo(StringBuffer buffer) { |
4778 buffer.write("typedef "); | 4773 buffer.write("typedef "); |
4779 buffer.write(displayName); | 4774 buffer.write(displayName); |
4780 List<TypeParameterElement> typeParameters = this.typeParameters; | 4775 List<TypeParameterElement> typeParameters = this.typeParameters; |
4781 int typeParameterCount = typeParameters.length; | 4776 int typeParameterCount = typeParameters.length; |
4782 if (typeParameterCount > 0) { | 4777 if (typeParameterCount > 0) { |
4783 buffer.write("<"); | 4778 buffer.write("<"); |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5174 (typeParameter as TypeParameterElementImpl).enclosingElement = this; | 5169 (typeParameter as TypeParameterElementImpl).enclosingElement = this; |
5175 } | 5170 } |
5176 this._typeParameterElements = typeParameters; | 5171 this._typeParameterElements = typeParameters; |
5177 } | 5172 } |
5178 | 5173 |
5179 @override | 5174 @override |
5180 List<UnlinkedTypeParam> get unlinkedTypeParams => | 5175 List<UnlinkedTypeParam> get unlinkedTypeParams => |
5181 _unlinkedTypedef?.typeParameters; | 5176 _unlinkedTypedef?.typeParameters; |
5182 | 5177 |
5183 @override | 5178 @override |
5184 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 5179 T accept<T>(ElementVisitor<T> visitor) => |
5185 visitor.visitFunctionTypeAliasElement(this); | 5180 visitor.visitFunctionTypeAliasElement(this); |
5186 | 5181 |
5187 @override | 5182 @override |
5188 void appendTo(StringBuffer buffer) { | 5183 void appendTo(StringBuffer buffer) { |
5189 buffer.write("typedef "); | 5184 buffer.write("typedef "); |
5190 buffer.write(displayName); | 5185 buffer.write(displayName); |
5191 var typeParameters = this.typeParameters; | 5186 var typeParameters = this.typeParameters; |
5192 int typeParameterCount = typeParameters.length; | 5187 int typeParameterCount = typeParameters.length; |
5193 if (typeParameterCount > 0) { | 5188 if (typeParameterCount > 0) { |
5194 buffer.write("<"); | 5189 buffer.write("<"); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5528 return super.uriOffset; | 5523 return super.uriOffset; |
5529 } | 5524 } |
5530 | 5525 |
5531 @override | 5526 @override |
5532 void set uriOffset(int uriOffset) { | 5527 void set uriOffset(int uriOffset) { |
5533 _assertNotResynthesized(_unlinkedImport); | 5528 _assertNotResynthesized(_unlinkedImport); |
5534 super.uriOffset = uriOffset; | 5529 super.uriOffset = uriOffset; |
5535 } | 5530 } |
5536 | 5531 |
5537 @override | 5532 @override |
5538 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 5533 T accept<T>(ElementVisitor<T> visitor) => visitor.visitImportElement(this); |
5539 visitor.visitImportElement(this); | |
5540 | 5534 |
5541 @override | 5535 @override |
5542 void appendTo(StringBuffer buffer) { | 5536 void appendTo(StringBuffer buffer) { |
5543 buffer.write("import "); | 5537 buffer.write("import "); |
5544 LibraryElementImpl.getImpl(importedLibrary).appendTo(buffer); | 5538 LibraryElementImpl.getImpl(importedLibrary).appendTo(buffer); |
5545 } | 5539 } |
5546 | 5540 |
5547 @override | 5541 @override |
5548 void visitChildren(ElementVisitor visitor) { | 5542 void visitChildren(ElementVisitor visitor) { |
5549 super.visitChildren(visitor); | 5543 super.visitChildren(visitor); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5658 int offset = super.nameOffset; | 5652 int offset = super.nameOffset; |
5659 if (offset == 0 && | 5653 if (offset == 0 && |
5660 _unlinkedLabel != null && | 5654 _unlinkedLabel != null && |
5661 _unlinkedLabel.nameOffset != 0) { | 5655 _unlinkedLabel.nameOffset != 0) { |
5662 return _unlinkedLabel.nameOffset; | 5656 return _unlinkedLabel.nameOffset; |
5663 } | 5657 } |
5664 return offset; | 5658 return offset; |
5665 } | 5659 } |
5666 | 5660 |
5667 @override | 5661 @override |
5668 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 5662 T accept<T>(ElementVisitor<T> visitor) => visitor.visitLabelElement(this); |
5669 visitor.visitLabelElement(this); | |
5670 | 5663 |
5671 /** | 5664 /** |
5672 * Create and return [LabelElement]s for the given [unlinkedLabels]. | 5665 * Create and return [LabelElement]s for the given [unlinkedLabels]. |
5673 */ | 5666 */ |
5674 static List<LabelElement> resynthesizeList( | 5667 static List<LabelElement> resynthesizeList( |
5675 ExecutableElementImpl enclosingExecutable, | 5668 ExecutableElementImpl enclosingExecutable, |
5676 List<UnlinkedLabel> unlinkedLabels) { | 5669 List<UnlinkedLabel> unlinkedLabels) { |
5677 int length = unlinkedLabels.length; | 5670 int length = unlinkedLabels.length; |
5678 if (length != 0) { | 5671 if (length != 0) { |
5679 List<LabelElement> elements = new List<LabelElement>(length); | 5672 List<LabelElement> elements = new List<LabelElement>(length); |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6210 | 6203 |
6211 @override | 6204 @override |
6212 List<CompilationUnitElement> get units { | 6205 List<CompilationUnitElement> get units { |
6213 List<CompilationUnitElement> units = new List<CompilationUnitElement>(); | 6206 List<CompilationUnitElement> units = new List<CompilationUnitElement>(); |
6214 units.add(_definingCompilationUnit); | 6207 units.add(_definingCompilationUnit); |
6215 units.addAll(_parts); | 6208 units.addAll(_parts); |
6216 return units; | 6209 return units; |
6217 } | 6210 } |
6218 | 6211 |
6219 @override | 6212 @override |
6220 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 6213 T accept<T>(ElementVisitor<T> visitor) => visitor.visitLibraryElement(this); |
6221 visitor.visitLibraryElement(this); | |
6222 | 6214 |
6223 /** | 6215 /** |
6224 * Create the [FunctionElement] to be returned by [loadLibraryFunction], | 6216 * Create the [FunctionElement] to be returned by [loadLibraryFunction], |
6225 * using types provided by [typeProvider]. | 6217 * using types provided by [typeProvider]. |
6226 */ | 6218 */ |
6227 void createLoadLibraryFunction(TypeProvider typeProvider) { | 6219 void createLoadLibraryFunction(TypeProvider typeProvider) { |
6228 FunctionElementImpl function = | 6220 FunctionElementImpl function = |
6229 new FunctionElementImpl(FunctionElement.LOAD_LIBRARY_NAME, -1); | 6221 new FunctionElementImpl(FunctionElement.LOAD_LIBRARY_NAME, -1); |
6230 function.isSynthetic = true; | 6222 function.isSynthetic = true; |
6231 function.enclosingElement = this; | 6223 function.enclosingElement = this; |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6511 return new SourceRange( | 6503 return new SourceRange( |
6512 _unlinkedVariable.visibleOffset, _unlinkedVariable.visibleLength); | 6504 _unlinkedVariable.visibleOffset, _unlinkedVariable.visibleLength); |
6513 } | 6505 } |
6514 if (_visibleRangeLength < 0) { | 6506 if (_visibleRangeLength < 0) { |
6515 return null; | 6507 return null; |
6516 } | 6508 } |
6517 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); | 6509 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); |
6518 } | 6510 } |
6519 | 6511 |
6520 @override | 6512 @override |
6521 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 6513 T accept<T>(ElementVisitor<T> visitor) => |
6522 visitor.visitLocalVariableElement(this); | 6514 visitor.visitLocalVariableElement(this); |
6523 | 6515 |
6524 @override | 6516 @override |
6525 void appendTo(StringBuffer buffer) { | 6517 void appendTo(StringBuffer buffer) { |
6526 buffer.write(type); | 6518 buffer.write(type); |
6527 buffer.write(" "); | 6519 buffer.write(" "); |
6528 buffer.write(displayName); | 6520 buffer.write(displayName); |
6529 } | 6521 } |
6530 | 6522 |
6531 @override | 6523 @override |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6632 @override | 6624 @override |
6633 String get name { | 6625 String get name { |
6634 String name = super.name; | 6626 String name = super.name; |
6635 if (name == '-' && parameters.isEmpty) { | 6627 if (name == '-' && parameters.isEmpty) { |
6636 return 'unary-'; | 6628 return 'unary-'; |
6637 } | 6629 } |
6638 return super.name; | 6630 return super.name; |
6639 } | 6631 } |
6640 | 6632 |
6641 @override | 6633 @override |
6642 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 6634 T accept<T>(ElementVisitor<T> visitor) => visitor.visitMethodElement(this); |
6643 visitor.visitMethodElement(this); | |
6644 | 6635 |
6645 @override | 6636 @override |
6646 void appendTo(StringBuffer buffer) { | 6637 void appendTo(StringBuffer buffer) { |
6647 buffer.write(displayName); | 6638 buffer.write(displayName); |
6648 super.appendTo(buffer); | 6639 super.appendTo(buffer); |
6649 } | 6640 } |
6650 | 6641 |
6651 @override | 6642 @override |
6652 MethodDeclaration computeNode() => | 6643 MethodDeclaration computeNode() => |
6653 getNodeMatching((node) => node is MethodDeclaration); | 6644 getNodeMatching((node) => node is MethodDeclaration); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6956 @override | 6947 @override |
6957 Source get source => null; | 6948 Source get source => null; |
6958 | 6949 |
6959 @override | 6950 @override |
6960 DartType get type => DynamicTypeImpl.instance; | 6951 DartType get type => DynamicTypeImpl.instance; |
6961 | 6952 |
6962 @override | 6953 @override |
6963 CompilationUnit get unit => null; | 6954 CompilationUnit get unit => null; |
6964 | 6955 |
6965 @override | 6956 @override |
6966 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 6957 T accept<T>(ElementVisitor<T> visitor) => |
6967 visitor.visitMultiplyDefinedElement(this); | 6958 visitor.visitMultiplyDefinedElement(this); |
6968 | 6959 |
6969 @override | 6960 @override |
6970 String computeDocumentationComment() => null; | 6961 String computeDocumentationComment() => null; |
6971 | 6962 |
6972 @override | 6963 @override |
6973 AstNode computeNode() => null; | 6964 AstNode computeNode() => null; |
6974 | 6965 |
6975 @override | 6966 @override |
6976 Element/*=E*/ getAncestor/*<E extends Element >*/( | 6967 E getAncestor<E extends Element>(Predicate<Element> predicate) => null; |
6977 Predicate<Element> predicate) => | |
6978 null; | |
6979 | 6968 |
6980 @override | 6969 @override |
6981 String getExtendedDisplayName(String shortName) { | 6970 String getExtendedDisplayName(String shortName) { |
6982 if (shortName != null) { | 6971 if (shortName != null) { |
6983 return shortName; | 6972 return shortName; |
6984 } | 6973 } |
6985 return displayName; | 6974 return displayName; |
6986 } | 6975 } |
6987 | 6976 |
6988 @override | 6977 @override |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7693 } | 7682 } |
7694 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); | 7683 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); |
7695 } | 7684 } |
7696 | 7685 |
7697 /** | 7686 /** |
7698 * Subclasses need this getter, see [ConstVariableElement._unlinkedConst]. | 7687 * Subclasses need this getter, see [ConstVariableElement._unlinkedConst]. |
7699 */ | 7688 */ |
7700 UnlinkedExpr get _unlinkedConst => _unlinkedParam?.initializer?.bodyExpr; | 7689 UnlinkedExpr get _unlinkedConst => _unlinkedParam?.initializer?.bodyExpr; |
7701 | 7690 |
7702 @override | 7691 @override |
7703 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 7692 T accept<T>(ElementVisitor<T> visitor) => visitor.visitParameterElement(this); |
7704 visitor.visitParameterElement(this); | |
7705 | 7693 |
7706 @override | 7694 @override |
7707 void appendTo(StringBuffer buffer) { | 7695 void appendTo(StringBuffer buffer) { |
7708 String left = ""; | 7696 String left = ""; |
7709 String right = ""; | 7697 String right = ""; |
7710 while (true) { | 7698 while (true) { |
7711 if (parameterKind == ParameterKind.NAMED) { | 7699 if (parameterKind == ParameterKind.NAMED) { |
7712 left = "{"; | 7700 left = "{"; |
7713 right = "}"; | 7701 right = "}"; |
7714 } else if (parameterKind == ParameterKind.POSITIONAL) { | 7702 } else if (parameterKind == ParameterKind.POSITIONAL) { |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7953 @override | 7941 @override |
7954 int get nameOffset { | 7942 int get nameOffset { |
7955 int offset = super.nameOffset; | 7943 int offset = super.nameOffset; |
7956 if (offset == 0 && _unlinkedImport != null) { | 7944 if (offset == 0 && _unlinkedImport != null) { |
7957 return _unlinkedImport.prefixOffset; | 7945 return _unlinkedImport.prefixOffset; |
7958 } | 7946 } |
7959 return offset; | 7947 return offset; |
7960 } | 7948 } |
7961 | 7949 |
7962 @override | 7950 @override |
7963 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 7951 T accept<T>(ElementVisitor<T> visitor) => visitor.visitPrefixElement(this); |
7964 visitor.visitPrefixElement(this); | |
7965 | 7952 |
7966 @override | 7953 @override |
7967 void appendTo(StringBuffer buffer) { | 7954 void appendTo(StringBuffer buffer) { |
7968 buffer.write("as "); | 7955 buffer.write("as "); |
7969 super.appendTo(buffer); | 7956 super.appendTo(buffer); |
7970 } | 7957 } |
7971 } | 7958 } |
7972 | 7959 |
7973 /** | 7960 /** |
7974 * A concrete implementation of a [PropertyAccessorElement]. | 7961 * A concrete implementation of a [PropertyAccessorElement]. |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8126 | 8113 |
8127 /** | 8114 /** |
8128 * Set whether this accessor is a setter. | 8115 * Set whether this accessor is a setter. |
8129 */ | 8116 */ |
8130 void set setter(bool isSetter) { | 8117 void set setter(bool isSetter) { |
8131 _assertNotResynthesized(serializedExecutable); | 8118 _assertNotResynthesized(serializedExecutable); |
8132 setModifier(Modifier.SETTER, isSetter); | 8119 setModifier(Modifier.SETTER, isSetter); |
8133 } | 8120 } |
8134 | 8121 |
8135 @override | 8122 @override |
8136 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 8123 T accept<T>(ElementVisitor<T> visitor) => |
8137 visitor.visitPropertyAccessorElement(this); | 8124 visitor.visitPropertyAccessorElement(this); |
8138 | 8125 |
8139 @override | 8126 @override |
8140 void appendTo(StringBuffer buffer) { | 8127 void appendTo(StringBuffer buffer) { |
8141 buffer.write(isGetter ? "get " : "set "); | 8128 buffer.write(isGetter ? "get " : "set "); |
8142 buffer.write(variable.displayName); | 8129 buffer.write(variable.displayName); |
8143 super.appendTo(buffer); | 8130 super.appendTo(buffer); |
8144 } | 8131 } |
8145 | 8132 |
8146 @override | 8133 @override |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8492 UnlinkedVariable unlinkedVariable, ElementImpl enclosingElement) | 8479 UnlinkedVariable unlinkedVariable, ElementImpl enclosingElement) |
8493 : super.forSerialized(unlinkedVariable, enclosingElement); | 8480 : super.forSerialized(unlinkedVariable, enclosingElement); |
8494 | 8481 |
8495 @override | 8482 @override |
8496 bool get isStatic => true; | 8483 bool get isStatic => true; |
8497 | 8484 |
8498 @override | 8485 @override |
8499 ElementKind get kind => ElementKind.TOP_LEVEL_VARIABLE; | 8486 ElementKind get kind => ElementKind.TOP_LEVEL_VARIABLE; |
8500 | 8487 |
8501 @override | 8488 @override |
8502 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 8489 T accept<T>(ElementVisitor<T> visitor) => |
8503 visitor.visitTopLevelVariableElement(this); | 8490 visitor.visitTopLevelVariableElement(this); |
8504 | 8491 |
8505 @override | 8492 @override |
8506 VariableDeclaration computeNode() => | 8493 VariableDeclaration computeNode() => |
8507 getNodeMatching((node) => node is VariableDeclaration); | 8494 getNodeMatching((node) => node is VariableDeclaration); |
8508 } | 8495 } |
8509 | 8496 |
8510 /** | 8497 /** |
8511 * A concrete implementation of a [TypeParameterElement]. | 8498 * A concrete implementation of a [TypeParameterElement]. |
8512 */ | 8499 */ |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8641 _type ??= new TypeParameterTypeImpl(this); | 8628 _type ??= new TypeParameterTypeImpl(this); |
8642 } | 8629 } |
8643 return _type; | 8630 return _type; |
8644 } | 8631 } |
8645 | 8632 |
8646 void set type(TypeParameterType type) { | 8633 void set type(TypeParameterType type) { |
8647 _type = type; | 8634 _type = type; |
8648 } | 8635 } |
8649 | 8636 |
8650 @override | 8637 @override |
8651 /*=T*/ accept/*<T>*/(ElementVisitor<dynamic/*=T*/ > visitor) => | 8638 T accept<T>(ElementVisitor<T> visitor) => |
8652 visitor.visitTypeParameterElement(this); | 8639 visitor.visitTypeParameterElement(this); |
8653 | 8640 |
8654 @override | 8641 @override |
8655 void appendTo(StringBuffer buffer) { | 8642 void appendTo(StringBuffer buffer) { |
8656 buffer.write(displayName); | 8643 buffer.write(displayName); |
8657 if (bound != null) { | 8644 if (bound != null) { |
8658 buffer.write(" extends "); | 8645 buffer.write(" extends "); |
8659 buffer.write(bound); | 8646 buffer.write(bound); |
8660 } | 8647 } |
8661 } | 8648 } |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9093 | 9080 |
9094 @override | 9081 @override |
9095 void visitElement(Element element) { | 9082 void visitElement(Element element) { |
9096 int offset = element.nameOffset; | 9083 int offset = element.nameOffset; |
9097 if (offset != -1) { | 9084 if (offset != -1) { |
9098 map[offset] = element; | 9085 map[offset] = element; |
9099 } | 9086 } |
9100 super.visitElement(element); | 9087 super.visitElement(element); |
9101 } | 9088 } |
9102 } | 9089 } |
OLD | NEW |