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

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

Issue 1565283002: Add uriOffset and uriEnd to the summary. (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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 kind: PrelinkedReferenceKind.typedef, 200 kind: PrelinkedReferenceKind.typedef,
201 name: typedef.name, 201 name: typedef.name,
202 numTypeParameters: typedef.typeParameters.length)); 202 numTypeParameters: typedef.typeParameters.length));
203 } 203 }
204 } 204 }
205 if (unitNum == 0) { 205 if (unitNum == 0) {
206 if (libraryElement.name.isNotEmpty) { 206 if (libraryElement.name.isNotEmpty) {
207 b.libraryName = libraryElement.name; 207 b.libraryName = libraryElement.name;
208 } 208 }
209 b.publicNamespace = encodeUnlinkedPublicNamespace(ctx, 209 b.publicNamespace = encodeUnlinkedPublicNamespace(ctx,
210 exports: libraryElement.exports.map(serializeExport).toList(), 210 exports: libraryElement.exports.map(serializeExportPublic).toList(),
211 parts: libraryElement.parts 211 parts: libraryElement.parts
212 .map((CompilationUnitElement e) => 212 .map((CompilationUnitElement e) => e.uri)
213 encodeUnlinkedPart(ctx, uri: e.uri))
214 .toList(), 213 .toList(),
215 names: names); 214 names: names);
215 b.exports = libraryElement.exports.map(serializeExportNonPublic).toList();
216 b.imports = libraryElement.imports.map(serializeImport).toList(); 216 b.imports = libraryElement.imports.map(serializeImport).toList();
217 b.parts = libraryElement.parts
218 .map((CompilationUnitElement e) =>
219 encodeUnlinkedPart(ctx, uriOffset: e.uriOffset, uriEnd: e.uriEnd))
220 .toList();
217 } else { 221 } else {
218 // TODO(paulberry): we need to figure out a way to record library, part, 222 // TODO(paulberry): we need to figure out a way to record library, part,
219 // import, and export declarations that appear in non-defining 223 // import, and export declarations that appear in non-defining
220 // compilation units (even though such declarations are prohibited by the 224 // compilation units (even though such declarations are prohibited by the
221 // language), so that if the user makes code changes that cause a 225 // language), so that if the user makes code changes that cause a
222 // non-defining compilation unit to become a defining compilation unit, 226 // non-defining compilation unit to become a defining compilation unit,
223 // we can create a correct summary by simply re-linking. 227 // we can create a correct summary by simply re-linking.
224 b.publicNamespace = encodeUnlinkedPublicNamespace(ctx, names: names); 228 b.publicNamespace = encodeUnlinkedPublicNamespace(ctx, names: names);
225 } 229 }
226 b.classes = element.types.map(serializeClass).toList(); 230 b.classes = element.types.map(serializeClass).toList();
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 429 }
426 b.isAbstract = executableElement.isAbstract; 430 b.isAbstract = executableElement.isAbstract;
427 b.isStatic = executableElement.isStatic && 431 b.isStatic = executableElement.isStatic &&
428 executableElement.enclosingElement is ClassElement; 432 executableElement.enclosingElement is ClassElement;
429 b.hasImplicitReturnType = executableElement.hasImplicitReturnType; 433 b.hasImplicitReturnType = executableElement.hasImplicitReturnType;
430 b.isExternal = executableElement.isExternal; 434 b.isExternal = executableElement.isExternal;
431 return b; 435 return b;
432 } 436 }
433 437
434 /** 438 /**
435 * Serialize the given [exportElement] into an [UnlinkedExport]. 439 * Serialize the given [exportElement] into an [UnlinkedExportNonPublic].
436 */ 440 */
437 UnlinkedExportBuilder serializeExport(ExportElement exportElement) { 441 UnlinkedExportNonPublicBuilder serializeExportNonPublic(
438 UnlinkedExportBuilder b = new UnlinkedExportBuilder(ctx); 442 ExportElement exportElement) {
443 UnlinkedExportNonPublicBuilder b = new UnlinkedExportNonPublicBuilder(ctx);
444 b.uriOffset = exportElement.uriOffset;
445 b.uriEnd = exportElement.uriEnd;
446 return b;
447 }
448
449 /**
450 * Serialize the given [exportElement] into an [UnlinkedExportPublic].
451 */
452 UnlinkedExportPublicBuilder serializeExportPublic(
453 ExportElement exportElement) {
454 UnlinkedExportPublicBuilder b = new UnlinkedExportPublicBuilder(ctx);
439 b.uri = exportElement.uri; 455 b.uri = exportElement.uri;
440 b.combinators = exportElement.combinators.map(serializeCombinator).toList(); 456 b.combinators = exportElement.combinators.map(serializeCombinator).toList();
441 return b; 457 return b;
442 } 458 }
443 459
444 /** 460 /**
445 * Serialize the given [importElement] yielding an [UnlinkedImportBuilder]. 461 * Serialize the given [importElement] yielding an [UnlinkedImportBuilder].
446 * Also, add pre-linked information about it to the [prelinkedImports] list. 462 * Also, add pre-linked information about it to the [prelinkedImports] list.
447 */ 463 */
448 UnlinkedImportBuilder serializeImport(ImportElement importElement) { 464 UnlinkedImportBuilder serializeImport(ImportElement importElement) {
449 UnlinkedImportBuilder b = new UnlinkedImportBuilder(ctx); 465 UnlinkedImportBuilder b = new UnlinkedImportBuilder(ctx);
450 b.isDeferred = importElement.isDeferred; 466 b.isDeferred = importElement.isDeferred;
451 b.offset = importElement.nameOffset; 467 b.offset = importElement.nameOffset;
452 b.combinators = importElement.combinators.map(serializeCombinator).toList(); 468 b.combinators = importElement.combinators.map(serializeCombinator).toList();
453 if (importElement.prefix != null) { 469 if (importElement.prefix != null) {
454 b.prefixReference = serializePrefix(importElement.prefix); 470 b.prefixReference = serializePrefix(importElement.prefix);
455 } 471 }
456 if (importElement.isSynthetic) { 472 if (importElement.isSynthetic) {
457 b.isImplicit = true; 473 b.isImplicit = true;
458 } else { 474 } else {
459 b.uri = importElement.uri; 475 b.uri = importElement.uri;
476 b.uriOffset = importElement.uriOffset;
477 b.uriEnd = importElement.uriEnd;
460 } 478 }
461 addTransitiveExportClosure(importElement.importedLibrary); 479 addTransitiveExportClosure(importElement.importedLibrary);
462 prelinkedImports.add(serializeDependency(importElement.importedLibrary)); 480 prelinkedImports.add(serializeDependency(importElement.importedLibrary));
463 return b; 481 return b;
464 } 482 }
465 483
466 /** 484 /**
467 * Serialize the whole library element into a [PrelinkedLibrary]. Should be 485 * Serialize the whole library element into a [PrelinkedLibrary]. Should be
468 * called exactly once for each instance of [_LibrarySerializer]. 486 * called exactly once for each instance of [_LibrarySerializer].
469 * 487 *
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(ctx); 665 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(ctx);
648 b.name = variable.name; 666 b.name = variable.name;
649 b.type = serializeTypeRef(variable.type, variable); 667 b.type = serializeTypeRef(variable.type, variable);
650 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement; 668 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement;
651 b.isFinal = variable.isFinal; 669 b.isFinal = variable.isFinal;
652 b.isConst = variable.isConst; 670 b.isConst = variable.isConst;
653 b.hasImplicitType = variable.hasImplicitType; 671 b.hasImplicitType = variable.hasImplicitType;
654 return b; 672 return b;
655 } 673 }
656 } 674 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698