AnalysisSetAnalysisRootsParams.fromJson constructor

AnalysisSetAnalysisRootsParams.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json, {
  4. ClientUriConverter? clientUriConverter,
})

Implementation

factory AnalysisSetAnalysisRootsParams.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(
      jsonPath,
      "'analysis.setAnalysisRoots params'",
      json,
    );
  }
  List<String> included;
  if (json case {'included': var encodedIncluded}) {
    included = jsonDecoder.decodeList(
      '$jsonPath.included',
      encodedIncluded,
      (String jsonPath, Object? json) =>
          clientUriConverter?.fromClientFilePath(
            jsonDecoder.decodeString(jsonPath, json),
          ) ??
          jsonDecoder.decodeString(jsonPath, json),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'included'", json);
  }
  List<String> excluded;
  if (json case {'excluded': var encodedExcluded}) {
    excluded = jsonDecoder.decodeList(
      '$jsonPath.excluded',
      encodedExcluded,
      (String jsonPath, Object? json) =>
          clientUriConverter?.fromClientFilePath(
            jsonDecoder.decodeString(jsonPath, json),
          ) ??
          jsonDecoder.decodeString(jsonPath, json),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'excluded'", json);
  }
  return AnalysisSetAnalysisRootsParams(included, excluded);
}