From dd451d1424f9fb476b60cabb8bdeaefb0659efc4 Mon Sep 17 00:00:00 2001 From: "scheglov@google.com" Date: Thu, 14 May 2015 21:51:38 +0000 Subject: [PATCH] Move DartWorkManager notification to _sourceChanged(). This fixes scheduling analysis after overlay changes. R=brianwilkerson@google.com BUG= Review URL: https://codereview.chromium.org//1126233008 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45797 260f80e4-7a28-3924-810f-c04153c831b5 --- pkg/analyzer/lib/src/context/context.dart | 4 ++-- pkg/analyzer/test/src/context/context_test.dart | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pkg/analyzer/lib/src/context/context.dart b/pkg/analyzer/lib/src/context/context.dart index bc3d62f01d6..f2c54924129 100644 --- a/pkg/analyzer/lib/src/context/context.dart +++ b/pkg/analyzer/lib/src/context/context.dart @@ -1171,8 +1171,6 @@ class AnalysisContextImpl implements InternalAnalysisContext { @override void setContents(Source source, String contents) { _contentsChanged(source, contents, true); - dartWorkManager.applyChange( - Source.EMPTY_LIST, [source], Source.EMPTY_LIST); } @override @@ -1693,6 +1691,8 @@ class AnalysisContextImpl implements InternalAnalysisContext { } // We need to invalidate the cache. entry.setState(CONTENT, CacheState.INVALID); + dartWorkManager.applyChange( + Source.EMPTY_LIST, [source], Source.EMPTY_LIST); } /** diff --git a/pkg/analyzer/test/src/context/context_test.dart b/pkg/analyzer/test/src/context/context_test.dart index 0ae0ea56e55..d799f1df241 100644 --- a/pkg/analyzer/test/src/context/context_test.dart +++ b/pkg/analyzer/test/src/context/context_test.dart @@ -1664,6 +1664,23 @@ main() {}'''); // assertLength(0, statistics.getSources()); } + void test_handleContentsChanged() { + ContentCache contentCache = new ContentCache(); + context.contentCache = contentCache; + String oldContents = 'foo() {}'; + String newContents = 'bar() {}'; + // old contents + Source source = addSource("/test.dart", oldContents); + _analyzeAll_assertFinished(); + expect(context.getResolvedCompilationUnit2(source, source), isNotNull); + // new contents + contentCache.setContents(source, newContents); + context.handleContentsChanged(source, oldContents, newContents, true); + // there is some work to do + AnalysisResult analysisResult = context.performAnalysisTask(); + expect(analysisResult.changeNotices, isNotNull); + } + void test_isClientLibrary_dart() { Source source = addSource("/test.dart", r''' import 'dart:html';