| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 /** | 197 /** |
| 198 * Return a new [ElementInfo] for the given [element] in the given [unitId]. | 198 * Return a new [ElementInfo] for the given [element] in the given [unitId]. |
| 199 * This method is static, so it cannot add any information to the index. | 199 * This method is static, so it cannot add any information to the index. |
| 200 */ | 200 */ |
| 201 static ElementInfo newElementInfo(int unitId, Element element) { | 201 static ElementInfo newElementInfo(int unitId, Element element) { |
| 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') { |
| 208 kind = IndexSyntheticElementKind.loadLibrary; |
| 209 element = element.library; |
| 207 } else if (element is PropertyAccessorElement) { | 210 } else if (element is PropertyAccessorElement) { |
| 208 PropertyAccessorElement property = element; | 211 PropertyAccessorElement accessor = element; |
| 209 kind = property.isGetter | 212 kind = accessor.isGetter |
| 210 ? IndexSyntheticElementKind.getter | 213 ? IndexSyntheticElementKind.getter |
| 211 : IndexSyntheticElementKind.setter; | 214 : IndexSyntheticElementKind.setter; |
| 212 element = element.enclosingElement; | 215 element = element.enclosingElement; |
| 216 } else if (element is TopLevelVariableElement) { |
| 217 TopLevelVariableElement property = element; |
| 218 kind = IndexSyntheticElementKind.topLevelVariable; |
| 219 element = property.getter; |
| 220 element ??= property.setter; |
| 213 } else { | 221 } else { |
| 214 throw new ArgumentError( | 222 throw new ArgumentError( |
| 215 'Unsupported synthetic element ${element.runtimeType}'); | 223 'Unsupported synthetic element ${element.runtimeType}'); |
| 216 } | 224 } |
| 217 } | 225 } |
| 218 int offset = element.nameOffset; | 226 int offset = element.nameOffset; |
| 219 if (element is LibraryElement || element is CompilationUnitElement) { | 227 if (element is LibraryElement || element is CompilationUnitElement) { |
| 220 offset = 0; | 228 offset = 0; |
| 221 } | 229 } |
| 222 return new ElementInfo(unitId, offset, kind); | 230 return new ElementInfo(unitId, offset, kind); |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 usedNames: nameRelations.map((r) => r.nameInfo.id).toList(), | 764 usedNames: nameRelations.map((r) => r.nameInfo.id).toList(), |
| 757 usedNameKinds: nameRelations.map((r) => r.kind).toList(), | 765 usedNameKinds: nameRelations.map((r) => r.kind).toList(), |
| 758 usedNameOffsets: nameRelations.map((r) => r.offset).toList()); | 766 usedNameOffsets: nameRelations.map((r) => r.offset).toList()); |
| 759 } | 767 } |
| 760 | 768 |
| 761 void defineName(String name, IndexNameKind kind, int offset) { | 769 void defineName(String name, IndexNameKind kind, int offset) { |
| 762 _StringInfo nameInfo = pkg._getStringInfo(name); | 770 _StringInfo nameInfo = pkg._getStringInfo(name); |
| 763 definedNames.add(new _DefinedNameInfo(nameInfo, kind, offset)); | 771 definedNames.add(new _DefinedNameInfo(nameInfo, kind, offset)); |
| 764 } | 772 } |
| 765 } | 773 } |
| OLD | NEW |