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

Side by Side Diff: pkg/analyzer/test/src/task/dart_work_manager_test.dart

Issue 2229603003: Extract unresolved AST parsing (PARSED_UNIT1) from full parsing, which includes UriBasedDirective(s… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update task graph. Created 4 years, 4 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
OLDNEW
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 analyzer.test.src.task.dart_work_manager_test; 5 library analyzer.test.src.task.dart_work_manager_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/src/context/cache.dart'; 8 import 'package:analyzer/src/context/cache.dart';
9 import 'package:analyzer/src/dart/scanner/scanner.dart' show ScannerErrorCode; 9 import 'package:analyzer/src/dart/scanner/scanner.dart' show ScannerErrorCode;
10 import 'package:analyzer/src/generated/engine.dart' 10 import 'package:analyzer/src/generated/engine.dart'
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 expect(manager.getNextResultPriority(), WorkOrderPriority.NORMAL); 520 expect(manager.getNextResultPriority(), WorkOrderPriority.NORMAL);
521 } 521 }
522 522
523 void test_getNextResultPriority_nothingToDo() { 523 void test_getNextResultPriority_nothingToDo() {
524 expect(manager.getNextResultPriority(), WorkOrderPriority.NONE); 524 expect(manager.getNextResultPriority(), WorkOrderPriority.NONE);
525 } 525 }
526 526
527 void test_onAnalysisOptionsChanged() { 527 void test_onAnalysisOptionsChanged() {
528 when(context.exists(anyObject)).thenReturn(true); 528 when(context.exists(anyObject)).thenReturn(true);
529 // set cache values 529 // set cache values
530 entry1.setValue(PARSED_UNIT, AstFactory.compilationUnit(), []); 530 entry1.setValue(PARSED_UNIT1, AstFactory.compilationUnit(), []);
531 entry1.setValue(IMPORTED_LIBRARIES, <Source>[], []); 531 entry1.setValue(IMPORTED_LIBRARIES, <Source>[], []);
532 entry1.setValue(EXPLICITLY_IMPORTED_LIBRARIES, <Source>[], []); 532 entry1.setValue(EXPLICITLY_IMPORTED_LIBRARIES, <Source>[], []);
533 entry1.setValue(EXPORTED_LIBRARIES, <Source>[], []); 533 entry1.setValue(EXPORTED_LIBRARIES, <Source>[], []);
534 entry1.setValue(INCLUDED_PARTS, <Source>[], []); 534 entry1.setValue(INCLUDED_PARTS, <Source>[], []);
535 // configure LibrarySpecificUnit 535 // configure LibrarySpecificUnit
536 LibrarySpecificUnit unitTarget = new LibrarySpecificUnit(source2, source3); 536 LibrarySpecificUnit unitTarget = new LibrarySpecificUnit(source2, source3);
537 CacheEntry unitEntry = new CacheEntry(unitTarget); 537 CacheEntry unitEntry = new CacheEntry(unitTarget);
538 cache.put(unitEntry); 538 cache.put(unitEntry);
539 unitEntry.setValue(BUILD_LIBRARY_ERRORS, <AnalysisError>[], []); 539 unitEntry.setValue(BUILD_LIBRARY_ERRORS, <AnalysisError>[], []);
540 expect(unitEntry.getState(BUILD_LIBRARY_ERRORS), CacheState.VALID); 540 expect(unitEntry.getState(BUILD_LIBRARY_ERRORS), CacheState.VALID);
541 // notify 541 // notify
542 manager.onAnalysisOptionsChanged(); 542 manager.onAnalysisOptionsChanged();
543 // resolution is invalidated 543 // resolution is invalidated
544 expect(unitEntry.getState(BUILD_LIBRARY_ERRORS), CacheState.INVALID); 544 expect(unitEntry.getState(BUILD_LIBRARY_ERRORS), CacheState.INVALID);
545 // ...but URIs are still value 545 // ...but URIs are still value
546 expect(entry1.getState(PARSED_UNIT), CacheState.VALID); 546 expect(entry1.getState(PARSED_UNIT1), CacheState.VALID);
547 expect(entry1.getState(IMPORTED_LIBRARIES), CacheState.VALID); 547 expect(entry1.getState(IMPORTED_LIBRARIES), CacheState.VALID);
548 expect(entry1.getState(EXPLICITLY_IMPORTED_LIBRARIES), CacheState.VALID); 548 expect(entry1.getState(EXPLICITLY_IMPORTED_LIBRARIES), CacheState.VALID);
549 expect(entry1.getState(EXPORTED_LIBRARIES), CacheState.VALID); 549 expect(entry1.getState(EXPORTED_LIBRARIES), CacheState.VALID);
550 expect(entry1.getState(INCLUDED_PARTS), CacheState.VALID); 550 expect(entry1.getState(INCLUDED_PARTS), CacheState.VALID);
551 } 551 }
552 552
553 void test_onResultInvalidated_scheduleInvalidatedLibraries() { 553 void test_onResultInvalidated_scheduleInvalidatedLibraries() {
554 // make source3 implicit 554 // make source3 implicit
555 entry3.explicitlyAdded = false; 555 entry3.explicitlyAdded = false;
556 // set SOURCE_KIND 556 // set SOURCE_KIND
557 entry1.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); 557 entry1.setValue(SOURCE_KIND, SourceKind.LIBRARY, []);
558 entry2.setValue(SOURCE_KIND, SourceKind.PART, []); 558 entry2.setValue(SOURCE_KIND, SourceKind.PART, []);
559 entry3.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); 559 entry3.setValue(SOURCE_KIND, SourceKind.LIBRARY, []);
560 // set LIBRARY_ERRORS_READY for source1 and source3 560 // set LIBRARY_ERRORS_READY for source1 and source3
561 entry1.setValue(LIBRARY_ERRORS_READY, true, []); 561 entry1.setValue(LIBRARY_ERRORS_READY, true, []);
562 entry3.setValue(LIBRARY_ERRORS_READY, true, []); 562 entry3.setValue(LIBRARY_ERRORS_READY, true, []);
563 // invalidate LIBRARY_ERRORS_READY for source1, schedule it 563 // invalidate LIBRARY_ERRORS_READY for source1, schedule it
564 entry1.setState(LIBRARY_ERRORS_READY, CacheState.INVALID); 564 entry1.setState(LIBRARY_ERRORS_READY, CacheState.INVALID);
565 expect_librarySourceQueue([source1]); 565 expect_librarySourceQueue([source1]);
566 // invalidate LIBRARY_ERRORS_READY for source3, implicit, not scheduled 566 // invalidate LIBRARY_ERRORS_READY for source3, implicit, not scheduled
567 entry3.setState(LIBRARY_ERRORS_READY, CacheState.INVALID); 567 entry3.setState(LIBRARY_ERRORS_READY, CacheState.INVALID);
568 expect_librarySourceQueue([source1]); 568 expect_librarySourceQueue([source1]);
569 } 569 }
570 570
571 void test_onSourceFactoryChanged() { 571 void test_onSourceFactoryChanged() {
572 when(context.exists(anyObject)).thenReturn(true); 572 when(context.exists(anyObject)).thenReturn(true);
573 // set cache values 573 // set cache values
574 entry1.setValue(PARSED_UNIT, AstFactory.compilationUnit(), []); 574 CompilationUnit unit = AstFactory.compilationUnit();
575 entry1.setValue(PARSED_UNIT1, unit, []);
576 entry1.setValue(PARSED_UNIT, unit, []);
575 entry1.setValue(IMPORTED_LIBRARIES, <Source>[], []); 577 entry1.setValue(IMPORTED_LIBRARIES, <Source>[], []);
576 entry1.setValue(EXPLICITLY_IMPORTED_LIBRARIES, <Source>[], []); 578 entry1.setValue(EXPLICITLY_IMPORTED_LIBRARIES, <Source>[], []);
577 entry1.setValue(EXPORTED_LIBRARIES, <Source>[], []); 579 entry1.setValue(EXPORTED_LIBRARIES, <Source>[], []);
578 entry1.setValue(INCLUDED_PARTS, <Source>[], []); 580 entry1.setValue(INCLUDED_PARTS, <Source>[], []);
579 entry1.setValue(LIBRARY_SPECIFIC_UNITS, <LibrarySpecificUnit>[], []); 581 entry1.setValue(LIBRARY_SPECIFIC_UNITS, <LibrarySpecificUnit>[], []);
580 entry1.setValue(UNITS, <Source>[], []); 582 entry1.setValue(UNITS, <Source>[], []);
581 // configure LibrarySpecificUnit 583 // configure LibrarySpecificUnit
582 LibrarySpecificUnit unitTarget = new LibrarySpecificUnit(source2, source3); 584 LibrarySpecificUnit unitTarget = new LibrarySpecificUnit(source2, source3);
583 CacheEntry unitEntry = new CacheEntry(unitTarget); 585 CacheEntry unitEntry = new CacheEntry(unitTarget);
584 cache.put(unitEntry); 586 cache.put(unitEntry);
585 unitEntry.setValue(BUILD_LIBRARY_ERRORS, <AnalysisError>[], []); 587 unitEntry.setValue(BUILD_LIBRARY_ERRORS, <AnalysisError>[], []);
586 expect(unitEntry.getState(BUILD_LIBRARY_ERRORS), CacheState.VALID); 588 expect(unitEntry.getState(BUILD_LIBRARY_ERRORS), CacheState.VALID);
587 // notify 589 // notify
588 manager.onSourceFactoryChanged(); 590 manager.onSourceFactoryChanged();
589 // resolution is invalidated 591 // resolution is invalidated
590 expect(unitEntry.getState(BUILD_LIBRARY_ERRORS), CacheState.INVALID); 592 expect(unitEntry.getState(BUILD_LIBRARY_ERRORS), CacheState.INVALID);
591 // ...and URIs resolution too 593 // ...and URIs resolution too
594 expect(entry1.getState(PARSED_UNIT1), CacheState.INVALID);
592 expect(entry1.getState(PARSED_UNIT), CacheState.INVALID); 595 expect(entry1.getState(PARSED_UNIT), CacheState.INVALID);
593 expect(entry1.getState(IMPORTED_LIBRARIES), CacheState.INVALID); 596 expect(entry1.getState(IMPORTED_LIBRARIES), CacheState.INVALID);
594 expect(entry1.getState(EXPLICITLY_IMPORTED_LIBRARIES), CacheState.INVALID); 597 expect(entry1.getState(EXPLICITLY_IMPORTED_LIBRARIES), CacheState.INVALID);
595 expect(entry1.getState(EXPORTED_LIBRARIES), CacheState.INVALID); 598 expect(entry1.getState(EXPORTED_LIBRARIES), CacheState.INVALID);
596 expect(entry1.getState(INCLUDED_PARTS), CacheState.INVALID); 599 expect(entry1.getState(INCLUDED_PARTS), CacheState.INVALID);
597 expect(entry1.getState(LIBRARY_SPECIFIC_UNITS), CacheState.INVALID); 600 expect(entry1.getState(LIBRARY_SPECIFIC_UNITS), CacheState.INVALID);
598 expect(entry1.getState(UNITS), CacheState.INVALID); 601 expect(entry1.getState(UNITS), CacheState.INVALID);
599 } 602 }
600 603
601 void test_resultsComputed_errors_forLibrarySpecificUnit() { 604 void test_resultsComputed_errors_forLibrarySpecificUnit() {
(...skipping 27 matching lines...) Expand all
629 AnalysisError error2 = 632 AnalysisError error2 =
630 new AnalysisError(source1, 2, 0, ScannerErrorCode.MISSING_DIGIT); 633 new AnalysisError(source1, 2, 0, ScannerErrorCode.MISSING_DIGIT);
631 when(context.getLibrariesContaining(source1)).thenReturn([source2]); 634 when(context.getLibrariesContaining(source1)).thenReturn([source2]);
632 when(context.getErrors(source1)) 635 when(context.getErrors(source1))
633 .thenReturn(new AnalysisErrorInfoImpl([error1, error2], lineInfo)); 636 .thenReturn(new AnalysisErrorInfoImpl([error1, error2], lineInfo));
634 entry1.setValue(LINE_INFO, lineInfo, []); 637 entry1.setValue(LINE_INFO, lineInfo, []);
635 entry1.setValue(SCAN_ERRORS, <AnalysisError>[error1], []); 638 entry1.setValue(SCAN_ERRORS, <AnalysisError>[error1], []);
636 entry1.setValue(PARSE_ERRORS, <AnalysisError>[error2], []); 639 entry1.setValue(PARSE_ERRORS, <AnalysisError>[error2], []);
637 // PARSED_UNIT is ready, set errors 640 // PARSED_UNIT is ready, set errors
638 manager 641 manager
639 .resultsComputed(source1, {PARSED_UNIT: AstFactory.compilationUnit()}); 642 .resultsComputed(source1, {PARSED_UNIT1: AstFactory.compilationUnit()});
640 // all of the errors are included 643 // all of the errors are included
641 ChangeNoticeImpl notice = context.getNotice(source1); 644 ChangeNoticeImpl notice = context.getNotice(source1);
642 expect(notice.errors, unorderedEquals([error1, error2])); 645 expect(notice.errors, unorderedEquals([error1, error2]));
643 expect(notice.lineInfo, lineInfo); 646 expect(notice.lineInfo, lineInfo);
644 } 647 }
645 648
646 void test_resultsComputed_includedParts_updatePartLibraries() { 649 void test_resultsComputed_includedParts_updatePartLibraries() {
647 Source part1 = new TestSource('part1.dart'); 650 Source part1 = new TestSource('part1.dart');
648 Source part2 = new TestSource('part2.dart'); 651 Source part2 = new TestSource('part2.dart');
649 Source part3 = new TestSource('part3.dart'); 652 Source part3 = new TestSource('part3.dart');
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 expect_unknownSourceQueue([source1, source2]); 717 expect_unknownSourceQueue([source1, source2]);
715 } 718 }
716 719
717 void test_resultsComputed_parsedUnit() { 720 void test_resultsComputed_parsedUnit() {
718 LineInfo lineInfo = new LineInfo([0]); 721 LineInfo lineInfo = new LineInfo([0]);
719 when(context.getLibrariesContaining(source1)).thenReturn([]); 722 when(context.getLibrariesContaining(source1)).thenReturn([]);
720 when(context.getErrors(source1)) 723 when(context.getErrors(source1))
721 .thenReturn(new AnalysisErrorInfoImpl([], lineInfo)); 724 .thenReturn(new AnalysisErrorInfoImpl([], lineInfo));
722 entry1.setValue(LINE_INFO, lineInfo, []); 725 entry1.setValue(LINE_INFO, lineInfo, []);
723 CompilationUnit unit = AstFactory.compilationUnit(); 726 CompilationUnit unit = AstFactory.compilationUnit();
724 manager.resultsComputed(source1, {PARSED_UNIT: unit}); 727 manager.resultsComputed(source1, {PARSED_UNIT1: unit});
725 ChangeNoticeImpl notice = context.getNotice(source1); 728 ChangeNoticeImpl notice = context.getNotice(source1);
726 expect(notice.parsedDartUnit, unit); 729 expect(notice.parsedDartUnit, unit);
727 expect(notice.resolvedDartUnit, isNull); 730 expect(notice.resolvedDartUnit, isNull);
728 expect(notice.lineInfo, lineInfo); 731 expect(notice.lineInfo, lineInfo);
729 } 732 }
730 733
731 void test_resultsComputed_resolvedUnit() { 734 void test_resultsComputed_resolvedUnit() {
732 LineInfo lineInfo = new LineInfo([0]); 735 LineInfo lineInfo = new LineInfo([0]);
733 when(context.getLibrariesContaining(source2)).thenReturn([]); 736 when(context.getLibrariesContaining(source2)).thenReturn([]);
734 when(context.getErrors(source2)) 737 when(context.getErrors(source2))
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 class _SourceFactoryMock extends TypedMock implements SourceFactory {} 857 class _SourceFactoryMock extends TypedMock implements SourceFactory {}
855 858
856 class _SourceMock extends TypedMock implements Source { 859 class _SourceMock extends TypedMock implements Source {
857 final String shortName; 860 final String shortName;
858 _SourceMock(this.shortName); 861 _SourceMock(this.shortName);
859 @override 862 @override
860 String get fullName => '/' + shortName; 863 String get fullName => '/' + shortName;
861 @override 864 @override
862 String toString() => fullName; 865 String toString() => fullName;
863 } 866 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/task/dart_test.dart ('k') | pkg/analyzer/test/src/task/incremental_element_builder_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698