| 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.generated.incremental_resolver_test; | 5 library analyzer.test.generated.incremental_resolver_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/src/context/cache.dart'; | 10 import 'package:analyzer/src/context/cache.dart'; |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 @reflectiveTest | 513 @reflectiveTest |
| 514 class PoorMansIncrementalResolutionTest extends ResolverTestCase { | 514 class PoorMansIncrementalResolutionTest extends ResolverTestCase { |
| 515 final _TestLogger logger = new _TestLogger(); | 515 final _TestLogger logger = new _TestLogger(); |
| 516 | 516 |
| 517 Source source; | 517 Source source; |
| 518 String code; | 518 String code; |
| 519 LibraryElement oldLibrary; | 519 LibraryElement oldLibrary; |
| 520 CompilationUnit oldUnit; | 520 CompilationUnit oldUnit; |
| 521 CompilationUnitElement oldUnitElement; | 521 CompilationUnitElement oldUnitElement; |
| 522 | 522 |
| 523 void assertSameReferencedNames( |
| 524 ReferencedNames incNames, ReferencedNames fullNames) { |
| 525 expectEqualSets(Iterable actual, Iterable expected) { |
| 526 expect(actual, unorderedEquals(expected)); |
| 527 } |
| 528 expectEqualSets(incNames.names, fullNames.names); |
| 529 expectEqualSets(incNames.instantiatedNames, fullNames.instantiatedNames); |
| 530 expectEqualSets(incNames.superToSubs.keys, fullNames.superToSubs.keys); |
| 531 for (String key in fullNames.superToSubs.keys) { |
| 532 expectEqualSets(incNames.superToSubs[key], fullNames.superToSubs[key]); |
| 533 } |
| 534 } |
| 535 |
| 523 @override | 536 @override |
| 524 void setUp() { | 537 void setUp() { |
| 525 super.setUp(); | 538 super.setUp(); |
| 526 _resetWithIncremental(true); | 539 _resetWithIncremental(true); |
| 527 } | 540 } |
| 528 | 541 |
| 529 void test_computeConstants() { | 542 void test_computeConstants() { |
| 530 _resolveUnit(r''' | 543 _resolveUnit(r''' |
| 531 int f() => 0; | 544 int f() => 0; |
| 532 main() { | 545 main() { |
| (...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1902 _runTasks(); | 1915 _runTasks(); |
| 1903 } | 1916 } |
| 1904 // Update the source - currently this may cause incremental resolution. | 1917 // Update the source - currently this may cause incremental resolution. |
| 1905 // Then request the updated resolved unit. | 1918 // Then request the updated resolved unit. |
| 1906 _resetWithIncremental(true); | 1919 _resetWithIncremental(true); |
| 1907 analysisContext2.setContents(source, newCode); | 1920 analysisContext2.setContents(source, newCode); |
| 1908 CompilationUnit newUnit = resolveCompilationUnit(source, oldLibrary); | 1921 CompilationUnit newUnit = resolveCompilationUnit(source, oldLibrary); |
| 1909 logger.expectNoErrors(); | 1922 logger.expectNoErrors(); |
| 1910 List<AnalysisError> newErrors = analysisContext.computeErrors(source); | 1923 List<AnalysisError> newErrors = analysisContext.computeErrors(source); |
| 1911 LineInfo newLineInfo = analysisContext.getLineInfo(source); | 1924 LineInfo newLineInfo = analysisContext.getLineInfo(source); |
| 1925 ReferencedNames newReferencedNames = |
| 1926 analysisContext.getResult(source, REFERENCED_NAMES); |
| 1912 // check for expected failure | 1927 // check for expected failure |
| 1913 if (!expectedSuccess) { | 1928 if (!expectedSuccess) { |
| 1914 expect(newUnit.element, isNot(same(oldUnitElement))); | 1929 expect(newUnit.element, isNot(same(oldUnitElement))); |
| 1915 return; | 1930 return; |
| 1916 } | 1931 } |
| 1917 // The cache must still have enough results to make the incremental | 1932 // The cache must still have enough results to make the incremental |
| 1918 // resolution useful. | 1933 // resolution useful. |
| 1919 _assertCacheResults( | 1934 _assertCacheResults( |
| 1920 expectLibraryUnchanged: expectLibraryUnchanged, | 1935 expectLibraryUnchanged: expectLibraryUnchanged, |
| 1921 expectCachePostConstantsValid: expectCachePostConstantsValid); | 1936 expectCachePostConstantsValid: expectCachePostConstantsValid); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1934 _resetWithIncremental(false); | 1949 _resetWithIncremental(false); |
| 1935 changeSource(source, ''); | 1950 changeSource(source, ''); |
| 1936 changeSource(source, newCode); | 1951 changeSource(source, newCode); |
| 1937 _runTasks(); | 1952 _runTasks(); |
| 1938 LibraryElement library = resolve2(source); | 1953 LibraryElement library = resolve2(source); |
| 1939 CompilationUnit fullNewUnit = resolveCompilationUnit(source, library); | 1954 CompilationUnit fullNewUnit = resolveCompilationUnit(source, library); |
| 1940 // Validate tokens. | 1955 // Validate tokens. |
| 1941 _assertEqualTokens(newUnit, fullNewUnit); | 1956 _assertEqualTokens(newUnit, fullNewUnit); |
| 1942 // Validate LineInfo | 1957 // Validate LineInfo |
| 1943 _assertEqualLineInfo(newLineInfo, analysisContext.getLineInfo(source)); | 1958 _assertEqualLineInfo(newLineInfo, analysisContext.getLineInfo(source)); |
| 1959 // Validate referenced names. |
| 1960 ReferencedNames fullReferencedNames = |
| 1961 analysisContext.getResult(source, REFERENCED_NAMES); |
| 1962 assertSameReferencedNames(newReferencedNames, fullReferencedNames); |
| 1944 // Validate that "incremental" and "full" units have the same resolution. | 1963 // Validate that "incremental" and "full" units have the same resolution. |
| 1945 try { | 1964 try { |
| 1946 assertSameResolution(newUnit, fullNewUnit, validateTypes: true); | 1965 assertSameResolution(newUnit, fullNewUnit, validateTypes: true); |
| 1947 } on IncrementalResolutionMismatch catch (mismatch) { | 1966 } on IncrementalResolutionMismatch catch (mismatch) { |
| 1948 fail(mismatch.message); | 1967 fail(mismatch.message); |
| 1949 } | 1968 } |
| 1950 List<AnalysisError> newFullErrors = | 1969 List<AnalysisError> newFullErrors = |
| 1951 analysisContext.getErrors(source).errors; | 1970 analysisContext.getErrors(source).errors; |
| 1952 _assertEqualErrors(newErrors, newFullErrors); | 1971 _assertEqualErrors(newErrors, newFullErrors); |
| 1953 } | 1972 } |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2229 void logException(Object exception, [Object stackTrace]) { | 2248 void logException(Object exception, [Object stackTrace]) { |
| 2230 lastException = exception; | 2249 lastException = exception; |
| 2231 lastStackTrace = stackTrace; | 2250 lastStackTrace = stackTrace; |
| 2232 } | 2251 } |
| 2233 | 2252 |
| 2234 @override | 2253 @override |
| 2235 logging.LoggingTimer startTimer() { | 2254 logging.LoggingTimer startTimer() { |
| 2236 return new logging.LoggingTimer(this); | 2255 return new logging.LoggingTimer(this); |
| 2237 } | 2256 } |
| 2238 } | 2257 } |
| OLD | NEW |