| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.src.context.context_test; | 5 library test.src.context.context_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analyzer/src/cancelable_future.dart'; | 10 import 'package:analyzer/src/cancelable_future.dart'; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 AnalysisOptionsImpl, | 25 AnalysisOptionsImpl, |
| 26 AnalysisResult, | 26 AnalysisResult, |
| 27 ChangeNotice, | 27 ChangeNotice, |
| 28 ChangeSet, | 28 ChangeSet, |
| 29 IncrementalAnalysisCache, | 29 IncrementalAnalysisCache, |
| 30 TimestampedData; | 30 TimestampedData; |
| 31 import 'package:analyzer/src/generated/error.dart'; | 31 import 'package:analyzer/src/generated/error.dart'; |
| 32 import 'package:analyzer/src/generated/html.dart' as ht; | 32 import 'package:analyzer/src/generated/html.dart' as ht; |
| 33 import 'package:analyzer/src/generated/java_engine.dart'; | 33 import 'package:analyzer/src/generated/java_engine.dart'; |
| 34 import 'package:analyzer/src/generated/java_engine_io.dart'; | 34 import 'package:analyzer/src/generated/java_engine_io.dart'; |
| 35 import 'package:analyzer/src/generated/java_io.dart'; | |
| 36 import 'package:analyzer/src/generated/resolver.dart'; | 35 import 'package:analyzer/src/generated/resolver.dart'; |
| 37 import 'package:analyzer/src/generated/scanner.dart'; | 36 import 'package:analyzer/src/generated/scanner.dart'; |
| 38 import 'package:analyzer/src/generated/sdk.dart'; | 37 import 'package:analyzer/src/generated/sdk.dart'; |
| 39 import 'package:analyzer/src/generated/sdk_io.dart'; | 38 import 'package:analyzer/src/generated/sdk_io.dart'; |
| 40 import 'package:analyzer/src/generated/source.dart'; | 39 import 'package:analyzer/src/generated/source.dart'; |
| 41 import 'package:analyzer/src/generated/source_io.dart'; | 40 import 'package:analyzer/src/generated/source_io.dart'; |
| 42 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 41 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 43 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 42 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 44 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; | 43 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; |
| 45 import 'package:analyzer/src/generated/utilities_dart.dart'; | 44 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 46 import 'package:analyzer/src/plugin/engine_plugin.dart'; | 45 import 'package:analyzer/src/plugin/engine_plugin.dart'; |
| 46 import 'package:analyzer/task/dart.dart'; |
| 47 import 'package:plugin/manager.dart'; | 47 import 'package:plugin/manager.dart'; |
| 48 import 'package:unittest/unittest.dart'; | 48 import 'package:unittest/unittest.dart'; |
| 49 import 'package:watcher/src/utils.dart'; | 49 import 'package:watcher/src/utils.dart'; |
| 50 | 50 |
| 51 import '../../generated/engine_test.dart'; | 51 import '../../generated/engine_test.dart'; |
| 52 import '../../generated/test_support.dart'; | 52 import '../../generated/test_support.dart'; |
| 53 import '../../reflective_tests.dart'; | 53 import '../../reflective_tests.dart'; |
| 54 import 'package:analyzer/task/dart.dart'; | |
| 55 import '../mock_sdk.dart'; | 54 import '../mock_sdk.dart'; |
| 56 | 55 |
| 57 main() { | 56 main() { |
| 58 groupSep = ' | '; | 57 groupSep = ' | '; |
| 59 runReflectiveTests(AnalysisContextImplTest); | 58 runReflectiveTests(AnalysisContextImplTest); |
| 60 } | 59 } |
| 61 | 60 |
| 62 contextWithCore() { | 61 contextWithCore() { |
| 63 return new AnalysisContextForTests(); | 62 return new AnalysisContextForTests(); |
| 64 } | 63 } |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 new HashMap<Source, LibraryElement>(); | 359 new HashMap<Source, LibraryElement>(); |
| 361 elementMap[coreSource] = coreLibrary; | 360 elementMap[coreSource] = coreLibrary; |
| 362 elementMap[asyncSource] = asyncLibrary; | 361 elementMap[asyncSource] = asyncLibrary; |
| 363 elementMap[htmlSource] = htmlLibrary; | 362 elementMap[htmlSource] = htmlLibrary; |
| 364 elementMap[mathSource] = mathLibrary; | 363 elementMap[mathSource] = mathLibrary; |
| 365 recordLibraryElements(elementMap); | 364 recordLibraryElements(elementMap); |
| 366 elementMap.forEach((Source librarySource, LibraryElement library) { | 365 elementMap.forEach((Source librarySource, LibraryElement library) { |
| 367 CompilationUnit unit = new CompilationUnit(null, null, null, null, null); | 366 CompilationUnit unit = new CompilationUnit(null, null, null, null, null); |
| 368 unit.element = library.definingCompilationUnit; | 367 unit.element = library.definingCompilationUnit; |
| 369 CacheEntry entry = getCacheEntry(librarySource); | 368 CacheEntry entry = getCacheEntry(librarySource); |
| 370 entry.setValue(PARSED_UNIT, unit); | 369 entry.setValue(PARSED_UNIT, unit, TargetedResult.EMPTY_LIST); |
| 371 }); | 370 }); |
| 372 } | 371 } |
| 373 | 372 |
| 374 /** | 373 /** |
| 375 * Set the analysis options, even if they would force re-analysis. This method
should only be | 374 * Set the analysis options, even if they would force re-analysis. This method
should only be |
| 376 * invoked before the fake SDK is initialized. | 375 * invoked before the fake SDK is initialized. |
| 377 * | 376 * |
| 378 * @param options the analysis options to be set | 377 * @param options the analysis options to be set |
| 379 */ | 378 */ |
| 380 void _internalSetAnalysisOptions(AnalysisOptions options) { | 379 void _internalSetAnalysisOptions(AnalysisOptions options) { |
| 381 super.analysisOptions = options; | 380 super.analysisOptions = options; |
| 382 } | 381 } |
| 383 } | 382 } |
| 384 | 383 |
| 385 @reflectiveTest | 384 @reflectiveTest |
| 386 class AnalysisContextImplTest extends EngineTestCase { | 385 class AnalysisContextImplTest extends EngineTestCase { |
| 387 /** | 386 /** |
| 388 * An analysis context whose source factory is [sourceFactory]. | 387 * An analysis context whose source factory is [sourceFactory]. |
| 389 */ | 388 */ |
| 390 AnalysisContextImpl _context; | 389 AnalysisContextImpl _context; |
| 391 | 390 |
| 392 /** | 391 /** |
| 393 * The source factory associated with the analysis [context]. | 392 * The source factory associated with the analysis [context]. |
| 394 */ | 393 */ |
| 395 SourceFactory _sourceFactory; | 394 SourceFactory _sourceFactory; |
| 396 | 395 |
| 397 void fail_applyChanges_change_flush_element() { | |
| 398 _context = contextWithCore(); | |
| 399 _sourceFactory = _context.sourceFactory; | |
| 400 Source librarySource = _addSource("/lib.dart", r''' | |
| 401 library lib; | |
| 402 int a = 0;'''); | |
| 403 expect(_context.computeLibraryElement(librarySource), isNotNull); | |
| 404 _context.setContents(librarySource, r''' | |
| 405 library lib; | |
| 406 int aa = 0;'''); | |
| 407 expect(_context.getLibraryElement(librarySource), isNull); | |
| 408 } | |
| 409 | |
| 410 Future test_applyChanges_change_multiple() { | |
| 411 _context = contextWithCore(); | |
| 412 SourcesChangedListener listener = new SourcesChangedListener(); | |
| 413 _context.onSourcesChanged.listen(listener.onData); | |
| 414 _sourceFactory = _context.sourceFactory; | |
| 415 String libraryContents1 = r''' | |
| 416 library lib; | |
| 417 part 'part.dart'; | |
| 418 int a = 0;'''; | |
| 419 Source librarySource = _addSource("/lib.dart", libraryContents1); | |
| 420 String partContents1 = r''' | |
| 421 part of lib; | |
| 422 int b = a;'''; | |
| 423 Source partSource = _addSource("/part.dart", partContents1); | |
| 424 _context.computeLibraryElement(librarySource); | |
| 425 String libraryContents2 = r''' | |
| 426 library lib; | |
| 427 part 'part.dart'; | |
| 428 int aa = 0;'''; | |
| 429 _context.setContents(librarySource, libraryContents2); | |
| 430 String partContents2 = r''' | |
| 431 part of lib; | |
| 432 int b = aa;'''; | |
| 433 _context.setContents(partSource, partContents2); | |
| 434 _context.computeLibraryElement(librarySource); | |
| 435 CompilationUnit libraryUnit = | |
| 436 _context.resolveCompilationUnit2(librarySource, librarySource); | |
| 437 expect(libraryUnit, isNotNull); | |
| 438 CompilationUnit partUnit = | |
| 439 _context.resolveCompilationUnit2(partSource, librarySource); | |
| 440 expect(partUnit, isNotNull); | |
| 441 TopLevelVariableDeclaration declaration = | |
| 442 libraryUnit.declarations[0] as TopLevelVariableDeclaration; | |
| 443 Element declarationElement = declaration.variables.variables[0].element; | |
| 444 TopLevelVariableDeclaration use = | |
| 445 partUnit.declarations[0] as TopLevelVariableDeclaration; | |
| 446 Element useElement = (use.variables.variables[ | |
| 447 0].initializer as SimpleIdentifier).staticElement; | |
| 448 expect((useElement as PropertyAccessorElement).variable, | |
| 449 same(declarationElement)); | |
| 450 return pumpEventQueue().then((_) { | |
| 451 listener.assertEvent(wereSourcesAdded: true); | |
| 452 listener.assertEvent(changedSources: [librarySource]); | |
| 453 listener.assertEvent(wereSourcesAdded: true); | |
| 454 listener.assertEvent(changedSources: [partSource]); | |
| 455 listener.assertEvent(changedSources: [librarySource]); | |
| 456 listener.assertEvent(changedSources: [partSource]); | |
| 457 listener.assertNoMoreEvents(); | |
| 458 }); | |
| 459 } | |
| 460 | |
| 461 void fail_applyChanges_empty() { | 396 void fail_applyChanges_empty() { |
| 462 _context.applyChanges(new ChangeSet()); | 397 _context.applyChanges(new ChangeSet()); |
| 463 expect(_context.performAnalysisTask().changeNotices, isNull); | 398 expect(_context.performAnalysisTask().changeNotices, isNull); |
| 464 // This test appears to be flaky. If it is named "test_" it fails, if it's | 399 // This test appears to be flaky. If it is named "test_" it fails, if it's |
| 465 // named "fail_" it doesn't fail. I'm guessing that it's dependent on some | 400 // named "fail_" it doesn't fail. I'm guessing that it's dependent on some |
| 466 // other test being run (or not). | 401 // other test being run (or not). |
| 467 fail('Should have failed'); | 402 fail('Should have failed'); |
| 468 } | 403 } |
| 469 | 404 |
| 470 void fail_applyChanges_overriddenSource() { | 405 void fail_applyChanges_overriddenSource() { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 return pumpEventQueue().then((_) { | 480 return pumpEventQueue().then((_) { |
| 546 listener.assertEvent(wereSourcesAdded: true); | 481 listener.assertEvent(wereSourcesAdded: true); |
| 547 listener.assertEvent(changedSources: [libA]); | 482 listener.assertEvent(changedSources: [libA]); |
| 548 listener.assertEvent(wereSourcesAdded: true); | 483 listener.assertEvent(wereSourcesAdded: true); |
| 549 listener.assertEvent(changedSources: [libB]); | 484 listener.assertEvent(changedSources: [libB]); |
| 550 listener.assertEvent(wereSourcesRemovedOrDeleted: true); | 485 listener.assertEvent(wereSourcesRemovedOrDeleted: true); |
| 551 listener.assertNoMoreEvents(); | 486 listener.assertNoMoreEvents(); |
| 552 }); | 487 }); |
| 553 } | 488 } |
| 554 | 489 |
| 555 void test_computeDocumentationComment_block() { | |
| 556 _context = contextWithCore(); | |
| 557 _sourceFactory = _context.sourceFactory; | |
| 558 String comment = "/** Comment */"; | |
| 559 Source source = _addSource("/test.dart", """ | |
| 560 $comment | |
| 561 class A {}"""); | |
| 562 LibraryElement libraryElement = _context.computeLibraryElement(source); | |
| 563 expect(libraryElement, isNotNull); | |
| 564 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | |
| 565 expect(libraryElement, isNotNull); | |
| 566 expect(_context.computeDocumentationComment(classElement), comment); | |
| 567 } | |
| 568 | |
| 569 void test_computeDocumentationComment_none() { | |
| 570 _context = contextWithCore(); | |
| 571 _sourceFactory = _context.sourceFactory; | |
| 572 Source source = _addSource("/test.dart", "class A {}"); | |
| 573 LibraryElement libraryElement = _context.computeLibraryElement(source); | |
| 574 expect(libraryElement, isNotNull); | |
| 575 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | |
| 576 expect(libraryElement, isNotNull); | |
| 577 expect(_context.computeDocumentationComment(classElement), isNull); | |
| 578 } | |
| 579 | |
| 580 void test_computeDocumentationComment_singleLine_multiple_EOL_n() { | |
| 581 _context = contextWithCore(); | |
| 582 _sourceFactory = _context.sourceFactory; | |
| 583 String comment = "/// line 1\n/// line 2\n/// line 3\n"; | |
| 584 Source source = _addSource("/test.dart", "${comment}class A {}"); | |
| 585 LibraryElement libraryElement = _context.computeLibraryElement(source); | |
| 586 expect(libraryElement, isNotNull); | |
| 587 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | |
| 588 expect(libraryElement, isNotNull); | |
| 589 String actual = _context.computeDocumentationComment(classElement); | |
| 590 expect(actual, "/// line 1\n/// line 2\n/// line 3"); | |
| 591 } | |
| 592 | |
| 593 void test_computeDocumentationComment_singleLine_multiple_EOL_rn() { | |
| 594 _context = contextWithCore(); | |
| 595 _sourceFactory = _context.sourceFactory; | |
| 596 String comment = "/// line 1\r\n/// line 2\r\n/// line 3\r\n"; | |
| 597 Source source = _addSource("/test.dart", "${comment}class A {}"); | |
| 598 LibraryElement libraryElement = _context.computeLibraryElement(source); | |
| 599 expect(libraryElement, isNotNull); | |
| 600 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | |
| 601 expect(libraryElement, isNotNull); | |
| 602 String actual = _context.computeDocumentationComment(classElement); | |
| 603 expect(actual, "/// line 1\n/// line 2\n/// line 3"); | |
| 604 } | |
| 605 | |
| 606 void fail_computeErrors_dart_none() { | 490 void fail_computeErrors_dart_none() { |
| 607 Source source = _addSource("/lib.dart", "library lib;"); | 491 Source source = _addSource("/lib.dart", "library lib;"); |
| 608 List<AnalysisError> errors = _context.computeErrors(source); | 492 List<AnalysisError> errors = _context.computeErrors(source); |
| 609 expect(errors, hasLength(0)); | 493 expect(errors, hasLength(0)); |
| 610 } | 494 } |
| 611 | 495 |
| 612 void fail_computeErrors_dart_part() { | 496 void fail_computeErrors_dart_part() { |
| 613 Source librarySource = | 497 Source librarySource = |
| 614 _addSource("/lib.dart", "library lib; part 'part.dart';"); | 498 _addSource("/lib.dart", "library lib; part 'part.dart';"); |
| 615 Source partSource = _addSource("/part.dart", "part of 'lib';"); | 499 Source partSource = _addSource("/part.dart", "part of 'lib';"); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 Source source = _addSource( | 534 Source source = _addSource( |
| 651 "/test.dart", "library test; import 'lib1.dart'; import 'lib2.dart';"); | 535 "/test.dart", "library test; import 'lib1.dart'; import 'lib2.dart';"); |
| 652 expect(_context.computeImportedLibraries(source), hasLength(2)); | 536 expect(_context.computeImportedLibraries(source), hasLength(2)); |
| 653 } | 537 } |
| 654 | 538 |
| 655 void fail_computeKindOf_html() { | 539 void fail_computeKindOf_html() { |
| 656 Source source = _addSource("/test.html", ""); | 540 Source source = _addSource("/test.html", ""); |
| 657 expect(_context.computeKindOf(source), same(SourceKind.HTML)); | 541 expect(_context.computeKindOf(source), same(SourceKind.HTML)); |
| 658 } | 542 } |
| 659 | 543 |
| 660 void test_computeLibraryElement() { | |
| 661 _context = contextWithCore(); | |
| 662 _sourceFactory = _context.sourceFactory; | |
| 663 Source source = _addSource("/test.dart", "library lib;"); | |
| 664 LibraryElement element = _context.computeLibraryElement(source); | |
| 665 expect(element, isNotNull); | |
| 666 } | |
| 667 | |
| 668 void fail_computeResolvableCompilationUnit_dart_exception() { | 544 void fail_computeResolvableCompilationUnit_dart_exception() { |
| 669 TestSource source = _addSourceWithException("/test.dart"); | 545 TestSource source = _addSourceWithException("/test.dart"); |
| 670 try { | 546 try { |
| 671 _context.computeResolvableCompilationUnit(source); | 547 _context.computeResolvableCompilationUnit(source); |
| 672 fail("Expected AnalysisException"); | 548 fail("Expected AnalysisException"); |
| 673 } on AnalysisException { | 549 } on AnalysisException { |
| 674 // Expected | 550 // Expected |
| 675 } | 551 } |
| 676 } | 552 } |
| 677 | 553 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 688 void fail_computeResolvableCompilationUnit_valid() { | 564 void fail_computeResolvableCompilationUnit_valid() { |
| 689 Source source = _addSource("/lib.dart", "library lib;"); | 565 Source source = _addSource("/lib.dart", "library lib;"); |
| 690 CompilationUnit parsedUnit = _context.parseCompilationUnit(source); | 566 CompilationUnit parsedUnit = _context.parseCompilationUnit(source); |
| 691 expect(parsedUnit, isNotNull); | 567 expect(parsedUnit, isNotNull); |
| 692 CompilationUnit resolvedUnit = | 568 CompilationUnit resolvedUnit = |
| 693 _context.computeResolvableCompilationUnit(source); | 569 _context.computeResolvableCompilationUnit(source); |
| 694 expect(resolvedUnit, isNotNull); | 570 expect(resolvedUnit, isNotNull); |
| 695 expect(resolvedUnit, same(parsedUnit)); | 571 expect(resolvedUnit, same(parsedUnit)); |
| 696 } | 572 } |
| 697 | 573 |
| 698 Future fail_computeResolvedCompilationUnitAsync() { | |
| 699 _context = contextWithCore(); | |
| 700 _sourceFactory = _context.sourceFactory; | |
| 701 Source source = _addSource("/lib.dart", "library lib;"); | |
| 702 // Complete all pending analysis tasks and flush the AST so that it won't | |
| 703 // be available immediately. | |
| 704 _performPendingAnalysisTasks(); | |
| 705 CacheEntry entry = _context.getReadableSourceEntryOrNull(source); | |
| 706 entry.flushAstStructures(); | |
| 707 bool completed = false; | |
| 708 _context | |
| 709 .computeResolvedCompilationUnitAsync(source, source) | |
| 710 .then((CompilationUnit unit) { | |
| 711 expect(unit, isNotNull); | |
| 712 completed = true; | |
| 713 }); | |
| 714 return pumpEventQueue().then((_) { | |
| 715 expect(completed, isFalse); | |
| 716 _performPendingAnalysisTasks(); | |
| 717 }).then((_) => pumpEventQueue()).then((_) { | |
| 718 expect(completed, isTrue); | |
| 719 }); | |
| 720 } | |
| 721 | |
| 722 Future test_computeResolvedCompilationUnitAsync_afterDispose() { | |
| 723 _context = contextWithCore(); | |
| 724 _sourceFactory = _context.sourceFactory; | |
| 725 Source source = _addSource("/lib.dart", "library lib;"); | |
| 726 // Complete all pending analysis tasks and flush the AST so that it won't | |
| 727 // be available immediately. | |
| 728 _performPendingAnalysisTasks(); | |
| 729 CacheEntry entry = _context.getReadableSourceEntryOrNull(source); | |
| 730 entry.flushAstStructures(); | |
| 731 // Dispose of the context. | |
| 732 _context.dispose(); | |
| 733 // Any attempt to start an asynchronous computation should return a future | |
| 734 // which completes with error. | |
| 735 CancelableFuture<CompilationUnit> future = | |
| 736 _context.computeResolvedCompilationUnitAsync(source, source); | |
| 737 bool completed = false; | |
| 738 future.then((CompilationUnit unit) { | |
| 739 fail('Future should have completed with error'); | |
| 740 }, onError: (error) { | |
| 741 expect(error, new isInstanceOf<AnalysisNotScheduledError>()); | |
| 742 completed = true; | |
| 743 }); | |
| 744 return pumpEventQueue().then((_) { | |
| 745 expect(completed, isTrue); | |
| 746 }); | |
| 747 } | |
| 748 | |
| 749 Future fail_computeResolvedCompilationUnitAsync_cancel() { | |
| 750 _context = contextWithCore(); | |
| 751 _sourceFactory = _context.sourceFactory; | |
| 752 Source source = _addSource("/lib.dart", "library lib;"); | |
| 753 // Complete all pending analysis tasks and flush the AST so that it won't | |
| 754 // be available immediately. | |
| 755 _performPendingAnalysisTasks(); | |
| 756 CacheEntry entry = _context.getReadableSourceEntryOrNull(source); | |
| 757 entry.flushAstStructures(); | |
| 758 CancelableFuture<CompilationUnit> future = | |
| 759 _context.computeResolvedCompilationUnitAsync(source, source); | |
| 760 bool completed = false; | |
| 761 future.then((CompilationUnit unit) { | |
| 762 fail('Future should have been canceled'); | |
| 763 }, onError: (error) { | |
| 764 expect(error, new isInstanceOf<FutureCanceledError>()); | |
| 765 completed = true; | |
| 766 }); | |
| 767 expect(completed, isFalse); | |
| 768 expect(_context.pendingFutureSources_forTesting, isNotEmpty); | |
| 769 future.cancel(); | |
| 770 expect(_context.pendingFutureSources_forTesting, isEmpty); | |
| 771 return pumpEventQueue().then((_) { | |
| 772 expect(completed, isTrue); | |
| 773 expect(_context.pendingFutureSources_forTesting, isEmpty); | |
| 774 }); | |
| 775 } | |
| 776 | |
| 777 Future fail_computeResolvedCompilationUnitAsync_dispose() { | 574 Future fail_computeResolvedCompilationUnitAsync_dispose() { |
| 778 _context = contextWithCore(); | 575 _context = contextWithCore(); |
| 779 _sourceFactory = _context.sourceFactory; | 576 _sourceFactory = _context.sourceFactory; |
| 780 Source source = _addSource("/lib.dart", "library lib;"); | 577 Source source = _addSource("/lib.dart", "library lib;"); |
| 781 // Complete all pending analysis tasks and flush the AST so that it won't | 578 // Complete all pending analysis tasks and flush the AST so that it won't |
| 782 // be available immediately. | 579 // be available immediately. |
| 783 _performPendingAnalysisTasks(); | 580 _performPendingAnalysisTasks(); |
| 784 CacheEntry entry = _context.getReadableSourceEntryOrNull(source); | 581 CacheEntry entry = _context.getReadableSourceEntryOrNull(source); |
| 785 entry.flushAstStructures(); | 582 entry.flushAstStructures(); |
| 786 CancelableFuture<CompilationUnit> future = | 583 CancelableFuture<CompilationUnit> future = |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 <script type='application/dart' src='test.js'/> | 798 <script type='application/dart' src='test.js'/> |
| 1002 </head></html>'''); | 799 </head></html>'''); |
| 1003 Source librarySource = _addSource("/test.dart", "library lib;"); | 800 Source librarySource = _addSource("/test.dart", "library lib;"); |
| 1004 _context.computeLibraryElement(librarySource); | 801 _context.computeLibraryElement(librarySource); |
| 1005 _context.parseHtmlUnit(htmlSource); | 802 _context.parseHtmlUnit(htmlSource); |
| 1006 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); | 803 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); |
| 1007 expect(result, hasLength(1)); | 804 expect(result, hasLength(1)); |
| 1008 expect(result[0], librarySource); | 805 expect(result[0], librarySource); |
| 1009 } | 806 } |
| 1010 | 807 |
| 1011 void test_getLibraryElement() { | |
| 1012 _context = contextWithCore(); | |
| 1013 _sourceFactory = _context.sourceFactory; | |
| 1014 Source source = _addSource("/test.dart", "library lib;"); | |
| 1015 LibraryElement element = _context.getLibraryElement(source); | |
| 1016 expect(element, isNull); | |
| 1017 _context.computeLibraryElement(source); | |
| 1018 element = _context.getLibraryElement(source); | |
| 1019 expect(element, isNotNull); | |
| 1020 } | |
| 1021 | |
| 1022 void test_getPublicNamespace_element() { | |
| 1023 _context = contextWithCore(); | |
| 1024 _sourceFactory = _context.sourceFactory; | |
| 1025 Source source = _addSource("/test.dart", "class A {}"); | |
| 1026 LibraryElement library = _context.computeLibraryElement(source); | |
| 1027 expect(library, isNotNull); | |
| 1028 Namespace namespace = _context.getPublicNamespace(library); | |
| 1029 expect(namespace, isNotNull); | |
| 1030 EngineTestCase.assertInstanceOf( | |
| 1031 (obj) => obj is ClassElement, ClassElement, namespace.get("A")); | |
| 1032 } | |
| 1033 | |
| 1034 void fail_getResolvedCompilationUnit_library() { | 808 void fail_getResolvedCompilationUnit_library() { |
| 1035 _context = contextWithCore(); | 809 _context = contextWithCore(); |
| 1036 _sourceFactory = _context.sourceFactory; | 810 _sourceFactory = _context.sourceFactory; |
| 1037 Source source = _addSource("/lib.dart", "library libb;"); | 811 Source source = _addSource("/lib.dart", "library libb;"); |
| 1038 LibraryElement library = _context.computeLibraryElement(source); | 812 LibraryElement library = _context.computeLibraryElement(source); |
| 1039 expect(_context.getResolvedCompilationUnit(source, library), isNotNull); | 813 expect(_context.getResolvedCompilationUnit(source, library), isNotNull); |
| 1040 _context.setContents(source, "library lib;"); | 814 _context.setContents(source, "library lib;"); |
| 1041 expect(_context.getResolvedCompilationUnit(source, library), isNull); | 815 expect(_context.getResolvedCompilationUnit(source, library), isNull); |
| 1042 } | 816 } |
| 1043 | 817 |
| 1044 void test_getResolvedCompilationUnit_source_dart() { | |
| 1045 _context = contextWithCore(); | |
| 1046 _sourceFactory = _context.sourceFactory; | |
| 1047 Source source = _addSource("/lib.dart", "library lib;"); | |
| 1048 expect(_context.getResolvedCompilationUnit2(source, source), isNull); | |
| 1049 _context.resolveCompilationUnit2(source, source); | |
| 1050 expect(_context.getResolvedCompilationUnit2(source, source), isNotNull); | |
| 1051 } | |
| 1052 | |
| 1053 void fail_getResolvedHtmlUnit() { | 818 void fail_getResolvedHtmlUnit() { |
| 1054 _context = contextWithCore(); | 819 _context = contextWithCore(); |
| 1055 _sourceFactory = _context.sourceFactory; | 820 _sourceFactory = _context.sourceFactory; |
| 1056 Source source = _addSource("/test.html", "<html></html>"); | 821 Source source = _addSource("/test.html", "<html></html>"); |
| 1057 expect(_context.getResolvedHtmlUnit(source), isNull); | 822 expect(_context.getResolvedHtmlUnit(source), isNull); |
| 1058 _context.resolveHtmlUnit(source); | 823 _context.resolveHtmlUnit(source); |
| 1059 expect(_context.getResolvedHtmlUnit(source), isNotNull); | 824 expect(_context.getResolvedHtmlUnit(source), isNotNull); |
| 1060 } | 825 } |
| 1061 | 826 |
| 1062 void fail_mergeContext() { | 827 void fail_mergeContext() { |
| 1063 fail("Implement this"); | 828 fail("Implement this"); |
| 1064 } | 829 } |
| 1065 | 830 |
| 1066 void test_parseCompilationUnit_errors() { | |
| 1067 Source source = _addSource("/lib.dart", "library {"); | |
| 1068 CompilationUnit compilationUnit = _context.parseCompilationUnit(source); | |
| 1069 expect(compilationUnit, isNotNull); | |
| 1070 var errorInfo = _context.getErrors(source); | |
| 1071 expect(errorInfo, isNotNull); | |
| 1072 List<AnalysisError> errors = errorInfo.errors; | |
| 1073 expect(errors, isNotNull); | |
| 1074 expect(errors.length > 0, isTrue); | |
| 1075 } | |
| 1076 | |
| 1077 void test_parseCompilationUnit_exception() { | |
| 1078 Source source = _addSourceWithException("/test.dart"); | |
| 1079 try { | |
| 1080 _context.parseCompilationUnit(source); | |
| 1081 fail("Expected AnalysisException"); | |
| 1082 } on AnalysisException { | |
| 1083 // Expected | |
| 1084 } | |
| 1085 } | |
| 1086 | |
| 1087 void test_parseCompilationUnit_noErrors() { | |
| 1088 Source source = _addSource("/lib.dart", "library lib;"); | |
| 1089 CompilationUnit compilationUnit = _context.parseCompilationUnit(source); | |
| 1090 expect(compilationUnit, isNotNull); | |
| 1091 AnalysisErrorInfo errorInfo = _context.getErrors(source); | |
| 1092 expect(errorInfo, isNotNull); | |
| 1093 expect(errorInfo.errors, hasLength(0)); | |
| 1094 } | |
| 1095 | |
| 1096 void test_parseCompilationUnit_nonExistentSource() { | |
| 1097 Source source = | |
| 1098 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | |
| 1099 try { | |
| 1100 _context.parseCompilationUnit(source); | |
| 1101 fail("Expected AnalysisException because file does not exist"); | |
| 1102 } on AnalysisException { | |
| 1103 // Expected result | |
| 1104 } | |
| 1105 } | |
| 1106 | |
| 1107 void fail_parseHtmlUnit_noErrors() { | 831 void fail_parseHtmlUnit_noErrors() { |
| 1108 Source source = _addSource("/lib.html", "<html></html>"); | 832 Source source = _addSource("/lib.html", "<html></html>"); |
| 1109 ht.HtmlUnit unit = _context.parseHtmlUnit(source); | 833 ht.HtmlUnit unit = _context.parseHtmlUnit(source); |
| 1110 expect(unit, isNotNull); | 834 expect(unit, isNotNull); |
| 1111 } | 835 } |
| 1112 | 836 |
| 1113 void fail_parseHtmlUnit_resolveDirectives() { | 837 void fail_parseHtmlUnit_resolveDirectives() { |
| 1114 Source libSource = _addSource("/lib.dart", r''' | 838 Source libSource = _addSource("/lib.dart", r''' |
| 1115 library lib; | 839 library lib; |
| 1116 class ClassA {}'''); | 840 class ClassA {}'''); |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 CompilationUnit compilationUnit = | 1234 CompilationUnit compilationUnit = |
| 1511 _context.resolveCompilationUnit2(sourceA, sourceA); | 1235 _context.resolveCompilationUnit2(sourceA, sourceA); |
| 1512 expect(compilationUnit, isNotNull); | 1236 expect(compilationUnit, isNotNull); |
| 1513 LibraryElement library = compilationUnit.element.library; | 1237 LibraryElement library = compilationUnit.element.library; |
| 1514 List<LibraryElement> importedLibraries = library.importedLibraries; | 1238 List<LibraryElement> importedLibraries = library.importedLibraries; |
| 1515 assertNamedElements(importedLibraries, ["dart.core", "libB"]); | 1239 assertNamedElements(importedLibraries, ["dart.core", "libB"]); |
| 1516 List<LibraryElement> visibleLibraries = library.visibleLibraries; | 1240 List<LibraryElement> visibleLibraries = library.visibleLibraries; |
| 1517 assertNamedElements(visibleLibraries, ["dart.core", "libA", "libB"]); | 1241 assertNamedElements(visibleLibraries, ["dart.core", "libA", "libB"]); |
| 1518 } | 1242 } |
| 1519 | 1243 |
| 1520 void test_resolveCompilationUnit_library() { | |
| 1521 _context = contextWithCore(); | |
| 1522 _sourceFactory = _context.sourceFactory; | |
| 1523 Source source = _addSource("/lib.dart", "library lib;"); | |
| 1524 LibraryElement library = _context.computeLibraryElement(source); | |
| 1525 CompilationUnit compilationUnit = | |
| 1526 _context.resolveCompilationUnit(source, library); | |
| 1527 expect(compilationUnit, isNotNull); | |
| 1528 expect(compilationUnit.element, isNotNull); | |
| 1529 } | |
| 1530 | |
| 1531 void test_resolveCompilationUnit_source() { | |
| 1532 _context = contextWithCore(); | |
| 1533 _sourceFactory = _context.sourceFactory; | |
| 1534 Source source = _addSource("/lib.dart", "library lib;"); | |
| 1535 CompilationUnit compilationUnit = | |
| 1536 _context.resolveCompilationUnit2(source, source); | |
| 1537 expect(compilationUnit, isNotNull); | |
| 1538 } | |
| 1539 | |
| 1540 void fail_resolveHtmlUnit() { | 1244 void fail_resolveHtmlUnit() { |
| 1541 Source source = _addSource("/lib.html", "<html></html>"); | 1245 Source source = _addSource("/lib.html", "<html></html>"); |
| 1542 ht.HtmlUnit unit = _context.resolveHtmlUnit(source); | 1246 ht.HtmlUnit unit = _context.resolveHtmlUnit(source); |
| 1543 expect(unit, isNotNull); | 1247 expect(unit, isNotNull); |
| 1544 } | 1248 } |
| 1545 | 1249 |
| 1546 void fail_setAnalysisOptions_reduceAnalysisPriorityOrder() { | 1250 void fail_setAnalysisOptions_reduceAnalysisPriorityOrder() { |
| 1547 AnalysisOptionsImpl options = | 1251 AnalysisOptionsImpl options = |
| 1548 new AnalysisOptionsImpl.con1(_context.analysisOptions); | 1252 new AnalysisOptionsImpl.con1(_context.analysisOptions); |
| 1549 List<Source> sources = new List<Source>(); | 1253 List<Source> sources = new List<Source>(); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1731 changeSet2.addedSource(source2); | 1435 changeSet2.addedSource(source2); |
| 1732 changeSet2.changedContent(source, 'library test;'); | 1436 changeSet2.changedContent(source, 'library test;'); |
| 1733 _context.applyChanges(changeSet2); | 1437 _context.applyChanges(changeSet2); |
| 1734 return pumpEventQueue().then((_) { | 1438 return pumpEventQueue().then((_) { |
| 1735 listener.assertEvent(wereSourcesAdded: true); | 1439 listener.assertEvent(wereSourcesAdded: true); |
| 1736 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]); | 1440 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]); |
| 1737 listener.assertNoMoreEvents(); | 1441 listener.assertNoMoreEvents(); |
| 1738 }); | 1442 }); |
| 1739 } | 1443 } |
| 1740 | 1444 |
| 1445 void test_applyChanges_change_flush_element() { |
| 1446 _context = contextWithCore(); |
| 1447 _sourceFactory = _context.sourceFactory; |
| 1448 Source librarySource = _addSource("/lib.dart", r''' |
| 1449 library lib; |
| 1450 int a = 0;'''); |
| 1451 expect(_context.computeLibraryElement(librarySource), isNotNull); |
| 1452 _context.setContents(librarySource, r''' |
| 1453 library lib; |
| 1454 int aa = 0;'''); |
| 1455 expect(_context.getLibraryElement(librarySource), isNull); |
| 1456 } |
| 1457 |
| 1458 Future test_applyChanges_change_multiple() { |
| 1459 _context = contextWithCore(); |
| 1460 SourcesChangedListener listener = new SourcesChangedListener(); |
| 1461 _context.onSourcesChanged.listen(listener.onData); |
| 1462 _sourceFactory = _context.sourceFactory; |
| 1463 String libraryContents1 = r''' |
| 1464 library lib; |
| 1465 part 'part.dart'; |
| 1466 int a = 0;'''; |
| 1467 Source librarySource = _addSource("/lib.dart", libraryContents1); |
| 1468 String partContents1 = r''' |
| 1469 part of lib; |
| 1470 int b = a;'''; |
| 1471 Source partSource = _addSource("/part.dart", partContents1); |
| 1472 _context.computeLibraryElement(librarySource); |
| 1473 String libraryContents2 = r''' |
| 1474 library lib; |
| 1475 part 'part.dart'; |
| 1476 int aa = 0;'''; |
| 1477 _context.setContents(librarySource, libraryContents2); |
| 1478 String partContents2 = r''' |
| 1479 part of lib; |
| 1480 int b = aa;'''; |
| 1481 _context.setContents(partSource, partContents2); |
| 1482 _context.computeLibraryElement(librarySource); |
| 1483 CompilationUnit libraryUnit = |
| 1484 _context.resolveCompilationUnit2(librarySource, librarySource); |
| 1485 expect(libraryUnit, isNotNull); |
| 1486 CompilationUnit partUnit = |
| 1487 _context.resolveCompilationUnit2(partSource, librarySource); |
| 1488 expect(partUnit, isNotNull); |
| 1489 TopLevelVariableDeclaration declaration = |
| 1490 libraryUnit.declarations[0] as TopLevelVariableDeclaration; |
| 1491 Element declarationElement = declaration.variables.variables[0].element; |
| 1492 TopLevelVariableDeclaration use = |
| 1493 partUnit.declarations[0] as TopLevelVariableDeclaration; |
| 1494 Element useElement = (use.variables.variables[ |
| 1495 0].initializer as SimpleIdentifier).staticElement; |
| 1496 expect((useElement as PropertyAccessorElement).variable, |
| 1497 same(declarationElement)); |
| 1498 return pumpEventQueue().then((_) { |
| 1499 listener.assertEvent(wereSourcesAdded: true); |
| 1500 listener.assertEvent(changedSources: [librarySource]); |
| 1501 listener.assertEvent(wereSourcesAdded: true); |
| 1502 listener.assertEvent(changedSources: [partSource]); |
| 1503 listener.assertEvent(changedSources: [librarySource]); |
| 1504 listener.assertEvent(changedSources: [partSource]); |
| 1505 listener.assertNoMoreEvents(); |
| 1506 }); |
| 1507 } |
| 1508 |
| 1741 Future test_applyChanges_change_range() { | 1509 Future test_applyChanges_change_range() { |
| 1742 SourcesChangedListener listener = new SourcesChangedListener(); | 1510 SourcesChangedListener listener = new SourcesChangedListener(); |
| 1743 _context.onSourcesChanged.listen(listener.onData); | 1511 _context.onSourcesChanged.listen(listener.onData); |
| 1744 expect(_context.sourcesNeedingProcessing.isEmpty, isTrue); | 1512 expect(_context.sourcesNeedingProcessing.isEmpty, isTrue); |
| 1745 Source source = | 1513 Source source = |
| 1746 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 1514 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); |
| 1747 ChangeSet changeSet1 = new ChangeSet(); | 1515 ChangeSet changeSet1 = new ChangeSet(); |
| 1748 changeSet1.addedSource(source); | 1516 changeSet1.addedSource(source); |
| 1749 _context.applyChanges(changeSet1); | 1517 _context.applyChanges(changeSet1); |
| 1750 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); | 1518 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); |
| 1751 Source source2 = | 1519 Source source2 = |
| 1752 new FileBasedSource.con1(FileUtilities2.createFile("/test2.dart")); | 1520 new FileBasedSource.con1(FileUtilities2.createFile("/test2.dart")); |
| 1753 ChangeSet changeSet2 = new ChangeSet(); | 1521 ChangeSet changeSet2 = new ChangeSet(); |
| 1754 changeSet2.addedSource(source2); | 1522 changeSet2.addedSource(source2); |
| 1755 changeSet2.changedRange(source, 'library test;', 0, 0, 13); | 1523 changeSet2.changedRange(source, 'library test;', 0, 0, 13); |
| 1756 _context.applyChanges(changeSet2); | 1524 _context.applyChanges(changeSet2); |
| 1757 return pumpEventQueue().then((_) { | 1525 return pumpEventQueue().then((_) { |
| 1758 listener.assertEvent(wereSourcesAdded: true); | 1526 listener.assertEvent(wereSourcesAdded: true); |
| 1759 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]); | 1527 listener.assertEvent(wereSourcesAdded: true, changedSources: [source]); |
| 1760 listener.assertNoMoreEvents(); | 1528 listener.assertNoMoreEvents(); |
| 1761 }); | 1529 }); |
| 1762 } | 1530 } |
| 1763 | 1531 |
| 1532 void test_computeDocumentationComment_block() { |
| 1533 _context = contextWithCore(); |
| 1534 _sourceFactory = _context.sourceFactory; |
| 1535 String comment = "/** Comment */"; |
| 1536 Source source = _addSource("/test.dart", """ |
| 1537 $comment |
| 1538 class A {}"""); |
| 1539 LibraryElement libraryElement = _context.computeLibraryElement(source); |
| 1540 expect(libraryElement, isNotNull); |
| 1541 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
| 1542 expect(libraryElement, isNotNull); |
| 1543 expect(_context.computeDocumentationComment(classElement), comment); |
| 1544 } |
| 1545 |
| 1546 void test_computeDocumentationComment_none() { |
| 1547 _context = contextWithCore(); |
| 1548 _sourceFactory = _context.sourceFactory; |
| 1549 Source source = _addSource("/test.dart", "class A {}"); |
| 1550 LibraryElement libraryElement = _context.computeLibraryElement(source); |
| 1551 expect(libraryElement, isNotNull); |
| 1552 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
| 1553 expect(libraryElement, isNotNull); |
| 1554 expect(_context.computeDocumentationComment(classElement), isNull); |
| 1555 } |
| 1556 |
| 1764 void test_computeDocumentationComment_null() { | 1557 void test_computeDocumentationComment_null() { |
| 1765 expect(_context.computeDocumentationComment(null), isNull); | 1558 expect(_context.computeDocumentationComment(null), isNull); |
| 1766 } | 1559 } |
| 1767 | 1560 |
| 1561 void test_computeDocumentationComment_singleLine_multiple_EOL_n() { |
| 1562 _context = contextWithCore(); |
| 1563 _sourceFactory = _context.sourceFactory; |
| 1564 String comment = "/// line 1\n/// line 2\n/// line 3\n"; |
| 1565 Source source = _addSource("/test.dart", "${comment}class A {}"); |
| 1566 LibraryElement libraryElement = _context.computeLibraryElement(source); |
| 1567 expect(libraryElement, isNotNull); |
| 1568 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
| 1569 expect(libraryElement, isNotNull); |
| 1570 String actual = _context.computeDocumentationComment(classElement); |
| 1571 expect(actual, "/// line 1\n/// line 2\n/// line 3"); |
| 1572 } |
| 1573 |
| 1574 void test_computeDocumentationComment_singleLine_multiple_EOL_rn() { |
| 1575 _context = contextWithCore(); |
| 1576 _sourceFactory = _context.sourceFactory; |
| 1577 String comment = "/// line 1\r\n/// line 2\r\n/// line 3\r\n"; |
| 1578 Source source = _addSource("/test.dart", "${comment}class A {}"); |
| 1579 LibraryElement libraryElement = _context.computeLibraryElement(source); |
| 1580 expect(libraryElement, isNotNull); |
| 1581 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
| 1582 expect(libraryElement, isNotNull); |
| 1583 String actual = _context.computeDocumentationComment(classElement); |
| 1584 expect(actual, "/// line 1\n/// line 2\n/// line 3"); |
| 1585 } |
| 1586 |
| 1768 void test_computeExportedLibraries_none() { | 1587 void test_computeExportedLibraries_none() { |
| 1769 Source source = _addSource("/test.dart", "library test;"); | 1588 Source source = _addSource("/test.dart", "library test;"); |
| 1770 expect(_context.computeExportedLibraries(source), hasLength(0)); | 1589 expect(_context.computeExportedLibraries(source), hasLength(0)); |
| 1771 } | 1590 } |
| 1772 | 1591 |
| 1773 void test_computeExportedLibraries_some() { | 1592 void test_computeExportedLibraries_some() { |
| 1774 // addSource("/lib1.dart", "library lib1;"); | 1593 // addSource("/lib1.dart", "library lib1;"); |
| 1775 // addSource("/lib2.dart", "library lib2;"); | 1594 // addSource("/lib2.dart", "library lib2;"); |
| 1776 Source source = _addSource( | 1595 Source source = _addSource( |
| 1777 "/test.dart", "library test; export 'lib1.dart'; export 'lib2.dart';"); | 1596 "/test.dart", "library test; export 'lib1.dart'; export 'lib2.dart';"); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1791 void test_computeKindOf_libraryAndPart() { | 1610 void test_computeKindOf_libraryAndPart() { |
| 1792 Source source = _addSource("/test.dart", "library lib; part of lib;"); | 1611 Source source = _addSource("/test.dart", "library lib; part of lib;"); |
| 1793 expect(_context.computeKindOf(source), same(SourceKind.LIBRARY)); | 1612 expect(_context.computeKindOf(source), same(SourceKind.LIBRARY)); |
| 1794 } | 1613 } |
| 1795 | 1614 |
| 1796 void test_computeKindOf_part() { | 1615 void test_computeKindOf_part() { |
| 1797 Source source = _addSource("/test.dart", "part of lib;"); | 1616 Source source = _addSource("/test.dart", "part of lib;"); |
| 1798 expect(_context.computeKindOf(source), same(SourceKind.PART)); | 1617 expect(_context.computeKindOf(source), same(SourceKind.PART)); |
| 1799 } | 1618 } |
| 1800 | 1619 |
| 1620 void test_computeLibraryElement() { |
| 1621 _context = contextWithCore(); |
| 1622 _sourceFactory = _context.sourceFactory; |
| 1623 Source source = _addSource("/test.dart", "library lib;"); |
| 1624 LibraryElement element = _context.computeLibraryElement(source); |
| 1625 expect(element, isNotNull); |
| 1626 } |
| 1627 |
| 1801 void test_computeLineInfo_dart() { | 1628 void test_computeLineInfo_dart() { |
| 1802 Source source = _addSource("/test.dart", r''' | 1629 Source source = _addSource("/test.dart", r''' |
| 1803 library lib; | 1630 library lib; |
| 1804 | 1631 |
| 1805 main() {}'''); | 1632 main() {}'''); |
| 1806 LineInfo info = _context.computeLineInfo(source); | 1633 LineInfo info = _context.computeLineInfo(source); |
| 1807 expect(info, isNotNull); | 1634 expect(info, isNotNull); |
| 1808 } | 1635 } |
| 1809 | 1636 |
| 1810 void test_computeLineInfo_html() { | 1637 void test_computeLineInfo_html() { |
| 1811 Source source = _addSource("/test.html", r''' | 1638 Source source = _addSource("/test.html", r''' |
| 1812 <html> | 1639 <html> |
| 1813 <body> | 1640 <body> |
| 1814 <h1>A</h1> | 1641 <h1>A</h1> |
| 1815 </body> | 1642 </body> |
| 1816 </html>'''); | 1643 </html>'''); |
| 1817 LineInfo info = _context.computeLineInfo(source); | 1644 LineInfo info = _context.computeLineInfo(source); |
| 1818 expect(info, isNotNull); | 1645 expect(info, isNotNull); |
| 1819 } | 1646 } |
| 1820 | 1647 |
| 1648 Future test_computeResolvedCompilationUnitAsync_afterDispose() { |
| 1649 _context = contextWithCore(); |
| 1650 _sourceFactory = _context.sourceFactory; |
| 1651 Source source = _addSource("/lib.dart", "library lib;"); |
| 1652 // Complete all pending analysis tasks and flush the AST so that it won't |
| 1653 // be available immediately. |
| 1654 _performPendingAnalysisTasks(); |
| 1655 CacheEntry entry = _context.getReadableSourceEntryOrNull(source); |
| 1656 entry.flushAstStructures(); |
| 1657 // Dispose of the context. |
| 1658 _context.dispose(); |
| 1659 // Any attempt to start an asynchronous computation should return a future |
| 1660 // which completes with error. |
| 1661 CancelableFuture<CompilationUnit> future = |
| 1662 _context.computeResolvedCompilationUnitAsync(source, source); |
| 1663 bool completed = false; |
| 1664 future.then((CompilationUnit unit) { |
| 1665 fail('Future should have completed with error'); |
| 1666 }, onError: (error) { |
| 1667 expect(error, new isInstanceOf<AnalysisNotScheduledError>()); |
| 1668 completed = true; |
| 1669 }); |
| 1670 return pumpEventQueue().then((_) { |
| 1671 expect(completed, isTrue); |
| 1672 }); |
| 1673 } |
| 1674 |
| 1821 void test_dispose() { | 1675 void test_dispose() { |
| 1822 expect(_context.isDisposed, isFalse); | 1676 expect(_context.isDisposed, isFalse); |
| 1823 _context.dispose(); | 1677 _context.dispose(); |
| 1824 expect(_context.isDisposed, isTrue); | 1678 expect(_context.isDisposed, isTrue); |
| 1825 } | 1679 } |
| 1826 | 1680 |
| 1827 void test_exists_false() { | 1681 void test_exists_false() { |
| 1828 TestSource source = new TestSource(); | 1682 TestSource source = new TestSource(); |
| 1829 source.exists2 = false; | 1683 source.exists2 = false; |
| 1830 expect(_context.exists(source), isFalse); | 1684 expect(_context.exists(source), isFalse); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2057 Source htmlSource = _addSource("/test.html", r''' | 1911 Source htmlSource = _addSource("/test.html", r''' |
| 2058 <html><head> | 1912 <html><head> |
| 2059 <script type='application/dart' src='test.js'/> | 1913 <script type='application/dart' src='test.js'/> |
| 2060 </head></html>'''); | 1914 </head></html>'''); |
| 2061 _addSource("/test.dart", "library lib;"); | 1915 _addSource("/test.dart", "library lib;"); |
| 2062 _context.parseHtmlUnit(htmlSource); | 1916 _context.parseHtmlUnit(htmlSource); |
| 2063 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); | 1917 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); |
| 2064 expect(result, hasLength(0)); | 1918 expect(result, hasLength(0)); |
| 2065 } | 1919 } |
| 2066 | 1920 |
| 1921 void test_getLibraryElement() { |
| 1922 _context = contextWithCore(); |
| 1923 _sourceFactory = _context.sourceFactory; |
| 1924 Source source = _addSource("/test.dart", "library lib;"); |
| 1925 LibraryElement element = _context.getLibraryElement(source); |
| 1926 expect(element, isNull); |
| 1927 _context.computeLibraryElement(source); |
| 1928 element = _context.getLibraryElement(source); |
| 1929 expect(element, isNotNull); |
| 1930 } |
| 1931 |
| 2067 void test_getLibrarySources() { | 1932 void test_getLibrarySources() { |
| 2068 List<Source> sources = _context.librarySources; | 1933 List<Source> sources = _context.librarySources; |
| 2069 int originalLength = sources.length; | 1934 int originalLength = sources.length; |
| 2070 Source source = _addSource("/test.dart", "library lib;"); | 1935 Source source = _addSource("/test.dart", "library lib;"); |
| 2071 _context.computeKindOf(source); | 1936 _context.computeKindOf(source); |
| 2072 sources = _context.librarySources; | 1937 sources = _context.librarySources; |
| 2073 expect(sources, hasLength(originalLength + 1)); | 1938 expect(sources, hasLength(originalLength + 1)); |
| 2074 for (Source returnedSource in sources) { | 1939 for (Source returnedSource in sources) { |
| 2075 if (returnedSource == source) { | 1940 if (returnedSource == source) { |
| 2076 return; | 1941 return; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2100 | 1965 |
| 2101 void test_getModificationStamp_overridden() { | 1966 void test_getModificationStamp_overridden() { |
| 2102 int stamp = 42; | 1967 int stamp = 42; |
| 2103 Source source = | 1968 Source source = |
| 2104 new AnalysisContextImplTest_Source_getModificationStamp_overridden( | 1969 new AnalysisContextImplTest_Source_getModificationStamp_overridden( |
| 2105 stamp); | 1970 stamp); |
| 2106 _context.setContents(source, ""); | 1971 _context.setContents(source, ""); |
| 2107 expect(stamp != _context.getModificationStamp(source), isTrue); | 1972 expect(stamp != _context.getModificationStamp(source), isTrue); |
| 2108 } | 1973 } |
| 2109 | 1974 |
| 1975 void test_getPublicNamespace_element() { |
| 1976 _context = contextWithCore(); |
| 1977 _sourceFactory = _context.sourceFactory; |
| 1978 Source source = _addSource("/test.dart", "class A {}"); |
| 1979 LibraryElement library = _context.computeLibraryElement(source); |
| 1980 expect(library, isNotNull); |
| 1981 Namespace namespace = _context.getPublicNamespace(library); |
| 1982 expect(namespace, isNotNull); |
| 1983 EngineTestCase.assertInstanceOf( |
| 1984 (obj) => obj is ClassElement, ClassElement, namespace.get("A")); |
| 1985 } |
| 1986 |
| 2110 void test_getResolvedCompilationUnit_library_null() { | 1987 void test_getResolvedCompilationUnit_library_null() { |
| 2111 _context = contextWithCore(); | 1988 _context = contextWithCore(); |
| 2112 _sourceFactory = _context.sourceFactory; | 1989 _sourceFactory = _context.sourceFactory; |
| 2113 Source source = _addSource("/lib.dart", "library lib;"); | 1990 Source source = _addSource("/lib.dart", "library lib;"); |
| 2114 expect(_context.getResolvedCompilationUnit(source, null), isNull); | 1991 expect(_context.getResolvedCompilationUnit(source, null), isNull); |
| 2115 } | 1992 } |
| 2116 | 1993 |
| 1994 void test_getResolvedCompilationUnit_source_dart() { |
| 1995 _context = contextWithCore(); |
| 1996 _sourceFactory = _context.sourceFactory; |
| 1997 Source source = _addSource("/lib.dart", "library lib;"); |
| 1998 expect(_context.getResolvedCompilationUnit2(source, source), isNull); |
| 1999 _context.resolveCompilationUnit2(source, source); |
| 2000 expect(_context.getResolvedCompilationUnit2(source, source), isNotNull); |
| 2001 } |
| 2002 |
| 2117 void test_getResolvedCompilationUnit_source_html() { | 2003 void test_getResolvedCompilationUnit_source_html() { |
| 2118 _context = contextWithCore(); | 2004 _context = contextWithCore(); |
| 2119 _sourceFactory = _context.sourceFactory; | 2005 _sourceFactory = _context.sourceFactory; |
| 2120 Source source = _addSource("/test.html", "<html></html>"); | 2006 Source source = _addSource("/test.html", "<html></html>"); |
| 2121 expect(_context.getResolvedCompilationUnit2(source, source), isNull); | 2007 expect(_context.getResolvedCompilationUnit2(source, source), isNull); |
| 2122 expect(_context.resolveCompilationUnit2(source, source), isNull); | 2008 expect(_context.resolveCompilationUnit2(source, source), isNull); |
| 2123 expect(_context.getResolvedCompilationUnit2(source, source), isNull); | 2009 expect(_context.getResolvedCompilationUnit2(source, source), isNull); |
| 2124 } | 2010 } |
| 2125 | 2011 |
| 2126 void test_getSourceFactory() { | 2012 void test_getSourceFactory() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2150 void test_getStatistics() { | 2036 void test_getStatistics() { |
| 2151 AnalysisContextStatistics statistics = _context.statistics; | 2037 AnalysisContextStatistics statistics = _context.statistics; |
| 2152 expect(statistics, isNotNull); | 2038 expect(statistics, isNotNull); |
| 2153 // The following lines are fragile. | 2039 // The following lines are fragile. |
| 2154 // The values depend on the number of libraries in the SDK. | 2040 // The values depend on the number of libraries in the SDK. |
| 2155 // assertLength(0, statistics.getCacheRows()); | 2041 // assertLength(0, statistics.getCacheRows()); |
| 2156 // assertLength(0, statistics.getExceptions()); | 2042 // assertLength(0, statistics.getExceptions()); |
| 2157 // assertLength(0, statistics.getSources()); | 2043 // assertLength(0, statistics.getSources()); |
| 2158 } | 2044 } |
| 2159 | 2045 |
| 2160 // void test_resolveCompilationUnit_sourceChangeDuringResolution() { | |
| 2161 // _context = new _AnalysisContext_sourceChangeDuringResolution(); | |
| 2162 // AnalysisContextFactory.initContextWithCore(_context); | |
| 2163 // _sourceFactory = _context.sourceFactory; | |
| 2164 // Source source = _addSource("/lib.dart", "library lib;"); | |
| 2165 // CompilationUnit compilationUnit = | |
| 2166 // _context.resolveCompilationUnit2(source, source); | |
| 2167 // expect(compilationUnit, isNotNull); | |
| 2168 // expect(_context.getLineInfo(source), isNotNull); | |
| 2169 // } | |
| 2170 | |
| 2171 void test_isClientLibrary_dart() { | 2046 void test_isClientLibrary_dart() { |
| 2172 _context = contextWithCore(); | 2047 _context = contextWithCore(); |
| 2173 _sourceFactory = _context.sourceFactory; | 2048 _sourceFactory = _context.sourceFactory; |
| 2174 Source source = _addSource("/test.dart", r''' | 2049 Source source = _addSource("/test.dart", r''' |
| 2175 import 'dart:html'; | 2050 import 'dart:html'; |
| 2176 | 2051 |
| 2177 main() {}'''); | 2052 main() {}'''); |
| 2178 expect(_context.isClientLibrary(source), isFalse); | 2053 expect(_context.isClientLibrary(source), isFalse); |
| 2179 expect(_context.isServerLibrary(source), isFalse); | 2054 expect(_context.isServerLibrary(source), isFalse); |
| 2180 _context.computeLibraryElement(source); | 2055 _context.computeLibraryElement(source); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2199 _context.computeLibraryElement(source); | 2074 _context.computeLibraryElement(source); |
| 2200 expect(_context.isClientLibrary(source), isFalse); | 2075 expect(_context.isClientLibrary(source), isFalse); |
| 2201 expect(_context.isServerLibrary(source), isTrue); | 2076 expect(_context.isServerLibrary(source), isTrue); |
| 2202 } | 2077 } |
| 2203 | 2078 |
| 2204 void test_isServerLibrary_html() { | 2079 void test_isServerLibrary_html() { |
| 2205 Source source = _addSource("/test.html", "<html></html>"); | 2080 Source source = _addSource("/test.html", "<html></html>"); |
| 2206 expect(_context.isServerLibrary(source), isFalse); | 2081 expect(_context.isServerLibrary(source), isFalse); |
| 2207 } | 2082 } |
| 2208 | 2083 |
| 2084 void test_parseCompilationUnit_errors() { |
| 2085 Source source = _addSource("/lib.dart", "library {"); |
| 2086 CompilationUnit compilationUnit = _context.parseCompilationUnit(source); |
| 2087 expect(compilationUnit, isNotNull); |
| 2088 var errorInfo = _context.getErrors(source); |
| 2089 expect(errorInfo, isNotNull); |
| 2090 List<AnalysisError> errors = errorInfo.errors; |
| 2091 expect(errors, isNotNull); |
| 2092 expect(errors.length > 0, isTrue); |
| 2093 } |
| 2094 |
| 2095 void test_parseCompilationUnit_exception() { |
| 2096 Source source = _addSourceWithException("/test.dart"); |
| 2097 try { |
| 2098 _context.parseCompilationUnit(source); |
| 2099 fail("Expected AnalysisException"); |
| 2100 } on AnalysisException { |
| 2101 // Expected |
| 2102 } |
| 2103 } |
| 2104 |
| 2209 void test_parseCompilationUnit_html() { | 2105 void test_parseCompilationUnit_html() { |
| 2210 Source source = _addSource("/test.html", "<html></html>"); | 2106 Source source = _addSource("/test.html", "<html></html>"); |
| 2211 expect(_context.parseCompilationUnit(source), isNull); | 2107 expect(_context.parseCompilationUnit(source), isNull); |
| 2212 } | 2108 } |
| 2213 | 2109 |
| 2110 void test_parseCompilationUnit_noErrors() { |
| 2111 Source source = _addSource("/lib.dart", "library lib;"); |
| 2112 CompilationUnit compilationUnit = _context.parseCompilationUnit(source); |
| 2113 expect(compilationUnit, isNotNull); |
| 2114 AnalysisErrorInfo errorInfo = _context.getErrors(source); |
| 2115 expect(errorInfo, isNotNull); |
| 2116 expect(errorInfo.errors, hasLength(0)); |
| 2117 } |
| 2118 |
| 2119 // void test_resolveCompilationUnit_sourceChangeDuringResolution() { |
| 2120 // _context = new _AnalysisContext_sourceChangeDuringResolution(); |
| 2121 // AnalysisContextFactory.initContextWithCore(_context); |
| 2122 // _sourceFactory = _context.sourceFactory; |
| 2123 // Source source = _addSource("/lib.dart", "library lib;"); |
| 2124 // CompilationUnit compilationUnit = |
| 2125 // _context.resolveCompilationUnit2(source, source); |
| 2126 // expect(compilationUnit, isNotNull); |
| 2127 // expect(_context.getLineInfo(source), isNotNull); |
| 2128 // } |
| 2129 |
| 2130 void test_parseCompilationUnit_nonExistentSource() { |
| 2131 Source source = |
| 2132 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); |
| 2133 try { |
| 2134 _context.parseCompilationUnit(source); |
| 2135 fail("Expected AnalysisException because file does not exist"); |
| 2136 } on AnalysisException { |
| 2137 // Expected result |
| 2138 } |
| 2139 } |
| 2140 |
| 2214 void test_performAnalysisTask_modifiedAfterParse() { | 2141 void test_performAnalysisTask_modifiedAfterParse() { |
| 2215 // TODO(scheglov) no threads in Dart | 2142 // TODO(scheglov) no threads in Dart |
| 2216 // Source source = _addSource("/test.dart", "library lib;"); | 2143 // Source source = _addSource("/test.dart", "library lib;"); |
| 2217 // int initialTime = _context.getModificationStamp(source); | 2144 // int initialTime = _context.getModificationStamp(source); |
| 2218 // List<Source> sources = new List<Source>(); | 2145 // List<Source> sources = new List<Source>(); |
| 2219 // sources.add(source); | 2146 // sources.add(source); |
| 2220 // _context.analysisPriorityOrder = sources; | 2147 // _context.analysisPriorityOrder = sources; |
| 2221 // _context.parseCompilationUnit(source); | 2148 // _context.parseCompilationUnit(source); |
| 2222 // while (initialTime == JavaSystem.currentTimeMillis()) { | 2149 // while (initialTime == JavaSystem.currentTimeMillis()) { |
| 2223 // Thread.sleep(1); | 2150 // Thread.sleep(1); |
| 2224 // // Force the modification time to be different. | 2151 // // Force the modification time to be different. |
| 2225 // } | 2152 // } |
| 2226 // _context.setContents(source, "library test;"); | 2153 // _context.setContents(source, "library test;"); |
| 2227 // JUnitTestCase.assertTrue(initialTime != _context.getModificationStamp(sour
ce)); | 2154 // JUnitTestCase.assertTrue(initialTime != _context.getModificationStamp(sour
ce)); |
| 2228 // _analyzeAll_assertFinished(); | 2155 // _analyzeAll_assertFinished(); |
| 2229 // JUnitTestCase.assertNotNullMsg("performAnalysisTask failed to compute an e
lement model", _context.getLibraryElement(source)); | 2156 // JUnitTestCase.assertNotNullMsg("performAnalysisTask failed to compute an e
lement model", _context.getLibraryElement(source)); |
| 2230 } | 2157 } |
| 2231 | 2158 |
| 2159 void test_resolveCompilationUnit_library() { |
| 2160 _context = contextWithCore(); |
| 2161 _sourceFactory = _context.sourceFactory; |
| 2162 Source source = _addSource("/lib.dart", "library lib;"); |
| 2163 LibraryElement library = _context.computeLibraryElement(source); |
| 2164 CompilationUnit compilationUnit = |
| 2165 _context.resolveCompilationUnit(source, library); |
| 2166 expect(compilationUnit, isNotNull); |
| 2167 expect(compilationUnit.element, isNotNull); |
| 2168 } |
| 2169 |
| 2170 void test_resolveCompilationUnit_source() { |
| 2171 _context = contextWithCore(); |
| 2172 _sourceFactory = _context.sourceFactory; |
| 2173 Source source = _addSource("/lib.dart", "library lib;"); |
| 2174 CompilationUnit compilationUnit = |
| 2175 _context.resolveCompilationUnit2(source, source); |
| 2176 expect(compilationUnit, isNotNull); |
| 2177 } |
| 2178 |
| 2232 void test_setAnalysisOptions() { | 2179 void test_setAnalysisOptions() { |
| 2233 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 2180 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 2234 options.cacheSize = 42; | 2181 options.cacheSize = 42; |
| 2235 options.dart2jsHint = false; | 2182 options.dart2jsHint = false; |
| 2236 options.hint = false; | 2183 options.hint = false; |
| 2237 _context.analysisOptions = options; | 2184 _context.analysisOptions = options; |
| 2238 AnalysisOptions result = _context.analysisOptions; | 2185 AnalysisOptions result = _context.analysisOptions; |
| 2239 expect(result.cacheSize, options.cacheSize); | 2186 expect(result.cacheSize, options.cacheSize); |
| 2240 expect(result.dart2jsHint, options.dart2jsHint); | 2187 expect(result.dart2jsHint, options.dart2jsHint); |
| 2241 expect(result.hint, options.hint); | 2188 expect(result.hint, options.hint); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2339 AnalysisDelta delta = new AnalysisDelta(); | 2286 AnalysisDelta delta = new AnalysisDelta(); |
| 2340 delta.setAnalysisLevel(source, AnalysisLevel.ALL); | 2287 delta.setAnalysisLevel(source, AnalysisLevel.ALL); |
| 2341 _context.applyAnalysisDelta(delta); | 2288 _context.applyAnalysisDelta(delta); |
| 2342 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); | 2289 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); |
| 2343 delta = new AnalysisDelta(); | 2290 delta = new AnalysisDelta(); |
| 2344 delta.setAnalysisLevel(source, AnalysisLevel.NONE); | 2291 delta.setAnalysisLevel(source, AnalysisLevel.NONE); |
| 2345 _context.applyAnalysisDelta(delta); | 2292 _context.applyAnalysisDelta(delta); |
| 2346 expect(_context.sourcesNeedingProcessing.contains(source), isFalse); | 2293 expect(_context.sourcesNeedingProcessing.contains(source), isFalse); |
| 2347 } | 2294 } |
| 2348 | 2295 |
| 2296 Future xtest_computeResolvedCompilationUnitAsync() { |
| 2297 _context = contextWithCore(); |
| 2298 _sourceFactory = _context.sourceFactory; |
| 2299 Source source = _addSource("/lib.dart", "library lib;"); |
| 2300 // Complete all pending analysis tasks and flush the AST so that it won't |
| 2301 // be available immediately. |
| 2302 _performPendingAnalysisTasks(); |
| 2303 CacheEntry entry = _context.getReadableSourceEntryOrNull(source); |
| 2304 entry.flushAstStructures(); |
| 2305 bool completed = false; |
| 2306 _context |
| 2307 .computeResolvedCompilationUnitAsync(source, source) |
| 2308 .then((CompilationUnit unit) { |
| 2309 expect(unit, isNotNull); |
| 2310 completed = true; |
| 2311 }); |
| 2312 return pumpEventQueue().then((_) { |
| 2313 expect(completed, isFalse); |
| 2314 _performPendingAnalysisTasks(); |
| 2315 }).then((_) => pumpEventQueue()).then((_) { |
| 2316 expect(completed, isTrue); |
| 2317 }); |
| 2318 } |
| 2319 |
| 2320 Future xtest_computeResolvedCompilationUnitAsync_cancel() { |
| 2321 _context = contextWithCore(); |
| 2322 _sourceFactory = _context.sourceFactory; |
| 2323 Source source = _addSource("/lib.dart", "library lib;"); |
| 2324 // Complete all pending analysis tasks and flush the AST so that it won't |
| 2325 // be available immediately. |
| 2326 _performPendingAnalysisTasks(); |
| 2327 CacheEntry entry = _context.getReadableSourceEntryOrNull(source); |
| 2328 entry.flushAstStructures(); |
| 2329 CancelableFuture<CompilationUnit> future = |
| 2330 _context.computeResolvedCompilationUnitAsync(source, source); |
| 2331 bool completed = false; |
| 2332 future.then((CompilationUnit unit) { |
| 2333 fail('Future should have been canceled'); |
| 2334 }, onError: (error) { |
| 2335 expect(error, new isInstanceOf<FutureCanceledError>()); |
| 2336 completed = true; |
| 2337 }); |
| 2338 expect(completed, isFalse); |
| 2339 expect(_context.pendingFutureSources_forTesting, isNotEmpty); |
| 2340 future.cancel(); |
| 2341 expect(_context.pendingFutureSources_forTesting, isEmpty); |
| 2342 return pumpEventQueue().then((_) { |
| 2343 expect(completed, isTrue); |
| 2344 expect(_context.pendingFutureSources_forTesting, isEmpty); |
| 2345 }); |
| 2346 } |
| 2347 |
| 2349 void xtest_performAnalysisTask_stress() { | 2348 void xtest_performAnalysisTask_stress() { |
| 2350 int maxCacheSize = 4; | 2349 int maxCacheSize = 4; |
| 2351 AnalysisOptionsImpl options = | 2350 AnalysisOptionsImpl options = |
| 2352 new AnalysisOptionsImpl.con1(_context.analysisOptions); | 2351 new AnalysisOptionsImpl.con1(_context.analysisOptions); |
| 2353 options.cacheSize = maxCacheSize; | 2352 options.cacheSize = maxCacheSize; |
| 2354 _context.analysisOptions = options; | 2353 _context.analysisOptions = options; |
| 2355 int sourceCount = maxCacheSize + 2; | 2354 int sourceCount = maxCacheSize + 2; |
| 2356 List<Source> sources = new List<Source>(); | 2355 List<Source> sources = new List<Source>(); |
| 2357 ChangeSet changeSet = new ChangeSet(); | 2356 ChangeSet changeSet = new ChangeSet(); |
| 2358 for (int i = 0; i < sourceCount; i++) { | 2357 for (int i = 0; i < sourceCount; i++) { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2526 : super(name, UriKind.FILE_URI); | 2525 : super(name, UriKind.FILE_URI); |
| 2527 | 2526 |
| 2528 @override | 2527 @override |
| 2529 TimestampedData<String> get contents { | 2528 TimestampedData<String> get contents { |
| 2530 throw 'Read error'; | 2529 throw 'Read error'; |
| 2531 } | 2530 } |
| 2532 | 2531 |
| 2533 @override | 2532 @override |
| 2534 bool exists() => true; | 2533 bool exists() => true; |
| 2535 } | 2534 } |
| OLD | NEW |