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 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1657 void test_getStatistics() { | 1657 void test_getStatistics() { |
1658 AnalysisContextStatistics statistics = context.statistics; | 1658 AnalysisContextStatistics statistics = context.statistics; |
1659 expect(statistics, isNotNull); | 1659 expect(statistics, isNotNull); |
1660 // The following lines are fragile. | 1660 // The following lines are fragile. |
1661 // The values depend on the number of libraries in the SDK. | 1661 // The values depend on the number of libraries in the SDK. |
1662 // assertLength(0, statistics.getCacheRows()); | 1662 // assertLength(0, statistics.getCacheRows()); |
1663 // assertLength(0, statistics.getExceptions()); | 1663 // assertLength(0, statistics.getExceptions()); |
1664 // assertLength(0, statistics.getSources()); | 1664 // assertLength(0, statistics.getSources()); |
1665 } | 1665 } |
1666 | 1666 |
| 1667 void test_handleContentsChanged() { |
| 1668 ContentCache contentCache = new ContentCache(); |
| 1669 context.contentCache = contentCache; |
| 1670 String oldContents = 'foo() {}'; |
| 1671 String newContents = 'bar() {}'; |
| 1672 // old contents |
| 1673 Source source = addSource("/test.dart", oldContents); |
| 1674 _analyzeAll_assertFinished(); |
| 1675 expect(context.getResolvedCompilationUnit2(source, source), isNotNull); |
| 1676 // new contents |
| 1677 contentCache.setContents(source, newContents); |
| 1678 context.handleContentsChanged(source, oldContents, newContents, true); |
| 1679 // there is some work to do |
| 1680 AnalysisResult analysisResult = context.performAnalysisTask(); |
| 1681 expect(analysisResult.changeNotices, isNotNull); |
| 1682 } |
| 1683 |
1667 void test_isClientLibrary_dart() { | 1684 void test_isClientLibrary_dart() { |
1668 Source source = addSource("/test.dart", r''' | 1685 Source source = addSource("/test.dart", r''' |
1669 import 'dart:html'; | 1686 import 'dart:html'; |
1670 | 1687 |
1671 main() {}'''); | 1688 main() {}'''); |
1672 expect(context.isClientLibrary(source), isFalse); | 1689 expect(context.isClientLibrary(source), isFalse); |
1673 expect(context.isServerLibrary(source), isFalse); | 1690 expect(context.isServerLibrary(source), isFalse); |
1674 context.computeLibraryElement(source); | 1691 context.computeLibraryElement(source); |
1675 expect(context.isClientLibrary(source), isTrue); | 1692 expect(context.isClientLibrary(source), isTrue); |
1676 expect(context.isServerLibrary(source), isFalse); | 1693 expect(context.isServerLibrary(source), isFalse); |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2112 : super(name, UriKind.FILE_URI); | 2129 : super(name, UriKind.FILE_URI); |
2113 | 2130 |
2114 @override | 2131 @override |
2115 TimestampedData<String> get contents { | 2132 TimestampedData<String> get contents { |
2116 throw 'Read error'; | 2133 throw 'Read error'; |
2117 } | 2134 } |
2118 | 2135 |
2119 @override | 2136 @override |
2120 bool exists() => true; | 2137 bool exists() => true; |
2121 } | 2138 } |
OLD | NEW |