Skip to content

Commit d37ac8d

Browse files
committed
Fixed bug in implicit analysis notification and renamed tests
[email protected] Review URL: https://codereview.chromium.org//1236013003 .
1 parent cb5335d commit d37ac8d

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

pkg/analyzer/lib/src/context/context.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ class AnalysisContextImpl implements InternalAnalysisContext {
16591659

16601660
void _removeFromCache(Source source) {
16611661
CacheEntry entry = _cache.remove(source);
1662-
if (entry != null && entry.explicitlyAdded) {
1662+
if (entry != null && !entry.explicitlyAdded) {
16631663
_implicitAnalysisEventsController
16641664
.add(new ImplicitAnalysisEvent(source, false));
16651665
}

pkg/analyzer/lib/src/generated/engine.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4599,7 +4599,7 @@ class AnalysisContextImpl implements InternalAnalysisContext {
45994599

46004600
void _removeFromCache(Source source) {
46014601
SourceEntry entry = _cache.remove(source);
4602-
if (entry != null && entry.explicitlyAdded) {
4602+
if (entry != null && !entry.explicitlyAdded) {
46034603
_implicitAnalysisEventsController
46044604
.add(new ImplicitAnalysisEvent(source, false));
46054605
}

pkg/analyzer/test/generated/engine_test.dart

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -245,21 +245,6 @@ class AnalysisContextImplTest extends EngineTestCase {
245245
super.tearDown();
246246
}
247247

248-
Future test_analyzedSources_added() async {
249-
AnalyzedSourcesListener listener = new AnalyzedSourcesListener();
250-
_context.implicitAnalysisEvents.listen(listener.onData);
251-
//
252-
// Create a file that references an file that is not explicitly being
253-
// analyzed and fully analyze it. Ensure that the listener is told about
254-
// the implicitly analyzed file.
255-
//
256-
Source sourceA = _addSource('/a.dart', "library a; import 'b.dart';");
257-
Source sourceB = _createSource('/b.dart', "library b;");
258-
_context.computeErrors(sourceA);
259-
await pumpEventQueue();
260-
listener.expectAnalyzed(sourceB);
261-
}
262-
263248
Future test_applyChanges_add() {
264249
SourcesChangedListener listener = new SourcesChangedListener();
265250
_context.onSourcesChanged.listen(listener.onData);
@@ -1348,6 +1333,21 @@ main() {}''');
13481333
// assertLength(0, statistics.getSources());
13491334
}
13501335

1336+
Future test_implicitAnalysisEvents_added() async {
1337+
AnalyzedSourcesListener listener = new AnalyzedSourcesListener();
1338+
_context.implicitAnalysisEvents.listen(listener.onData);
1339+
//
1340+
// Create a file that references an file that is not explicitly being
1341+
// analyzed and fully analyze it. Ensure that the listener is told about
1342+
// the implicitly analyzed file.
1343+
//
1344+
Source sourceA = _addSource('/a.dart', "library a; import 'b.dart';");
1345+
Source sourceB = _createSource('/b.dart', "library b;");
1346+
_context.computeErrors(sourceA);
1347+
await pumpEventQueue();
1348+
listener.expectAnalyzed(sourceB);
1349+
}
1350+
13511351
void test_isClientLibrary_dart() {
13521352
_context = AnalysisContextFactory.oldContextWithCore();
13531353
_sourceFactory = _context.sourceFactory;

pkg/analyzer/test/src/context/context_test.dart

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ main() {
5555

5656
@reflectiveTest
5757
class AnalysisContextImplTest extends AbstractContextTest {
58-
Future fail_analyzedSources_removed() async {
58+
Future fail_implicitAnalysisEvents_removed() async {
5959
AnalyzedSourcesListener listener = new AnalyzedSourcesListener();
6060
context.implicitAnalysisEvents.listen(listener.onData);
6161
//
@@ -116,24 +116,6 @@ class AnalysisContextImplTest extends AbstractContextTest {
116116
super.tearDown();
117117
}
118118

119-
Future test_analyzedSources_added() async {
120-
AnalyzedSourcesListener listener = new AnalyzedSourcesListener();
121-
context.implicitAnalysisEvents.listen(listener.onData);
122-
//
123-
// Create a file that references an file that is not explicitly being
124-
// analyzed and fully analyze it. Ensure that the listener is told about
125-
// the implicitly analyzed file.
126-
//
127-
Source sourceA = newSource('/a.dart', "library a; import 'b.dart';");
128-
Source sourceB = newSource('/b.dart', "library b;");
129-
ChangeSet changeSet = new ChangeSet();
130-
changeSet.addedSource(sourceA);
131-
context.applyChanges(changeSet);
132-
context.computeErrors(sourceA);
133-
await pumpEventQueue();
134-
listener.expectAnalyzed(sourceB);
135-
}
136-
137119
Future test_applyChanges_add() {
138120
SourcesChangedListener listener = new SourcesChangedListener();
139121
context.onSourcesChanged.listen(listener.onData);
@@ -1250,6 +1232,24 @@ main() {}''');
12501232
expect(analysisResult.changeNotices, isNotNull);
12511233
}
12521234

1235+
Future test_implicitAnalysisEvents_added() async {
1236+
AnalyzedSourcesListener listener = new AnalyzedSourcesListener();
1237+
context.implicitAnalysisEvents.listen(listener.onData);
1238+
//
1239+
// Create a file that references an file that is not explicitly being
1240+
// analyzed and fully analyze it. Ensure that the listener is told about
1241+
// the implicitly analyzed file.
1242+
//
1243+
Source sourceA = newSource('/a.dart', "library a; import 'b.dart';");
1244+
Source sourceB = newSource('/b.dart', "library b;");
1245+
ChangeSet changeSet = new ChangeSet();
1246+
changeSet.addedSource(sourceA);
1247+
context.applyChanges(changeSet);
1248+
context.computeErrors(sourceA);
1249+
await pumpEventQueue();
1250+
listener.expectAnalyzed(sourceB);
1251+
}
1252+
12531253
void test_isClientLibrary_dart() {
12541254
Source source = addSource("/test.dart", r'''
12551255
import 'dart:html';

0 commit comments

Comments
 (0)