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

Side by Side Diff: pkg/analyzer/lib/src/summary/summarize_elements.dart

Issue 1468583002: Add a unit index to prelinked type references in summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove an unnecessary TODO. Created 5 years, 1 month 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 serialization.elements; 5 library serialization.elements;
6 6
7 import 'package:analyzer/src/generated/element.dart'; 7 import 'package:analyzer/src/generated/element.dart';
8 import 'package:analyzer/src/generated/resolver.dart'; 8 import 'package:analyzer/src/generated/resolver.dart';
9 import 'package:analyzer/src/generated/utilities_dart.dart'; 9 import 'package:analyzer/src/generated/utilities_dart.dart';
10 import 'package:analyzer/src/summary/builder.dart'; 10 import 'package:analyzer/src/summary/builder.dart';
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 if (dependentLibrary == null) { 548 if (dependentLibrary == null) {
549 assert(type.isDynamic); 549 assert(type.isDynamic);
550 if (type is UndefinedTypeImpl) { 550 if (type is UndefinedTypeImpl) {
551 b.reference = serializeUnresolvedReference(); 551 b.reference = serializeUnresolvedReference();
552 } else { 552 } else {
553 b.reference = serializeDynamicReference(); 553 b.reference = serializeDynamicReference();
554 } 554 }
555 } else { 555 } else {
556 b.reference = referenceMap.putIfAbsent(element, () { 556 b.reference = referenceMap.putIfAbsent(element, () {
557 assert(unlinkedReferences.length == prelinkedReferences.length); 557 assert(unlinkedReferences.length == prelinkedReferences.length);
558 CompilationUnitElement unitElement =
559 element.getAncestor((Element e) => e is CompilationUnitElement);
560 int unit = dependentLibrary.units.indexOf(unitElement);
561 assert(unit != -1);
558 int index = unlinkedReferences.length; 562 int index = unlinkedReferences.length;
559 // TODO(paulberry): set UnlinkedReference.prefix. 563 // TODO(paulberry): set UnlinkedReference.prefix.
560 unlinkedReferences 564 unlinkedReferences
561 .add(encodeUnlinkedReference(ctx, name: element.name)); 565 .add(encodeUnlinkedReference(ctx, name: element.name));
562 prelinkedReferences.add(encodePrelinkedReference(ctx, 566 prelinkedReferences.add(encodePrelinkedReference(ctx,
563 dependency: serializeDependency(dependentLibrary), 567 dependency: serializeDependency(dependentLibrary),
564 kind: element is FunctionTypeAliasElement 568 kind: element is FunctionTypeAliasElement
565 ? PrelinkedReferenceKind.typedef 569 ? PrelinkedReferenceKind.typedef
566 : PrelinkedReferenceKind.classOrEnum)); 570 : PrelinkedReferenceKind.classOrEnum,
571 unit: unit));
567 return index; 572 return index;
568 }); 573 });
569 } 574 }
570 List<DartType> typeArguments; 575 List<DartType> typeArguments;
571 if (type is InterfaceType) { 576 if (type is InterfaceType) {
572 typeArguments = type.typeArguments; 577 typeArguments = type.typeArguments;
573 } else if (type is FunctionType) { 578 } else if (type is FunctionType) {
574 typeArguments = type.typeArguments; 579 typeArguments = type.typeArguments;
575 } 580 }
576 if (typeArguments != null && 581 if (typeArguments != null &&
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(ctx); 621 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(ctx);
617 b.name = variable.name; 622 b.name = variable.name;
618 b.unit = unitNum; 623 b.unit = unitNum;
619 b.type = serializeTypeRef(variable.type, variable); 624 b.type = serializeTypeRef(variable.type, variable);
620 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement; 625 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement;
621 b.isFinal = variable.isFinal; 626 b.isFinal = variable.isFinal;
622 b.isConst = variable.isConst; 627 b.isConst = variable.isConst;
623 return b; 628 return b;
624 } 629 }
625 } 630 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/format.dart ('k') | pkg/analyzer/test/src/summary/summary_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698