| 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 test.src.context.context_test; | 5 library test.src.context.context_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/cancelable_future.dart'; | 9 import 'package:analyzer/src/cancelable_future.dart'; |
| 10 import 'package:analyzer/src/context/cache.dart'; | 10 import 'package:analyzer/src/context/cache.dart'; |
| (...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1579 } | 1579 } |
| 1580 | 1580 |
| 1581 void test_performAnalysisTask_IOException() { | 1581 void test_performAnalysisTask_IOException() { |
| 1582 TestSource source = _addSourceWithException2("/test.dart", "library test;"); | 1582 TestSource source = _addSourceWithException2("/test.dart", "library test;"); |
| 1583 source.generateExceptionOnRead = false; | 1583 source.generateExceptionOnRead = false; |
| 1584 _analyzeAll_assertFinished(); | 1584 _analyzeAll_assertFinished(); |
| 1585 expect(source.readCount, 1); | 1585 expect(source.readCount, 1); |
| 1586 _changeSource(source, ""); | 1586 _changeSource(source, ""); |
| 1587 source.generateExceptionOnRead = true; | 1587 source.generateExceptionOnRead = true; |
| 1588 _analyzeAll_assertFinished(); | 1588 _analyzeAll_assertFinished(); |
| 1589 expect(source.readCount, 3); | 1589 expect(source.readCount, 5); |
| 1590 } | 1590 } |
| 1591 | 1591 |
| 1592 void test_performAnalysisTask_missingPart() { | 1592 void test_performAnalysisTask_missingPart() { |
| 1593 Source source = | 1593 Source source = |
| 1594 addSource("/test.dart", "library lib; part 'no-such-file.dart';"); | 1594 addSource("/test.dart", "library lib; part 'no-such-file.dart';"); |
| 1595 _analyzeAll_assertFinished(); | 1595 _analyzeAll_assertFinished(); |
| 1596 expect(context.getLibraryElement(source), isNotNull, | 1596 expect(context.getLibraryElement(source), isNotNull, |
| 1597 reason: "performAnalysisTask failed to compute an element model"); | 1597 reason: "performAnalysisTask failed to compute an element model"); |
| 1598 } | 1598 } |
| 1599 | 1599 |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1993 return false; | 1993 return false; |
| 1994 } | 1994 } |
| 1995 } | 1995 } |
| 1996 | 1996 |
| 1997 @reflectiveTest | 1997 @reflectiveTest |
| 1998 class LimitedInvalidateTest extends AbstractContextTest { | 1998 class LimitedInvalidateTest extends AbstractContextTest { |
| 1999 @override | 1999 @override |
| 2000 void setUp() { | 2000 void setUp() { |
| 2001 AnalysisEngine.instance.limitInvalidationInTaskModel = true; | 2001 AnalysisEngine.instance.limitInvalidationInTaskModel = true; |
| 2002 super.setUp(); | 2002 super.setUp(); |
| 2003 AnalysisOptionsImpl options = |
| 2004 new AnalysisOptionsImpl.from(context.analysisOptions); |
| 2005 options.incremental = true; |
| 2006 context.analysisOptions = options; |
| 2003 } | 2007 } |
| 2004 | 2008 |
| 2005 @override | 2009 @override |
| 2006 void tearDown() { | 2010 void tearDown() { |
| 2007 AnalysisEngine.instance.limitInvalidationInTaskModel = false; | 2011 AnalysisEngine.instance.limitInvalidationInTaskModel = false; |
| 2008 super.tearDown(); | 2012 super.tearDown(); |
| 2009 } | 2013 } |
| 2010 | 2014 |
| 2011 void test_noChange_thenChange() { | 2015 void test_noChange_thenChange() { |
| 2012 Source sourceA = addSource("/a.dart", r''' | 2016 Source sourceA = addSource("/a.dart", r''' |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2156 class B {} | 2160 class B {} |
| 2157 class C {} | 2161 class C {} |
| 2158 '''); | 2162 '''); |
| 2159 _assertInvalid(sourceA, LIBRARY_ERRORS_READY); | 2163 _assertInvalid(sourceA, LIBRARY_ERRORS_READY); |
| 2160 _assertInvalid(sourceB, LIBRARY_ERRORS_READY); | 2164 _assertInvalid(sourceB, LIBRARY_ERRORS_READY); |
| 2161 _performPendingAnalysisTasks(); | 2165 _performPendingAnalysisTasks(); |
| 2162 // Now b.dart is analyzed and it again has the error. | 2166 // Now b.dart is analyzed and it again has the error. |
| 2163 expect(context.getErrors(sourceB).errors, hasLength(1)); | 2167 expect(context.getErrors(sourceB).errors, hasLength(1)); |
| 2164 } | 2168 } |
| 2165 | 2169 |
| 2170 void test_usedName_directUser_withIncremental() { |
| 2171 Source sourceA = addSource("/a.dart", r''' |
| 2172 library lib_a; |
| 2173 class A { |
| 2174 m() {} |
| 2175 } |
| 2176 '''); |
| 2177 Source sourceB = addSource("/b.dart", r''' |
| 2178 library lib_b; |
| 2179 import 'a.dart'; |
| 2180 main() { |
| 2181 A a = new A(); |
| 2182 a.m(); |
| 2183 } |
| 2184 '''); |
| 2185 _performPendingAnalysisTasks(); |
| 2186 // Update A. |
| 2187 context.setContents(sourceA, r''' |
| 2188 library lib_a; |
| 2189 class A { |
| 2190 m2() {} |
| 2191 } |
| 2192 '''); |
| 2193 _assertInvalid(sourceA, LIBRARY_ERRORS_READY); |
| 2194 _assertInvalid(sourceB, LIBRARY_ERRORS_READY); |
| 2195 } |
| 2196 |
| 2166 void test_usedName_indirectUser() { | 2197 void test_usedName_indirectUser() { |
| 2167 Source sourceA = addSource("/a.dart", r''' | 2198 Source sourceA = addSource("/a.dart", r''' |
| 2168 library lib_a; | 2199 library lib_a; |
| 2169 class A { | 2200 class A { |
| 2170 m() {} | 2201 m() {} |
| 2171 } | 2202 } |
| 2172 '''); | 2203 '''); |
| 2173 Source sourceB = addSource("/b.dart", r''' | 2204 Source sourceB = addSource("/b.dart", r''' |
| 2174 library lib_b; | 2205 library lib_b; |
| 2175 import 'a.dart'; | 2206 import 'a.dart'; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2235 } | 2266 } |
| 2236 } | 2267 } |
| 2237 | 2268 |
| 2238 class _AnalysisContextImplTest_test_applyChanges_removeContainer | 2269 class _AnalysisContextImplTest_test_applyChanges_removeContainer |
| 2239 implements SourceContainer { | 2270 implements SourceContainer { |
| 2240 Source libB; | 2271 Source libB; |
| 2241 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB); | 2272 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB); |
| 2242 @override | 2273 @override |
| 2243 bool contains(Source source) => source == libB; | 2274 bool contains(Source source) => source == libB; |
| 2244 } | 2275 } |
| OLD | NEW |