Chromium Code Reviews| 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 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1924 Source sourceA = addSource( | 1924 Source sourceA = addSource( |
| 1925 "/a.dart", | 1925 "/a.dart", |
| 1926 r''' | 1926 r''' |
| 1927 library expectedToFindSemicolon | 1927 library expectedToFindSemicolon |
| 1928 '''); | 1928 '''); |
| 1929 // Analyze to the point where some of the results stop depending on | 1929 // Analyze to the point where some of the results stop depending on |
| 1930 // the source content. | 1930 // the source content. |
| 1931 LibrarySpecificUnit unitA = new LibrarySpecificUnit(sourceA, sourceA); | 1931 LibrarySpecificUnit unitA = new LibrarySpecificUnit(sourceA, sourceA); |
| 1932 for (int i = 0; i < 10000; i++) { | 1932 for (int i = 0; i < 10000; i++) { |
| 1933 context.performAnalysisTask(); | 1933 context.performAnalysisTask(); |
| 1934 if (context.getResult(unitA, RESOLVED_UNIT2) != null) { | 1934 if (context.getResult(unitA, RESOLVED_UNIT3) != null) { |
| 1935 break; | 1935 break; |
| 1936 } | 1936 } |
| 1937 } | 1937 } |
| 1938 // Update the source. | 1938 // Update the source. |
| 1939 // This should invalidate all the results and also reset the driver. | 1939 // This should invalidate all the results and also reset the driver. |
| 1940 context.setContents(sourceA, "library semicolonWasAdded;"); | 1940 context.setContents(sourceA, "library semicolonWasAdded;"); |
| 1941 expect(context.getResult(unitA, RESOLVED_UNIT2), isNull); | 1941 expect(context.getResult(unitA, RESOLVED_UNIT3), isNull); |
| 1942 expect(analysisDriver.currentWorkOrder, isNull); | 1942 expect(analysisDriver.currentWorkOrder, isNull); |
| 1943 // Continue analysis. | 1943 // Continue analysis. |
| 1944 _analyzeAll_assertFinished(); | 1944 _analyzeAll_assertFinished(); |
| 1945 expect(context.getErrors(sourceA).errors, isEmpty); | 1945 expect(context.getErrors(sourceA).errors, isEmpty); |
| 1946 } | 1946 } |
| 1947 | 1947 |
| 1948 void test_performAnalysisTask_IOException() { | 1948 void test_performAnalysisTask_IOException() { |
| 1949 TestSource source = _addSourceWithException2("/test.dart", "library test;"); | 1949 TestSource source = _addSourceWithException2("/test.dart", "library test;"); |
| 1950 source.generateExceptionOnRead = false; | 1950 source.generateExceptionOnRead = false; |
| 1951 _analyzeAll_assertFinished(); | 1951 _analyzeAll_assertFinished(); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2113 } | 2113 } |
| 2114 '''); | 2114 '''); |
| 2115 context.resolveCompilationUnit2(source, source); | 2115 context.resolveCompilationUnit2(source, source); |
| 2116 LibraryElement firstElement = context.computeLibraryElement(source); | 2116 LibraryElement firstElement = context.computeLibraryElement(source); |
| 2117 _ElementGatherer gatherer = new _ElementGatherer(); | 2117 _ElementGatherer gatherer = new _ElementGatherer(); |
| 2118 firstElement.accept(gatherer); | 2118 firstElement.accept(gatherer); |
| 2119 | 2119 |
| 2120 CacheEntry entry = | 2120 CacheEntry entry = |
| 2121 context.analysisCache.get(new LibrarySpecificUnit(source, source)); | 2121 context.analysisCache.get(new LibrarySpecificUnit(source, source)); |
| 2122 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED); | 2122 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED); |
| 2123 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED); | |
|
Paul Berry
2016/04/01 19:13:03
Was this line deleted by mistake? It seems like f
scheglov
2016/04/01 19:49:15
Acknowledged.
| |
| 2124 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); | 2123 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); |
| 2125 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); | 2124 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); |
| 2126 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); | 2125 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); |
| 2127 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED); | 2126 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED); |
| 2128 entry.setState(RESOLVED_UNIT7, CacheState.FLUSHED); | 2127 entry.setState(RESOLVED_UNIT7, CacheState.FLUSHED); |
| 2129 entry.setState(RESOLVED_UNIT8, CacheState.FLUSHED); | 2128 entry.setState(RESOLVED_UNIT8, CacheState.FLUSHED); |
| 2130 entry.setState(RESOLVED_UNIT9, CacheState.FLUSHED); | 2129 entry.setState(RESOLVED_UNIT9, CacheState.FLUSHED); |
| 2131 entry.setState(RESOLVED_UNIT10, CacheState.FLUSHED); | 2130 entry.setState(RESOLVED_UNIT10, CacheState.FLUSHED); |
| 2132 entry.setState(RESOLVED_UNIT11, CacheState.FLUSHED); | 2131 entry.setState(RESOLVED_UNIT11, CacheState.FLUSHED); |
| 2132 entry.setState(RESOLVED_UNIT12, CacheState.FLUSHED); | |
| 2133 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); | 2133 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); |
| 2134 | 2134 |
| 2135 context.resolveCompilationUnit2(source, source); | 2135 context.resolveCompilationUnit2(source, source); |
| 2136 LibraryElement secondElement = context.computeLibraryElement(source); | 2136 LibraryElement secondElement = context.computeLibraryElement(source); |
| 2137 _ElementComparer comparer = new _ElementComparer(gatherer.elements); | 2137 _ElementComparer comparer = new _ElementComparer(gatherer.elements); |
| 2138 secondElement.accept(comparer); | 2138 secondElement.accept(comparer); |
| 2139 comparer.expectNoDifferences(); | 2139 comparer.expectNoDifferences(); |
| 2140 } | 2140 } |
| 2141 | 2141 |
| 2142 void test_resolveCompilationUnit_import_relative() { | 2142 void test_resolveCompilationUnit_import_relative() { |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2942 * Initialize the visitor. | 2942 * Initialize the visitor. |
| 2943 */ | 2943 */ |
| 2944 _ElementGatherer(); | 2944 _ElementGatherer(); |
| 2945 | 2945 |
| 2946 @override | 2946 @override |
| 2947 void visitElement(Element element) { | 2947 void visitElement(Element element) { |
| 2948 elements[element] = element; | 2948 elements[element] = element; |
| 2949 super.visitElement(element); | 2949 super.visitElement(element); |
| 2950 } | 2950 } |
| 2951 } | 2951 } |
| OLD | NEW |