Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: pkg/analyzer/test/src/summary/index_unit_test.dart

Issue 2203173002: Use unitMember/classMember/parameter names instead of offsets in index. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/index_unit.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/index_unit.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698