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

Side by Side Diff: pkg/analyzer/lib/src/generated/element_handle.dart

Issue 1526243002: Introduce code to resynthesize element models from summaries. (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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 analyzer.src.generated.element_handle; 5 library analyzer.src.generated.element_handle;
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/element.dart'; 9 import 'package:analyzer/src/dart/element/element.dart';
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
11 import 'package:analyzer/src/generated/constant.dart'; 11 import 'package:analyzer/src/generated/constant.dart';
12 import 'package:analyzer/src/generated/engine.dart'; 12 import 'package:analyzer/src/generated/engine.dart';
13 import 'package:analyzer/src/generated/java_core.dart'; 13 import 'package:analyzer/src/generated/java_core.dart';
14 import 'package:analyzer/src/generated/java_engine.dart'; 14 import 'package:analyzer/src/generated/java_engine.dart';
15 import 'package:analyzer/src/generated/resolver.dart'; 15 import 'package:analyzer/src/generated/resolver.dart';
16 import 'package:analyzer/src/generated/source.dart'; 16 import 'package:analyzer/src/generated/source.dart';
17 import 'package:analyzer/src/generated/utilities_dart.dart'; 17 import 'package:analyzer/src/generated/utilities_dart.dart';
18 18
19 /** 19 /**
20 * Instances of the class `ClassElementHandle` implement a handle to a `ClassEle ment`. 20 * Instances of the class `ClassElementHandle` implement a handle to a `ClassEle ment`.
21 */ 21 */
22 class ClassElementHandle extends ElementHandle implements ClassElement { 22 class ClassElementHandle extends ElementHandle implements ClassElement {
23 /** 23 /**
24 * Initialize a newly created element handle to represent the given element. 24 * Initialize a newly created element handle to represent the given element.
25 * 25 *
26 * @param element the element being represented 26 * @param element the element being represented
27 */ 27 */
28 ClassElementHandle(ClassElement element) : super(element); 28 ClassElementHandle(
29 ElementResynthesizer resynthesizer, ElementLocation location)
30 : super(resynthesizer, location);
29 31
30 @override 32 @override
31 List<PropertyAccessorElement> get accessors => actualElement.accessors; 33 List<PropertyAccessorElement> get accessors => actualElement.accessors;
32 34
33 @override 35 @override
34 ClassElement get actualElement => super.actualElement as ClassElement; 36 ClassElement get actualElement => super.actualElement as ClassElement;
35 37
36 @override 38 @override
37 List<InterfaceType> get allSupertypes => actualElement.allSupertypes; 39 List<InterfaceType> get allSupertypes => actualElement.allSupertypes;
38 40
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 * Instances of the class `CompilationUnitElementHandle` implements a handle to a 162 * Instances of the class `CompilationUnitElementHandle` implements a handle to a
161 * [CompilationUnitElement]. 163 * [CompilationUnitElement].
162 */ 164 */
163 class CompilationUnitElementHandle extends ElementHandle 165 class CompilationUnitElementHandle extends ElementHandle
164 implements CompilationUnitElement { 166 implements CompilationUnitElement {
165 /** 167 /**
166 * Initialize a newly created element handle to represent the given element. 168 * Initialize a newly created element handle to represent the given element.
167 * 169 *
168 * @param element the element being represented 170 * @param element the element being represented
169 */ 171 */
170 CompilationUnitElementHandle(CompilationUnitElement element) : super(element); 172 CompilationUnitElementHandle(
173 ElementResynthesizer resynthesizer, ElementLocation location)
174 : super(resynthesizer, location);
171 175
172 @override 176 @override
173 List<PropertyAccessorElement> get accessors => actualElement.accessors; 177 List<PropertyAccessorElement> get accessors => actualElement.accessors;
174 178
175 @override 179 @override
176 CompilationUnitElement get actualElement => 180 CompilationUnitElement get actualElement =>
177 super.actualElement as CompilationUnitElement; 181 super.actualElement as CompilationUnitElement;
178 182
179 @override 183 @override
180 LibraryElement get enclosingElement => 184 LibraryElement get enclosingElement =>
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 * Instances of the class `ConstructorElementHandle` implement a handle to a 238 * Instances of the class `ConstructorElementHandle` implement a handle to a
235 * `ConstructorElement`. 239 * `ConstructorElement`.
236 */ 240 */
237 class ConstructorElementHandle extends ExecutableElementHandle 241 class ConstructorElementHandle extends ExecutableElementHandle
238 implements ConstructorElement { 242 implements ConstructorElement {
239 /** 243 /**
240 * Initialize a newly created element handle to represent the given element. 244 * Initialize a newly created element handle to represent the given element.
241 * 245 *
242 * @param element the element being represented 246 * @param element the element being represented
243 */ 247 */
244 ConstructorElementHandle(ConstructorElement element) : super(element); 248 ConstructorElementHandle(
249 ElementResynthesizer resynthesizer, ElementLocation location)
250 : super(resynthesizer, location);
245 251
246 @override 252 @override
247 ConstructorElement get actualElement => 253 ConstructorElement get actualElement =>
248 super.actualElement as ConstructorElement; 254 super.actualElement as ConstructorElement;
249 255
250 @override 256 @override
251 ClassElement get enclosingElement => actualElement.enclosingElement; 257 ClassElement get enclosingElement => actualElement.enclosingElement;
252 258
253 @override 259 @override
254 bool get isConst => actualElement.isConst; 260 bool get isConst => actualElement.isConst;
(...skipping 25 matching lines...) Expand all
280 * The abstract class `ElementHandle` implements the behavior common to objects that implement 286 * The abstract class `ElementHandle` implements the behavior common to objects that implement
281 * a handle to an [Element]. 287 * a handle to an [Element].
282 */ 288 */
283 abstract class ElementHandle implements Element { 289 abstract class ElementHandle implements Element {
284 /** 290 /**
285 * The unique integer identifier of this element. 291 * The unique integer identifier of this element.
286 */ 292 */
287 final int id = 0; 293 final int id = 0;
288 294
289 /** 295 /**
290 * The context in which the element is defined. 296 * The [ElementResynthesizer] which will be used to resynthesize elements on
297 * demand.
291 */ 298 */
292 AnalysisContext _context; 299 final ElementResynthesizer _resynthesizer;
293 300
294 /** 301 /**
295 * The location of this element, used to reconstitute the element if it has be en garbage 302 * The location of this element, used to reconstitute the element if it has be en garbage
296 * collected. 303 * collected.
297 */ 304 */
298 ElementLocation _location; 305 final ElementLocation _location;
299 306
300 /** 307 /**
301 * A reference to the element being referenced by this handle, or `null` if th e element has 308 * A reference to the element being referenced by this handle, or `null` if th e element has
302 * been garbage collected. 309 * been garbage collected.
303 */ 310 */
304 WeakReference<Element> _elementReference; 311 Element _elementReference;
305 312
306 /** 313 /**
307 * Initialize a newly created element handle to represent the given element. 314 * Initialize a newly created element handle to represent the element at the
308 * 315 * given [_location]. [_resynthesizer] will be used to resynthesize the
309 * @param element the element being represented 316 * element when needed.
310 */ 317 */
311 ElementHandle(Element element) { 318 ElementHandle(this._resynthesizer, this._location);
312 _context = element.context;
313 _location = element.location;
314 _elementReference = new WeakReference<Element>(element);
315 }
316 319
317 /** 320 /**
318 * Return the element being represented by this handle, reconstituting the ele ment if the 321 * Return the element being represented by this handle, reconstituting the ele ment if the
319 * reference has been set to `null`. 322 * reference has been set to `null`.
320 * 323 *
321 * @return the element being represented by this handle 324 * @return the element being represented by this handle
322 */ 325 */
323 Element get actualElement { 326 Element get actualElement {
324 Element element = _elementReference.get(); 327 if (_elementReference == null) {
325 if (element == null) { 328 _elementReference = _resynthesizer.getElement(_location);
326 element = _context.getElement(_location);
327 _elementReference = new WeakReference<Element>(element);
328 } 329 }
329 return element; 330 return _elementReference;
330 } 331 }
331 332
332 @override 333 @override
333 AnalysisContext get context => _context; 334 AnalysisContext get context => _resynthesizer.context;
334 335
335 @override 336 @override
336 String get displayName => actualElement.displayName; 337 String get displayName => actualElement.displayName;
337 338
338 @override 339 @override
339 SourceRange get docRange => actualElement.docRange; 340 SourceRange get docRange => actualElement.docRange;
340 341
341 @override 342 @override
342 Element get enclosingElement => actualElement.enclosingElement; 343 Element get enclosingElement => actualElement.enclosingElement;
343 344
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 actualElement.getExtendedDisplayName(shortName); 408 actualElement.getExtendedDisplayName(shortName);
408 409
409 @override 410 @override
410 bool isAccessibleIn(LibraryElement library) => 411 bool isAccessibleIn(LibraryElement library) =>
411 actualElement.isAccessibleIn(library); 412 actualElement.isAccessibleIn(library);
412 413
413 @override 414 @override
414 void visitChildren(ElementVisitor visitor) { 415 void visitChildren(ElementVisitor visitor) {
415 actualElement.visitChildren(visitor); 416 actualElement.visitChildren(visitor);
416 } 417 }
417
418 /**
419 * Return a handle on the given element. If the element is already a handle, t hen it will be
420 * returned directly, otherwise a handle of the appropriate class will be cons tructed.
421 *
422 * @param element the element for which a handle is to be constructed
423 * @return a handle on the given element
424 */
425 static Element forElement(Element element) {
426 if (element is ElementHandle) {
427 return element;
428 }
429 while (true) {
430 if (element.kind == ElementKind.CLASS) {
431 return new ClassElementHandle(element as ClassElement);
432 } else if (element.kind == ElementKind.COMPILATION_UNIT) {
433 return new CompilationUnitElementHandle(
434 element as CompilationUnitElement);
435 } else if (element.kind == ElementKind.CONSTRUCTOR) {
436 return new ConstructorElementHandle(element as ConstructorElement);
437 } else if (element.kind == ElementKind.EXPORT) {
438 return new ExportElementHandle(element as ExportElement);
439 } else if (element.kind == ElementKind.FIELD) {
440 return new FieldElementHandle(element as FieldElement);
441 } else if (element.kind == ElementKind.FUNCTION) {
442 return new FunctionElementHandle(element as FunctionElement);
443 } else if (element.kind == ElementKind.GETTER) {
444 return new PropertyAccessorElementHandle(
445 element as PropertyAccessorElement);
446 } else if (element.kind == ElementKind.IMPORT) {
447 return new ImportElementHandle(element as ImportElement);
448 } else if (element.kind == ElementKind.LABEL) {
449 return new LabelElementHandle(element as LabelElement);
450 } else if (element.kind == ElementKind.LIBRARY) {
451 return new LibraryElementHandle(element as LibraryElement);
452 } else if (element.kind == ElementKind.LOCAL_VARIABLE) {
453 return new LocalVariableElementHandle(element as LocalVariableElement);
454 } else if (element.kind == ElementKind.METHOD) {
455 return new MethodElementHandle(element as MethodElement);
456 } else if (element.kind == ElementKind.PARAMETER) {
457 return new ParameterElementHandle(element as ParameterElement);
458 } else if (element.kind == ElementKind.PREFIX) {
459 return new PrefixElementHandle(element as PrefixElement);
460 } else if (element.kind == ElementKind.SETTER) {
461 return new PropertyAccessorElementHandle(
462 element as PropertyAccessorElement);
463 } else if (element.kind == ElementKind.TOP_LEVEL_VARIABLE) {
464 return new TopLevelVariableElementHandle(
465 element as TopLevelVariableElement);
466 } else if (element.kind == ElementKind.FUNCTION_TYPE_ALIAS) {
467 return new FunctionTypeAliasElementHandle(
468 element as FunctionTypeAliasElement);
469 } else if (element.kind == ElementKind.TYPE_PARAMETER) {
470 return new TypeParameterElementHandle(element as TypeParameterElement);
471 } else {
472 throw new UnsupportedOperationException();
473 }
474 break;
475 }
476 }
477
478 /**
479 * Return an array of the same size as the given array where each element of t he returned array is
480 * a handle for the corresponding element of the given array.
481 *
482 * @param elements the elements for which handles are to be created
483 * @return an array of handles to the given elements
484 */
485 static List<Element> forElements(List<Element> elements) {
486 int length = elements.length;
487 List<Element> handles = new List<Element>.from(elements);
488 for (int i = 0; i < length; i++) {
489 handles[i] = forElement(elements[i]);
490 }
491 return handles;
492 }
493 } 418 }
494 419
495 /** 420 /**
421 * Interface which allows an [Element] handle to be resynthesized based on an
422 * [ElementLocation]. The concrete classes implementing element handles use
423 * this interface to retrieve the underlying elements when queried.
424 */
425 abstract class ElementResynthesizer {
426 final AnalysisContext context;
427
428 ElementResynthesizer(this.context);
429
430 Element getElement(ElementLocation location);
431 }
432
433 /**
496 * The abstract class `ExecutableElementHandle` implements the behavior common t o objects that 434 * The abstract class `ExecutableElementHandle` implements the behavior common t o objects that
497 * implement a handle to an [ExecutableElement]. 435 * implement a handle to an [ExecutableElement].
498 */ 436 */
499 abstract class ExecutableElementHandle extends ElementHandle 437 abstract class ExecutableElementHandle extends ElementHandle
500 implements ExecutableElement { 438 implements ExecutableElement {
501 /** 439 /**
502 * Initialize a newly created element handle to represent the given element. 440 * Initialize a newly created element handle to represent the given element.
503 * 441 *
504 * @param element the element being represented 442 * @param element the element being represented
505 */ 443 */
506 ExecutableElementHandle(ExecutableElement element) : super(element); 444 ExecutableElementHandle(
445 ElementResynthesizer resynthesizer, ElementLocation location)
446 : super(resynthesizer, location);
507 447
508 @override 448 @override
509 ExecutableElement get actualElement => 449 ExecutableElement get actualElement =>
510 super.actualElement as ExecutableElement; 450 super.actualElement as ExecutableElement;
511 451
512 @override 452 @override
513 List<FunctionElement> get functions => actualElement.functions; 453 List<FunctionElement> get functions => actualElement.functions;
514 454
515 @override 455 @override
516 bool get hasImplicitReturnType => actualElement.hasImplicitReturnType; 456 bool get hasImplicitReturnType => actualElement.hasImplicitReturnType;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 /** 498 /**
559 * Instances of the class `ExportElementHandle` implement a handle to an `Export Element` 499 * Instances of the class `ExportElementHandle` implement a handle to an `Export Element`
560 * . 500 * .
561 */ 501 */
562 class ExportElementHandle extends ElementHandle implements ExportElement { 502 class ExportElementHandle extends ElementHandle implements ExportElement {
563 /** 503 /**
564 * Initialize a newly created element handle to represent the given element. 504 * Initialize a newly created element handle to represent the given element.
565 * 505 *
566 * @param element the element being represented 506 * @param element the element being represented
567 */ 507 */
568 ExportElementHandle(ExportElement element) : super(element); 508 ExportElementHandle(
509 ElementResynthesizer resynthesizer, ElementLocation location)
510 : super(resynthesizer, location);
569 511
570 @override 512 @override
571 ExportElement get actualElement => super.actualElement as ExportElement; 513 ExportElement get actualElement => super.actualElement as ExportElement;
572 514
573 @override 515 @override
574 List<NamespaceCombinator> get combinators => actualElement.combinators; 516 List<NamespaceCombinator> get combinators => actualElement.combinators;
575 517
576 @override 518 @override
577 LibraryElement get exportedLibrary => actualElement.exportedLibrary; 519 LibraryElement get exportedLibrary => actualElement.exportedLibrary;
578 520
(...skipping 13 matching lines...) Expand all
592 /** 534 /**
593 * Instances of the class `FieldElementHandle` implement a handle to a `FieldEle ment`. 535 * Instances of the class `FieldElementHandle` implement a handle to a `FieldEle ment`.
594 */ 536 */
595 class FieldElementHandle extends PropertyInducingElementHandle 537 class FieldElementHandle extends PropertyInducingElementHandle
596 implements FieldElement { 538 implements FieldElement {
597 /** 539 /**
598 * Initialize a newly created element handle to represent the given element. 540 * Initialize a newly created element handle to represent the given element.
599 * 541 *
600 * @param element the element being represented 542 * @param element the element being represented
601 */ 543 */
602 FieldElementHandle(FieldElement element) : super(element); 544 FieldElementHandle(
545 ElementResynthesizer resynthesizer, ElementLocation location)
546 : super(resynthesizer, location);
603 547
604 @override 548 @override
605 FieldElement get actualElement => super.actualElement as FieldElement; 549 FieldElement get actualElement => super.actualElement as FieldElement;
606 550
607 @override 551 @override
608 ClassElement get enclosingElement => actualElement.enclosingElement; 552 ClassElement get enclosingElement => actualElement.enclosingElement;
609 553
610 @override 554 @override
611 bool get isEnumConstant => actualElement.isEnumConstant; 555 bool get isEnumConstant => actualElement.isEnumConstant;
612 556
613 @override 557 @override
614 ElementKind get kind => ElementKind.FIELD; 558 ElementKind get kind => ElementKind.FIELD;
615 559
616 @override 560 @override
617 VariableDeclaration computeNode() => actualElement.computeNode(); 561 VariableDeclaration computeNode() => actualElement.computeNode();
618 } 562 }
619 563
620 /** 564 /**
621 * Instances of the class `FunctionElementHandle` implement a handle to a 565 * Instances of the class `FunctionElementHandle` implement a handle to a
622 * `FunctionElement`. 566 * `FunctionElement`.
623 */ 567 */
624 class FunctionElementHandle extends ExecutableElementHandle 568 class FunctionElementHandle extends ExecutableElementHandle
625 implements FunctionElement { 569 implements FunctionElement {
626 /** 570 /**
627 * Initialize a newly created element handle to represent the given element. 571 * Initialize a newly created element handle to represent the given element.
628 * 572 *
629 * @param element the element being represented 573 * @param element the element being represented
630 */ 574 */
631 FunctionElementHandle(FunctionElement element) : super(element); 575 FunctionElementHandle(
576 ElementResynthesizer resynthesizer, ElementLocation location)
577 : super(resynthesizer, location);
632 578
633 @override 579 @override
634 FunctionElement get actualElement => super.actualElement as FunctionElement; 580 FunctionElement get actualElement => super.actualElement as FunctionElement;
635 581
636 @override 582 @override
637 bool get isEntryPoint => actualElement.isEntryPoint; 583 bool get isEntryPoint => actualElement.isEntryPoint;
638 584
639 @override 585 @override
640 ElementKind get kind => ElementKind.FUNCTION; 586 ElementKind get kind => ElementKind.FUNCTION;
641 587
642 @override 588 @override
643 SourceRange get visibleRange => actualElement.visibleRange; 589 SourceRange get visibleRange => actualElement.visibleRange;
644 590
645 @override 591 @override
646 FunctionDeclaration computeNode() => actualElement.computeNode(); 592 FunctionDeclaration computeNode() => actualElement.computeNode();
647 } 593 }
648 594
649 /** 595 /**
650 * Instances of the class `FunctionTypeAliasElementHandle` implement a handle to a 596 * Instances of the class `FunctionTypeAliasElementHandle` implement a handle to a
651 * `FunctionTypeAliasElement`. 597 * `FunctionTypeAliasElement`.
652 */ 598 */
653 class FunctionTypeAliasElementHandle extends ElementHandle 599 class FunctionTypeAliasElementHandle extends ElementHandle
654 implements FunctionTypeAliasElement { 600 implements FunctionTypeAliasElement {
655 /** 601 /**
656 * Initialize a newly created element handle to represent the given element. 602 * Initialize a newly created element handle to represent the given element.
657 * 603 *
658 * @param element the element being represented 604 * @param element the element being represented
659 */ 605 */
660 FunctionTypeAliasElementHandle(FunctionTypeAliasElement element) 606 FunctionTypeAliasElementHandle(
661 : super(element); 607 ElementResynthesizer resynthesizer, ElementLocation location)
608 : super(resynthesizer, location);
662 609
663 @override 610 @override
664 FunctionTypeAliasElement get actualElement => 611 FunctionTypeAliasElement get actualElement =>
665 super.actualElement as FunctionTypeAliasElement; 612 super.actualElement as FunctionTypeAliasElement;
666 613
667 @override 614 @override
668 CompilationUnitElement get enclosingElement => 615 CompilationUnitElement get enclosingElement =>
669 super.enclosingElement as CompilationUnitElement; 616 super.enclosingElement as CompilationUnitElement;
670 617
671 @override 618 @override
(...skipping 18 matching lines...) Expand all
690 /** 637 /**
691 * Instances of the class `ImportElementHandle` implement a handle to an `Import Element` 638 * Instances of the class `ImportElementHandle` implement a handle to an `Import Element`
692 * . 639 * .
693 */ 640 */
694 class ImportElementHandle extends ElementHandle implements ImportElement { 641 class ImportElementHandle extends ElementHandle implements ImportElement {
695 /** 642 /**
696 * Initialize a newly created element handle to represent the given element. 643 * Initialize a newly created element handle to represent the given element.
697 * 644 *
698 * @param element the element being represented 645 * @param element the element being represented
699 */ 646 */
700 ImportElementHandle(ImportElement element) : super(element); 647 ImportElementHandle(
648 ElementResynthesizer resynthesizer, ElementLocation location)
649 : super(resynthesizer, location);
701 650
702 @override 651 @override
703 ImportElement get actualElement => super.actualElement as ImportElement; 652 ImportElement get actualElement => super.actualElement as ImportElement;
704 653
705 @override 654 @override
706 List<NamespaceCombinator> get combinators => actualElement.combinators; 655 List<NamespaceCombinator> get combinators => actualElement.combinators;
707 656
708 @override 657 @override
709 LibraryElement get importedLibrary => actualElement.importedLibrary; 658 LibraryElement get importedLibrary => actualElement.importedLibrary;
710 659
(...skipping 21 matching lines...) Expand all
732 681
733 /** 682 /**
734 * Instances of the class `LabelElementHandle` implement a handle to a `LabelEle ment`. 683 * Instances of the class `LabelElementHandle` implement a handle to a `LabelEle ment`.
735 */ 684 */
736 class LabelElementHandle extends ElementHandle implements LabelElement { 685 class LabelElementHandle extends ElementHandle implements LabelElement {
737 /** 686 /**
738 * Initialize a newly created element handle to represent the given element. 687 * Initialize a newly created element handle to represent the given element.
739 * 688 *
740 * @param element the element being represented 689 * @param element the element being represented
741 */ 690 */
742 LabelElementHandle(LabelElement element) : super(element); 691 LabelElementHandle(
692 ElementResynthesizer resynthesizer, ElementLocation location)
693 : super(resynthesizer, location);
743 694
744 @override 695 @override
745 ExecutableElement get enclosingElement => 696 ExecutableElement get enclosingElement =>
746 super.enclosingElement as ExecutableElement; 697 super.enclosingElement as ExecutableElement;
747 698
748 @override 699 @override
749 ElementKind get kind => ElementKind.LABEL; 700 ElementKind get kind => ElementKind.LABEL;
750 } 701 }
751 702
752 /** 703 /**
753 * Instances of the class `LibraryElementHandle` implement a handle to a 704 * Instances of the class `LibraryElementHandle` implement a handle to a
754 * `LibraryElement`. 705 * `LibraryElement`.
755 */ 706 */
756 class LibraryElementHandle extends ElementHandle implements LibraryElement { 707 class LibraryElementHandle extends ElementHandle implements LibraryElement {
757 /** 708 /**
758 * Initialize a newly created element handle to represent the given element. 709 * Initialize a newly created element handle to represent the given element.
759 * 710 *
760 * @param element the element being represented 711 * @param element the element being represented
761 */ 712 */
762 LibraryElementHandle(LibraryElement element) : super(element); 713 LibraryElementHandle(
714 ElementResynthesizer resynthesizer, ElementLocation location)
715 : super(resynthesizer, location);
763 716
764 @override 717 @override
765 LibraryElement get actualElement => super.actualElement as LibraryElement; 718 LibraryElement get actualElement => super.actualElement as LibraryElement;
766 719
767 @override 720 @override
768 CompilationUnitElement get definingCompilationUnit => 721 CompilationUnitElement get definingCompilationUnit =>
769 actualElement.definingCompilationUnit; 722 actualElement.definingCompilationUnit;
770 723
771 @override 724 @override
772 FunctionElement get entryPoint => actualElement.entryPoint; 725 FunctionElement get entryPoint => actualElement.entryPoint;
773 726
774 @override 727 @override
775 List<LibraryElement> get exportedLibraries => actualElement.exportedLibraries; 728 List<LibraryElement> get exportedLibraries => actualElement.exportedLibraries;
776 729
777 @override 730 @override
778 Namespace get exportNamespace => actualElement.exportNamespace; 731 Namespace get exportNamespace => actualElement.exportNamespace;
779 732
780 @override 733 @override
781 List<ExportElement> get exports => actualElement.exports; 734 List<ExportElement> get exports => actualElement.exports;
782 735
783 @override 736 @override
784 bool get hasExtUri => actualElement.hasExtUri; 737 bool get hasExtUri => actualElement.hasExtUri;
785 738
786 @override 739 @override
787 bool get hasLoadLibraryFunction => actualElement.hasLoadLibraryFunction; 740 bool get hasLoadLibraryFunction => actualElement.hasLoadLibraryFunction;
788 741
789 @override 742 @override
743 String get identifier => location.components.last;
744
745 @override
790 List<LibraryElement> get importedLibraries => actualElement.importedLibraries; 746 List<LibraryElement> get importedLibraries => actualElement.importedLibraries;
791 747
792 @override 748 @override
793 List<ImportElement> get imports => actualElement.imports; 749 List<ImportElement> get imports => actualElement.imports;
794 750
795 @override 751 @override
796 bool get isBrowserApplication => actualElement.isBrowserApplication; 752 bool get isBrowserApplication => actualElement.isBrowserApplication;
797 753
798 @override 754 @override
799 bool get isDartCore => actualElement.isDartCore; 755 bool get isDartCore => actualElement.isDartCore;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 * Instances of the class `LocalVariableElementHandle` implement a handle to a 793 * Instances of the class `LocalVariableElementHandle` implement a handle to a
838 * `LocalVariableElement`. 794 * `LocalVariableElement`.
839 */ 795 */
840 class LocalVariableElementHandle extends VariableElementHandle 796 class LocalVariableElementHandle extends VariableElementHandle
841 implements LocalVariableElement { 797 implements LocalVariableElement {
842 /** 798 /**
843 * Initialize a newly created element handle to represent the given element. 799 * Initialize a newly created element handle to represent the given element.
844 * 800 *
845 * @param element the element being represented 801 * @param element the element being represented
846 */ 802 */
847 LocalVariableElementHandle(LocalVariableElement element) : super(element); 803 LocalVariableElementHandle(
804 ElementResynthesizer resynthesizer, ElementLocation location)
805 : super(resynthesizer, location);
848 806
849 @override 807 @override
850 LocalVariableElement get actualElement => 808 LocalVariableElement get actualElement =>
851 super.actualElement as LocalVariableElement; 809 super.actualElement as LocalVariableElement;
852 810
853 @override 811 @override
854 ElementKind get kind => ElementKind.LOCAL_VARIABLE; 812 ElementKind get kind => ElementKind.LOCAL_VARIABLE;
855 813
856 @override 814 @override
857 SourceRange get visibleRange => actualElement.visibleRange; 815 SourceRange get visibleRange => actualElement.visibleRange;
858 816
859 @override 817 @override
860 VariableDeclaration computeNode() => actualElement.computeNode(); 818 VariableDeclaration computeNode() => actualElement.computeNode();
861 } 819 }
862 820
863 /** 821 /**
864 * Instances of the class `MethodElementHandle` implement a handle to a `MethodE lement`. 822 * Instances of the class `MethodElementHandle` implement a handle to a `MethodE lement`.
865 */ 823 */
866 class MethodElementHandle extends ExecutableElementHandle 824 class MethodElementHandle extends ExecutableElementHandle
867 implements MethodElement { 825 implements MethodElement {
868 /** 826 /**
869 * Initialize a newly created element handle to represent the given element. 827 * Initialize a newly created element handle to represent the given element.
870 * 828 *
871 * @param element the element being represented 829 * @param element the element being represented
872 */ 830 */
873 MethodElementHandle(MethodElement element) : super(element); 831 MethodElementHandle(
832 ElementResynthesizer resynthesizer, ElementLocation location)
833 : super(resynthesizer, location);
874 834
875 @override 835 @override
876 MethodElement get actualElement => super.actualElement as MethodElement; 836 MethodElement get actualElement => super.actualElement as MethodElement;
877 837
878 @override 838 @override
879 ClassElement get enclosingElement => super.enclosingElement as ClassElement; 839 ClassElement get enclosingElement => super.enclosingElement as ClassElement;
880 840
881 @override 841 @override
882 bool get isStatic => actualElement.isStatic; 842 bool get isStatic => actualElement.isStatic;
883 843
884 @override 844 @override
885 ElementKind get kind => ElementKind.METHOD; 845 ElementKind get kind => ElementKind.METHOD;
886 846
887 @override 847 @override
888 MethodDeclaration computeNode() => actualElement.computeNode(); 848 MethodDeclaration computeNode() => actualElement.computeNode();
889 } 849 }
890 850
891 /** 851 /**
892 * Instances of the class `ParameterElementHandle` implement a handle to a 852 * Instances of the class `ParameterElementHandle` implement a handle to a
893 * `ParameterElement`. 853 * `ParameterElement`.
894 */ 854 */
895 class ParameterElementHandle extends VariableElementHandle 855 class ParameterElementHandle extends VariableElementHandle
896 with ParameterElementMixin 856 with ParameterElementMixin
897 implements ParameterElement { 857 implements ParameterElement {
898 /** 858 /**
899 * Initialize a newly created element handle to represent the given element. 859 * Initialize a newly created element handle to represent the given element.
900 * 860 *
901 * @param element the element being represented 861 * @param element the element being represented
902 */ 862 */
903 ParameterElementHandle(ParameterElement element) : super(element); 863 ParameterElementHandle(
864 ElementResynthesizer resynthesizer, ElementLocation location)
865 : super(resynthesizer, location);
904 866
905 @override 867 @override
906 ParameterElement get actualElement => super.actualElement as ParameterElement; 868 ParameterElement get actualElement => super.actualElement as ParameterElement;
907 869
908 @override 870 @override
909 String get defaultValueCode => actualElement.defaultValueCode; 871 String get defaultValueCode => actualElement.defaultValueCode;
910 872
911 @override 873 @override
912 bool get isInitializingFormal => actualElement.isInitializingFormal; 874 bool get isInitializingFormal => actualElement.isInitializingFormal;
913 875
(...skipping 15 matching lines...) Expand all
929 891
930 /** 892 /**
931 * Instances of the class `PrefixElementHandle` implement a handle to a `PrefixE lement`. 893 * Instances of the class `PrefixElementHandle` implement a handle to a `PrefixE lement`.
932 */ 894 */
933 class PrefixElementHandle extends ElementHandle implements PrefixElement { 895 class PrefixElementHandle extends ElementHandle implements PrefixElement {
934 /** 896 /**
935 * Initialize a newly created element handle to represent the given element. 897 * Initialize a newly created element handle to represent the given element.
936 * 898 *
937 * @param element the element being represented 899 * @param element the element being represented
938 */ 900 */
939 PrefixElementHandle(PrefixElement element) : super(element); 901 PrefixElementHandle(
902 ElementResynthesizer resynthesizer, ElementLocation location)
903 : super(resynthesizer, location);
940 904
941 @override 905 @override
942 PrefixElement get actualElement => super.actualElement as PrefixElement; 906 PrefixElement get actualElement => super.actualElement as PrefixElement;
943 907
944 @override 908 @override
945 LibraryElement get enclosingElement => 909 LibraryElement get enclosingElement =>
946 super.enclosingElement as LibraryElement; 910 super.enclosingElement as LibraryElement;
947 911
948 @override 912 @override
949 List<LibraryElement> get importedLibraries => actualElement.importedLibraries; 913 List<LibraryElement> get importedLibraries => actualElement.importedLibraries;
950 914
951 @override 915 @override
952 ElementKind get kind => ElementKind.PREFIX; 916 ElementKind get kind => ElementKind.PREFIX;
953 } 917 }
954 918
955 /** 919 /**
956 * Instances of the class `PropertyAccessorElementHandle` implement a handle to a 920 * Instances of the class `PropertyAccessorElementHandle` implement a handle to a
957 * `PropertyAccessorElement`. 921 * `PropertyAccessorElement`.
958 */ 922 */
959 class PropertyAccessorElementHandle extends ExecutableElementHandle 923 class PropertyAccessorElementHandle extends ExecutableElementHandle
960 implements PropertyAccessorElement { 924 implements PropertyAccessorElement {
961 /** 925 /**
962 * Initialize a newly created element handle to represent the given element. 926 * Initialize a newly created element handle to represent the given element.
963 * 927 *
964 * @param element the element being represented 928 * @param element the element being represented
965 */ 929 */
966 PropertyAccessorElementHandle(PropertyAccessorElement element) 930 PropertyAccessorElementHandle(
967 : super(element); 931 ElementResynthesizer resynthesizer, ElementLocation location)
932 : super(resynthesizer, location);
968 933
969 @override 934 @override
970 PropertyAccessorElement get actualElement => 935 PropertyAccessorElement get actualElement =>
971 super.actualElement as PropertyAccessorElement; 936 super.actualElement as PropertyAccessorElement;
972 937
973 @override 938 @override
974 PropertyAccessorElement get correspondingGetter => 939 PropertyAccessorElement get correspondingGetter =>
975 actualElement.correspondingGetter; 940 actualElement.correspondingGetter;
976 941
977 @override 942 @override
(...skipping 23 matching lines...) Expand all
1001 * The abstract class `PropertyInducingElementHandle` implements the behavior co mmon to 966 * The abstract class `PropertyInducingElementHandle` implements the behavior co mmon to
1002 * objects that implement a handle to an `PropertyInducingElement`. 967 * objects that implement a handle to an `PropertyInducingElement`.
1003 */ 968 */
1004 abstract class PropertyInducingElementHandle extends VariableElementHandle 969 abstract class PropertyInducingElementHandle extends VariableElementHandle
1005 implements PropertyInducingElement { 970 implements PropertyInducingElement {
1006 /** 971 /**
1007 * Initialize a newly created element handle to represent the given element. 972 * Initialize a newly created element handle to represent the given element.
1008 * 973 *
1009 * @param element the element being represented 974 * @param element the element being represented
1010 */ 975 */
1011 PropertyInducingElementHandle(PropertyInducingElement element) 976 PropertyInducingElementHandle(
1012 : super(element); 977 ElementResynthesizer resynthesizer, ElementLocation location)
978 : super(resynthesizer, location);
1013 979
1014 @override 980 @override
1015 PropertyInducingElement get actualElement => 981 PropertyInducingElement get actualElement =>
1016 super.actualElement as PropertyInducingElement; 982 super.actualElement as PropertyInducingElement;
1017 983
1018 @override 984 @override
1019 PropertyAccessorElement get getter => actualElement.getter; 985 PropertyAccessorElement get getter => actualElement.getter;
1020 986
1021 @override 987 @override
1022 DartType get propagatedType => actualElement.propagatedType; 988 DartType get propagatedType => actualElement.propagatedType;
1023 989
1024 @override 990 @override
1025 PropertyAccessorElement get setter => actualElement.setter; 991 PropertyAccessorElement get setter => actualElement.setter;
1026 } 992 }
1027 993
1028 /** 994 /**
1029 * Instances of the class `TopLevelVariableElementHandle` implement a handle to a 995 * Instances of the class `TopLevelVariableElementHandle` implement a handle to a
1030 * `TopLevelVariableElement`. 996 * `TopLevelVariableElement`.
1031 */ 997 */
1032 class TopLevelVariableElementHandle extends PropertyInducingElementHandle 998 class TopLevelVariableElementHandle extends PropertyInducingElementHandle
1033 implements TopLevelVariableElement { 999 implements TopLevelVariableElement {
1034 /** 1000 /**
1035 * Initialize a newly created element handle to represent the given element. 1001 * Initialize a newly created element handle to represent the given element.
1036 * 1002 *
1037 * @param element the element being represented 1003 * @param element the element being represented
1038 */ 1004 */
1039 TopLevelVariableElementHandle(TopLevelVariableElement element) 1005 TopLevelVariableElementHandle(
1040 : super(element); 1006 ElementResynthesizer resynthesizer, ElementLocation location)
1007 : super(resynthesizer, location);
1041 1008
1042 @override 1009 @override
1043 ElementKind get kind => ElementKind.TOP_LEVEL_VARIABLE; 1010 ElementKind get kind => ElementKind.TOP_LEVEL_VARIABLE;
1044 } 1011 }
1045 1012
1046 /** 1013 /**
1047 * Instances of the class `TypeParameterElementHandle` implement a handle to a 1014 * Instances of the class `TypeParameterElementHandle` implement a handle to a
1048 * [TypeParameterElement]. 1015 * [TypeParameterElement].
1049 */ 1016 */
1050 class TypeParameterElementHandle extends ElementHandle 1017 class TypeParameterElementHandle extends ElementHandle
1051 implements TypeParameterElement { 1018 implements TypeParameterElement {
1052 /** 1019 /**
1053 * Initialize a newly created element handle to represent the given element. 1020 * Initialize a newly created element handle to represent the given element.
1054 * 1021 *
1055 * @param element the element being represented 1022 * @param element the element being represented
1056 */ 1023 */
1057 TypeParameterElementHandle(TypeParameterElement element) : super(element); 1024 TypeParameterElementHandle(
1025 ElementResynthesizer resynthesizer, ElementLocation location)
1026 : super(resynthesizer, location);
1058 1027
1059 @override 1028 @override
1060 TypeParameterElement get actualElement => 1029 TypeParameterElement get actualElement =>
1061 super.actualElement as TypeParameterElement; 1030 super.actualElement as TypeParameterElement;
1062 1031
1063 @override 1032 @override
1064 DartType get bound => actualElement.bound; 1033 DartType get bound => actualElement.bound;
1065 1034
1066 @override 1035 @override
1067 ElementKind get kind => ElementKind.TYPE_PARAMETER; 1036 ElementKind get kind => ElementKind.TYPE_PARAMETER;
1068 1037
1069 @override 1038 @override
1070 TypeParameterType get type => actualElement.type; 1039 TypeParameterType get type => actualElement.type;
1071 } 1040 }
1072 1041
1073 /** 1042 /**
1074 * The abstract class `VariableElementHandle` implements the behavior common to objects that 1043 * The abstract class `VariableElementHandle` implements the behavior common to objects that
1075 * implement a handle to an `VariableElement`. 1044 * implement a handle to an `VariableElement`.
1076 */ 1045 */
1077 abstract class VariableElementHandle extends ElementHandle 1046 abstract class VariableElementHandle extends ElementHandle
1078 implements VariableElement { 1047 implements VariableElement {
1079 /** 1048 /**
1080 * Initialize a newly created element handle to represent the given element. 1049 * Initialize a newly created element handle to represent the given element.
1081 * 1050 *
1082 * @param element the element being represented 1051 * @param element the element being represented
1083 */ 1052 */
1084 VariableElementHandle(VariableElement element) : super(element); 1053 VariableElementHandle(
1054 ElementResynthesizer resynthesizer, ElementLocation location)
1055 : super(resynthesizer, location);
1085 1056
1086 @override 1057 @override
1087 VariableElement get actualElement => super.actualElement as VariableElement; 1058 VariableElement get actualElement => super.actualElement as VariableElement;
1088 1059
1089 @override 1060 @override
1090 DartObject get constantValue => actualElement.constantValue; 1061 DartObject get constantValue => actualElement.constantValue;
1091 1062
1092 @override 1063 @override
1093 bool get hasImplicitType => actualElement.hasImplicitType; 1064 bool get hasImplicitType => actualElement.hasImplicitType;
1094 1065
(...skipping 22 matching lines...) Expand all
1117 } 1088 }
1118 1089
1119 /** 1090 /**
1120 * TODO(scheglov) invalid implementation 1091 * TODO(scheglov) invalid implementation
1121 */ 1092 */
1122 class WeakReference<T> { 1093 class WeakReference<T> {
1123 final T value; 1094 final T value;
1124 WeakReference(this.value); 1095 WeakReference(this.value);
1125 T get() => value; 1096 T get() => value;
1126 } 1097 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698