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

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

Issue 1575143002: Fix referencing prefixed types from parts. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
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/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/dart/element/type.dart'; 8 import 'package:analyzer/dart/element/type.dart';
9 import 'package:analyzer/src/dart/element/type.dart'; 9 import 'package:analyzer/src/dart/element/type.dart';
10 import 'package:analyzer/src/generated/resolver.dart'; 10 import 'package:analyzer/src/generated/resolver.dart';
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 b.reference = referenceMap.putIfAbsent(element, () { 667 b.reference = referenceMap.putIfAbsent(element, () {
668 assert(unlinkedReferences.length == prelinkedReferences.length); 668 assert(unlinkedReferences.length == prelinkedReferences.length);
669 CompilationUnitElement unitElement = 669 CompilationUnitElement unitElement =
670 element.getAncestor((Element e) => e is CompilationUnitElement); 670 element.getAncestor((Element e) => e is CompilationUnitElement);
671 int unit = dependentLibrary.units.indexOf(unitElement); 671 int unit = dependentLibrary.units.indexOf(unitElement);
672 assert(unit != -1); 672 assert(unit != -1);
673 int numTypeParameters = 0; 673 int numTypeParameters = 0;
674 if (element is TypeParameterizedElement) { 674 if (element is TypeParameterizedElement) {
675 numTypeParameters = element.typeParameters.length; 675 numTypeParameters = element.typeParameters.length;
676 } 676 }
677 int index = unlinkedReferences.length;
678 // Figure out a prefix that may be used to refer to the given type. 677 // Figure out a prefix that may be used to refer to the given type.
679 // TODO(paulberry): to avoid subtle relinking inconsistencies we 678 // TODO(paulberry): to avoid subtle relinking inconsistencies we
680 // should use the actual prefix from the AST (a given type may be 679 // should use the actual prefix from the AST (a given type may be
681 // reachable via multiple prefixes), but sadly, this information is 680 // reachable via multiple prefixes), but sadly, this information is
682 // not recorded in the element model. 681 // not recorded in the element model.
683 int prefixReference = 0; 682 int prefixReference = 0;
684 PrefixElement prefix = prefixMap[element]; 683 PrefixElement prefix = prefixMap[element];
685 if (prefix != null) { 684 if (prefix != null) {
686 prefixReference = serializePrefix(prefix); 685 prefixReference = serializePrefix(prefix);
687 } 686 }
687 int index = unlinkedReferences.length;
688 unlinkedReferences.add(encodeUnlinkedReference( 688 unlinkedReferences.add(encodeUnlinkedReference(
689 name: element.name, prefixReference: prefixReference)); 689 name: element.name, prefixReference: prefixReference));
690 prelinkedReferences.add(encodePrelinkedReference( 690 prelinkedReferences.add(encodePrelinkedReference(
691 dependency: serializeDependency(dependentLibrary), 691 dependency: serializeDependency(dependentLibrary),
692 kind: element is FunctionTypeAliasElement 692 kind: element is FunctionTypeAliasElement
693 ? PrelinkedReferenceKind.typedef 693 ? PrelinkedReferenceKind.typedef
694 : PrelinkedReferenceKind.classOrEnum, 694 : PrelinkedReferenceKind.classOrEnum,
695 unit: unit, 695 unit: unit,
696 numTypeParameters: numTypeParameters)); 696 numTypeParameters: numTypeParameters));
697 return index; 697 return index;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 b.nameOffset = variable.nameOffset; 744 b.nameOffset = variable.nameOffset;
745 b.type = serializeTypeRef(variable.type, variable); 745 b.type = serializeTypeRef(variable.type, variable);
746 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement; 746 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement;
747 b.isFinal = variable.isFinal; 747 b.isFinal = variable.isFinal;
748 b.isConst = variable.isConst; 748 b.isConst = variable.isConst;
749 b.hasImplicitType = variable.hasImplicitType; 749 b.hasImplicitType = variable.hasImplicitType;
750 b.documentationComment = serializeDocumentation(variable); 750 b.documentationComment = serializeDocumentation(variable);
751 return b; 751 return b;
752 } 752 }
753 } 753 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/summary_test.dart » ('j') | pkg/analyzer/test/src/summary/summary_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698