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

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

Issue 1523093003: Move summary references into UnlinkedUnit and PrelinkedUnit. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 final List<UnlinkedPrefixBuilder> prefixes = <UnlinkedPrefixBuilder>[]; 73 final List<UnlinkedPrefixBuilder> prefixes = <UnlinkedPrefixBuilder>[];
74 74
75 /** 75 /**
76 * Map from [Element] to the index of the entry in the "references table" 76 * Map from [Element] to the index of the entry in the "references table"
77 * that refers to it. 77 * that refers to it.
78 */ 78 */
79 final Map<Element, int> referenceMap = <Element, int>{}; 79 final Map<Element, int> referenceMap = <Element, int>{};
80 80
81 /** 81 /**
82 * The unlinked portion of the "references table". This is the list of 82 * The unlinked portion of the "references table". This is the list of
83 * objects which should be written to [UnlinkedLibrary.references]. 83 * objects which should be written to [UnlinkedUnit.references].
84 */ 84 */
85 final List<UnlinkedReferenceBuilder> unlinkedReferences = 85 List<UnlinkedReferenceBuilder> unlinkedReferences;
86 <UnlinkedReferenceBuilder>[];
87 86
88 /** 87 /**
89 * The prelinked portion of the "references table". This is the list of 88 * The prelinked portion of the "references table". This is the list of
90 * objects which should be written to [PrelinkedLibrary.references]. 89 * objects which should be written to [PrelinkedUnit.references].
91 */ 90 */
92 final List<PrelinkedReferenceBuilder> prelinkedReferences = 91 List<PrelinkedReferenceBuilder> prelinkedReferences;
93 <PrelinkedReferenceBuilder>[];
94 92
95 //final Map<String, int> prefixIndices = <String, int>{}; 93 //final Map<String, int> prefixIndices = <String, int>{};
96 94
97 /** 95 /**
98 * Index into the "references table" representing `dynamic`, if such an index 96 * Index into the "references table" representing `dynamic`, if such an index
99 * exists. `null` if no such entry has been made in the references table 97 * exists. `null` if no such entry has been made in the references table
100 * yet. 98 * yet.
101 */ 99 */
102 int dynamicReferenceIndex = null; 100 int dynamicReferenceIndex = null;
103 101
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 if (libraryElement.name.isNotEmpty) { 147 if (libraryElement.name.isNotEmpty) {
150 b.libraryName = libraryElement.name; 148 b.libraryName = libraryElement.name;
151 } 149 }
152 b.exports = libraryElement.exports.map(serializeExport).toList(); 150 b.exports = libraryElement.exports.map(serializeExport).toList();
153 b.imports = libraryElement.imports.map(serializeImport).toList(); 151 b.imports = libraryElement.imports.map(serializeImport).toList();
154 b.parts = libraryElement.parts 152 b.parts = libraryElement.parts
155 .map( 153 .map(
156 (CompilationUnitElement e) => encodeUnlinkedPart(ctx, uri: e.uri)) 154 (CompilationUnitElement e) => encodeUnlinkedPart(ctx, uri: e.uri))
157 .toList(); 155 .toList();
158 } 156 }
157 unlinkedReferences = <UnlinkedReferenceBuilder>[];
158 prelinkedReferences = <PrelinkedReferenceBuilder>[];
159 b.classes = element.types.map(serializeClass).toList(); 159 b.classes = element.types.map(serializeClass).toList();
160 b.enums = element.enums.map(serializeEnum).toList(); 160 b.enums = element.enums.map(serializeEnum).toList();
161 b.typedefs = element.functionTypeAliases.map(serializeTypedef).toList(); 161 b.typedefs = element.functionTypeAliases.map(serializeTypedef).toList();
162 List<UnlinkedExecutableBuilder> executables = 162 List<UnlinkedExecutableBuilder> executables =
163 element.functions.map(serializeExecutable).toList(); 163 element.functions.map(serializeExecutable).toList();
164 for (PropertyAccessorElement accessor in element.accessors) { 164 for (PropertyAccessorElement accessor in element.accessors) {
165 if (!accessor.isSynthetic) { 165 if (!accessor.isSynthetic) {
166 executables.add(serializeExecutable(accessor)); 166 executables.add(serializeExecutable(accessor));
167 } 167 }
168 } 168 }
169 b.executables = executables; 169 b.executables = executables;
170 List<UnlinkedVariableBuilder> variables = <UnlinkedVariableBuilder>[]; 170 List<UnlinkedVariableBuilder> variables = <UnlinkedVariableBuilder>[];
171 for (PropertyAccessorElement accessor in element.accessors) { 171 for (PropertyAccessorElement accessor in element.accessors) {
172 if (accessor.isSynthetic && accessor.isGetter) { 172 if (accessor.isSynthetic && accessor.isGetter) {
173 PropertyInducingElement variable = accessor.variable; 173 PropertyInducingElement variable = accessor.variable;
174 if (variable != null) { 174 if (variable != null) {
175 assert(!variable.isSynthetic); 175 assert(!variable.isSynthetic);
176 variables.add(serializeVariable(variable)); 176 variables.add(serializeVariable(variable));
177 } 177 }
178 } 178 }
179 } 179 }
180 b.variables = variables; 180 b.variables = variables;
181 units.add(encodePrelinkedUnit(ctx, unlinked: b)); 181 b.references = unlinkedReferences;
182 units.add(
183 encodePrelinkedUnit(ctx, unlinked: b, references: prelinkedReferences));
184 unlinkedReferences = null;
185 prelinkedReferences = null;
182 } 186 }
183 187
184 /** 188 /**
185 * Add [exportedLibrary] (and the transitive closure of all libraries it 189 * Add [exportedLibrary] (and the transitive closure of all libraries it
186 * exports) to the dependency table ([PrelinkedLibrary.dependencies]). 190 * exports) to the dependency table ([PrelinkedLibrary.dependencies]).
187 */ 191 */
188 void addTransitiveExportClosure(LibraryElement exportedLibrary) { 192 void addTransitiveExportClosure(LibraryElement exportedLibrary) {
189 if (librariesAddedToTransitiveExportClosure.add(exportedLibrary)) { 193 if (librariesAddedToTransitiveExportClosure.add(exportedLibrary)) {
190 serializeDependency(exportedLibrary); 194 serializeDependency(exportedLibrary);
191 for (LibraryElement transitiveExport 195 for (LibraryElement transitiveExport
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 * called exactly once for each instance of [_LibrarySerializer]. 417 * called exactly once for each instance of [_LibrarySerializer].
414 */ 418 */
415 PrelinkedLibraryBuilder serializeLibrary() { 419 PrelinkedLibraryBuilder serializeLibrary() {
416 UnlinkedLibraryBuilder ub = new UnlinkedLibraryBuilder(ctx); 420 UnlinkedLibraryBuilder ub = new UnlinkedLibraryBuilder(ctx);
417 PrelinkedLibraryBuilder pb = new PrelinkedLibraryBuilder(ctx); 421 PrelinkedLibraryBuilder pb = new PrelinkedLibraryBuilder(ctx);
418 addCompilationUnitElements(libraryElement.definingCompilationUnit, 0); 422 addCompilationUnitElements(libraryElement.definingCompilationUnit, 0);
419 for (int i = 0; i < libraryElement.parts.length; i++) { 423 for (int i = 0; i < libraryElement.parts.length; i++) {
420 addCompilationUnitElements(libraryElement.parts[i], i + 1); 424 addCompilationUnitElements(libraryElement.parts[i], i + 1);
421 } 425 }
422 ub.prefixes = prefixes; 426 ub.prefixes = prefixes;
423 ub.references = unlinkedReferences;
424 pb.units = units; 427 pb.units = units;
425 pb.unlinked = ub; 428 pb.unlinked = ub;
426 pb.dependencies = dependencies; 429 pb.dependencies = dependencies;
427 pb.importDependencies = prelinkedImports; 430 pb.importDependencies = prelinkedImports;
428 pb.references = prelinkedReferences;
429 return pb; 431 return pb;
430 } 432 }
431 433
432 /** 434 /**
433 * Serialize the given [parameter] into an [UnlinkedParam]. 435 * Serialize the given [parameter] into an [UnlinkedParam].
434 */ 436 */
435 UnlinkedParamBuilder serializeParam(ParameterElement parameter) { 437 UnlinkedParamBuilder serializeParam(ParameterElement parameter) {
436 UnlinkedParamBuilder b = new UnlinkedParamBuilder(ctx); 438 UnlinkedParamBuilder b = new UnlinkedParamBuilder(ctx);
437 b.name = parameter.name; 439 b.name = parameter.name;
438 switch (parameter.parameterKind) { 440 switch (parameter.parameterKind) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(ctx); 573 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(ctx);
572 b.name = variable.name; 574 b.name = variable.name;
573 b.type = serializeTypeRef(variable.type, variable); 575 b.type = serializeTypeRef(variable.type, variable);
574 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement; 576 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement;
575 b.isFinal = variable.isFinal; 577 b.isFinal = variable.isFinal;
576 b.isConst = variable.isConst; 578 b.isConst = variable.isConst;
577 b.hasImplicitType = variable.hasImplicitType; 579 b.hasImplicitType = variable.hasImplicitType;
578 return b; 580 return b;
579 } 581 }
580 } 582 }
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