@@ -43,7 +43,8 @@ const _debugTokenPositions = bool.fromEnvironment('DEBUG_COVERAGE');
4343/// scripts that start with any of the provided paths are considered.
4444///
4545/// If [isolateIds] is set, coverage gathering **will not be restricted** to
46- /// only those VM isolates. Instead, coverage will be collected for **all isolates
46+ /// only those VM isolates. Instead, coverage will be collected for
47+ /// **all isolates
4748/// in the same isolate group** as the provided isolate(s).
4849///
4950/// If [coverableLineCache] is set, the collector will avoid recompiling
@@ -57,11 +58,12 @@ const _debugTokenPositions = bool.fromEnvironment('DEBUG_COVERAGE');
5758Future <Map <String , dynamic >> collect (Uri serviceUri, bool resume,
5859 bool waitPaused, bool includeDart, Set <String >? scopedOutput,
5960 {Set <String >? isolateIds,
60- Duration ? timeout,
61- bool functionCoverage = false ,
62- bool branchCoverage = false ,
63- Map <String , Set <int >>? coverableLineCache,
64- VmService ? serviceOverrideForTesting}) async {
61+ Duration ? timeout,
62+ bool functionCoverage = false ,
63+ bool branchCoverage = false ,
64+ Map <String , Set <int >>? coverableLineCache,
65+ VmService ? serviceOverrideForTesting,
66+ bool Function (String )? filter}) async { // Correct function type
6567 scopedOutput ?? = < String > {};
6668
6769 late VmService service;
@@ -95,7 +97,7 @@ Future<Map<String, dynamic>> collect(Uri serviceUri, bool resume,
9597 }
9698
9799 try {
98- return await _getAllCoverage (
100+ final coverageData = await _getAllCoverage (
99101 service,
100102 includeDart,
101103 functionCoverage,
@@ -104,6 +106,13 @@ Future<Map<String, dynamic>> collect(Uri serviceUri, bool resume,
104106 isolateIds,
105107 coverableLineCache,
106108 waitPaused);
109+
110+ // Apply filtering if a filter function is provided
111+ if (filter != null ) {
112+ coverageData.removeWhere ((key, value) => ! filter (key));
113+ }
114+
115+ return coverageData;
107116 } finally {
108117 if (resume && ! waitPaused) {
109118 await _resumeIsolates (service);
@@ -114,6 +123,8 @@ Future<Map<String, dynamic>> collect(Uri serviceUri, bool resume,
114123 }
115124}
116125
126+
127+
117128Future <Map <String , dynamic >> _getAllCoverage (
118129 VmService service,
119130 bool includeDart,
0 commit comments