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 5154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5165 @override | 5165 @override |
5166 int get nameOffset { | 5166 int get nameOffset { |
5167 int offset = super.nameOffset; | 5167 int offset = super.nameOffset; |
5168 if (offset == 0 && _unlinkedTypedef != null) { | 5168 if (offset == 0 && _unlinkedTypedef != null) { |
5169 return _unlinkedTypedef.nameOffset; | 5169 return _unlinkedTypedef.nameOffset; |
5170 } | 5170 } |
5171 return offset; | 5171 return offset; |
5172 } | 5172 } |
5173 | 5173 |
5174 @override | 5174 @override |
5175 List<ParameterElement> get parameters => function.parameters; | 5175 List<ParameterElement> get parameters => |
| 5176 function?.parameters ?? const <ParameterElement>[]; |
5176 | 5177 |
5177 @override | 5178 @override |
5178 DartType get returnType => function.returnType; | 5179 DartType get returnType => function?.returnType; |
5179 | 5180 |
5180 @override | 5181 @override |
5181 FunctionType get type { | 5182 FunctionType get type { |
5182 if (_unlinkedTypedef != null && _type == null) { | 5183 if (_unlinkedTypedef != null && _type == null) { |
5183 _type = new FunctionTypeImpl.forTypedef(this); | 5184 _type = new FunctionTypeImpl.forTypedef(this); |
5184 } | 5185 } |
5185 return _type; | 5186 return _type; |
5186 } | 5187 } |
5187 | 5188 |
5188 void set type(FunctionType type) { | 5189 void set type(FunctionType type) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5220 buffer.write("<"); | 5221 buffer.write("<"); |
5221 for (int i = 0; i < typeParameterCount; i++) { | 5222 for (int i = 0; i < typeParameterCount; i++) { |
5222 if (i > 0) { | 5223 if (i > 0) { |
5223 buffer.write(", "); | 5224 buffer.write(", "); |
5224 } | 5225 } |
5225 (typeParameters[i] as TypeParameterElementImpl).appendTo(buffer); | 5226 (typeParameters[i] as TypeParameterElementImpl).appendTo(buffer); |
5226 } | 5227 } |
5227 buffer.write(">"); | 5228 buffer.write(">"); |
5228 } | 5229 } |
5229 buffer.write(" = "); | 5230 buffer.write(" = "); |
5230 (function as FunctionElementImpl).appendTo(buffer); | 5231 if (function != null) { |
| 5232 (function as ElementImpl).appendTo(buffer); |
| 5233 } |
5231 } | 5234 } |
5232 | 5235 |
5233 @override | 5236 @override |
5234 FunctionTypeAlias computeNode() => | 5237 FunctionTypeAlias computeNode() => |
5235 getNodeMatching((node) => node is GenericTypeAlias); | 5238 getNodeMatching((node) => node is GenericTypeAlias); |
5236 | 5239 |
5237 @override | 5240 @override |
5238 ElementImpl getChild(String identifier) { | 5241 ElementImpl getChild(String identifier) { |
5239 for (TypeParameterElement typeParameter in typeParameters) { | 5242 for (TypeParameterElement typeParameter in typeParameters) { |
5240 TypeParameterElementImpl typeParameterImpl = typeParameter; | 5243 TypeParameterElementImpl typeParameterImpl = typeParameter; |
(...skipping 3863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9104 | 9107 |
9105 @override | 9108 @override |
9106 void visitElement(Element element) { | 9109 void visitElement(Element element) { |
9107 int offset = element.nameOffset; | 9110 int offset = element.nameOffset; |
9108 if (offset != -1) { | 9111 if (offset != -1) { |
9109 map[offset] = element; | 9112 map[offset] = element; |
9110 } | 9113 } |
9111 super.visitElement(element); | 9114 super.visitElement(element); |
9112 } | 9115 } |
9113 } | 9116 } |
OLD | NEW |