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

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

Issue 1543403002: Create a section of the summary for public namespace information. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 12 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 */ 156 */
157 void addCompilationUnitElements(CompilationUnitElement element, int unitNum) { 157 void addCompilationUnitElements(CompilationUnitElement element, int unitNum) {
158 UnlinkedUnitBuilder b = new UnlinkedUnitBuilder(ctx); 158 UnlinkedUnitBuilder b = new UnlinkedUnitBuilder(ctx);
159 referenceMap.clear(); 159 referenceMap.clear();
160 unlinkedReferences = <UnlinkedReferenceBuilder>[ 160 unlinkedReferences = <UnlinkedReferenceBuilder>[
161 encodeUnlinkedReference(ctx) 161 encodeUnlinkedReference(ctx)
162 ]; 162 ];
163 prelinkedReferences = <PrelinkedReferenceBuilder>[ 163 prelinkedReferences = <PrelinkedReferenceBuilder>[
164 encodePrelinkedReference(ctx, kind: PrelinkedReferenceKind.classOrEnum) 164 encodePrelinkedReference(ctx, kind: PrelinkedReferenceKind.classOrEnum)
165 ]; 165 ];
166 List<UnlinkedPublicNameBuilder> names = <UnlinkedPublicNameBuilder>[];
167 for (PropertyAccessorElement accessor in element.accessors) {
168 if (accessor.isPublic) {
169 names.add(encodeUnlinkedPublicName(ctx,
170 kind: PrelinkedReferenceKind.other, name: accessor.name));
171 }
172 }
173 for (ClassElement cls in element.types) {
174 if (cls.isPublic) {
175 names.add(encodeUnlinkedPublicName(ctx,
176 kind: PrelinkedReferenceKind.classOrEnum, name: cls.name));
177 }
178 }
179 for (ClassElement enm in element.enums) {
180 if (enm.isPublic) {
181 names.add(encodeUnlinkedPublicName(ctx,
182 kind: PrelinkedReferenceKind.classOrEnum, name: enm.name));
183 }
184 }
185 for (FunctionElement function in element.functions) {
186 if (function.isPublic) {
187 names.add(encodeUnlinkedPublicName(ctx,
188 kind: PrelinkedReferenceKind.other, name: function.name));
189 }
190 }
191 for (FunctionTypeAliasElement typedef in element.functionTypeAliases) {
192 if (typedef.isPublic) {
193 names.add(encodeUnlinkedPublicName(ctx,
194 kind: PrelinkedReferenceKind.typedef, name: typedef.name));
195 }
196 }
166 if (unitNum == 0) { 197 if (unitNum == 0) {
198 if (libraryElement.name.isNotEmpty) {
199 b.libraryName = libraryElement.name;
200 }
201 b.publicNamespace = encodeUnlinkedPublicNamespace(ctx,
202 exports: libraryElement.exports.map(serializeExport).toList(),
203 parts: libraryElement.parts
204 .map((CompilationUnitElement e) =>
205 encodeUnlinkedPart(ctx, uri: e.uri))
206 .toList(),
207 names: names);
208 b.imports = libraryElement.imports.map(serializeImport).toList();
209 } else {
167 // TODO(paulberry): we need to figure out a way to record library, part, 210 // TODO(paulberry): we need to figure out a way to record library, part,
168 // import, and export declarations that appear in non-defining 211 // import, and export declarations that appear in non-defining
169 // compilation units (even though such declarations are prohibited by the 212 // compilation units (even though such declarations are prohibited by the
170 // language), so that if the user makes code changes that cause a 213 // language), so that if the user makes code changes that cause a
171 // non-defining compilation unit to become a defining compilation unit, 214 // non-defining compilation unit to become a defining compilation unit,
172 // we can create a correct summary by simply re-linking. 215 // we can create a correct summary by simply re-linking.
173 if (libraryElement.name.isNotEmpty) { 216 b.publicNamespace = encodeUnlinkedPublicNamespace(ctx, names: names);
174 b.libraryName = libraryElement.name;
175 }
176 b.exports = libraryElement.exports.map(serializeExport).toList();
177 b.imports = libraryElement.imports.map(serializeImport).toList();
178 b.parts = libraryElement.parts
179 .map(
180 (CompilationUnitElement e) => encodeUnlinkedPart(ctx, uri: e.uri))
181 .toList();
182 } 217 }
183 b.classes = element.types.map(serializeClass).toList(); 218 b.classes = element.types.map(serializeClass).toList();
184 b.enums = element.enums.map(serializeEnum).toList(); 219 b.enums = element.enums.map(serializeEnum).toList();
185 b.typedefs = element.functionTypeAliases.map(serializeTypedef).toList(); 220 b.typedefs = element.functionTypeAliases.map(serializeTypedef).toList();
186 List<UnlinkedExecutableBuilder> executables = 221 List<UnlinkedExecutableBuilder> executables =
187 element.functions.map(serializeExecutable).toList(); 222 element.functions.map(serializeExecutable).toList();
188 for (PropertyAccessorElement accessor in element.accessors) { 223 for (PropertyAccessorElement accessor in element.accessors) {
189 if (!accessor.isSynthetic) { 224 if (!accessor.isSynthetic) {
190 executables.add(serializeExecutable(accessor)); 225 executables.add(serializeExecutable(accessor));
191 } 226 }
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(ctx); 640 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(ctx);
606 b.name = variable.name; 641 b.name = variable.name;
607 b.type = serializeTypeRef(variable.type, variable); 642 b.type = serializeTypeRef(variable.type, variable);
608 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement; 643 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement;
609 b.isFinal = variable.isFinal; 644 b.isFinal = variable.isFinal;
610 b.isConst = variable.isConst; 645 b.isConst = variable.isConst;
611 b.hasImplicitType = variable.hasImplicitType; 646 b.hasImplicitType = variable.hasImplicitType;
612 return b; 647 return b;
613 } 648 }
614 } 649 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.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