Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1033)

Side by Side Diff: pkg/analyzer/test/generated/incremental_resolver_test.dart

Issue 2835703002: Remove ReferencedNames(Builder). (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/error/error.dart'; 10 import 'package:analyzer/error/error.dart';
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 @reflectiveTest 507 @reflectiveTest
508 class PoorMansIncrementalResolutionTest extends ResolverTestCase { 508 class PoorMansIncrementalResolutionTest extends ResolverTestCase {
509 final _TestLogger logger = new _TestLogger(); 509 final _TestLogger logger = new _TestLogger();
510 510
511 Source source; 511 Source source;
512 String code; 512 String code;
513 LibraryElement oldLibrary; 513 LibraryElement oldLibrary;
514 CompilationUnit oldUnit; 514 CompilationUnit oldUnit;
515 CompilationUnitElement oldUnitElement; 515 CompilationUnitElement oldUnitElement;
516 516
517 void assertSameReferencedNames(
518 ReferencedNames incNames, ReferencedNames fullNames) {
519 expectEqualSets(Iterable actual, Iterable expected) {
520 expect(actual, unorderedEquals(expected));
521 }
522
523 expectEqualSets(incNames.names, fullNames.names);
524 expectEqualSets(incNames.instantiatedNames, fullNames.instantiatedNames);
525 expectEqualSets(incNames.superToSubs.keys, fullNames.superToSubs.keys);
526 for (String key in fullNames.superToSubs.keys) {
527 expectEqualSets(incNames.superToSubs[key], fullNames.superToSubs[key]);
528 }
529 }
530
531 @override 517 @override
532 void setUp() { 518 void setUp() {
533 super.setUp(); 519 super.setUp();
534 _resetWithIncremental(true); 520 _resetWithIncremental(true);
535 } 521 }
536 522
537 void test_computeConstants() { 523 void test_computeConstants() {
538 _resolveUnit(r''' 524 _resolveUnit(r'''
539 int f() => 0; 525 int f() => 0;
540 main() { 526 main() {
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 _runTasks(); 2076 _runTasks();
2091 } 2077 }
2092 // Update the source - currently this may cause incremental resolution. 2078 // Update the source - currently this may cause incremental resolution.
2093 // Then request the updated resolved unit. 2079 // Then request the updated resolved unit.
2094 _resetWithIncremental(true); 2080 _resetWithIncremental(true);
2095 analysisContext2.setContents(source, newCode); 2081 analysisContext2.setContents(source, newCode);
2096 CompilationUnit newUnit = resolveCompilationUnit(source, oldLibrary); 2082 CompilationUnit newUnit = resolveCompilationUnit(source, oldLibrary);
2097 logger.expectNoErrors(); 2083 logger.expectNoErrors();
2098 List<AnalysisError> newErrors = analysisContext.computeErrors(source); 2084 List<AnalysisError> newErrors = analysisContext.computeErrors(source);
2099 LineInfo newLineInfo = analysisContext.getLineInfo(source); 2085 LineInfo newLineInfo = analysisContext.getLineInfo(source);
2100 ReferencedNames newReferencedNames =
2101 analysisContext.getResult(source, REFERENCED_NAMES);
2102 // check for expected failure 2086 // check for expected failure
2103 if (!expectedSuccess) { 2087 if (!expectedSuccess) {
2104 expect(newUnit.element, isNot(same(oldUnitElement))); 2088 expect(newUnit.element, isNot(same(oldUnitElement)));
2105 return; 2089 return;
2106 } 2090 }
2107 // The cache must still have enough results to make the incremental 2091 // The cache must still have enough results to make the incremental
2108 // resolution useful. 2092 // resolution useful.
2109 _assertCacheResults( 2093 _assertCacheResults(
2110 expectLibraryUnchanged: expectLibraryUnchanged, 2094 expectLibraryUnchanged: expectLibraryUnchanged,
2111 expectCachePostConstantsValid: expectCachePostConstantsValid); 2095 expectCachePostConstantsValid: expectCachePostConstantsValid);
(...skipping 12 matching lines...) Expand all
2124 _resetWithIncremental(false); 2108 _resetWithIncremental(false);
2125 changeSource(source, ''); 2109 changeSource(source, '');
2126 changeSource(source, newCode); 2110 changeSource(source, newCode);
2127 _runTasks(); 2111 _runTasks();
2128 LibraryElement library = resolve2(source); 2112 LibraryElement library = resolve2(source);
2129 CompilationUnit fullNewUnit = resolveCompilationUnit(source, library); 2113 CompilationUnit fullNewUnit = resolveCompilationUnit(source, library);
2130 // Validate tokens. 2114 // Validate tokens.
2131 _assertEqualTokens(newUnit, fullNewUnit); 2115 _assertEqualTokens(newUnit, fullNewUnit);
2132 // Validate LineInfo 2116 // Validate LineInfo
2133 _assertEqualLineInfo(newLineInfo, analysisContext.getLineInfo(source)); 2117 _assertEqualLineInfo(newLineInfo, analysisContext.getLineInfo(source));
2134 // Validate referenced names.
2135 ReferencedNames fullReferencedNames =
2136 analysisContext.getResult(source, REFERENCED_NAMES);
2137 assertSameReferencedNames(newReferencedNames, fullReferencedNames);
2138 // Validate that "incremental" and "full" units have the same resolution. 2118 // Validate that "incremental" and "full" units have the same resolution.
2139 try { 2119 try {
2140 assertSameResolution(newUnit, fullNewUnit, validateTypes: true); 2120 assertSameResolution(newUnit, fullNewUnit, validateTypes: true);
2141 } on IncrementalResolutionMismatch catch (mismatch) { 2121 } on IncrementalResolutionMismatch catch (mismatch) {
2142 fail(mismatch.message); 2122 fail(mismatch.message);
2143 } 2123 }
2144 List<AnalysisError> newFullErrors = 2124 List<AnalysisError> newFullErrors =
2145 analysisContext.getErrors(source).errors; 2125 analysisContext.getErrors(source).errors;
2146 _assertEqualErrors(newErrors, newFullErrors); 2126 _assertEqualErrors(newErrors, newFullErrors);
2147 } 2127 }
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 void logException(Object exception, [Object stackTrace]) { 2402 void logException(Object exception, [Object stackTrace]) {
2423 lastException = exception; 2403 lastException = exception;
2424 lastStackTrace = stackTrace; 2404 lastStackTrace = stackTrace;
2425 } 2405 }
2426 2406
2427 @override 2407 @override
2428 logging.LoggingTimer startTimer() { 2408 logging.LoggingTimer startTimer() {
2429 return new logging.LoggingTimer(this); 2409 return new logging.LoggingTimer(this);
2430 } 2410 }
2431 } 2411 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698