OLD | NEW |
---|---|
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.test.src.context.context_test; | 5 library analyzer.test.src.context.context_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 2832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2843 } | 2843 } |
2844 ''', | 2844 ''', |
2845 r''' | 2845 r''' |
2846 import 'a.dart'; | 2846 import 'a.dart'; |
2847 main() { | 2847 main() { |
2848 new A.named(); | 2848 new A.named(); |
2849 } | 2849 } |
2850 '''); | 2850 '''); |
2851 } | 2851 } |
2852 | 2852 |
2853 void test_class_constructor_named_parameters_change_usedSuper() { | |
2854 // Update a.dart: change A.named(). | |
2855 // b.dart is invalid, because it references A.named(). | |
2856 _verifyTwoLibrariesInvalidatesResolution( | |
2857 r''' | |
2858 class A { | |
2859 A.named(int a); | |
2860 } | |
2861 ''', | |
2862 r''' | |
2863 class A { | |
2864 A.named(String a); | |
2865 } | |
2866 ''', | |
2867 r''' | |
2868 import 'a.dart'; | |
2869 class B extends A { | |
2870 B() : super.named(42); | |
2871 } | |
2872 '''); | |
2873 } | |
2874 | |
2853 void test_class_constructor_named_parameters_remove() { | 2875 void test_class_constructor_named_parameters_remove() { |
2854 // Update a.dart: remove a new parameter of A.named(). | 2876 // Update a.dart: remove a new parameter of A.named(). |
2855 // b.dart is invalid, because it references A.named(). | 2877 // b.dart is invalid, because it references A.named(). |
2856 _verifyTwoLibrariesInvalidatesResolution( | 2878 _verifyTwoLibrariesInvalidatesResolution( |
2857 r''' | 2879 r''' |
2858 class A { | 2880 class A { |
2859 A.named(int p); | 2881 A.named(int p); |
2860 } | 2882 } |
2861 ''', | 2883 ''', |
2862 r''' | 2884 r''' |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2909 } | 2931 } |
2910 ''', | 2932 ''', |
2911 r''' | 2933 r''' |
2912 import 'a.dart'; | 2934 import 'a.dart'; |
2913 main() { | 2935 main() { |
2914 new A.named(); | 2936 new A.named(); |
2915 } | 2937 } |
2916 '''); | 2938 '''); |
2917 } | 2939 } |
2918 | 2940 |
2941 void test_class_constructor_unnamed_parameters_change_notUsedSuper() { | |
2942 // Update a.dart: change A(). | |
2943 // Resolution of b.dart is valid, because it does not reference A(). | |
2944 // Hints and verify errors are invalid, because it extends A. | |
2945 // TODO(scheglov) we could keep valid hints and verify errors, | |
2946 // because only constructor is changed - this cannot add/remove | |
2947 // inherited unimplemented members. | |
Brian Wilkerson
2016/07/27 22:09:33
This seems like the wrong place for this TODO comm
| |
2948 _verifyTwoLibrariesInvalidHintsVerifyErrors( | |
2949 r''' | |
2950 class A { | |
2951 A(int a); | |
2952 A.named(int a); | |
2953 } | |
2954 ''', | |
2955 r''' | |
2956 class A { | |
2957 A(String a); | |
2958 A.named(int a); | |
2959 } | |
2960 ''', | |
2961 r''' | |
2962 import 'a.dart'; | |
2963 class B extends A { | |
2964 B() : super.named(42); | |
2965 } | |
2966 '''); | |
2967 } | |
2968 | |
2969 void test_class_constructor_unnamed_parameters_change_usedSuper() { | |
2970 // Update a.dart: change A(). | |
2971 // b.dart is invalid, because it references A(). | |
2972 _verifyTwoLibrariesInvalidatesResolution( | |
2973 r''' | |
2974 class A { | |
2975 A(int a); | |
2976 } | |
2977 ''', | |
2978 r''' | |
2979 class A { | |
2980 A(String a); | |
2981 } | |
2982 ''', | |
2983 r''' | |
2984 import 'a.dart'; | |
2985 class B extends A { | |
2986 B() : super(42); | |
2987 } | |
2988 '''); | |
2989 } | |
2990 | |
2919 void test_class_constructor_unnamed_parameters_remove() { | 2991 void test_class_constructor_unnamed_parameters_remove() { |
2920 // Update a.dart: change A(). | 2992 // Update a.dart: change A(). |
2921 // b.dart is invalid, because it references A(). | 2993 // b.dart is invalid, because it references A(). |
2922 _verifyTwoLibrariesInvalidatesResolution( | 2994 _verifyTwoLibrariesInvalidatesResolution( |
2923 r''' | 2995 r''' |
2924 class A { | 2996 class A { |
2925 A(int a, int b); | 2997 A(int a, int b); |
2926 } | 2998 } |
2927 ''', | 2999 ''', |
2928 r''' | 3000 r''' |
(...skipping 26 matching lines...) Expand all Loading... | |
2955 ''', | 3027 ''', |
2956 r''' | 3028 r''' |
2957 import 'a.dart'; | 3029 import 'a.dart'; |
2958 main() { | 3030 main() { |
2959 new A.named(); | 3031 new A.named(); |
2960 } | 3032 } |
2961 '''); | 3033 '''); |
2962 } | 3034 } |
2963 | 3035 |
2964 void test_class_constructor_unnamed_remove_used() { | 3036 void test_class_constructor_unnamed_remove_used() { |
2965 // Update a.dart: remove A.named(). | 3037 // Update a.dart: remove A(). |
2966 // b.dart is invalid, because it references A.named(). | 3038 // b.dart is invalid, because it references A(). |
2967 _verifyTwoLibrariesInvalidatesResolution( | 3039 _verifyTwoLibrariesInvalidatesResolution( |
2968 r''' | 3040 r''' |
2969 class A { | 3041 class A { |
2970 A(); | 3042 A(); |
2971 } | 3043 } |
2972 ''', | 3044 ''', |
2973 r''' | 3045 r''' |
2974 class A { | 3046 class A { |
2975 } | 3047 } |
2976 ''', | 3048 ''', |
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4672 Source a = addSource('/a.dart', firstCodeA); | 4744 Source a = addSource('/a.dart', firstCodeA); |
4673 Source b = addSource('/b.dart', codeB); | 4745 Source b = addSource('/b.dart', codeB); |
4674 _performPendingAnalysisTasks(); | 4746 _performPendingAnalysisTasks(); |
4675 context.setContents(a, secondCodeA); | 4747 context.setContents(a, secondCodeA); |
4676 _assertValidForChangedLibrary(a); | 4748 _assertValidForChangedLibrary(a); |
4677 _assertInvalid(a, LIBRARY_ERRORS_READY); | 4749 _assertInvalid(a, LIBRARY_ERRORS_READY); |
4678 _assertValidForDependentLibrary(b); | 4750 _assertValidForDependentLibrary(b); |
4679 _assertInvalid(b, LIBRARY_ERRORS_READY); | 4751 _assertInvalid(b, LIBRARY_ERRORS_READY); |
4680 _assertInvalidUnits(b, RESOLVED_UNIT4); | 4752 _assertInvalidUnits(b, RESOLVED_UNIT4); |
4681 } | 4753 } |
4754 | |
4755 void _verifyTwoLibrariesInvalidHintsVerifyErrors( | |
4756 String firstCodeA, String secondCodeA, String codeB) { | |
4757 Source a = addSource('/a.dart', firstCodeA); | |
4758 Source b = addSource('/b.dart', codeB); | |
4759 _performPendingAnalysisTasks(); | |
4760 context.setContents(a, secondCodeA); | |
4761 _assertValidForChangedLibrary(a); | |
4762 _assertInvalid(a, LIBRARY_ERRORS_READY); | |
4763 _assertValidForDependentLibrary(b); | |
4764 _assertValidAllResolution(b); | |
4765 _assertUnitValid(b, RESOLVE_UNIT_ERRORS); | |
4766 _assertInvalidHintsVerifyErrors(b); | |
4767 } | |
4682 } | 4768 } |
4683 | 4769 |
4684 class _AnalysisContextImplTest_Source_exists_true extends TestSource { | 4770 class _AnalysisContextImplTest_Source_exists_true extends TestSource { |
4685 @override | 4771 @override |
4686 bool exists() => true; | 4772 bool exists() => true; |
4687 } | 4773 } |
4688 | 4774 |
4689 class _AnalysisContextImplTest_Source_getModificationStamp_fromSource | 4775 class _AnalysisContextImplTest_Source_getModificationStamp_fromSource |
4690 extends TestSource { | 4776 extends TestSource { |
4691 int stamp; | 4777 int stamp; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4781 * Initialize the visitor. | 4867 * Initialize the visitor. |
4782 */ | 4868 */ |
4783 _ElementGatherer(); | 4869 _ElementGatherer(); |
4784 | 4870 |
4785 @override | 4871 @override |
4786 void visitElement(Element element) { | 4872 void visitElement(Element element) { |
4787 elements[element] = element; | 4873 elements[element] = element; |
4788 super.visitElement(element); | 4874 super.visitElement(element); |
4789 } | 4875 } |
4790 } | 4876 } |
OLD | NEW |