getSourceReport method Null safety

  1. @override
Future<SourceReport> getSourceReport(
  1. String isolateId,
  2. List<String> reports,
  3. {String? scriptId,
  4. int? tokenPos,
  5. int? endTokenPos,
  6. bool? forceCompile,
  7. bool? reportLines}
)
override

The getSourceReport RPC is used to generate a set of reports tied to source locations in an isolate.

The reports parameter is used to specify which reports should be generated. The reports parameter is a list, which allows multiple reports to be generated simultaneously from a consistent isolate state. The reports parameter is allowed to be empty (this might be used to force compilation of a particular subrange of some script).

The available report kinds are:

report kindmeaning
CoverageProvide code coverage information
PossibleBreakpointsProvide a list of token positions which correspond
to possible breakpoints.

The scriptId parameter is used to restrict the report to a particular script. When analyzing a particular script, either or both of the tokenPos and endTokenPos parameters may be provided to restrict the analysis to a subrange of a script (for example, these can be used to restrict the report to the range of a particular class or function).

If the scriptId parameter is not provided then the reports are generated for all loaded scripts and the tokenPos and endTokenPos parameters are disallowed.

The forceCompilation parameter can be used to force compilation of all functions in the range of the report. Forcing compilation can cause a compilation error, which could terminate the running Dart program. If this parameter is not provided, it is considered to have the value false.

The reportLines parameter changes the token positions in SourceReportRange.possibleBreakpoints and SourceReportCoverage to be line numbers. This is designed to reduce the number of RPCs that need to be performed in the case that the client is only interested in line numbers. If this parameter is not provided, it is considered to have the value false.

If isolateId refers to an isolate which has exited, then the Collected Sentinel is returned.

See SourceReport.

This method will throw a SentinelException in the case a Sentinel is returned.

Implementation

@override
Future<SourceReport> getSourceReport(
  String isolateId,
  /*List<SourceReportKind>*/ List<String> reports, {
  String? scriptId,
  int? tokenPos,
  int? endTokenPos,
  bool? forceCompile,
  bool? reportLines,
}) =>
    _call('getSourceReport', {
      'isolateId': isolateId,
      'reports': reports,
      if (scriptId != null) 'scriptId': scriptId,
      if (tokenPos != null) 'tokenPos': tokenPos,
      if (endTokenPos != null) 'endTokenPos': endTokenPos,
      if (forceCompile != null) 'forceCompile': forceCompile,
      if (reportLines != null) 'reportLines': reportLines,
    });