| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 test.src.task.dart_work_manager_test; | 5 library test.src.task.dart_work_manager_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/context/cache.dart'; | 7 import 'package:analyzer/src/context/cache.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart' | 9 import 'package:analyzer/src/generated/engine.dart' |
| 10 show | 10 show |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 new AnalysisError(source1, 1, 0, ScannerErrorCode.MISSING_DIGIT); | 408 new AnalysisError(source1, 1, 0, ScannerErrorCode.MISSING_DIGIT); |
| 409 AnalysisError error2 = | 409 AnalysisError error2 = |
| 410 new AnalysisError(source1, 2, 0, ScannerErrorCode.MISSING_DIGIT); | 410 new AnalysisError(source1, 2, 0, ScannerErrorCode.MISSING_DIGIT); |
| 411 when(context.getLibrariesContaining(source1)).thenReturn([source2]); | 411 when(context.getLibrariesContaining(source1)).thenReturn([source2]); |
| 412 LineInfo lineInfo = new LineInfo([0]); | 412 LineInfo lineInfo = new LineInfo([0]); |
| 413 entry1.setValue(LINE_INFO, lineInfo, []); | 413 entry1.setValue(LINE_INFO, lineInfo, []); |
| 414 entry1.setValue(SCAN_ERRORS, <AnalysisError>[error1], []); | 414 entry1.setValue(SCAN_ERRORS, <AnalysisError>[error1], []); |
| 415 AnalysisTarget unitTarget = new LibrarySpecificUnit(source2, source1); | 415 AnalysisTarget unitTarget = new LibrarySpecificUnit(source2, source1); |
| 416 context.getCacheEntry(unitTarget).setValue( | 416 context.getCacheEntry(unitTarget).setValue( |
| 417 VERIFY_ERRORS, <AnalysisError>[error2], []); | 417 VERIFY_ERRORS, <AnalysisError>[error2], []); |
| 418 // notify about LibrarySpecificUnit specific errors | 418 // RESOLVED_UNIT is ready, set errors |
| 419 manager.resultsComputed(unitTarget, {VERIFY_ERRORS: []}); | 419 manager.resultsComputed( |
| 420 unitTarget, {RESOLVED_UNIT: AstFactory.compilationUnit()}); |
| 420 // all of the errors are included | 421 // all of the errors are included |
| 421 ChangeNoticeImpl notice = context.getNotice(source1); | 422 ChangeNoticeImpl notice = context.getNotice(source1); |
| 422 expect(notice.errors, unorderedEquals([error1, error2])); | 423 expect(notice.errors, unorderedEquals([error1, error2])); |
| 423 expect(notice.lineInfo, lineInfo); | 424 expect(notice.lineInfo, lineInfo); |
| 424 } | 425 } |
| 425 | 426 |
| 426 void test_resultsComputed_errors_forSource() { | 427 void test_resultsComputed_errors_forSource() { |
| 427 AnalysisError error1 = | 428 AnalysisError error1 = |
| 428 new AnalysisError(source1, 1, 0, ScannerErrorCode.MISSING_DIGIT); | 429 new AnalysisError(source1, 1, 0, ScannerErrorCode.MISSING_DIGIT); |
| 429 AnalysisError error2 = | 430 AnalysisError error2 = |
| 430 new AnalysisError(source1, 2, 0, ScannerErrorCode.MISSING_DIGIT); | 431 new AnalysisError(source1, 2, 0, ScannerErrorCode.MISSING_DIGIT); |
| 431 when(context.getLibrariesContaining(source1)).thenReturn([source2]); | 432 when(context.getLibrariesContaining(source1)).thenReturn([source2]); |
| 432 LineInfo lineInfo = new LineInfo([0]); | 433 LineInfo lineInfo = new LineInfo([0]); |
| 433 entry1.setValue(LINE_INFO, lineInfo, []); | 434 entry1.setValue(LINE_INFO, lineInfo, []); |
| 434 entry1.setValue(SCAN_ERRORS, <AnalysisError>[error1], []); | 435 entry1.setValue(SCAN_ERRORS, <AnalysisError>[error1], []); |
| 435 AnalysisTarget unitTarget = new LibrarySpecificUnit(source2, source1); | 436 entry1.setValue(PARSE_ERRORS, <AnalysisError>[error2], []); |
| 436 context.getCacheEntry(unitTarget).setValue( | 437 // PARSED_UNIT is ready, set errors |
| 437 VERIFY_ERRORS, <AnalysisError>[error2], []); | 438 manager.resultsComputed( |
| 438 // notify about Source specific errors | 439 source1, {PARSED_UNIT: AstFactory.compilationUnit()}); |
| 439 manager.resultsComputed(source1, {SCAN_ERRORS: []}); | |
| 440 // all of the errors are included | 440 // all of the errors are included |
| 441 ChangeNoticeImpl notice = context.getNotice(source1); | 441 ChangeNoticeImpl notice = context.getNotice(source1); |
| 442 expect(notice.errors, unorderedEquals([error1, error2])); | 442 expect(notice.errors, unorderedEquals([error1, error2])); |
| 443 expect(notice.lineInfo, lineInfo); | 443 expect(notice.lineInfo, lineInfo); |
| 444 } | 444 } |
| 445 | 445 |
| 446 void test_resultsComputed_includedParts() { | 446 void test_resultsComputed_includedParts() { |
| 447 Source part1 = new TestSource('part1.dart'); | 447 Source part1 = new TestSource('part1.dart'); |
| 448 Source part2 = new TestSource('part2.dart'); | 448 Source part2 = new TestSource('part2.dart'); |
| 449 Source part3 = new TestSource('part3.dart'); | 449 Source part3 = new TestSource('part3.dart'); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 } | 541 } |
| 542 | 542 |
| 543 @override | 543 @override |
| 544 ChangeNoticeImpl getNotice(Source source) { | 544 ChangeNoticeImpl getNotice(Source source) { |
| 545 return _pendingNotices.putIfAbsent( | 545 return _pendingNotices.putIfAbsent( |
| 546 source, () => new ChangeNoticeImpl(source)); | 546 source, () => new ChangeNoticeImpl(source)); |
| 547 } | 547 } |
| 548 | 548 |
| 549 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 549 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 550 } | 550 } |
| OLD | NEW |