OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:io'; | 5 import 'dart:io'; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 | 674 |
675 void writePropertyAccessorElement(PropertyAccessorElement e) { | 675 void writePropertyAccessorElement(PropertyAccessorElement e) { |
676 if (e.isSynthetic && !withSyntheticAccessors) { | 676 if (e.isSynthetic && !withSyntheticAccessors) { |
677 return; | 677 return; |
678 } | 678 } |
679 | 679 |
680 if (!e.isSynthetic) { | 680 if (!e.isSynthetic) { |
681 PropertyInducingElement variable = e.variable; | 681 PropertyInducingElement variable = e.variable; |
682 expect(variable, isNotNull); | 682 expect(variable, isNotNull); |
683 expect(variable.isSynthetic, isTrue); | 683 expect(variable.isSynthetic, isTrue); |
| 684 |
| 685 var variableEnclosing = variable.enclosingElement; |
| 686 if (variableEnclosing is CompilationUnitElement) { |
| 687 expect(variableEnclosing.topLevelVariables, contains(variable)); |
| 688 } else if (variableEnclosing is ClassElement) { |
| 689 expect(variableEnclosing.fields, contains(variable)); |
| 690 } |
| 691 |
684 if (e.isGetter) { | 692 if (e.isGetter) { |
685 expect(variable.getter, same(e)); | 693 expect(variable.getter, same(e)); |
686 if (variable.setter != null) { | 694 if (variable.setter != null) { |
687 expect(variable.setter.variable, same(variable)); | 695 expect(variable.setter.variable, same(variable)); |
688 } | 696 } |
689 } else { | 697 } else { |
690 expect(variable.setter, same(e)); | 698 expect(variable.setter, same(e)); |
691 if (variable.getter != null) { | 699 if (variable.getter != null) { |
692 expect(variable.getter.variable, same(variable)); | 700 expect(variable.getter.variable, same(variable)); |
693 } | 701 } |
(...skipping 29 matching lines...) Expand all Loading... |
723 if (e.isSetter || e.parameters.isNotEmpty) { | 731 if (e.isSetter || e.parameters.isNotEmpty) { |
724 writeParameterElements(e.parameters); | 732 writeParameterElements(e.parameters); |
725 } | 733 } |
726 | 734 |
727 expect(e.typeParameters, isEmpty); | 735 expect(e.typeParameters, isEmpty); |
728 | 736 |
729 expect(e.isSynchronous, isTrue); | 737 expect(e.isSynchronous, isTrue); |
730 expect(e.isAsynchronous, isFalse); | 738 expect(e.isAsynchronous, isFalse); |
731 expect(e.isGenerator, isFalse); | 739 expect(e.isGenerator, isFalse); |
732 | 740 |
733 if (e.isAbstract) { | 741 if (e.isAbstract || e.isExternal) { |
734 buffer.writeln(';'); | 742 buffer.writeln(';'); |
735 } else { | 743 } else { |
736 buffer.writeln(' {}'); | 744 buffer.writeln(' {}'); |
737 } | 745 } |
738 } | 746 } |
739 | 747 |
740 void writePropertyInducingElement(PropertyInducingElement e) { | 748 void writePropertyInducingElement(PropertyInducingElement e) { |
741 if (e.isSynthetic && !withSyntheticFields && !isEnumField(e)) { | 749 if (e.isSynthetic && !withSyntheticFields && !isEnumField(e)) { |
742 return; | 750 return; |
743 } | 751 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 return components.join(';'); | 897 return components.join(';'); |
890 } | 898 } |
891 } | 899 } |
892 | 900 |
893 class _Replacement { | 901 class _Replacement { |
894 final int offset; | 902 final int offset; |
895 final int end; | 903 final int end; |
896 final String text; | 904 final String text; |
897 _Replacement(this.offset, this.end, this.text); | 905 _Replacement(this.offset, this.end, this.text); |
898 } | 906 } |
OLD | NEW |