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 engine.incremental_resolver_test; | 5 library engine.incremental_resolver_test; |
6 | 6 |
7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
9 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
10 import 'package:analyzer/src/generated/error.dart'; | 10 import 'package:analyzer/src/generated/error.dart'; |
(...skipping 2453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2464 } | 2464 } |
2465 } | 2465 } |
2466 | 2466 |
2467 @reflectiveTest | 2467 @reflectiveTest |
2468 class IncrementalResolverTest extends ResolverTestCase { | 2468 class IncrementalResolverTest extends ResolverTestCase { |
2469 Source source; | 2469 Source source; |
2470 String code; | 2470 String code; |
2471 LibraryElement library; | 2471 LibraryElement library; |
2472 CompilationUnit unit; | 2472 CompilationUnit unit; |
2473 | 2473 |
| 2474 @override |
| 2475 void reset() { |
| 2476 analysisContext2 = AnalysisContextFactory.oldContextWithCore(); |
| 2477 } |
| 2478 |
| 2479 @override |
| 2480 void resetWithOptions(AnalysisOptions options) { |
| 2481 analysisContext2 = |
| 2482 AnalysisContextFactory.oldContextWithCoreAndOptions(options); |
| 2483 } |
| 2484 |
2474 void setUp() { | 2485 void setUp() { |
2475 super.setUp(); | 2486 super.setUp(); |
2476 test_resolveApiChanges = true; | 2487 test_resolveApiChanges = true; |
2477 log.logger = log.NULL_LOGGER; | 2488 log.logger = log.NULL_LOGGER; |
2478 } | 2489 } |
2479 | 2490 |
2480 void test_classMemberAccessor_body() { | 2491 void test_classMemberAccessor_body() { |
2481 _resolveUnit(r''' | 2492 _resolveUnit(r''' |
2482 class A { | 2493 class A { |
2483 int get test { | 2494 int get test { |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2795 // update tokens | 2806 // update tokens |
2796 { | 2807 { |
2797 int delta = edit.replacement.length - edit.length; | 2808 int delta = edit.replacement.length - edit.length; |
2798 _shiftTokens(unit.beginToken, offset, delta); | 2809 _shiftTokens(unit.beginToken, offset, delta); |
2799 } | 2810 } |
2800 // do incremental resolution | 2811 // do incremental resolution |
2801 int updateOffset = edit.offset; | 2812 int updateOffset = edit.offset; |
2802 int updateEndOld = updateOffset + edit.length; | 2813 int updateEndOld = updateOffset + edit.length; |
2803 int updateOldNew = updateOffset + edit.replacement.length; | 2814 int updateOldNew = updateOffset + edit.replacement.length; |
2804 IncrementalResolver resolver = new IncrementalResolver( | 2815 IncrementalResolver resolver = new IncrementalResolver( |
2805 analysisContext2.getReadableSourceEntryOrNull(source), null, null, | 2816 (analysisContext2 as AnalysisContextImpl) |
2806 unit.element, updateOffset, updateEndOld, updateOldNew); | 2817 .getReadableSourceEntryOrNull(source), null, null, unit.element, |
| 2818 updateOffset, updateEndOld, updateOldNew); |
2807 bool success = resolver.resolve(newNode); | 2819 bool success = resolver.resolve(newNode); |
2808 expect(success, isTrue); | 2820 expect(success, isTrue); |
2809 List<AnalysisError> newErrors = analysisContext.computeErrors(source); | 2821 List<AnalysisError> newErrors = analysisContext.computeErrors(source); |
2810 // resolve "newCode" from scratch | 2822 // resolve "newCode" from scratch |
2811 CompilationUnit fullNewUnit; | 2823 CompilationUnit fullNewUnit; |
2812 { | 2824 { |
2813 source = addSource(newCode); | 2825 source = addSource(newCode); |
2814 _runTasks(); | 2826 _runTasks(); |
2815 LibraryElement library = resolve(source); | 2827 LibraryElement library = resolve(source); |
2816 fullNewUnit = resolveCompilationUnit(source, library); | 2828 fullNewUnit = resolveCompilationUnit(source, library); |
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4144 return ResolutionContextBuilder.contextFor(node, listener).scope; | 4156 return ResolutionContextBuilder.contextFor(node, listener).scope; |
4145 } | 4157 } |
4146 } | 4158 } |
4147 | 4159 |
4148 class _Edit { | 4160 class _Edit { |
4149 final int offset; | 4161 final int offset; |
4150 final int length; | 4162 final int length; |
4151 final String replacement; | 4163 final String replacement; |
4152 _Edit(this.offset, this.length, this.replacement); | 4164 _Edit(this.offset, this.length, this.replacement); |
4153 } | 4165 } |
OLD | NEW |