| OLD | NEW |
| 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 summary_resynthesizer; | 5 library summary_resynthesizer; |
| 6 | 6 |
| 7 import 'package:analyzer/analyzer.dart'; | 7 import 'package:analyzer/analyzer.dart'; |
| 8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
| 9 import 'package:analyzer/src/generated/element_handle.dart'; | 9 import 'package:analyzer/src/generated/element_handle.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 return field; | 592 return field; |
| 593 } | 593 } |
| 594 } | 594 } |
| 595 | 595 |
| 596 /** | 596 /** |
| 597 * Build the implicit top level variable associated with a getter or setter, | 597 * Build the implicit top level variable associated with a getter or setter, |
| 598 * and place it in [holder]. | 598 * and place it in [holder]. |
| 599 */ | 599 */ |
| 600 PropertyInducingElementImpl buildImplicitTopLevelVariable( | 600 PropertyInducingElementImpl buildImplicitTopLevelVariable( |
| 601 String name, UnlinkedExecutableKind kind, ElementHolder holder) { | 601 String name, UnlinkedExecutableKind kind, ElementHolder holder) { |
| 602 if (holder.getTopLevelVariable(name) == null) { | 602 TopLevelVariableElementImpl variable = holder.getTopLevelVariable(name); |
| 603 TopLevelVariableElementImpl variable = | 603 if (variable == null) { |
| 604 new TopLevelVariableElementImpl(name, -1); | 604 variable = new TopLevelVariableElementImpl(name, -1); |
| 605 variable.synthetic = true; | 605 variable.synthetic = true; |
| 606 variable.final2 = kind == UnlinkedExecutableKind.getter; | 606 variable.final2 = kind == UnlinkedExecutableKind.getter; |
| 607 holder.addTopLevelVariable(variable); | 607 holder.addTopLevelVariable(variable); |
| 608 return variable; | 608 return variable; |
| 609 } else { | 609 } else { |
| 610 // TODO(paulberry): if adding a setter where there was previously | |
| 611 // only a getter, remove "final" modifier. | |
| 612 // TODO(paulberry): what if the getter and setter have a type mismatch? | 610 // TODO(paulberry): what if the getter and setter have a type mismatch? |
| 613 throw new UnimplementedError(); | 611 variable.final2 = false; |
| 612 return variable; |
| 614 } | 613 } |
| 615 } | 614 } |
| 616 | 615 |
| 617 /** | 616 /** |
| 618 * Resynthesize an [ImportElement]. | 617 * Resynthesize an [ImportElement]. |
| 619 */ | 618 */ |
| 620 ImportElement buildImport(UnlinkedImport serializedImport, int dependency) { | 619 ImportElement buildImport(UnlinkedImport serializedImport, int dependency) { |
| 621 bool isSynthetic = serializedImport.isImplicit; | 620 bool isSynthetic = serializedImport.isImplicit; |
| 622 // TODO(paulberry): it seems problematic for the offset to be 0 for | 621 // TODO(paulberry): it seems problematic for the offset to be 0 for |
| 623 // non-synthetic imports, since it is used to disambiguate location. | 622 // non-synthetic imports, since it is used to disambiguate location. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 /** | 770 /** |
| 772 * Build a [DartType] object based on an [UnlinkedTypeRef]. This [DartType] | 771 * Build a [DartType] object based on an [UnlinkedTypeRef]. This [DartType] |
| 773 * may refer to elements in other libraries than the library being | 772 * may refer to elements in other libraries than the library being |
| 774 * deserialized, so handles are used to avoid having to deserialize other | 773 * deserialized, so handles are used to avoid having to deserialize other |
| 775 * libraries in the process. | 774 * libraries in the process. |
| 776 */ | 775 */ |
| 777 DartType buildType(UnlinkedTypeRef type) { | 776 DartType buildType(UnlinkedTypeRef type) { |
| 778 if (type.paramReference != 0) { | 777 if (type.paramReference != 0) { |
| 779 // TODO(paulberry): make this work for generic methods. | 778 // TODO(paulberry): make this work for generic methods. |
| 780 return currentTypeParameters[ | 779 return currentTypeParameters[ |
| 781 currentTypeParameters.length - type.paramReference].type; | 780 currentTypeParameters.length - type.paramReference] |
| 781 .type; |
| 782 } else { | 782 } else { |
| 783 // TODO(paulberry): handle references to things other than classes (note: | 783 // TODO(paulberry): handle references to things other than classes (note: |
| 784 // this should only occur in the case of erroneous code). | 784 // this should only occur in the case of erroneous code). |
| 785 // TODO(paulberry): test reference to something inside a part. | 785 // TODO(paulberry): test reference to something inside a part. |
| 786 // TODO(paulberry): test reference to something inside a part of the | 786 // TODO(paulberry): test reference to something inside a part of the |
| 787 // current lib. | 787 // current lib. |
| 788 UnlinkedReference reference = unlinkedUnit.references[type.reference]; | 788 UnlinkedReference reference = unlinkedUnit.references[type.reference]; |
| 789 PrelinkedReference referenceResolution = | 789 PrelinkedReference referenceResolution = |
| 790 prelinkedUnit.references[type.reference]; | 790 prelinkedUnit.references[type.reference]; |
| 791 String referencedLibraryUri; | 791 String referencedLibraryUri; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 break; | 999 break; |
| 1000 } | 1000 } |
| 1001 } | 1001 } |
| 1002 resummarizedElements[absoluteUri] = elementMap; | 1002 resummarizedElements[absoluteUri] = elementMap; |
| 1003 unitHolder = null; | 1003 unitHolder = null; |
| 1004 prelinkedUnit = null; | 1004 prelinkedUnit = null; |
| 1005 unlinkedUnit = null; | 1005 unlinkedUnit = null; |
| 1006 return entryPoint; | 1006 return entryPoint; |
| 1007 } | 1007 } |
| 1008 } | 1008 } |
| OLD | NEW |