@@ -305,6 +305,18 @@ class AnalysisDomainHandlerTest extends AbstractAnalysisTest {
305305class AnalysisDomainTest extends AbstractAnalysisTest {
306306 Map <String , List <AnalysisError >> filesErrors = {};
307307
308+ void assertHasErrors (String path) {
309+ expect (filesErrors[path], isNotEmpty);
310+ }
311+
312+ void assertNoErrors (String path) {
313+ expect (filesErrors[path], isEmpty);
314+ }
315+
316+ void assertNoErrorsNotification (String path) {
317+ expect (filesErrors[path], isNull);
318+ }
319+
308320 @override
309321 void processNotification (Notification notification) {
310322 if (notification.event == ANALYSIS_NOTIFICATION_ERRORS ) {
@@ -313,6 +325,117 @@ class AnalysisDomainTest extends AbstractAnalysisTest {
313325 }
314326 }
315327
328+ Future <void > test_fileSystem_addFile_excluded () async {
329+ var a_path = convertPath ('$projectPath /lib/a.dart' );
330+ var b_path = convertPath ('$projectPath /lib/b.dart' );
331+
332+ newFile ('$projectPath /analysis_options.yaml' , content: r'''
333+ analyzer:
334+ exclude:
335+ - "**/a.dart"
336+ ''' );
337+
338+ newFile (b_path, content: r'''
339+ import 'a.dart';
340+ void f(A a) {}
341+ ''' );
342+
343+ createProject ();
344+ await pumpEventQueue ();
345+ await server.onAnalysisComplete;
346+
347+ // We don't have a.dart, so the import cannot be resolved.
348+ assertHasErrors (b_path);
349+
350+ newFile (a_path, content: r'''
351+ class A {}
352+ ''' );
353+ await pumpEventQueue ();
354+ await server.onAnalysisComplete;
355+
356+ // We excluded 'a.dart' from analysis, no errors notification for it.
357+ assertNoErrorsNotification (a_path);
358+
359+ // We added a.dart with `A`, so no errors.
360+ assertNoErrors (b_path);
361+ }
362+
363+ Future <void > test_fileSystem_changeFile_excluded () async {
364+ var a_path = convertPath ('$projectPath /lib/a.dart' );
365+ var b_path = convertPath ('$projectPath /lib/b.dart' );
366+
367+ newFile ('$projectPath /analysis_options.yaml' , content: r'''
368+ analyzer:
369+ exclude:
370+ - "**/a.dart"
371+ ''' );
372+
373+ newFile (a_path, content: r'''
374+ class B {}
375+ ''' );
376+
377+ newFile (b_path, content: r'''
378+ import 'a.dart';
379+ void f(A a) {}
380+ ''' );
381+
382+ createProject ();
383+ await pumpEventQueue ();
384+ await server.onAnalysisComplete;
385+
386+ // We excluded 'a.dart' from analysis, no errors notification for it.
387+ assertNoErrorsNotification (a_path);
388+
389+ // We have `B`, not `A`, in a.dart, so has errors.
390+ assertHasErrors (b_path);
391+
392+ newFile (a_path, content: r'''
393+ class A {}
394+ ''' );
395+ await pumpEventQueue ();
396+ await server.onAnalysisComplete;
397+
398+ // We changed a.dart, to have `A`, so no errors.
399+ assertNoErrors (b_path);
400+ }
401+
402+ Future <void > test_fileSystem_deleteFile_excluded () async {
403+ var a_path = convertPath ('$projectPath /lib/a.dart' );
404+ var b_path = convertPath ('$projectPath /lib/b.dart' );
405+
406+ newFile ('$projectPath /analysis_options.yaml' , content: r'''
407+ analyzer:
408+ exclude:
409+ - "**/a.dart"
410+ ''' );
411+
412+ newFile (a_path, content: r'''
413+ class A {}
414+ ''' );
415+
416+ newFile (b_path, content: r'''
417+ import 'a.dart';
418+ void f(A a) {}
419+ ''' );
420+
421+ createProject ();
422+ await pumpEventQueue ();
423+ await server.onAnalysisComplete;
424+
425+ // We excluded 'a.dart' from analysis, no errors notification for it.
426+ assertNoErrorsNotification (a_path);
427+
428+ // We have `A` in a.dart, so no errors.
429+ assertNoErrors (b_path);
430+
431+ deleteFile (a_path);
432+ await pumpEventQueue ();
433+ await server.onAnalysisComplete;
434+
435+ // We deleted a.dart, so `A` cannot be resolved.
436+ assertHasErrors (b_path);
437+ }
438+
316439 Future <void > test_setRoots_packages () {
317440 // prepare package
318441 var pkgFile = newFile ('/packages/pkgA/libA.dart' , content: '''
0 commit comments