| 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 3085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3096 _assertValidForChangedLibrary(a); | 3096 _assertValidForChangedLibrary(a); |
| 3097 _assertInvalid(a, LIBRARY_ERRORS_READY); | 3097 _assertInvalid(a, LIBRARY_ERRORS_READY); |
| 3098 _assertValidForDependentLibrary(b); | 3098 _assertValidForDependentLibrary(b); |
| 3099 _assertInvalid(b, LIBRARY_ERRORS_READY); | 3099 _assertInvalid(b, LIBRARY_ERRORS_READY); |
| 3100 _assertInvalidUnits(b, RESOLVED_UNIT4); | 3100 _assertInvalidUnits(b, RESOLVED_UNIT4); |
| 3101 // Now b.dart is analyzed and it again has the error. | 3101 // Now b.dart is analyzed and it again has the error. |
| 3102 _performPendingAnalysisTasks(); | 3102 _performPendingAnalysisTasks(); |
| 3103 expect(context.getErrors(b).errors, hasLength(1)); | 3103 expect(context.getErrors(b).errors, hasLength(1)); |
| 3104 } | 3104 } |
| 3105 | 3105 |
| 3106 void test_sequence_inBodyChange_addRef_deltaChange() { |
| 3107 Source a = addSource( |
| 3108 '/a.dart', |
| 3109 r''' |
| 3110 class A { |
| 3111 } |
| 3112 '''); |
| 3113 Source b = addSource( |
| 3114 '/b.dart', |
| 3115 r''' |
| 3116 import 'a.dart'; |
| 3117 main(A a) { |
| 3118 } |
| 3119 '''); |
| 3120 _performPendingAnalysisTasks(); |
| 3121 expect(context.getErrors(b).errors, hasLength(0)); |
| 3122 // Update b.dart: in-body incremental change - start referencing 'foo'. |
| 3123 // Should update referenced names. |
| 3124 context.setContents( |
| 3125 b, |
| 3126 r''' |
| 3127 import 'a.dart'; |
| 3128 main(A a) { |
| 3129 a.foo; |
| 3130 } |
| 3131 '''); |
| 3132 _performPendingAnalysisTasks(); |
| 3133 expect(context.getErrors(b).errors, hasLength(1)); |
| 3134 // Update a.dart: add A.foo |
| 3135 // b.dart is invalid, because it references 'foo'. |
| 3136 context.setContents( |
| 3137 a, |
| 3138 r''' |
| 3139 class A { |
| 3140 int foo; |
| 3141 } |
| 3142 '''); |
| 3143 _assertValidForChangedLibrary(a); |
| 3144 _assertInvalid(a, LIBRARY_ERRORS_READY); |
| 3145 _assertValidForDependentLibrary(b); |
| 3146 _assertInvalid(b, LIBRARY_ERRORS_READY); |
| 3147 _assertInvalidUnits(b, RESOLVED_UNIT4); |
| 3148 // No errors after analysis. |
| 3149 _performPendingAnalysisTasks(); |
| 3150 expect(context.getErrors(b).errors, hasLength(0)); |
| 3151 } |
| 3152 |
| 3153 void test_sequence_inBodyChange_removeRef_deltaChange() { |
| 3154 Source a = addSource( |
| 3155 '/a.dart', |
| 3156 r''' |
| 3157 class A { |
| 3158 } |
| 3159 '''); |
| 3160 Source b = addSource( |
| 3161 '/b.dart', |
| 3162 r''' |
| 3163 import 'a.dart'; |
| 3164 main(A a) { |
| 3165 a.foo; |
| 3166 } |
| 3167 '''); |
| 3168 _performPendingAnalysisTasks(); |
| 3169 expect(context.getErrors(b).errors, hasLength(1)); |
| 3170 // Update b.dart: in-body incremental change - stop referencing 'foo'. |
| 3171 // Should update referenced names. |
| 3172 context.setContents( |
| 3173 b, |
| 3174 r''' |
| 3175 import 'a.dart'; |
| 3176 main(A a) { |
| 3177 } |
| 3178 '''); |
| 3179 _performPendingAnalysisTasks(); |
| 3180 expect(context.getErrors(b).errors, hasLength(0)); |
| 3181 // Update a.dart: add A.foo |
| 3182 // b.dart is still valid, because it does references 'foo' anymore. |
| 3183 context.setContents( |
| 3184 a, |
| 3185 r''' |
| 3186 class A { |
| 3187 int foo; |
| 3188 } |
| 3189 '''); |
| 3190 _assertValidForChangedLibrary(a); |
| 3191 _assertInvalid(a, LIBRARY_ERRORS_READY); |
| 3192 _assertValidForDependentLibrary(b); |
| 3193 _assertValidAllLibraryUnitResults(b); |
| 3194 _assertValid(b, LIBRARY_ERRORS_READY); |
| 3195 } |
| 3196 |
| 3106 void test_sequence_noChange_thenChange() { | 3197 void test_sequence_noChange_thenChange() { |
| 3107 Source a = addSource( | 3198 Source a = addSource( |
| 3108 '/a.dart', | 3199 '/a.dart', |
| 3109 r''' | 3200 r''' |
| 3110 class A { | 3201 class A { |
| 3111 A(); | 3202 A(); |
| 3112 } | 3203 } |
| 3113 | 3204 |
| 3114 class B { | 3205 class B { |
| 3115 B(); | 3206 B(); |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3741 * Initialize the visitor. | 3832 * Initialize the visitor. |
| 3742 */ | 3833 */ |
| 3743 _ElementGatherer(); | 3834 _ElementGatherer(); |
| 3744 | 3835 |
| 3745 @override | 3836 @override |
| 3746 void visitElement(Element element) { | 3837 void visitElement(Element element) { |
| 3747 elements[element] = element; | 3838 elements[element] = element; |
| 3748 super.visitElement(element); | 3839 super.visitElement(element); |
| 3749 } | 3840 } |
| 3750 } | 3841 } |
| OLD | NEW |