| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'package:analyzer/dart/ast/ast.dart'; | 5 import 'package:analyzer/dart/ast/ast.dart'; |
| 6 import 'package:analyzer/dart/ast/token.dart'; | 6 import 'package:analyzer/dart/ast/token.dart'; |
| 7 import 'package:analyzer/dart/ast/visitor.dart'; | 7 import 'package:analyzer/dart/ast/visitor.dart'; |
| 8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
| 9 import 'package:analyzer/dart/element/type.dart'; | 9 import 'package:analyzer/dart/element/type.dart'; |
| 10 import 'package:analyzer/src/dart/element/member.dart'; | 10 import 'package:analyzer/src/dart/element/member.dart'; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 IndexSyntheticElementKind kind = IndexSyntheticElementKind.notSynthetic; | 202 IndexSyntheticElementKind kind = IndexSyntheticElementKind.notSynthetic; |
| 203 if (element.isSynthetic) { | 203 if (element.isSynthetic) { |
| 204 if (element is ConstructorElement) { | 204 if (element is ConstructorElement) { |
| 205 kind = IndexSyntheticElementKind.constructor; | 205 kind = IndexSyntheticElementKind.constructor; |
| 206 element = element.enclosingElement; | 206 element = element.enclosingElement; |
| 207 } else if (element is FunctionElement && element.name == 'loadLibrary') { | 207 } else if (element is FunctionElement && element.name == 'loadLibrary') { |
| 208 kind = IndexSyntheticElementKind.loadLibrary; | 208 kind = IndexSyntheticElementKind.loadLibrary; |
| 209 element = element.library; | 209 element = element.library; |
| 210 } else if (element is PropertyAccessorElement) { | 210 } else if (element is PropertyAccessorElement) { |
| 211 PropertyAccessorElement accessor = element; | 211 PropertyAccessorElement accessor = element; |
| 212 kind = accessor.isGetter | 212 Element enclosing = element.enclosingElement; |
| 213 ? IndexSyntheticElementKind.getter | 213 bool isEnumGetter = enclosing is ClassElement && enclosing.isEnum; |
| 214 : IndexSyntheticElementKind.setter; | 214 if (isEnumGetter && accessor.name == 'index') { |
| 215 element = accessor.variable; | 215 kind = IndexSyntheticElementKind.enumIndex; |
| 216 element = enclosing; |
| 217 } else if (isEnumGetter && accessor.name == 'values') { |
| 218 kind = IndexSyntheticElementKind.enumValues; |
| 219 element = enclosing; |
| 220 } else { |
| 221 kind = accessor.isGetter |
| 222 ? IndexSyntheticElementKind.getter |
| 223 : IndexSyntheticElementKind.setter; |
| 224 element = accessor.variable; |
| 225 } |
| 216 } else if (element is TopLevelVariableElement) { | 226 } else if (element is TopLevelVariableElement) { |
| 217 TopLevelVariableElement property = element; | 227 TopLevelVariableElement property = element; |
| 218 kind = IndexSyntheticElementKind.topLevelVariable; | 228 kind = IndexSyntheticElementKind.topLevelVariable; |
| 219 element = property.getter; | 229 element = property.getter; |
| 220 element ??= property.setter; | 230 element ??= property.setter; |
| 221 } else { | 231 } else { |
| 222 throw new ArgumentError( | 232 throw new ArgumentError( |
| 223 'Unsupported synthetic element ${element.runtimeType}'); | 233 'Unsupported synthetic element ${element.runtimeType}'); |
| 224 } | 234 } |
| 225 } | 235 } |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 usedNames: nameRelations.map((r) => r.nameInfo.id).toList(), | 787 usedNames: nameRelations.map((r) => r.nameInfo.id).toList(), |
| 778 usedNameKinds: nameRelations.map((r) => r.kind).toList(), | 788 usedNameKinds: nameRelations.map((r) => r.kind).toList(), |
| 779 usedNameOffsets: nameRelations.map((r) => r.offset).toList()); | 789 usedNameOffsets: nameRelations.map((r) => r.offset).toList()); |
| 780 } | 790 } |
| 781 | 791 |
| 782 void defineName(String name, IndexNameKind kind, int offset) { | 792 void defineName(String name, IndexNameKind kind, int offset) { |
| 783 _StringInfo nameInfo = pkg._getStringInfo(name); | 793 _StringInfo nameInfo = pkg._getStringInfo(name); |
| 784 definedNames.add(new _DefinedNameInfo(nameInfo, kind, offset)); | 794 definedNames.add(new _DefinedNameInfo(nameInfo, kind, offset)); |
| 785 } | 795 } |
| 786 } | 796 } |
| OLD | NEW |