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 'dart:convert'; | 5 import 'dart:convert'; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
9 import 'package:analyzer/src/summary/format.dart'; | 9 import 'package:analyzer/src/summary/format.dart'; |
10 import 'package:analyzer/src/summary/idl.dart'; | 10 import 'package:analyzer/src/summary/idl.dart'; |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 String packageIndexJsonString = | 1127 String packageIndexJsonString = |
1128 new JsonEncoder.withIndent(' ').convert(packageIndex.toJson()); | 1128 new JsonEncoder.withIndent(' ').convert(packageIndex.toJson()); |
1129 fail('$msg in\n' + packageIndexJsonString); | 1129 fail('$msg in\n' + packageIndexJsonString); |
1130 } | 1130 } |
1131 | 1131 |
1132 /** | 1132 /** |
1133 * Return the [element] identifier in [packageIndex] or fail. | 1133 * Return the [element] identifier in [packageIndex] or fail. |
1134 */ | 1134 */ |
1135 int _findElementId(Element element) { | 1135 int _findElementId(Element element) { |
1136 int unitId = _getUnitId(element); | 1136 int unitId = _getUnitId(element); |
1137 ElementInfo info = PackageIndexAssembler.newElementInfo(unitId, element); | 1137 // Prepare the element that was put into the index. |
| 1138 IndexElementInfo info = new IndexElementInfo(element); |
| 1139 element = info.element; |
| 1140 // Prepare element's name components. |
| 1141 int unitMemberId = _getStringId(PackageIndexAssembler.NULL_STRING); |
| 1142 int classMemberId = _getStringId(PackageIndexAssembler.NULL_STRING); |
| 1143 int parameterId = _getStringId(PackageIndexAssembler.NULL_STRING); |
| 1144 for (Element e = element; e != null; e = e.enclosingElement) { |
| 1145 if (e.enclosingElement is CompilationUnitElement) { |
| 1146 unitMemberId = _getStringId(e.name); |
| 1147 } |
| 1148 } |
| 1149 for (Element e = element; e != null; e = e.enclosingElement) { |
| 1150 if (e.enclosingElement is ClassElement) { |
| 1151 classMemberId = _getStringId(e.name); |
| 1152 } |
| 1153 } |
| 1154 if (element is ParameterElement) { |
| 1155 parameterId = _getStringId(element.name); |
| 1156 } |
| 1157 // Find the element's id. |
1138 for (int elementId = 0; | 1158 for (int elementId = 0; |
1139 elementId < packageIndex.elementUnits.length; | 1159 elementId < packageIndex.elementUnits.length; |
1140 elementId++) { | 1160 elementId++) { |
1141 if (packageIndex.elementUnits[elementId] == unitId && | 1161 if (packageIndex.elementUnits[elementId] == unitId && |
1142 packageIndex.elementOffsets[elementId] == info.offset && | 1162 packageIndex.elementNameUnitMemberIds[elementId] == unitMemberId && |
| 1163 packageIndex.elementNameClassMemberIds[elementId] == classMemberId && |
| 1164 packageIndex.elementNameParameterIds[elementId] == parameterId && |
1143 packageIndex.elementKinds[elementId] == info.kind) { | 1165 packageIndex.elementKinds[elementId] == info.kind) { |
1144 return elementId; | 1166 return elementId; |
1145 } | 1167 } |
1146 } | 1168 } |
1147 _failWithIndexDump('Element $element is not referenced'); | 1169 _failWithIndexDump('Element $element is not referenced'); |
1148 return 0; | 1170 return 0; |
1149 } | 1171 } |
1150 | 1172 |
1151 /** | 1173 /** |
1152 * Return all relations with [element] in [unitIndex]. | 1174 * Return all relations with [element] in [unitIndex]. |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 final bool isQualified; | 1331 final bool isQualified; |
1310 | 1332 |
1311 _Relation(this.kind, this.offset, this.length, this.isQualified); | 1333 _Relation(this.kind, this.offset, this.length, this.isQualified); |
1312 | 1334 |
1313 @override | 1335 @override |
1314 String toString() { | 1336 String toString() { |
1315 return '_Relation{kind: $kind, offset: $offset, length: $length, ' | 1337 return '_Relation{kind: $kind, offset: $offset, length: $length, ' |
1316 'isQualified: $isQualified}'; | 1338 'isQualified: $isQualified}'; |
1317 } | 1339 } |
1318 } | 1340 } |
OLD | NEW |