| 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 2271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2282 expect(success, isTrue); | 2282 expect(success, isTrue); |
| 2283 List<AnalysisError> newErrors = analysisContext.getErrors(source).errors; | 2283 List<AnalysisError> newErrors = analysisContext.getErrors(source).errors; |
| 2284 // resolve "newCode" from scratch | 2284 // resolve "newCode" from scratch |
| 2285 CompilationUnit fullNewUnit; | 2285 CompilationUnit fullNewUnit; |
| 2286 { | 2286 { |
| 2287 source = addSource(newCode); | 2287 source = addSource(newCode); |
| 2288 _runTasks(); | 2288 _runTasks(); |
| 2289 LibraryElement library = resolve(source); | 2289 LibraryElement library = resolve(source); |
| 2290 fullNewUnit = resolveCompilationUnit(source, library); | 2290 fullNewUnit = resolveCompilationUnit(source, library); |
| 2291 } | 2291 } |
| 2292 assertSameResolution(unit, fullNewUnit, fail); | 2292 try { |
| 2293 assertSameResolution(unit, fullNewUnit); |
| 2294 } on IncrementalResolutionMismatch catch (mismatch) { |
| 2295 fail(mismatch.message); |
| 2296 } |
| 2293 // errors | 2297 // errors |
| 2294 List<AnalysisError> newFullErrors = | 2298 List<AnalysisError> newFullErrors = |
| 2295 analysisContext.getErrors(source).errors; | 2299 analysisContext.getErrors(source).errors; |
| 2296 _assertEqualErrors(newErrors, newFullErrors); | 2300 _assertEqualErrors(newErrors, newFullErrors); |
| 2297 // prepare for the next cycle | 2301 // prepare for the next cycle |
| 2298 code = newCode; | 2302 code = newCode; |
| 2299 } | 2303 } |
| 2300 | 2304 |
| 2301 void _resolveUnit(String code) { | 2305 void _resolveUnit(String code) { |
| 2302 this.code = code; | 2306 this.code = code; |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3106 ChangeNotice notice = analysisResult.changeNotices[0]; | 3110 ChangeNotice notice = analysisResult.changeNotices[0]; |
| 3107 expect(notice.compilationUnit, same(newUnit)); | 3111 expect(notice.compilationUnit, same(newUnit)); |
| 3108 // Resolve "newCode" from scratch. | 3112 // Resolve "newCode" from scratch. |
| 3109 if (compareWithFull) { | 3113 if (compareWithFull) { |
| 3110 _resetWithIncremental(false); | 3114 _resetWithIncremental(false); |
| 3111 source = addSource(newCode); | 3115 source = addSource(newCode); |
| 3112 _runTasks(); | 3116 _runTasks(); |
| 3113 LibraryElement library = resolve(source); | 3117 LibraryElement library = resolve(source); |
| 3114 CompilationUnit fullNewUnit = resolveCompilationUnit(source, library); | 3118 CompilationUnit fullNewUnit = resolveCompilationUnit(source, library); |
| 3115 // Validate that "incremental" and "full" units have the same resolution. | 3119 // Validate that "incremental" and "full" units have the same resolution. |
| 3116 assertSameResolution(newUnit, fullNewUnit, fail); | 3120 try { |
| 3121 assertSameResolution(newUnit, fullNewUnit, validateTypes: true); |
| 3122 } on IncrementalResolutionMismatch catch (mismatch) { |
| 3123 fail(mismatch.message); |
| 3124 } |
| 3117 _assertEqualTokens(newUnit, fullNewUnit); | 3125 _assertEqualTokens(newUnit, fullNewUnit); |
| 3118 List<AnalysisError> newFullErrors = | 3126 List<AnalysisError> newFullErrors = |
| 3119 analysisContext.getErrors(source).errors; | 3127 analysisContext.getErrors(source).errors; |
| 3120 _assertEqualErrors(newErrors, newFullErrors); | 3128 _assertEqualErrors(newErrors, newFullErrors); |
| 3121 // TODO(scheglov) check line info | 3129 // TODO(scheglov) check line info |
| 3122 } | 3130 } |
| 3123 } | 3131 } |
| 3124 | 3132 |
| 3125 static void _assertEqualToken(Token incrToken, Token fullToken) { | 3133 static void _assertEqualToken(Token incrToken, Token fullToken) { |
| 3126 expect(incrToken.type, fullToken.type); | 3134 expect(incrToken.type, fullToken.type); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3397 } | 3405 } |
| 3398 } | 3406 } |
| 3399 | 3407 |
| 3400 | 3408 |
| 3401 class _Edit { | 3409 class _Edit { |
| 3402 final int offset; | 3410 final int offset; |
| 3403 final int length; | 3411 final int length; |
| 3404 final String replacement; | 3412 final String replacement; |
| 3405 _Edit(this.offset, this.length, this.replacement); | 3413 _Edit(this.offset, this.length, this.replacement); |
| 3406 } | 3414 } |
| OLD | NEW |