| 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 1842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1853 addSource("/test.dart", "library lib; part 'test-part.dart';"); | 1853 addSource("/test.dart", "library lib; part 'test-part.dart';"); |
| 1854 Source partSource = addSource("/test-part.dart", "part of lib;"); | 1854 Source partSource = addSource("/test-part.dart", "part of lib;"); |
| 1855 _analyzeAll_assertFinished(); | 1855 _analyzeAll_assertFinished(); |
| 1856 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | 1856 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1857 reason: "library resolved 1"); | 1857 reason: "library resolved 1"); |
| 1858 expect( | 1858 expect( |
| 1859 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, | 1859 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, |
| 1860 reason: "part resolved 1"); | 1860 reason: "part resolved 1"); |
| 1861 // update and analyze #1 | 1861 // update and analyze #1 |
| 1862 context.setContents(partSource, "part of lib; // 1"); | 1862 context.setContents(partSource, "part of lib; // 1"); |
| 1863 if (AnalysisEngine.instance.limitInvalidationInTaskModel) { | 1863 if (context.analysisOptions.finerGrainedInvalidation) { |
| 1864 expect( | 1864 expect( |
| 1865 context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | 1865 context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1866 reason: "library changed 2"); | 1866 reason: "library changed 2"); |
| 1867 expect( | 1867 expect( |
| 1868 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, | 1868 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, |
| 1869 reason: "part changed 2"); | 1869 reason: "part changed 2"); |
| 1870 } else { | 1870 } else { |
| 1871 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, | 1871 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, |
| 1872 reason: "library changed 2"); | 1872 reason: "library changed 2"); |
| 1873 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, | 1873 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, |
| 1874 reason: "part changed 2"); | 1874 reason: "part changed 2"); |
| 1875 _analyzeAll_assertFinished(); | 1875 _analyzeAll_assertFinished(); |
| 1876 expect( | 1876 expect( |
| 1877 context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | 1877 context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1878 reason: "library resolved 2"); | 1878 reason: "library resolved 2"); |
| 1879 expect( | 1879 expect( |
| 1880 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, | 1880 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, |
| 1881 reason: "part resolved 2"); | 1881 reason: "part resolved 2"); |
| 1882 } | 1882 } |
| 1883 // update and analyze #2 | 1883 // update and analyze #2 |
| 1884 context.setContents(partSource, "part of lib; // 12"); | 1884 context.setContents(partSource, "part of lib; // 12"); |
| 1885 if (AnalysisEngine.instance.limitInvalidationInTaskModel) { | 1885 if (context.analysisOptions.finerGrainedInvalidation) { |
| 1886 expect( | 1886 expect( |
| 1887 context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, | 1887 context.getResolvedCompilationUnit2(libSource, libSource), isNotNull, |
| 1888 reason: "library changed 3"); | 1888 reason: "library changed 3"); |
| 1889 expect( | 1889 expect( |
| 1890 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, | 1890 context.getResolvedCompilationUnit2(partSource, libSource), isNotNull, |
| 1891 reason: "part changed 3"); | 1891 reason: "part changed 3"); |
| 1892 } else { | 1892 } else { |
| 1893 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, | 1893 expect(context.getResolvedCompilationUnit2(libSource, libSource), isNull, |
| 1894 reason: "library changed 3"); | 1894 reason: "library changed 3"); |
| 1895 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, | 1895 expect(context.getResolvedCompilationUnit2(partSource, libSource), isNull, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2031 } | 2031 } |
| 2032 | 2032 |
| 2033 void test_performAnalysisTask_IOException() { | 2033 void test_performAnalysisTask_IOException() { |
| 2034 TestSource source = _addSourceWithException2("/test.dart", "library test;"); | 2034 TestSource source = _addSourceWithException2("/test.dart", "library test;"); |
| 2035 source.generateExceptionOnRead = false; | 2035 source.generateExceptionOnRead = false; |
| 2036 _analyzeAll_assertFinished(); | 2036 _analyzeAll_assertFinished(); |
| 2037 expect(source.readCount, 2); | 2037 expect(source.readCount, 2); |
| 2038 _changeSource(source, ""); | 2038 _changeSource(source, ""); |
| 2039 source.generateExceptionOnRead = true; | 2039 source.generateExceptionOnRead = true; |
| 2040 _analyzeAll_assertFinished(); | 2040 _analyzeAll_assertFinished(); |
| 2041 if (AnalysisEngine.instance.limitInvalidationInTaskModel) { | 2041 if (context.analysisOptions.finerGrainedInvalidation) { |
| 2042 expect(source.readCount, 7); | 2042 expect(source.readCount, 7); |
| 2043 } else { | 2043 } else { |
| 2044 expect(source.readCount, 4); | 2044 expect(source.readCount, 4); |
| 2045 } | 2045 } |
| 2046 } | 2046 } |
| 2047 | 2047 |
| 2048 void test_performAnalysisTask_missingPart() { | 2048 void test_performAnalysisTask_missingPart() { |
| 2049 Source source = | 2049 Source source = |
| 2050 addSource("/test.dart", "library lib; part 'no-such-file.dart';"); | 2050 addSource("/test.dart", "library lib; part 'no-such-file.dart';"); |
| 2051 _analyzeAll_assertFinished(); | 2051 _analyzeAll_assertFinished(); |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2627 | 2627 |
| 2628 @reflectiveTest | 2628 @reflectiveTest |
| 2629 /** | 2629 /** |
| 2630 * TODO(scheglov) After changes that affect only resolution in method bodies, | 2630 * TODO(scheglov) After changes that affect only resolution in method bodies, |
| 2631 * it is theoretically possible to keep the same element model and resolve | 2631 * it is theoretically possible to keep the same element model and resolve |
| 2632 * only corresponding method bodies. | 2632 * only corresponding method bodies. |
| 2633 */ | 2633 */ |
| 2634 class LimitedInvalidateTest extends AbstractContextTest { | 2634 class LimitedInvalidateTest extends AbstractContextTest { |
| 2635 @override | 2635 @override |
| 2636 void setUp() { | 2636 void setUp() { |
| 2637 AnalysisEngine.instance.limitInvalidationInTaskModel = true; | |
| 2638 super.setUp(); | 2637 super.setUp(); |
| 2639 AnalysisOptionsImpl options = | 2638 AnalysisOptionsImpl options = |
| 2640 new AnalysisOptionsImpl.from(context.analysisOptions); | 2639 new AnalysisOptionsImpl.from(context.analysisOptions); |
| 2641 options.incremental = true; | 2640 options.incremental = true; |
| 2641 options.finerGrainedInvalidation = true; |
| 2642 context.analysisOptions = options; | 2642 context.analysisOptions = options; |
| 2643 } | 2643 } |
| 2644 | 2644 |
| 2645 @override | |
| 2646 void tearDown() { | |
| 2647 AnalysisEngine.instance.limitInvalidationInTaskModel = false; | |
| 2648 super.tearDown(); | |
| 2649 } | |
| 2650 | |
| 2651 void test_sequence_class_give_take() { | 2645 void test_sequence_class_give_take() { |
| 2652 Source a = addSource( | 2646 Source a = addSource( |
| 2653 '/a.dart', | 2647 '/a.dart', |
| 2654 r''' | 2648 r''' |
| 2655 class A {} | 2649 class A {} |
| 2656 class B {} | 2650 class B {} |
| 2657 class C {} | 2651 class C {} |
| 2658 '''); | 2652 '''); |
| 2659 Source b = addSource( | 2653 Source b = addSource( |
| 2660 '/b.dart', | 2654 '/b.dart', |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3227 * Initialize the visitor. | 3221 * Initialize the visitor. |
| 3228 */ | 3222 */ |
| 3229 _ElementGatherer(); | 3223 _ElementGatherer(); |
| 3230 | 3224 |
| 3231 @override | 3225 @override |
| 3232 void visitElement(Element element) { | 3226 void visitElement(Element element) { |
| 3233 elements[element] = element; | 3227 elements[element] = element; |
| 3234 super.visitElement(element); | 3228 super.visitElement(element); |
| 3235 } | 3229 } |
| 3236 } | 3230 } |
| OLD | NEW |