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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
7 | 7 |
8 library engine.engine_test; | 8 library engine.engine_test; |
9 | 9 |
10 import 'dart:async'; | 10 import 'dart:async'; |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 changeSet2.changedContent(source, 'library test;'); | 304 changeSet2.changedContent(source, 'library test;'); |
305 _context.applyChanges(changeSet2); | 305 _context.applyChanges(changeSet2); |
306 return pumpEventQueue().then((_) { | 306 return pumpEventQueue().then((_) { |
307 listener.assertEvent(wereSourcesAdded: true); | 307 listener.assertEvent(wereSourcesAdded: true); |
308 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]); | 308 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]); |
309 listener.assertNoMoreEvents(); | 309 listener.assertNoMoreEvents(); |
310 }); | 310 }); |
311 } | 311 } |
312 | 312 |
313 void test_applyChanges_change_flush_element() { | 313 void test_applyChanges_change_flush_element() { |
314 _context = AnalysisContextFactory.contextWithCore(); | 314 _context = AnalysisContextFactory.oldContextWithCore(); |
315 _sourceFactory = _context.sourceFactory; | 315 _sourceFactory = _context.sourceFactory; |
316 Source librarySource = _addSource("/lib.dart", r''' | 316 Source librarySource = _addSource("/lib.dart", r''' |
317 library lib; | 317 library lib; |
318 int a = 0;'''); | 318 int a = 0;'''); |
319 expect(_context.computeLibraryElement(librarySource), isNotNull); | 319 expect(_context.computeLibraryElement(librarySource), isNotNull); |
320 _context.setContents(librarySource, r''' | 320 _context.setContents(librarySource, r''' |
321 library lib; | 321 library lib; |
322 int aa = 0;'''); | 322 int aa = 0;'''); |
323 expect(_context.getLibraryElement(librarySource), isNull); | 323 expect(_context.getLibraryElement(librarySource), isNull); |
324 } | 324 } |
325 | 325 |
326 Future test_applyChanges_change_multiple() { | 326 Future test_applyChanges_change_multiple() { |
327 _context = AnalysisContextFactory.contextWithCore(); | 327 _context = AnalysisContextFactory.oldContextWithCore(); |
328 SourcesChangedListener listener = new SourcesChangedListener(); | 328 SourcesChangedListener listener = new SourcesChangedListener(); |
329 _context.onSourcesChanged.listen(listener.onData); | 329 _context.onSourcesChanged.listen(listener.onData); |
330 _sourceFactory = _context.sourceFactory; | 330 _sourceFactory = _context.sourceFactory; |
331 String libraryContents1 = r''' | 331 String libraryContents1 = r''' |
332 library lib; | 332 library lib; |
333 part 'part.dart'; | 333 part 'part.dart'; |
334 int a = 0;'''; | 334 int a = 0;'''; |
335 Source librarySource = _addSource("/lib.dart", libraryContents1); | 335 Source librarySource = _addSource("/lib.dart", libraryContents1); |
336 String partContents1 = r''' | 336 String partContents1 = r''' |
337 part of lib; | 337 part of lib; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 } | 409 } |
410 // Adding the source as a changedSource should have no effect since | 410 // Adding the source as a changedSource should have no effect since |
411 // it is already overridden in the content cache. | 411 // it is already overridden in the content cache. |
412 ChangeSet changeSet = new ChangeSet(); | 412 ChangeSet changeSet = new ChangeSet(); |
413 changeSet.changedSource(source); | 413 changeSet.changedSource(source); |
414 _context.applyChanges(changeSet); | 414 _context.applyChanges(changeSet); |
415 expect(_context.sourcesNeedingProcessing, hasLength(0)); | 415 expect(_context.sourcesNeedingProcessing, hasLength(0)); |
416 } | 416 } |
417 | 417 |
418 Future test_applyChanges_remove() { | 418 Future test_applyChanges_remove() { |
419 _context = AnalysisContextFactory.contextWithCore(); | 419 _context = AnalysisContextFactory.oldContextWithCore(); |
420 SourcesChangedListener listener = new SourcesChangedListener(); | 420 SourcesChangedListener listener = new SourcesChangedListener(); |
421 _context.onSourcesChanged.listen(listener.onData); | 421 _context.onSourcesChanged.listen(listener.onData); |
422 _sourceFactory = _context.sourceFactory; | 422 _sourceFactory = _context.sourceFactory; |
423 String libAContents = r''' | 423 String libAContents = r''' |
424 library libA; | 424 library libA; |
425 import 'libB.dart';'''; | 425 import 'libB.dart';'''; |
426 Source libA = _addSource("/libA.dart", libAContents); | 426 Source libA = _addSource("/libA.dart", libAContents); |
427 String libBContents = "library libB;"; | 427 String libBContents = "library libB;"; |
428 Source libB = _addSource("/libB.dart", libBContents); | 428 Source libB = _addSource("/libB.dart", libBContents); |
429 LibraryElement libAElement = _context.computeLibraryElement(libA); | 429 LibraryElement libAElement = _context.computeLibraryElement(libA); |
(...skipping 15 matching lines...) Expand all Loading... |
445 listener.assertEvent(changedSources: [libA]); | 445 listener.assertEvent(changedSources: [libA]); |
446 listener.assertEvent(wereSourcesAdded: true); | 446 listener.assertEvent(wereSourcesAdded: true); |
447 listener.assertEvent(changedSources: [libB]); | 447 listener.assertEvent(changedSources: [libB]); |
448 listener.assertEvent(changedSources: [libB]); | 448 listener.assertEvent(changedSources: [libB]); |
449 listener.assertEvent(wereSourcesRemovedOrDeleted: true); | 449 listener.assertEvent(wereSourcesRemovedOrDeleted: true); |
450 listener.assertNoMoreEvents(); | 450 listener.assertNoMoreEvents(); |
451 }); | 451 }); |
452 } | 452 } |
453 | 453 |
454 Future test_applyChanges_removeContainer() { | 454 Future test_applyChanges_removeContainer() { |
455 _context = AnalysisContextFactory.contextWithCore(); | 455 _context = AnalysisContextFactory.oldContextWithCore(); |
456 SourcesChangedListener listener = new SourcesChangedListener(); | 456 SourcesChangedListener listener = new SourcesChangedListener(); |
457 _context.onSourcesChanged.listen(listener.onData); | 457 _context.onSourcesChanged.listen(listener.onData); |
458 _sourceFactory = _context.sourceFactory; | 458 _sourceFactory = _context.sourceFactory; |
459 String libAContents = r''' | 459 String libAContents = r''' |
460 library libA; | 460 library libA; |
461 import 'libB.dart';'''; | 461 import 'libB.dart';'''; |
462 Source libA = _addSource("/libA.dart", libAContents); | 462 Source libA = _addSource("/libA.dart", libAContents); |
463 String libBContents = "library libB;"; | 463 String libBContents = "library libB;"; |
464 Source libB = _addSource("/libB.dart", libBContents); | 464 Source libB = _addSource("/libB.dart", libBContents); |
465 _context.computeLibraryElement(libA); | 465 _context.computeLibraryElement(libA); |
(...skipping 12 matching lines...) Expand all Loading... |
478 listener.assertEvent(wereSourcesAdded: true); | 478 listener.assertEvent(wereSourcesAdded: true); |
479 listener.assertEvent(changedSources: [libA]); | 479 listener.assertEvent(changedSources: [libA]); |
480 listener.assertEvent(wereSourcesAdded: true); | 480 listener.assertEvent(wereSourcesAdded: true); |
481 listener.assertEvent(changedSources: [libB]); | 481 listener.assertEvent(changedSources: [libB]); |
482 listener.assertEvent(wereSourcesRemovedOrDeleted: true); | 482 listener.assertEvent(wereSourcesRemovedOrDeleted: true); |
483 listener.assertNoMoreEvents(); | 483 listener.assertNoMoreEvents(); |
484 }); | 484 }); |
485 } | 485 } |
486 | 486 |
487 void test_computeDocumentationComment_block() { | 487 void test_computeDocumentationComment_block() { |
488 _context = AnalysisContextFactory.contextWithCore(); | 488 _context = AnalysisContextFactory.oldContextWithCore(); |
489 _sourceFactory = _context.sourceFactory; | 489 _sourceFactory = _context.sourceFactory; |
490 String comment = "/** Comment */"; | 490 String comment = "/** Comment */"; |
491 Source source = _addSource("/test.dart", """ | 491 Source source = _addSource("/test.dart", """ |
492 $comment | 492 $comment |
493 class A {}"""); | 493 class A {}"""); |
494 LibraryElement libraryElement = _context.computeLibraryElement(source); | 494 LibraryElement libraryElement = _context.computeLibraryElement(source); |
495 expect(libraryElement, isNotNull); | 495 expect(libraryElement, isNotNull); |
496 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | 496 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
497 expect(libraryElement, isNotNull); | 497 expect(libraryElement, isNotNull); |
498 expect(_context.computeDocumentationComment(classElement), comment); | 498 expect(_context.computeDocumentationComment(classElement), comment); |
499 } | 499 } |
500 | 500 |
501 void test_computeDocumentationComment_none() { | 501 void test_computeDocumentationComment_none() { |
502 _context = AnalysisContextFactory.contextWithCore(); | 502 _context = AnalysisContextFactory.oldContextWithCore(); |
503 _sourceFactory = _context.sourceFactory; | 503 _sourceFactory = _context.sourceFactory; |
504 Source source = _addSource("/test.dart", "class A {}"); | 504 Source source = _addSource("/test.dart", "class A {}"); |
505 LibraryElement libraryElement = _context.computeLibraryElement(source); | 505 LibraryElement libraryElement = _context.computeLibraryElement(source); |
506 expect(libraryElement, isNotNull); | 506 expect(libraryElement, isNotNull); |
507 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | 507 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
508 expect(libraryElement, isNotNull); | 508 expect(libraryElement, isNotNull); |
509 expect(_context.computeDocumentationComment(classElement), isNull); | 509 expect(_context.computeDocumentationComment(classElement), isNull); |
510 } | 510 } |
511 | 511 |
512 void test_computeDocumentationComment_null() { | 512 void test_computeDocumentationComment_null() { |
513 expect(_context.computeDocumentationComment(null), isNull); | 513 expect(_context.computeDocumentationComment(null), isNull); |
514 } | 514 } |
515 | 515 |
516 void test_computeDocumentationComment_singleLine_multiple_EOL_n() { | 516 void test_computeDocumentationComment_singleLine_multiple_EOL_n() { |
517 _context = AnalysisContextFactory.contextWithCore(); | 517 _context = AnalysisContextFactory.oldContextWithCore(); |
518 _sourceFactory = _context.sourceFactory; | 518 _sourceFactory = _context.sourceFactory; |
519 String comment = "/// line 1\n/// line 2\n/// line 3\n"; | 519 String comment = "/// line 1\n/// line 2\n/// line 3\n"; |
520 Source source = _addSource("/test.dart", "${comment}class A {}"); | 520 Source source = _addSource("/test.dart", "${comment}class A {}"); |
521 LibraryElement libraryElement = _context.computeLibraryElement(source); | 521 LibraryElement libraryElement = _context.computeLibraryElement(source); |
522 expect(libraryElement, isNotNull); | 522 expect(libraryElement, isNotNull); |
523 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | 523 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
524 expect(libraryElement, isNotNull); | 524 expect(libraryElement, isNotNull); |
525 String actual = _context.computeDocumentationComment(classElement); | 525 String actual = _context.computeDocumentationComment(classElement); |
526 expect(actual, "/// line 1\n/// line 2\n/// line 3"); | 526 expect(actual, "/// line 1\n/// line 2\n/// line 3"); |
527 } | 527 } |
528 | 528 |
529 void test_computeDocumentationComment_singleLine_multiple_EOL_rn() { | 529 void test_computeDocumentationComment_singleLine_multiple_EOL_rn() { |
530 _context = AnalysisContextFactory.contextWithCore(); | 530 _context = AnalysisContextFactory.oldContextWithCore(); |
531 _sourceFactory = _context.sourceFactory; | 531 _sourceFactory = _context.sourceFactory; |
532 String comment = "/// line 1\r\n/// line 2\r\n/// line 3\r\n"; | 532 String comment = "/// line 1\r\n/// line 2\r\n/// line 3\r\n"; |
533 Source source = _addSource("/test.dart", "${comment}class A {}"); | 533 Source source = _addSource("/test.dart", "${comment}class A {}"); |
534 LibraryElement libraryElement = _context.computeLibraryElement(source); | 534 LibraryElement libraryElement = _context.computeLibraryElement(source); |
535 expect(libraryElement, isNotNull); | 535 expect(libraryElement, isNotNull); |
536 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | 536 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
537 expect(libraryElement, isNotNull); | 537 expect(libraryElement, isNotNull); |
538 String actual = _context.computeDocumentationComment(classElement); | 538 String actual = _context.computeDocumentationComment(classElement); |
539 expect(actual, "/// line 1\n/// line 2\n/// line 3"); | 539 expect(actual, "/// line 1\n/// line 2\n/// line 3"); |
540 } | 540 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 Source source = _addSource("/test.dart", "library lib; part of lib;"); | 620 Source source = _addSource("/test.dart", "library lib; part of lib;"); |
621 expect(_context.computeKindOf(source), same(SourceKind.LIBRARY)); | 621 expect(_context.computeKindOf(source), same(SourceKind.LIBRARY)); |
622 } | 622 } |
623 | 623 |
624 void test_computeKindOf_part() { | 624 void test_computeKindOf_part() { |
625 Source source = _addSource("/test.dart", "part of lib;"); | 625 Source source = _addSource("/test.dart", "part of lib;"); |
626 expect(_context.computeKindOf(source), same(SourceKind.PART)); | 626 expect(_context.computeKindOf(source), same(SourceKind.PART)); |
627 } | 627 } |
628 | 628 |
629 void test_computeLibraryElement() { | 629 void test_computeLibraryElement() { |
630 _context = AnalysisContextFactory.contextWithCore(); | 630 _context = AnalysisContextFactory.oldContextWithCore(); |
631 _sourceFactory = _context.sourceFactory; | 631 _sourceFactory = _context.sourceFactory; |
632 Source source = _addSource("/test.dart", "library lib;"); | 632 Source source = _addSource("/test.dart", "library lib;"); |
633 LibraryElement element = _context.computeLibraryElement(source); | 633 LibraryElement element = _context.computeLibraryElement(source); |
634 expect(element, isNotNull); | 634 expect(element, isNotNull); |
635 } | 635 } |
636 | 636 |
637 void test_computeLineInfo_dart() { | 637 void test_computeLineInfo_dart() { |
638 Source source = _addSource("/test.dart", r''' | 638 Source source = _addSource("/test.dart", r''' |
639 library lib; | 639 library lib; |
640 | 640 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 Source source = _addSource("/lib.dart", "library lib;"); | 678 Source source = _addSource("/lib.dart", "library lib;"); |
679 CompilationUnit parsedUnit = _context.parseCompilationUnit(source); | 679 CompilationUnit parsedUnit = _context.parseCompilationUnit(source); |
680 expect(parsedUnit, isNotNull); | 680 expect(parsedUnit, isNotNull); |
681 CompilationUnit resolvedUnit = | 681 CompilationUnit resolvedUnit = |
682 _context.computeResolvableCompilationUnit(source); | 682 _context.computeResolvableCompilationUnit(source); |
683 expect(resolvedUnit, isNotNull); | 683 expect(resolvedUnit, isNotNull); |
684 expect(resolvedUnit, same(parsedUnit)); | 684 expect(resolvedUnit, same(parsedUnit)); |
685 } | 685 } |
686 | 686 |
687 Future test_computeResolvedCompilationUnitAsync() { | 687 Future test_computeResolvedCompilationUnitAsync() { |
688 _context = AnalysisContextFactory.contextWithCore(); | 688 _context = AnalysisContextFactory.oldContextWithCore(); |
689 _sourceFactory = _context.sourceFactory; | 689 _sourceFactory = _context.sourceFactory; |
690 Source source = _addSource("/lib.dart", "library lib;"); | 690 Source source = _addSource("/lib.dart", "library lib;"); |
691 // Complete all pending analysis tasks and flush the AST so that it won't | 691 // Complete all pending analysis tasks and flush the AST so that it won't |
692 // be available immediately. | 692 // be available immediately. |
693 _performPendingAnalysisTasks(); | 693 _performPendingAnalysisTasks(); |
694 DartEntry dartEntry = _context.getReadableSourceEntryOrNull(source); | 694 DartEntry dartEntry = _context.getReadableSourceEntryOrNull(source); |
695 dartEntry.flushAstStructures(); | 695 dartEntry.flushAstStructures(); |
696 bool completed = false; | 696 bool completed = false; |
697 _context | 697 _context |
698 .computeResolvedCompilationUnitAsync(source, source) | 698 .computeResolvedCompilationUnitAsync(source, source) |
699 .then((CompilationUnit unit) { | 699 .then((CompilationUnit unit) { |
700 expect(unit, isNotNull); | 700 expect(unit, isNotNull); |
701 completed = true; | 701 completed = true; |
702 }); | 702 }); |
703 return pumpEventQueue().then((_) { | 703 return pumpEventQueue().then((_) { |
704 expect(completed, isFalse); | 704 expect(completed, isFalse); |
705 _performPendingAnalysisTasks(); | 705 _performPendingAnalysisTasks(); |
706 }).then((_) => pumpEventQueue()).then((_) { | 706 }).then((_) => pumpEventQueue()).then((_) { |
707 expect(completed, isTrue); | 707 expect(completed, isTrue); |
708 }); | 708 }); |
709 } | 709 } |
710 | 710 |
711 Future test_computeResolvedCompilationUnitAsync_afterDispose() { | 711 Future test_computeResolvedCompilationUnitAsync_afterDispose() { |
712 _context = AnalysisContextFactory.contextWithCore(); | 712 _context = AnalysisContextFactory.oldContextWithCore(); |
713 _sourceFactory = _context.sourceFactory; | 713 _sourceFactory = _context.sourceFactory; |
714 Source source = _addSource("/lib.dart", "library lib;"); | 714 Source source = _addSource("/lib.dart", "library lib;"); |
715 // Complete all pending analysis tasks and flush the AST so that it won't | 715 // Complete all pending analysis tasks and flush the AST so that it won't |
716 // be available immediately. | 716 // be available immediately. |
717 _performPendingAnalysisTasks(); | 717 _performPendingAnalysisTasks(); |
718 DartEntry dartEntry = _context.getReadableSourceEntryOrNull(source); | 718 DartEntry dartEntry = _context.getReadableSourceEntryOrNull(source); |
719 dartEntry.flushAstStructures(); | 719 dartEntry.flushAstStructures(); |
720 // Dispose of the context. | 720 // Dispose of the context. |
721 _context.dispose(); | 721 _context.dispose(); |
722 // Any attempt to start an asynchronous computation should return a future | 722 // Any attempt to start an asynchronous computation should return a future |
723 // which completes with error. | 723 // which completes with error. |
724 CancelableFuture<CompilationUnit> future = | 724 CancelableFuture<CompilationUnit> future = |
725 _context.computeResolvedCompilationUnitAsync(source, source); | 725 _context.computeResolvedCompilationUnitAsync(source, source); |
726 bool completed = false; | 726 bool completed = false; |
727 future.then((CompilationUnit unit) { | 727 future.then((CompilationUnit unit) { |
728 fail('Future should have completed with error'); | 728 fail('Future should have completed with error'); |
729 }, onError: (error) { | 729 }, onError: (error) { |
730 expect(error, new isInstanceOf<AnalysisNotScheduledError>()); | 730 expect(error, new isInstanceOf<AnalysisNotScheduledError>()); |
731 completed = true; | 731 completed = true; |
732 }); | 732 }); |
733 return pumpEventQueue().then((_) { | 733 return pumpEventQueue().then((_) { |
734 expect(completed, isTrue); | 734 expect(completed, isTrue); |
735 }); | 735 }); |
736 } | 736 } |
737 | 737 |
738 Future test_computeResolvedCompilationUnitAsync_cancel() { | 738 Future test_computeResolvedCompilationUnitAsync_cancel() { |
739 _context = AnalysisContextFactory.contextWithCore(); | 739 _context = AnalysisContextFactory.oldContextWithCore(); |
740 _sourceFactory = _context.sourceFactory; | 740 _sourceFactory = _context.sourceFactory; |
741 Source source = _addSource("/lib.dart", "library lib;"); | 741 Source source = _addSource("/lib.dart", "library lib;"); |
742 // Complete all pending analysis tasks and flush the AST so that it won't | 742 // Complete all pending analysis tasks and flush the AST so that it won't |
743 // be available immediately. | 743 // be available immediately. |
744 _performPendingAnalysisTasks(); | 744 _performPendingAnalysisTasks(); |
745 DartEntry dartEntry = _context.getReadableSourceEntryOrNull(source); | 745 DartEntry dartEntry = _context.getReadableSourceEntryOrNull(source); |
746 dartEntry.flushAstStructures(); | 746 dartEntry.flushAstStructures(); |
747 CancelableFuture<CompilationUnit> future = | 747 CancelableFuture<CompilationUnit> future = |
748 _context.computeResolvedCompilationUnitAsync(source, source); | 748 _context.computeResolvedCompilationUnitAsync(source, source); |
749 bool completed = false; | 749 bool completed = false; |
750 future.then((CompilationUnit unit) { | 750 future.then((CompilationUnit unit) { |
751 fail('Future should have been canceled'); | 751 fail('Future should have been canceled'); |
752 }, onError: (error) { | 752 }, onError: (error) { |
753 expect(error, new isInstanceOf<FutureCanceledError>()); | 753 expect(error, new isInstanceOf<FutureCanceledError>()); |
754 completed = true; | 754 completed = true; |
755 }); | 755 }); |
756 expect(completed, isFalse); | 756 expect(completed, isFalse); |
757 expect(_context.pendingFutureSources_forTesting, isNotEmpty); | 757 expect(_context.pendingFutureSources_forTesting, isNotEmpty); |
758 future.cancel(); | 758 future.cancel(); |
759 expect(_context.pendingFutureSources_forTesting, isEmpty); | 759 expect(_context.pendingFutureSources_forTesting, isEmpty); |
760 return pumpEventQueue().then((_) { | 760 return pumpEventQueue().then((_) { |
761 expect(completed, isTrue); | 761 expect(completed, isTrue); |
762 expect(_context.pendingFutureSources_forTesting, isEmpty); | 762 expect(_context.pendingFutureSources_forTesting, isEmpty); |
763 }); | 763 }); |
764 } | 764 } |
765 | 765 |
766 Future test_computeResolvedCompilationUnitAsync_dispose() { | 766 Future test_computeResolvedCompilationUnitAsync_dispose() { |
767 _context = AnalysisContextFactory.contextWithCore(); | 767 _context = AnalysisContextFactory.oldContextWithCore(); |
768 _sourceFactory = _context.sourceFactory; | 768 _sourceFactory = _context.sourceFactory; |
769 Source source = _addSource("/lib.dart", "library lib;"); | 769 Source source = _addSource("/lib.dart", "library lib;"); |
770 // Complete all pending analysis tasks and flush the AST so that it won't | 770 // Complete all pending analysis tasks and flush the AST so that it won't |
771 // be available immediately. | 771 // be available immediately. |
772 _performPendingAnalysisTasks(); | 772 _performPendingAnalysisTasks(); |
773 DartEntry dartEntry = _context.getReadableSourceEntryOrNull(source); | 773 DartEntry dartEntry = _context.getReadableSourceEntryOrNull(source); |
774 dartEntry.flushAstStructures(); | 774 dartEntry.flushAstStructures(); |
775 CancelableFuture<CompilationUnit> future = | 775 CancelableFuture<CompilationUnit> future = |
776 _context.computeResolvedCompilationUnitAsync(source, source); | 776 _context.computeResolvedCompilationUnitAsync(source, source); |
777 bool completed = false; | 777 bool completed = false; |
778 future.then((CompilationUnit unit) { | 778 future.then((CompilationUnit unit) { |
779 fail('Future should have completed with error'); | 779 fail('Future should have completed with error'); |
780 }, onError: (error) { | 780 }, onError: (error) { |
781 expect(error, new isInstanceOf<AnalysisNotScheduledError>()); | 781 expect(error, new isInstanceOf<AnalysisNotScheduledError>()); |
782 completed = true; | 782 completed = true; |
783 }); | 783 }); |
784 expect(completed, isFalse); | 784 expect(completed, isFalse); |
785 expect(_context.pendingFutureSources_forTesting, isNotEmpty); | 785 expect(_context.pendingFutureSources_forTesting, isNotEmpty); |
786 // Disposing of the context should cause all pending futures to complete | 786 // Disposing of the context should cause all pending futures to complete |
787 // with AnalysisNotScheduled, so that no clients are left hanging. | 787 // with AnalysisNotScheduled, so that no clients are left hanging. |
788 _context.dispose(); | 788 _context.dispose(); |
789 expect(_context.pendingFutureSources_forTesting, isEmpty); | 789 expect(_context.pendingFutureSources_forTesting, isEmpty); |
790 return pumpEventQueue().then((_) { | 790 return pumpEventQueue().then((_) { |
791 expect(completed, isTrue); | 791 expect(completed, isTrue); |
792 expect(_context.pendingFutureSources_forTesting, isEmpty); | 792 expect(_context.pendingFutureSources_forTesting, isEmpty); |
793 }); | 793 }); |
794 } | 794 } |
795 | 795 |
796 Future test_computeResolvedCompilationUnitAsync_unrelatedLibrary() { | 796 Future test_computeResolvedCompilationUnitAsync_unrelatedLibrary() { |
797 _context = AnalysisContextFactory.contextWithCore(); | 797 _context = AnalysisContextFactory.oldContextWithCore(); |
798 _sourceFactory = _context.sourceFactory; | 798 _sourceFactory = _context.sourceFactory; |
799 Source librarySource = _addSource("/lib.dart", "library lib;"); | 799 Source librarySource = _addSource("/lib.dart", "library lib;"); |
800 Source partSource = _addSource("/part.dart", "part of foo;"); | 800 Source partSource = _addSource("/part.dart", "part of foo;"); |
801 bool completed = false; | 801 bool completed = false; |
802 _context | 802 _context |
803 .computeResolvedCompilationUnitAsync(partSource, librarySource) | 803 .computeResolvedCompilationUnitAsync(partSource, librarySource) |
804 .then((_) { | 804 .then((_) { |
805 fail('Expected resolution to fail'); | 805 fail('Expected resolution to fail'); |
806 }, onError: (e) { | 806 }, onError: (e) { |
807 expect(e, new isInstanceOf<AnalysisNotScheduledError>()); | 807 expect(e, new isInstanceOf<AnalysisNotScheduledError>()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 void test_getContents_unoverridden() { | 864 void test_getContents_unoverridden() { |
865 String content = "library lib;"; | 865 String content = "library lib;"; |
866 Source source = new TestSource('/test.dart', content); | 866 Source source = new TestSource('/test.dart', content); |
867 _context.setContents(source, "part of lib;"); | 867 _context.setContents(source, "part of lib;"); |
868 _context.setContents(source, null); | 868 _context.setContents(source, null); |
869 TimestampedData<String> contents = _context.getContents(source); | 869 TimestampedData<String> contents = _context.getContents(source); |
870 expect(contents.data.toString(), content); | 870 expect(contents.data.toString(), content); |
871 } | 871 } |
872 | 872 |
873 void test_getDeclaredVariables() { | 873 void test_getDeclaredVariables() { |
874 _context = AnalysisContextFactory.contextWithCore(); | 874 _context = AnalysisContextFactory.oldContextWithCore(); |
875 expect(_context.declaredVariables, isNotNull); | 875 expect(_context.declaredVariables, isNotNull); |
876 } | 876 } |
877 | 877 |
878 void test_getElement() { | 878 void test_getElement() { |
879 _context = AnalysisContextFactory.contextWithCore(); | 879 _context = AnalysisContextFactory.oldContextWithCore(); |
880 _sourceFactory = _context.sourceFactory; | 880 _sourceFactory = _context.sourceFactory; |
881 LibraryElement core = | 881 LibraryElement core = |
882 _context.computeLibraryElement(_sourceFactory.forUri("dart:core")); | 882 _context.computeLibraryElement(_sourceFactory.forUri("dart:core")); |
883 expect(core, isNotNull); | 883 expect(core, isNotNull); |
884 ClassElement classObject = | 884 ClassElement classObject = |
885 _findClass(core.definingCompilationUnit, "Object"); | 885 _findClass(core.definingCompilationUnit, "Object"); |
886 expect(classObject, isNotNull); | 886 expect(classObject, isNotNull); |
887 ElementLocation location = classObject.location; | 887 ElementLocation location = classObject.location; |
888 Element element = _context.getElement(location); | 888 Element element = _context.getElement(location); |
889 expect(element, same(classObject)); | 889 expect(element, same(classObject)); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 void test_getHtmlElement_html() { | 976 void test_getHtmlElement_html() { |
977 Source source = _addSource("/test.html", "<html></html>"); | 977 Source source = _addSource("/test.html", "<html></html>"); |
978 HtmlElement element = _context.getHtmlElement(source); | 978 HtmlElement element = _context.getHtmlElement(source); |
979 expect(element, isNull); | 979 expect(element, isNull); |
980 _context.computeHtmlElement(source); | 980 _context.computeHtmlElement(source); |
981 element = _context.getHtmlElement(source); | 981 element = _context.getHtmlElement(source); |
982 expect(element, isNotNull); | 982 expect(element, isNotNull); |
983 } | 983 } |
984 | 984 |
985 void test_getHtmlFilesReferencing_html() { | 985 void test_getHtmlFilesReferencing_html() { |
986 _context = AnalysisContextFactory.contextWithCore(); | 986 _context = AnalysisContextFactory.oldContextWithCore(); |
987 _sourceFactory = _context.sourceFactory; | 987 _sourceFactory = _context.sourceFactory; |
988 Source htmlSource = _addSource("/test.html", r''' | 988 Source htmlSource = _addSource("/test.html", r''' |
989 <html><head> | 989 <html><head> |
990 <script type='application/dart' src='test.dart'/> | 990 <script type='application/dart' src='test.dart'/> |
991 <script type='application/dart' src='test.js'/> | 991 <script type='application/dart' src='test.js'/> |
992 </head></html>'''); | 992 </head></html>'''); |
993 Source librarySource = _addSource("/test.dart", "library lib;"); | 993 Source librarySource = _addSource("/test.dart", "library lib;"); |
994 Source secondHtmlSource = _addSource("/test.html", "<html></html>"); | 994 Source secondHtmlSource = _addSource("/test.html", "<html></html>"); |
995 _context.computeLibraryElement(librarySource); | 995 _context.computeLibraryElement(librarySource); |
996 List<Source> result = _context.getHtmlFilesReferencing(secondHtmlSource); | 996 List<Source> result = _context.getHtmlFilesReferencing(secondHtmlSource); |
(...skipping 12 matching lines...) Expand all Loading... |
1009 Source librarySource = _addSource("/test.dart", "library lib;"); | 1009 Source librarySource = _addSource("/test.dart", "library lib;"); |
1010 List<Source> result = _context.getHtmlFilesReferencing(librarySource); | 1010 List<Source> result = _context.getHtmlFilesReferencing(librarySource); |
1011 expect(result, hasLength(0)); | 1011 expect(result, hasLength(0)); |
1012 _context.parseHtmlUnit(htmlSource); | 1012 _context.parseHtmlUnit(htmlSource); |
1013 result = _context.getHtmlFilesReferencing(librarySource); | 1013 result = _context.getHtmlFilesReferencing(librarySource); |
1014 expect(result, hasLength(1)); | 1014 expect(result, hasLength(1)); |
1015 expect(result[0], htmlSource); | 1015 expect(result[0], htmlSource); |
1016 } | 1016 } |
1017 | 1017 |
1018 void test_getHtmlFilesReferencing_part() { | 1018 void test_getHtmlFilesReferencing_part() { |
1019 _context = AnalysisContextFactory.contextWithCore(); | 1019 _context = AnalysisContextFactory.oldContextWithCore(); |
1020 _sourceFactory = _context.sourceFactory; | 1020 _sourceFactory = _context.sourceFactory; |
1021 Source htmlSource = _addSource("/test.html", r''' | 1021 Source htmlSource = _addSource("/test.html", r''' |
1022 <html><head> | 1022 <html><head> |
1023 <script type='application/dart' src='test.dart'/> | 1023 <script type='application/dart' src='test.dart'/> |
1024 <script type='application/dart' src='test.js'/> | 1024 <script type='application/dart' src='test.js'/> |
1025 </head></html>'''); | 1025 </head></html>'''); |
1026 Source librarySource = | 1026 Source librarySource = |
1027 _addSource("/test.dart", "library lib; part 'part.dart';"); | 1027 _addSource("/test.dart", "library lib; part 'part.dart';"); |
1028 Source partSource = _addSource("/part.dart", "part of lib;"); | 1028 Source partSource = _addSource("/part.dart", "part of lib;"); |
1029 _context.computeLibraryElement(librarySource); | 1029 _context.computeLibraryElement(librarySource); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 _context.computeKindOf(source); | 1063 _context.computeKindOf(source); |
1064 expect(_context.getKindOf(source), same(SourceKind.PART)); | 1064 expect(_context.getKindOf(source), same(SourceKind.PART)); |
1065 } | 1065 } |
1066 | 1066 |
1067 void test_getKindOf_unknown() { | 1067 void test_getKindOf_unknown() { |
1068 Source source = _addSource("/test.css", ""); | 1068 Source source = _addSource("/test.css", ""); |
1069 expect(_context.getKindOf(source), same(SourceKind.UNKNOWN)); | 1069 expect(_context.getKindOf(source), same(SourceKind.UNKNOWN)); |
1070 } | 1070 } |
1071 | 1071 |
1072 void test_getLaunchableClientLibrarySources() { | 1072 void test_getLaunchableClientLibrarySources() { |
1073 _context = AnalysisContextFactory.contextWithCore(); | 1073 _context = AnalysisContextFactory.oldContextWithCore(); |
1074 _sourceFactory = _context.sourceFactory; | 1074 _sourceFactory = _context.sourceFactory; |
1075 List<Source> sources = _context.launchableClientLibrarySources; | 1075 List<Source> sources = _context.launchableClientLibrarySources; |
1076 expect(sources, hasLength(0)); | 1076 expect(sources, hasLength(0)); |
1077 Source source = _addSource("/test.dart", r''' | 1077 Source source = _addSource("/test.dart", r''' |
1078 import 'dart:html'; | 1078 import 'dart:html'; |
1079 main() {}'''); | 1079 main() {}'''); |
1080 _context.computeLibraryElement(source); | 1080 _context.computeLibraryElement(source); |
1081 sources = _context.launchableClientLibrarySources; | 1081 sources = _context.launchableClientLibrarySources; |
1082 expect(sources, hasLength(1)); | 1082 expect(sources, hasLength(1)); |
1083 } | 1083 } |
1084 | 1084 |
1085 void test_getLaunchableServerLibrarySources() { | 1085 void test_getLaunchableServerLibrarySources() { |
1086 _context = AnalysisContextFactory.contextWithCore(); | 1086 _context = AnalysisContextFactory.oldContextWithCore(); |
1087 _sourceFactory = _context.sourceFactory; | 1087 _sourceFactory = _context.sourceFactory; |
1088 List<Source> sources = _context.launchableServerLibrarySources; | 1088 List<Source> sources = _context.launchableServerLibrarySources; |
1089 expect(sources, hasLength(0)); | 1089 expect(sources, hasLength(0)); |
1090 Source source = _addSource("/test.dart", "main() {}"); | 1090 Source source = _addSource("/test.dart", "main() {}"); |
1091 _context.computeLibraryElement(source); | 1091 _context.computeLibraryElement(source); |
1092 sources = _context.launchableServerLibrarySources; | 1092 sources = _context.launchableServerLibrarySources; |
1093 expect(sources, hasLength(1)); | 1093 expect(sources, hasLength(1)); |
1094 } | 1094 } |
1095 | 1095 |
1096 void test_getLibrariesContaining() { | 1096 void test_getLibrariesContaining() { |
1097 _context = AnalysisContextFactory.contextWithCore(); | 1097 _context = AnalysisContextFactory.oldContextWithCore(); |
1098 _sourceFactory = _context.sourceFactory; | 1098 _sourceFactory = _context.sourceFactory; |
1099 Source librarySource = _addSource("/lib.dart", r''' | 1099 Source librarySource = _addSource("/lib.dart", r''' |
1100 library lib; | 1100 library lib; |
1101 part 'part.dart';'''); | 1101 part 'part.dart';'''); |
1102 Source partSource = _addSource("/part.dart", "part of lib;"); | 1102 Source partSource = _addSource("/part.dart", "part of lib;"); |
1103 _context.computeLibraryElement(librarySource); | 1103 _context.computeLibraryElement(librarySource); |
1104 List<Source> result = _context.getLibrariesContaining(librarySource); | 1104 List<Source> result = _context.getLibrariesContaining(librarySource); |
1105 expect(result, hasLength(1)); | 1105 expect(result, hasLength(1)); |
1106 expect(result[0], librarySource); | 1106 expect(result[0], librarySource); |
1107 result = _context.getLibrariesContaining(partSource); | 1107 result = _context.getLibrariesContaining(partSource); |
1108 expect(result, hasLength(1)); | 1108 expect(result, hasLength(1)); |
1109 expect(result[0], librarySource); | 1109 expect(result[0], librarySource); |
1110 } | 1110 } |
1111 | 1111 |
1112 void test_getLibrariesDependingOn() { | 1112 void test_getLibrariesDependingOn() { |
1113 _context = AnalysisContextFactory.contextWithCore(); | 1113 _context = AnalysisContextFactory.oldContextWithCore(); |
1114 _sourceFactory = _context.sourceFactory; | 1114 _sourceFactory = _context.sourceFactory; |
1115 Source libASource = _addSource("/libA.dart", "library libA;"); | 1115 Source libASource = _addSource("/libA.dart", "library libA;"); |
1116 _addSource("/libB.dart", "library libB;"); | 1116 _addSource("/libB.dart", "library libB;"); |
1117 Source lib1Source = _addSource("/lib1.dart", r''' | 1117 Source lib1Source = _addSource("/lib1.dart", r''' |
1118 library lib1; | 1118 library lib1; |
1119 import 'libA.dart'; | 1119 import 'libA.dart'; |
1120 export 'libB.dart';'''); | 1120 export 'libB.dart';'''); |
1121 Source lib2Source = _addSource("/lib2.dart", r''' | 1121 Source lib2Source = _addSource("/lib2.dart", r''' |
1122 library lib2; | 1122 library lib2; |
1123 import 'libB.dart'; | 1123 import 'libB.dart'; |
1124 export 'libA.dart';'''); | 1124 export 'libA.dart';'''); |
1125 _context.computeLibraryElement(lib1Source); | 1125 _context.computeLibraryElement(lib1Source); |
1126 _context.computeLibraryElement(lib2Source); | 1126 _context.computeLibraryElement(lib2Source); |
1127 List<Source> result = _context.getLibrariesDependingOn(libASource); | 1127 List<Source> result = _context.getLibrariesDependingOn(libASource); |
1128 expect(result, unorderedEquals([lib1Source, lib2Source])); | 1128 expect(result, unorderedEquals([lib1Source, lib2Source])); |
1129 } | 1129 } |
1130 | 1130 |
1131 void test_getLibrariesReferencedFromHtml() { | 1131 void test_getLibrariesReferencedFromHtml() { |
1132 _context = AnalysisContextFactory.contextWithCore(); | 1132 _context = AnalysisContextFactory.oldContextWithCore(); |
1133 _sourceFactory = _context.sourceFactory; | 1133 _sourceFactory = _context.sourceFactory; |
1134 Source htmlSource = _addSource("/test.html", r''' | 1134 Source htmlSource = _addSource("/test.html", r''' |
1135 <html><head> | 1135 <html><head> |
1136 <script type='application/dart' src='test.dart'/> | 1136 <script type='application/dart' src='test.dart'/> |
1137 <script type='application/dart' src='test.js'/> | 1137 <script type='application/dart' src='test.js'/> |
1138 </head></html>'''); | 1138 </head></html>'''); |
1139 Source librarySource = _addSource("/test.dart", "library lib;"); | 1139 Source librarySource = _addSource("/test.dart", "library lib;"); |
1140 _context.computeLibraryElement(librarySource); | 1140 _context.computeLibraryElement(librarySource); |
1141 _context.parseHtmlUnit(htmlSource); | 1141 _context.parseHtmlUnit(htmlSource); |
1142 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); | 1142 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); |
1143 expect(result, hasLength(1)); | 1143 expect(result, hasLength(1)); |
1144 expect(result[0], librarySource); | 1144 expect(result[0], librarySource); |
1145 } | 1145 } |
1146 | 1146 |
1147 void test_getLibrariesReferencedFromHtml_no() { | 1147 void test_getLibrariesReferencedFromHtml_no() { |
1148 _context = AnalysisContextFactory.contextWithCore(); | 1148 _context = AnalysisContextFactory.oldContextWithCore(); |
1149 _sourceFactory = _context.sourceFactory; | 1149 _sourceFactory = _context.sourceFactory; |
1150 Source htmlSource = _addSource("/test.html", r''' | 1150 Source htmlSource = _addSource("/test.html", r''' |
1151 <html><head> | 1151 <html><head> |
1152 <script type='application/dart' src='test.js'/> | 1152 <script type='application/dart' src='test.js'/> |
1153 </head></html>'''); | 1153 </head></html>'''); |
1154 _addSource("/test.dart", "library lib;"); | 1154 _addSource("/test.dart", "library lib;"); |
1155 _context.parseHtmlUnit(htmlSource); | 1155 _context.parseHtmlUnit(htmlSource); |
1156 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); | 1156 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); |
1157 expect(result, hasLength(0)); | 1157 expect(result, hasLength(0)); |
1158 } | 1158 } |
1159 | 1159 |
1160 void test_getLibraryElement() { | 1160 void test_getLibraryElement() { |
1161 _context = AnalysisContextFactory.contextWithCore(); | 1161 _context = AnalysisContextFactory.oldContextWithCore(); |
1162 _sourceFactory = _context.sourceFactory; | 1162 _sourceFactory = _context.sourceFactory; |
1163 Source source = _addSource("/test.dart", "library lib;"); | 1163 Source source = _addSource("/test.dart", "library lib;"); |
1164 LibraryElement element = _context.getLibraryElement(source); | 1164 LibraryElement element = _context.getLibraryElement(source); |
1165 expect(element, isNull); | 1165 expect(element, isNull); |
1166 _context.computeLibraryElement(source); | 1166 _context.computeLibraryElement(source); |
1167 element = _context.getLibraryElement(source); | 1167 element = _context.getLibraryElement(source); |
1168 expect(element, isNotNull); | 1168 expect(element, isNotNull); |
1169 } | 1169 } |
1170 | 1170 |
1171 void test_getLibrarySources() { | 1171 void test_getLibrarySources() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 void test_getModificationStamp_overridden() { | 1205 void test_getModificationStamp_overridden() { |
1206 int stamp = 42; | 1206 int stamp = 42; |
1207 Source source = | 1207 Source source = |
1208 new AnalysisContextImplTest_Source_getModificationStamp_overridden( | 1208 new AnalysisContextImplTest_Source_getModificationStamp_overridden( |
1209 stamp); | 1209 stamp); |
1210 _context.setContents(source, ""); | 1210 _context.setContents(source, ""); |
1211 expect(stamp != _context.getModificationStamp(source), isTrue); | 1211 expect(stamp != _context.getModificationStamp(source), isTrue); |
1212 } | 1212 } |
1213 | 1213 |
1214 void test_getPublicNamespace_element() { | 1214 void test_getPublicNamespace_element() { |
1215 _context = AnalysisContextFactory.contextWithCore(); | 1215 _context = AnalysisContextFactory.oldContextWithCore(); |
1216 _sourceFactory = _context.sourceFactory; | 1216 _sourceFactory = _context.sourceFactory; |
1217 Source source = _addSource("/test.dart", "class A {}"); | 1217 Source source = _addSource("/test.dart", "class A {}"); |
1218 LibraryElement library = _context.computeLibraryElement(source); | 1218 LibraryElement library = _context.computeLibraryElement(source); |
1219 Namespace namespace = _context.getPublicNamespace(library); | 1219 Namespace namespace = _context.getPublicNamespace(library); |
1220 expect(namespace, isNotNull); | 1220 expect(namespace, isNotNull); |
1221 EngineTestCase.assertInstanceOf( | 1221 EngineTestCase.assertInstanceOf( |
1222 (obj) => obj is ClassElement, ClassElement, namespace.get("A")); | 1222 (obj) => obj is ClassElement, ClassElement, namespace.get("A")); |
1223 } | 1223 } |
1224 | 1224 |
1225 void test_getResolvedCompilationUnit_library() { | 1225 void test_getResolvedCompilationUnit_library() { |
1226 _context = AnalysisContextFactory.contextWithCore(); | 1226 _context = AnalysisContextFactory.oldContextWithCore(); |
1227 _sourceFactory = _context.sourceFactory; | 1227 _sourceFactory = _context.sourceFactory; |
1228 Source source = _addSource("/lib.dart", "library libb;"); | 1228 Source source = _addSource("/lib.dart", "library libb;"); |
1229 LibraryElement library = _context.computeLibraryElement(source); | 1229 LibraryElement library = _context.computeLibraryElement(source); |
1230 expect(_context.getResolvedCompilationUnit(source, library), isNotNull); | 1230 expect(_context.getResolvedCompilationUnit(source, library), isNotNull); |
1231 _context.setContents(source, "library lib;"); | 1231 _context.setContents(source, "library lib;"); |
1232 expect(_context.getResolvedCompilationUnit(source, library), isNull); | 1232 expect(_context.getResolvedCompilationUnit(source, library), isNull); |
1233 } | 1233 } |
1234 | 1234 |
1235 void test_getResolvedCompilationUnit_library_null() { | 1235 void test_getResolvedCompilationUnit_library_null() { |
1236 _context = AnalysisContextFactory.contextWithCore(); | 1236 _context = AnalysisContextFactory.oldContextWithCore(); |
1237 _sourceFactory = _context.sourceFactory; | 1237 _sourceFactory = _context.sourceFactory; |
1238 Source source = _addSource("/lib.dart", "library lib;"); | 1238 Source source = _addSource("/lib.dart", "library lib;"); |
1239 expect(_context.getResolvedCompilationUnit(source, null), isNull); | 1239 expect(_context.getResolvedCompilationUnit(source, null), isNull); |
1240 } | 1240 } |
1241 | 1241 |
1242 void test_getResolvedCompilationUnit_source_dart() { | 1242 void test_getResolvedCompilationUnit_source_dart() { |
1243 _context = AnalysisContextFactory.contextWithCore(); | 1243 _context = AnalysisContextFactory.oldContextWithCore(); |
1244 _sourceFactory = _context.sourceFactory; | 1244 _sourceFactory = _context.sourceFactory; |
1245 Source source = _addSource("/lib.dart", "library lib;"); | 1245 Source source = _addSource("/lib.dart", "library lib;"); |
1246 expect(_context.getResolvedCompilationUnit2(source, source), isNull); | 1246 expect(_context.getResolvedCompilationUnit2(source, source), isNull); |
1247 _context.resolveCompilationUnit2(source, source); | 1247 _context.resolveCompilationUnit2(source, source); |
1248 expect(_context.getResolvedCompilationUnit2(source, source), isNotNull); | 1248 expect(_context.getResolvedCompilationUnit2(source, source), isNotNull); |
1249 } | 1249 } |
1250 | 1250 |
1251 void test_getResolvedCompilationUnit_source_html() { | 1251 void test_getResolvedCompilationUnit_source_html() { |
1252 _context = AnalysisContextFactory.contextWithCore(); | 1252 _context = AnalysisContextFactory.oldContextWithCore(); |
1253 _sourceFactory = _context.sourceFactory; | 1253 _sourceFactory = _context.sourceFactory; |
1254 Source source = _addSource("/test.html", "<html></html>"); | 1254 Source source = _addSource("/test.html", "<html></html>"); |
1255 expect(_context.getResolvedCompilationUnit2(source, source), isNull); | 1255 expect(_context.getResolvedCompilationUnit2(source, source), isNull); |
1256 expect(_context.resolveCompilationUnit2(source, source), isNull); | 1256 expect(_context.resolveCompilationUnit2(source, source), isNull); |
1257 expect(_context.getResolvedCompilationUnit2(source, source), isNull); | 1257 expect(_context.getResolvedCompilationUnit2(source, source), isNull); |
1258 } | 1258 } |
1259 | 1259 |
1260 void test_getResolvedHtmlUnit() { | 1260 void test_getResolvedHtmlUnit() { |
1261 _context = AnalysisContextFactory.contextWithCore(); | 1261 _context = AnalysisContextFactory.oldContextWithCore(); |
1262 _sourceFactory = _context.sourceFactory; | 1262 _sourceFactory = _context.sourceFactory; |
1263 Source source = _addSource("/test.html", "<html></html>"); | 1263 Source source = _addSource("/test.html", "<html></html>"); |
1264 expect(_context.getResolvedHtmlUnit(source), isNull); | 1264 expect(_context.getResolvedHtmlUnit(source), isNull); |
1265 _context.resolveHtmlUnit(source); | 1265 _context.resolveHtmlUnit(source); |
1266 expect(_context.getResolvedHtmlUnit(source), isNotNull); | 1266 expect(_context.getResolvedHtmlUnit(source), isNotNull); |
1267 } | 1267 } |
1268 | 1268 |
1269 void test_getSourceFactory() { | 1269 void test_getSourceFactory() { |
1270 expect(_context.sourceFactory, same(_sourceFactory)); | 1270 expect(_context.sourceFactory, same(_sourceFactory)); |
1271 } | 1271 } |
(...skipping 22 matching lines...) Expand all Loading... |
1294 AnalysisContextStatistics statistics = _context.statistics; | 1294 AnalysisContextStatistics statistics = _context.statistics; |
1295 expect(statistics, isNotNull); | 1295 expect(statistics, isNotNull); |
1296 // The following lines are fragile. | 1296 // The following lines are fragile. |
1297 // The values depend on the number of libraries in the SDK. | 1297 // The values depend on the number of libraries in the SDK. |
1298 // assertLength(0, statistics.getCacheRows()); | 1298 // assertLength(0, statistics.getCacheRows()); |
1299 // assertLength(0, statistics.getExceptions()); | 1299 // assertLength(0, statistics.getExceptions()); |
1300 // assertLength(0, statistics.getSources()); | 1300 // assertLength(0, statistics.getSources()); |
1301 } | 1301 } |
1302 | 1302 |
1303 void test_isClientLibrary_dart() { | 1303 void test_isClientLibrary_dart() { |
1304 _context = AnalysisContextFactory.contextWithCore(); | 1304 _context = AnalysisContextFactory.oldContextWithCore(); |
1305 _sourceFactory = _context.sourceFactory; | 1305 _sourceFactory = _context.sourceFactory; |
1306 Source source = _addSource("/test.dart", r''' | 1306 Source source = _addSource("/test.dart", r''' |
1307 import 'dart:html'; | 1307 import 'dart:html'; |
1308 | 1308 |
1309 main() {}'''); | 1309 main() {}'''); |
1310 expect(_context.isClientLibrary(source), isFalse); | 1310 expect(_context.isClientLibrary(source), isFalse); |
1311 expect(_context.isServerLibrary(source), isFalse); | 1311 expect(_context.isServerLibrary(source), isFalse); |
1312 _context.computeLibraryElement(source); | 1312 _context.computeLibraryElement(source); |
1313 expect(_context.isClientLibrary(source), isTrue); | 1313 expect(_context.isClientLibrary(source), isTrue); |
1314 expect(_context.isServerLibrary(source), isFalse); | 1314 expect(_context.isServerLibrary(source), isFalse); |
1315 } | 1315 } |
1316 | 1316 |
1317 void test_isClientLibrary_html() { | 1317 void test_isClientLibrary_html() { |
1318 Source source = _addSource("/test.html", "<html></html>"); | 1318 Source source = _addSource("/test.html", "<html></html>"); |
1319 expect(_context.isClientLibrary(source), isFalse); | 1319 expect(_context.isClientLibrary(source), isFalse); |
1320 } | 1320 } |
1321 | 1321 |
1322 void test_isServerLibrary_dart() { | 1322 void test_isServerLibrary_dart() { |
1323 _context = AnalysisContextFactory.contextWithCore(); | 1323 _context = AnalysisContextFactory.oldContextWithCore(); |
1324 _sourceFactory = _context.sourceFactory; | 1324 _sourceFactory = _context.sourceFactory; |
1325 Source source = _addSource("/test.dart", r''' | 1325 Source source = _addSource("/test.dart", r''' |
1326 library lib; | 1326 library lib; |
1327 | 1327 |
1328 main() {}'''); | 1328 main() {}'''); |
1329 expect(_context.isClientLibrary(source), isFalse); | 1329 expect(_context.isClientLibrary(source), isFalse); |
1330 expect(_context.isServerLibrary(source), isFalse); | 1330 expect(_context.isServerLibrary(source), isFalse); |
1331 _context.computeLibraryElement(source); | 1331 _context.computeLibraryElement(source); |
1332 expect(_context.isClientLibrary(source), isFalse); | 1332 expect(_context.isClientLibrary(source), isFalse); |
1333 expect(_context.isServerLibrary(source), isTrue); | 1333 expect(_context.isServerLibrary(source), isTrue); |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1744 // Thread.sleep(1); | 1744 // Thread.sleep(1); |
1745 // // Force the modification time to be different. | 1745 // // Force the modification time to be different. |
1746 // } | 1746 // } |
1747 // _context.setContents(source, "library test;"); | 1747 // _context.setContents(source, "library test;"); |
1748 // JUnitTestCase.assertTrue(initialTime != _context.getModificationStamp(sour
ce)); | 1748 // JUnitTestCase.assertTrue(initialTime != _context.getModificationStamp(sour
ce)); |
1749 // _analyzeAll_assertFinished(); | 1749 // _analyzeAll_assertFinished(); |
1750 // JUnitTestCase.assertNotNullMsg("performAnalysisTask failed to compute an e
lement model", _context.getLibraryElement(source)); | 1750 // JUnitTestCase.assertNotNullMsg("performAnalysisTask failed to compute an e
lement model", _context.getLibraryElement(source)); |
1751 } | 1751 } |
1752 | 1752 |
1753 void test_resolveCompilationUnit_import_relative() { | 1753 void test_resolveCompilationUnit_import_relative() { |
1754 _context = AnalysisContextFactory.contextWithCore(); | 1754 _context = AnalysisContextFactory.oldContextWithCore(); |
1755 Source sourceA = | 1755 Source sourceA = |
1756 _addSource("/libA.dart", "library libA; import 'libB.dart'; class A{}"); | 1756 _addSource("/libA.dart", "library libA; import 'libB.dart'; class A{}"); |
1757 _addSource("/libB.dart", "library libB; class B{}"); | 1757 _addSource("/libB.dart", "library libB; class B{}"); |
1758 CompilationUnit compilationUnit = | 1758 CompilationUnit compilationUnit = |
1759 _context.resolveCompilationUnit2(sourceA, sourceA); | 1759 _context.resolveCompilationUnit2(sourceA, sourceA); |
1760 LibraryElement library = compilationUnit.element.library; | 1760 LibraryElement library = compilationUnit.element.library; |
1761 List<LibraryElement> importedLibraries = library.importedLibraries; | 1761 List<LibraryElement> importedLibraries = library.importedLibraries; |
1762 assertNamedElements(importedLibraries, ["dart.core", "libB"]); | 1762 assertNamedElements(importedLibraries, ["dart.core", "libB"]); |
1763 List<LibraryElement> visibleLibraries = library.visibleLibraries; | 1763 List<LibraryElement> visibleLibraries = library.visibleLibraries; |
1764 assertNamedElements(visibleLibraries, ["dart.core", "libA", "libB"]); | 1764 assertNamedElements(visibleLibraries, ["dart.core", "libA", "libB"]); |
1765 } | 1765 } |
1766 | 1766 |
1767 void test_resolveCompilationUnit_import_relative_cyclic() { | 1767 void test_resolveCompilationUnit_import_relative_cyclic() { |
1768 _context = AnalysisContextFactory.contextWithCore(); | 1768 _context = AnalysisContextFactory.oldContextWithCore(); |
1769 Source sourceA = | 1769 Source sourceA = |
1770 _addSource("/libA.dart", "library libA; import 'libB.dart'; class A{}"); | 1770 _addSource("/libA.dart", "library libA; import 'libB.dart'; class A{}"); |
1771 _addSource("/libB.dart", "library libB; import 'libA.dart'; class B{}"); | 1771 _addSource("/libB.dart", "library libB; import 'libA.dart'; class B{}"); |
1772 CompilationUnit compilationUnit = | 1772 CompilationUnit compilationUnit = |
1773 _context.resolveCompilationUnit2(sourceA, sourceA); | 1773 _context.resolveCompilationUnit2(sourceA, sourceA); |
1774 LibraryElement library = compilationUnit.element.library; | 1774 LibraryElement library = compilationUnit.element.library; |
1775 List<LibraryElement> importedLibraries = library.importedLibraries; | 1775 List<LibraryElement> importedLibraries = library.importedLibraries; |
1776 assertNamedElements(importedLibraries, ["dart.core", "libB"]); | 1776 assertNamedElements(importedLibraries, ["dart.core", "libB"]); |
1777 List<LibraryElement> visibleLibraries = library.visibleLibraries; | 1777 List<LibraryElement> visibleLibraries = library.visibleLibraries; |
1778 assertNamedElements(visibleLibraries, ["dart.core", "libA", "libB"]); | 1778 assertNamedElements(visibleLibraries, ["dart.core", "libA", "libB"]); |
1779 } | 1779 } |
1780 | 1780 |
1781 void test_resolveCompilationUnit_library() { | 1781 void test_resolveCompilationUnit_library() { |
1782 _context = AnalysisContextFactory.contextWithCore(); | 1782 _context = AnalysisContextFactory.oldContextWithCore(); |
1783 _sourceFactory = _context.sourceFactory; | 1783 _sourceFactory = _context.sourceFactory; |
1784 Source source = _addSource("/lib.dart", "library lib;"); | 1784 Source source = _addSource("/lib.dart", "library lib;"); |
1785 LibraryElement library = _context.computeLibraryElement(source); | 1785 LibraryElement library = _context.computeLibraryElement(source); |
1786 CompilationUnit compilationUnit = | 1786 CompilationUnit compilationUnit = |
1787 _context.resolveCompilationUnit(source, library); | 1787 _context.resolveCompilationUnit(source, library); |
1788 expect(compilationUnit, isNotNull); | 1788 expect(compilationUnit, isNotNull); |
1789 expect(compilationUnit.element, isNotNull); | 1789 expect(compilationUnit.element, isNotNull); |
1790 } | 1790 } |
1791 | 1791 |
1792 void test_resolveCompilationUnit_source() { | 1792 void test_resolveCompilationUnit_source() { |
1793 _context = AnalysisContextFactory.contextWithCore(); | 1793 _context = AnalysisContextFactory.oldContextWithCore(); |
1794 _sourceFactory = _context.sourceFactory; | 1794 _sourceFactory = _context.sourceFactory; |
1795 Source source = _addSource("/lib.dart", "library lib;"); | 1795 Source source = _addSource("/lib.dart", "library lib;"); |
1796 CompilationUnit compilationUnit = | 1796 CompilationUnit compilationUnit = |
1797 _context.resolveCompilationUnit2(source, source); | 1797 _context.resolveCompilationUnit2(source, source); |
1798 expect(compilationUnit, isNotNull); | 1798 expect(compilationUnit, isNotNull); |
1799 } | 1799 } |
1800 | 1800 |
1801 void test_resolveCompilationUnit_sourceChangeDuringResolution() { | 1801 void test_resolveCompilationUnit_sourceChangeDuringResolution() { |
1802 _context = new _AnalysisContext_sourceChangeDuringResolution(); | 1802 _context = new _AnalysisContext_sourceChangeDuringResolution(); |
1803 AnalysisContextFactory.initContextWithCore(_context); | 1803 AnalysisContextFactory.initContextWithCore(_context); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1857 | 1857 |
1858 void test_setAnalysisPriorityOrder_nonEmpty() { | 1858 void test_setAnalysisPriorityOrder_nonEmpty() { |
1859 List<Source> sources = new List<Source>(); | 1859 List<Source> sources = new List<Source>(); |
1860 sources.add(_addSource("/lib.dart", "library lib;")); | 1860 sources.add(_addSource("/lib.dart", "library lib;")); |
1861 _context.analysisPriorityOrder = sources; | 1861 _context.analysisPriorityOrder = sources; |
1862 } | 1862 } |
1863 | 1863 |
1864 Future test_setChangedContents_libraryWithPart() { | 1864 Future test_setChangedContents_libraryWithPart() { |
1865 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1865 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
1866 options.incremental = true; | 1866 options.incremental = true; |
1867 _context = AnalysisContextFactory.contextWithCoreAndOptions(options); | 1867 _context = AnalysisContextFactory.oldContextWithCoreAndOptions(options); |
1868 SourcesChangedListener listener = new SourcesChangedListener(); | 1868 SourcesChangedListener listener = new SourcesChangedListener(); |
1869 _context.onSourcesChanged.listen(listener.onData); | 1869 _context.onSourcesChanged.listen(listener.onData); |
1870 _sourceFactory = _context.sourceFactory; | 1870 _sourceFactory = _context.sourceFactory; |
1871 String oldCode = r''' | 1871 String oldCode = r''' |
1872 library lib; | 1872 library lib; |
1873 part 'part.dart'; | 1873 part 'part.dart'; |
1874 int a = 0;'''; | 1874 int a = 0;'''; |
1875 Source librarySource = _addSource("/lib.dart", oldCode); | 1875 Source librarySource = _addSource("/lib.dart", oldCode); |
1876 String partContents = r''' | 1876 String partContents = r''' |
1877 part of lib; | 1877 part of lib; |
(...skipping 22 matching lines...) Expand all Loading... |
1900 listener.assertEvent(wereSourcesAdded: true); | 1900 listener.assertEvent(wereSourcesAdded: true); |
1901 listener.assertEvent(changedSources: [librarySource]); | 1901 listener.assertEvent(changedSources: [librarySource]); |
1902 listener.assertEvent(wereSourcesAdded: true); | 1902 listener.assertEvent(wereSourcesAdded: true); |
1903 listener.assertEvent(changedSources: [partSource]); | 1903 listener.assertEvent(changedSources: [partSource]); |
1904 listener.assertEvent(changedSources: [librarySource]); | 1904 listener.assertEvent(changedSources: [librarySource]); |
1905 listener.assertNoMoreEvents(); | 1905 listener.assertNoMoreEvents(); |
1906 }); | 1906 }); |
1907 } | 1907 } |
1908 | 1908 |
1909 void test_setChangedContents_notResolved() { | 1909 void test_setChangedContents_notResolved() { |
1910 _context = AnalysisContextFactory.contextWithCore(); | 1910 _context = AnalysisContextFactory.oldContextWithCore(); |
1911 AnalysisOptionsImpl options = | 1911 AnalysisOptionsImpl options = |
1912 new AnalysisOptionsImpl.from(_context.analysisOptions); | 1912 new AnalysisOptionsImpl.from(_context.analysisOptions); |
1913 options.incremental = true; | 1913 options.incremental = true; |
1914 _context.analysisOptions = options; | 1914 _context.analysisOptions = options; |
1915 _sourceFactory = _context.sourceFactory; | 1915 _sourceFactory = _context.sourceFactory; |
1916 String oldCode = r''' | 1916 String oldCode = r''' |
1917 library lib; | 1917 library lib; |
1918 int a = 0;'''; | 1918 int a = 0;'''; |
1919 Source librarySource = _addSource("/lib.dart", oldCode); | 1919 Source librarySource = _addSource("/lib.dart", oldCode); |
1920 int offset = oldCode.indexOf("int a") + 4; | 1920 int offset = oldCode.indexOf("int a") + 4; |
1921 String newCode = r''' | 1921 String newCode = r''' |
1922 library lib; | 1922 library lib; |
1923 int ya = 0;'''; | 1923 int ya = 0;'''; |
1924 _context.setChangedContents(librarySource, newCode, offset, 0, 1); | 1924 _context.setChangedContents(librarySource, newCode, offset, 0, 1); |
1925 expect(_context.getContents(librarySource).data, newCode); | 1925 expect(_context.getContents(librarySource).data, newCode); |
1926 expect(_getIncrementalAnalysisCache(_context), isNull); | 1926 expect(_getIncrementalAnalysisCache(_context), isNull); |
1927 } | 1927 } |
1928 | 1928 |
1929 Future test_setContents_libraryWithPart() { | 1929 Future test_setContents_libraryWithPart() { |
1930 _context = AnalysisContextFactory.contextWithCore(); | 1930 _context = AnalysisContextFactory.oldContextWithCore(); |
1931 SourcesChangedListener listener = new SourcesChangedListener(); | 1931 SourcesChangedListener listener = new SourcesChangedListener(); |
1932 _context.onSourcesChanged.listen(listener.onData); | 1932 _context.onSourcesChanged.listen(listener.onData); |
1933 _sourceFactory = _context.sourceFactory; | 1933 _sourceFactory = _context.sourceFactory; |
1934 String libraryContents1 = r''' | 1934 String libraryContents1 = r''' |
1935 library lib; | 1935 library lib; |
1936 part 'part.dart'; | 1936 part 'part.dart'; |
1937 int a = 0;'''; | 1937 int a = 0;'''; |
1938 Source librarySource = _addSource("/lib.dart", libraryContents1); | 1938 Source librarySource = _addSource("/lib.dart", libraryContents1); |
1939 String partContents1 = r''' | 1939 String partContents1 = r''' |
1940 part of lib; | 1940 part of lib; |
(...skipping 16 matching lines...) Expand all Loading... |
1957 listener.assertEvent(wereSourcesAdded: true); | 1957 listener.assertEvent(wereSourcesAdded: true); |
1958 listener.assertEvent(changedSources: [librarySource]); | 1958 listener.assertEvent(changedSources: [librarySource]); |
1959 listener.assertEvent(wereSourcesAdded: true); | 1959 listener.assertEvent(wereSourcesAdded: true); |
1960 listener.assertEvent(changedSources: [partSource]); | 1960 listener.assertEvent(changedSources: [partSource]); |
1961 listener.assertEvent(changedSources: [librarySource]); | 1961 listener.assertEvent(changedSources: [librarySource]); |
1962 listener.assertNoMoreEvents(); | 1962 listener.assertNoMoreEvents(); |
1963 }); | 1963 }); |
1964 } | 1964 } |
1965 | 1965 |
1966 void test_setContents_null() { | 1966 void test_setContents_null() { |
1967 _context = AnalysisContextFactory.contextWithCore(); | 1967 _context = AnalysisContextFactory.oldContextWithCore(); |
1968 _sourceFactory = _context.sourceFactory; | 1968 _sourceFactory = _context.sourceFactory; |
1969 Source librarySource = _addSource("/lib.dart", r''' | 1969 Source librarySource = _addSource("/lib.dart", r''' |
1970 library lib; | 1970 library lib; |
1971 int a = 0;'''); | 1971 int a = 0;'''); |
1972 _context.computeLibraryElement(librarySource); | 1972 _context.computeLibraryElement(librarySource); |
1973 IncrementalAnalysisCache incrementalCache = new IncrementalAnalysisCache( | 1973 IncrementalAnalysisCache incrementalCache = new IncrementalAnalysisCache( |
1974 librarySource, librarySource, null, null, null, 0, 0, 0); | 1974 librarySource, librarySource, null, null, null, 0, 0, 0); |
1975 _setIncrementalAnalysisCache(_context, incrementalCache); | 1975 _setIncrementalAnalysisCache(_context, incrementalCache); |
1976 expect(_getIncrementalAnalysisCache(_context), same(incrementalCache)); | 1976 expect(_getIncrementalAnalysisCache(_context), same(incrementalCache)); |
1977 _context.setContents(librarySource, null); | 1977 _context.setContents(librarySource, null); |
(...skipping 20 matching lines...) Expand all Loading... |
1998 } | 1998 } |
1999 | 1999 |
2000 void test_setSourceFactory() { | 2000 void test_setSourceFactory() { |
2001 expect(_context.sourceFactory, _sourceFactory); | 2001 expect(_context.sourceFactory, _sourceFactory); |
2002 SourceFactory factory = new SourceFactory([]); | 2002 SourceFactory factory = new SourceFactory([]); |
2003 _context.sourceFactory = factory; | 2003 _context.sourceFactory = factory; |
2004 expect(_context.sourceFactory, factory); | 2004 expect(_context.sourceFactory, factory); |
2005 } | 2005 } |
2006 | 2006 |
2007 void test_unreadableSource() { | 2007 void test_unreadableSource() { |
2008 _context = AnalysisContextFactory.contextWithCore(); | 2008 _context = AnalysisContextFactory.oldContextWithCore(); |
2009 _sourceFactory = _context.sourceFactory; | 2009 _sourceFactory = _context.sourceFactory; |
2010 Source test1 = _addSource("/test1.dart", r''' | 2010 Source test1 = _addSource("/test1.dart", r''' |
2011 import 'test2.dart'; | 2011 import 'test2.dart'; |
2012 library test1;'''); | 2012 library test1;'''); |
2013 Source test2 = _addSource("/test2.dart", r''' | 2013 Source test2 = _addSource("/test2.dart", r''' |
2014 import 'test1.dart'; | 2014 import 'test1.dart'; |
2015 import 'test3.dart'; | 2015 import 'test3.dart'; |
2016 library test2;'''); | 2016 library test2;'''); |
2017 Source test3 = _addSourceWithException("/test3.dart"); | 2017 Source test3 = _addSourceWithException("/test3.dart"); |
2018 _analyzeAll_assertFinished(); | 2018 _analyzeAll_assertFinished(); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2299 } | 2299 } |
2300 @override | 2300 @override |
2301 void internalPerform() { | 2301 void internalPerform() { |
2302 throw new AnalysisException("Forced exception"); | 2302 throw new AnalysisException("Forced exception"); |
2303 } | 2303 } |
2304 } | 2304 } |
2305 | 2305 |
2306 @reflectiveTest | 2306 @reflectiveTest |
2307 class AnalysisTaskTest extends EngineTestCase { | 2307 class AnalysisTaskTest extends EngineTestCase { |
2308 void test_perform_exception() { | 2308 void test_perform_exception() { |
2309 InternalAnalysisContext context = new AnalysisContextImpl(); | 2309 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
2310 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | |
2311 AnalysisTask task = new AnalysisTask_test_perform_exception(context); | 2310 AnalysisTask task = new AnalysisTask_test_perform_exception(context); |
2312 task.perform(new TestTaskVisitor<Object>()); | 2311 task.perform(new TestTaskVisitor<Object>()); |
2313 } | 2312 } |
2314 } | 2313 } |
2315 | 2314 |
2316 class CompilationUnitMock extends TypedMock implements CompilationUnit { | 2315 class CompilationUnitMock extends TypedMock implements CompilationUnit { |
2317 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 2316 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
2318 } | 2317 } |
2319 | 2318 |
2320 @reflectiveTest | 2319 @reflectiveTest |
(...skipping 1556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3877 TestSource source = new TestSource(); | 3876 TestSource source = new TestSource(); |
3878 source.generateExceptionOnRead = true; | 3877 source.generateExceptionOnRead = true; |
3879 // final InternalAnalysisContext context = new AnalysisContextImpl(); | 3878 // final InternalAnalysisContext context = new AnalysisContextImpl(); |
3880 // context.setSourceFactory(new SourceFactory(new FileUriResolver())); | 3879 // context.setSourceFactory(new SourceFactory(new FileUriResolver())); |
3881 GetContentTask task = new GetContentTask(null, source); | 3880 GetContentTask task = new GetContentTask(null, source); |
3882 task.perform(new GetContentTaskTestTV_perform_exception()); | 3881 task.perform(new GetContentTaskTestTV_perform_exception()); |
3883 } | 3882 } |
3884 | 3883 |
3885 void test_perform_valid() { | 3884 void test_perform_valid() { |
3886 Source source = new TestSource('/test.dart', 'class A {}'); | 3885 Source source = new TestSource('/test.dart', 'class A {}'); |
3887 InternalAnalysisContext context = new AnalysisContextImpl(); | 3886 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
3888 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | |
3889 GetContentTask task = new GetContentTask(context, source); | 3887 GetContentTask task = new GetContentTask(context, source); |
3890 task.perform(new GetContentTaskTestTV_perform_valid(context, source)); | 3888 task.perform(new GetContentTaskTestTV_perform_valid(context, source)); |
3891 } | 3889 } |
3892 } | 3890 } |
3893 | 3891 |
3894 class GetContentTaskTestTV_accept extends TestTaskVisitor<bool> { | 3892 class GetContentTaskTestTV_accept extends TestTaskVisitor<bool> { |
3895 @override | 3893 @override |
3896 bool visitGetContentTask(GetContentTask task) => true; | 3894 bool visitGetContentTask(GetContentTask task) => true; |
3897 } | 3895 } |
3898 | 3896 |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4570 } | 4568 } |
4571 | 4569 |
4572 void test_hasPartOfDirective() { | 4570 void test_hasPartOfDirective() { |
4573 ParseDartTask task = new ParseDartTask(null, null, null, null); | 4571 ParseDartTask task = new ParseDartTask(null, null, null, null); |
4574 expect(task.hasPartOfDirective, isFalse); | 4572 expect(task.hasPartOfDirective, isFalse); |
4575 } | 4573 } |
4576 | 4574 |
4577 void test_perform_exception() { | 4575 void test_perform_exception() { |
4578 TestSource source = new TestSource(); | 4576 TestSource source = new TestSource(); |
4579 source.generateExceptionOnRead = true; | 4577 source.generateExceptionOnRead = true; |
4580 InternalAnalysisContext context = new AnalysisContextImpl(); | 4578 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
4581 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | |
4582 ParseDartTask task = new ParseDartTask(context, source, null, null); | 4579 ParseDartTask task = new ParseDartTask(context, source, null, null); |
4583 task.perform(new ParseDartTaskTestTV_perform_exception()); | 4580 task.perform(new ParseDartTaskTestTV_perform_exception()); |
4584 } | 4581 } |
4585 | 4582 |
4586 void test_perform_library() { | 4583 void test_perform_library() { |
4587 String content = r''' | 4584 String content = r''' |
4588 library lib; | 4585 library lib; |
4589 import 'lib2.dart'; | 4586 import 'lib2.dart'; |
4590 export 'lib3.dart'; | 4587 export 'lib3.dart'; |
4591 part 'part.dart'; | 4588 part 'part.dart'; |
4592 class A {'''; | 4589 class A {'''; |
4593 Source source = new TestSource('/test.dart', content); | 4590 Source source = new TestSource('/test.dart', content); |
4594 InternalAnalysisContext context = new AnalysisContextImpl(); | 4591 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
4595 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | |
4596 ParseDartTask task = _createParseTask(context, source, content); | 4592 ParseDartTask task = _createParseTask(context, source, content); |
4597 task.perform(new ParseDartTaskTestTV_perform_library(context, source)); | 4593 task.perform(new ParseDartTaskTestTV_perform_library(context, source)); |
4598 } | 4594 } |
4599 | 4595 |
4600 void test_perform_part() { | 4596 void test_perform_part() { |
4601 String content = r''' | 4597 String content = r''' |
4602 part of lib; | 4598 part of lib; |
4603 class B {}'''; | 4599 class B {}'''; |
4604 Source source = new TestSource('/test.dart', content); | 4600 Source source = new TestSource('/test.dart', content); |
4605 InternalAnalysisContext context = new AnalysisContextImpl(); | 4601 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
4606 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | |
4607 ParseDartTask task = _createParseTask(context, source, content); | 4602 ParseDartTask task = _createParseTask(context, source, content); |
4608 task.perform(new ParseDartTaskTestTV_perform_part(context, source)); | 4603 task.perform(new ParseDartTaskTestTV_perform_part(context, source)); |
4609 } | 4604 } |
4610 | 4605 |
4611 void test_perform_validateDirectives() { | 4606 void test_perform_validateDirectives() { |
4612 String content = r''' | 4607 String content = r''' |
4613 library lib; | 4608 library lib; |
4614 import '/does/not/exist.dart'; | 4609 import '/does/not/exist.dart'; |
4615 import '://invaliduri.dart'; | 4610 import '://invaliduri.dart'; |
4616 export '${a}lib3.dart'; | 4611 export '${a}lib3.dart'; |
4617 part 'part.dart'; | 4612 part 'part.dart'; |
4618 class A {}'''; | 4613 class A {}'''; |
4619 Source source = new TestSource('/test.dart', content); | 4614 Source source = new TestSource('/test.dart', content); |
4620 InternalAnalysisContext context = new AnalysisContextImpl(); | 4615 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
4621 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | |
4622 ParseDartTask task = _createParseTask(context, source, content); | 4616 ParseDartTask task = _createParseTask(context, source, content); |
4623 task.perform( | 4617 task.perform( |
4624 new ParseDartTaskTestTV_perform_validateDirectives(context, source)); | 4618 new ParseDartTaskTestTV_perform_validateDirectives(context, source)); |
4625 } | 4619 } |
4626 | 4620 |
4627 void test_resolveDirective_dartUri() { | 4621 void test_resolveDirective_dartUri() { |
4628 GatheringErrorListener listener = new GatheringErrorListener(); | 4622 GatheringErrorListener listener = new GatheringErrorListener(); |
4629 ImportDirective directive = AstFactory.importDirective3('dart:core', null); | 4623 ImportDirective directive = AstFactory.importDirective3('dart:core', null); |
4630 AnalysisContext context = AnalysisContextFactory.contextWithCore(); | 4624 AnalysisContext context = AnalysisContextFactory.contextWithCore(); |
4631 Source source = | 4625 Source source = |
4632 ParseDartTask.resolveDirective(context, null, directive, listener); | 4626 ParseDartTask.resolveDirective(context, null, directive, listener); |
4633 expect(source, isNotNull); | 4627 expect(source, isNotNull); |
4634 } | 4628 } |
4635 | 4629 |
4636 void test_resolveDirective_exception() { | 4630 void test_resolveDirective_exception() { |
4637 GatheringErrorListener listener = new GatheringErrorListener(); | 4631 GatheringErrorListener listener = new GatheringErrorListener(); |
4638 ImportDirective directive = AstFactory.importDirective3('dart:core', null); | 4632 ImportDirective directive = AstFactory.importDirective3('dart:core', null); |
4639 AnalysisContext context = new AnalysisContextImpl(); | 4633 AnalysisContext context = AnalysisContextFactory.contextWithCore(); |
4640 context.sourceFactory = new MockSourceFactory(); | 4634 context.sourceFactory = new MockSourceFactory(); |
4641 Source source = | 4635 Source source = |
4642 ParseDartTask.resolveDirective(context, null, directive, listener); | 4636 ParseDartTask.resolveDirective(context, null, directive, listener); |
4643 expect(source, isNull); | 4637 expect(source, isNull); |
4644 expect(listener.errors, hasLength(1)); | 4638 expect(listener.errors, hasLength(1)); |
4645 } | 4639 } |
4646 | 4640 |
4647 /** | 4641 /** |
4648 * Create and return a task that will parse the given content from the given s
ource in the given | 4642 * Create and return a task that will parse the given content from the given s
ource in the given |
4649 * context. | 4643 * context. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4746 | 4740 |
4747 @reflectiveTest | 4741 @reflectiveTest |
4748 class ParseHtmlTaskTest extends EngineTestCase { | 4742 class ParseHtmlTaskTest extends EngineTestCase { |
4749 ParseHtmlTask parseContents(String contents, TestLogger testLogger) { | 4743 ParseHtmlTask parseContents(String contents, TestLogger testLogger) { |
4750 return parseSource( | 4744 return parseSource( |
4751 new TestSource('/test.dart', contents), contents, testLogger); | 4745 new TestSource('/test.dart', contents), contents, testLogger); |
4752 } | 4746 } |
4753 | 4747 |
4754 ParseHtmlTask parseSource( | 4748 ParseHtmlTask parseSource( |
4755 Source source, String contents, TestLogger testLogger) { | 4749 Source source, String contents, TestLogger testLogger) { |
4756 InternalAnalysisContext context = new AnalysisContextImpl(); | 4750 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
4757 context.setContents(source, contents); | 4751 context.setContents(source, contents); |
4758 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | |
4759 ParseHtmlTask task = new ParseHtmlTask(context, source, contents); | 4752 ParseHtmlTask task = new ParseHtmlTask(context, source, contents); |
4760 Logger oldLogger = AnalysisEngine.instance.logger; | 4753 Logger oldLogger = AnalysisEngine.instance.logger; |
4761 try { | 4754 try { |
4762 AnalysisEngine.instance.logger = testLogger; | 4755 AnalysisEngine.instance.logger = testLogger; |
4763 task.perform(new ParseHtmlTaskTestTV_parseSource(context, source)); | 4756 task.perform(new ParseHtmlTaskTestTV_parseSource(context, source)); |
4764 } finally { | 4757 } finally { |
4765 AnalysisEngine.instance.logger = oldLogger; | 4758 AnalysisEngine.instance.logger = oldLogger; |
4766 } | 4759 } |
4767 return task; | 4760 return task; |
4768 } | 4761 } |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4972 } | 4965 } |
4973 void test_getUnitSource() { | 4966 void test_getUnitSource() { |
4974 Source source = new TestSource('/test.dart'); | 4967 Source source = new TestSource('/test.dart'); |
4975 ResolveDartLibraryTask task = | 4968 ResolveDartLibraryTask task = |
4976 new ResolveDartLibraryTask(null, source, null); | 4969 new ResolveDartLibraryTask(null, source, null); |
4977 expect(task.unitSource, same(source)); | 4970 expect(task.unitSource, same(source)); |
4978 } | 4971 } |
4979 void test_perform_exception() { | 4972 void test_perform_exception() { |
4980 TestSource source = new TestSource(); | 4973 TestSource source = new TestSource(); |
4981 source.generateExceptionOnRead = true; | 4974 source.generateExceptionOnRead = true; |
4982 InternalAnalysisContext context = new AnalysisContextImpl(); | 4975 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
4983 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | |
4984 ResolveDartLibraryTask task = | 4976 ResolveDartLibraryTask task = |
4985 new ResolveDartLibraryTask(context, source, source); | 4977 new ResolveDartLibraryTask(context, source, source); |
4986 task.perform(new ResolveDartLibraryTaskTestTV_perform_exception()); | 4978 task.perform(new ResolveDartLibraryTaskTestTV_perform_exception()); |
4987 } | 4979 } |
4988 void test_perform_library() { | 4980 void test_perform_library() { |
4989 Source source = new TestSource('/test.dart', r''' | 4981 Source source = new TestSource('/test.dart', r''' |
4990 library lib; | 4982 library lib; |
4991 class A {}'''); | 4983 class A {}'''); |
4992 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 4984 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
4993 ResolveDartLibraryTask task = | 4985 ResolveDartLibraryTask task = |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5147 } | 5139 } |
5148 | 5140 |
5149 void test_getSource() { | 5141 void test_getSource() { |
5150 Source source = new TestSource('test.dart', ''); | 5142 Source source = new TestSource('test.dart', ''); |
5151 ResolveHtmlTask task = new ResolveHtmlTask(null, source, 0, null); | 5143 ResolveHtmlTask task = new ResolveHtmlTask(null, source, 0, null); |
5152 expect(task.source, same(source)); | 5144 expect(task.source, same(source)); |
5153 } | 5145 } |
5154 | 5146 |
5155 void test_perform_exception() { | 5147 void test_perform_exception() { |
5156 Source source = new TestSource(); | 5148 Source source = new TestSource(); |
5157 InternalAnalysisContext context = new AnalysisContextImpl(); | 5149 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
5158 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | |
5159 ResolveHtmlTask task = new ResolveHtmlTask(context, source, 0, null); | 5150 ResolveHtmlTask task = new ResolveHtmlTask(context, source, 0, null); |
5160 task.perform(new ResolveHtmlTaskTestTV_perform_exception()); | 5151 task.perform(new ResolveHtmlTaskTestTV_perform_exception()); |
5161 } | 5152 } |
5162 | 5153 |
5163 void test_perform_valid() { | 5154 void test_perform_valid() { |
5164 int modificationStamp = 73; | 5155 int modificationStamp = 73; |
5165 String content = r''' | 5156 String content = r''' |
5166 <html> | 5157 <html> |
5167 <head> | 5158 <head> |
5168 <script type='application/dart'> | 5159 <script type='application/dart'> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5242 | 5233 |
5243 void test_getSource() { | 5234 void test_getSource() { |
5244 Source source = new TestSource('test.dart', ''); | 5235 Source source = new TestSource('test.dart', ''); |
5245 ScanDartTask task = new ScanDartTask(null, source, null); | 5236 ScanDartTask task = new ScanDartTask(null, source, null); |
5246 expect(task.source, same(source)); | 5237 expect(task.source, same(source)); |
5247 } | 5238 } |
5248 | 5239 |
5249 void test_perform_valid() { | 5240 void test_perform_valid() { |
5250 String content = 'class A {}'; | 5241 String content = 'class A {}'; |
5251 Source source = new TestSource('test.dart', content); | 5242 Source source = new TestSource('test.dart', content); |
5252 InternalAnalysisContext context = new AnalysisContextImpl(); | 5243 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
5253 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | |
5254 ScanDartTask task = new ScanDartTask(context, source, content); | 5244 ScanDartTask task = new ScanDartTask(context, source, content); |
5255 task.perform(new ScanDartTaskTestTV_perform_valid(context, source)); | 5245 task.perform(new ScanDartTaskTestTV_perform_valid(context, source)); |
5256 } | 5246 } |
5257 } | 5247 } |
5258 | 5248 |
5259 class ScanDartTaskTestTV_accept extends TestTaskVisitor<bool> { | 5249 class ScanDartTaskTestTV_accept extends TestTaskVisitor<bool> { |
5260 @override | 5250 @override |
5261 bool visitScanDartTask(ScanDartTask task) => true; | 5251 bool visitScanDartTask(ScanDartTask task) => true; |
5262 } | 5252 } |
5263 | 5253 |
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6607 @override | 6597 @override |
6608 bool exists() => true; | 6598 bool exists() => true; |
6609 } | 6599 } |
6610 | 6600 |
6611 class _UniversalCachePartitionTest_test_setMaxCacheSize | 6601 class _UniversalCachePartitionTest_test_setMaxCacheSize |
6612 implements CacheRetentionPolicy { | 6602 implements CacheRetentionPolicy { |
6613 @override | 6603 @override |
6614 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => | 6604 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => |
6615 RetentionPriority.LOW; | 6605 RetentionPriority.LOW; |
6616 } | 6606 } |
OLD | NEW |