| Index: pkg/analyzer/test/generated/engine_test.dart
|
| diff --git a/pkg/analyzer/test/generated/engine_test.dart b/pkg/analyzer/test/generated/engine_test.dart
|
| index e0a910a4fa4f3b59c1db78e75f94fb2e026e6023..4cf8fa7c38f2f888f5b52619ead42ed9d5e83c0f 100644
|
| --- a/pkg/analyzer/test/generated/engine_test.dart
|
| +++ b/pkg/analyzer/test/generated/engine_test.dart
|
| @@ -1022,6 +1022,23 @@ export 'libA.dart';''');
|
| expect(element, isNotNull);
|
| }
|
|
|
| + Future test_getLibraryElementFuture() {
|
| + _context = AnalysisContextFactory.contextWithCore();
|
| + _sourceFactory = _context.sourceFactory;
|
| + Source source = _addSource("/test.dart", "library lib;");
|
| + bool completed = false;
|
| + _context.getLibraryElementFuture(source).then((LibraryElement element) {
|
| + expect(element, isNotNull);
|
| + completed = true;
|
| + });
|
| + return pumpEventQueue().then((_) {
|
| + expect(completed, isFalse);
|
| + while (_context.performAnalysisTask().hasMoreWork) {}
|
| + }).then((_) => pumpEventQueue()).then((_) {
|
| + expect(completed, isTrue);
|
| + });
|
| + }
|
| +
|
| void test_getLibrarySources() {
|
| List<Source> sources = _context.librarySources;
|
| int originalLength = sources.length;
|
| @@ -1128,6 +1145,52 @@ main() {}''');
|
| expect(_context.getResolvedCompilationUnit2(source, source), isNull);
|
| }
|
|
|
| + Future test_getResolvedCompilationUnitFuture() {
|
| + _context = AnalysisContextFactory.contextWithCore();
|
| + _sourceFactory = _context.sourceFactory;
|
| + Source source = _addSource("/lib.dart", "library lib;");
|
| + LibraryElement library = _context.computeLibraryElement(source);
|
| + // Complete all pending analysis tasks and flush the AST so that it won't
|
| + // be available immediately.
|
| + while (_context.performAnalysisTask().hasMoreWork) {}
|
| + DartEntry dartEntry = _context.getReadableSourceEntryOrNull(source);
|
| + dartEntry.flushAstStructures();
|
| + bool completed = false;
|
| + _context.getResolvedCompilationUnitFuture(
|
| + source,
|
| + library).then((CompilationUnit unit) {
|
| + expect(unit, isNotNull);
|
| + completed = true;
|
| + });
|
| + return pumpEventQueue().then((_) {
|
| + expect(completed, isFalse);
|
| + while (_context.performAnalysisTask().hasMoreWork) {}
|
| + }).then((_) => pumpEventQueue()).then((_) {
|
| + expect(completed, isTrue);
|
| + });
|
| + }
|
| +
|
| + Future test_getResolvedCompilationUnitFuture_unrelatedLibrary() {
|
| + _context = AnalysisContextFactory.contextWithCore();
|
| + _sourceFactory = _context.sourceFactory;
|
| + Source librarySource = _addSource("/lib.dart", "library lib;");
|
| + LibraryElement library = _context.computeLibraryElement(librarySource);
|
| + Source partSource = _addSource("/part.dart", "part of foo;");
|
| + bool completed = false;
|
| + _context.getResolvedCompilationUnitFuture(partSource, library).then((_) {
|
| + fail('Expected resolution to fail');
|
| + }, onError: (e) {
|
| + expect(e, new isInstanceOf<AnalysisNotScheduledError>());
|
| + completed = true;
|
| + });
|
| + return pumpEventQueue().then((_) {
|
| + expect(completed, isFalse);
|
| + while (_context.performAnalysisTask().hasMoreWork) {}
|
| + }).then((_) => pumpEventQueue()).then((_) {
|
| + expect(completed, isTrue);
|
| + });
|
| + }
|
| +
|
| void test_getResolvedHtmlUnit() {
|
| _context = AnalysisContextFactory.contextWithCore();
|
| _sourceFactory = _context.sourceFactory;
|
| @@ -3892,6 +3955,7 @@ class GenerateDartErrorsTaskTestTV_perform_validateDirectives extends
|
| }
|
| }
|
|
|
| +
|
| @ReflectiveTestCase()
|
| class GenerateDartHintsTaskTest extends EngineTestCase {
|
| void test_accept() {
|
| @@ -3954,7 +4018,6 @@ class GenerateDartHintsTaskTestTV_accept extends TestTaskVisitor<bool> {
|
| bool visitGenerateDartHintsTask(GenerateDartHintsTask task) => true;
|
| }
|
|
|
| -
|
| class GenerateDartHintsTaskTestTV_perform extends TestTaskVisitor<bool> {
|
| Source librarySource;
|
| Source partSource;
|
| @@ -4827,7 +4890,6 @@ class IncrementalAnalysisCacheTest {
|
| }
|
|
|
|
|
| -
|
| @ReflectiveTestCase()
|
| class IncrementalAnalysisTaskTest extends EngineTestCase {
|
| void test_accept() {
|
| @@ -4893,6 +4955,7 @@ class IncrementalAnalysisTaskTestTV_accept extends TestTaskVisitor<bool> {
|
| }
|
|
|
|
|
| +
|
| class IncrementalAnalysisTaskTestTV_assertTask extends
|
| TestTaskVisitor<CompilationUnit> {
|
| IncrementalAnalysisTask task;
|
| @@ -6008,6 +6071,11 @@ class TestAnalysisContext implements InternalAnalysisContext {
|
| return null;
|
| }
|
| @override
|
| + Future<LibraryElement> getLibraryElementFuture(Source source) {
|
| + fail("Unexpected invocation of getLibraryElementFuture");
|
| + return null;
|
| + }
|
| + @override
|
| LineInfo getLineInfo(Source source) {
|
| fail("Unexpected invocation of getLineInfo");
|
| return null;
|
| @@ -6035,6 +6103,12 @@ class TestAnalysisContext implements InternalAnalysisContext {
|
| return null;
|
| }
|
| @override
|
| + Future<CompilationUnit> getResolvedCompilationUnitFuture(Source source,
|
| + LibraryElement library) {
|
| + fail("Unexpected invocation of getResolvedCompilationUnitFuture");
|
| + return null;
|
| + }
|
| + @override
|
| ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) {
|
| fail("Unexpected invocation of getResolvedHtmlUnit");
|
| return null;
|
| @@ -6098,6 +6172,7 @@ class TestAnalysisContext implements InternalAnalysisContext {
|
| void setContents(Source source, String contents) {
|
| fail("Unexpected invocation of setContents");
|
| }
|
| +
|
| @override
|
| void visitCacheItems(void callback(Source source, SourceEntry dartEntry,
|
| DataDescriptor rowDesc, CacheState state)) {
|
|
|