AnalysisSetContextRootsParams.fromJson constructor

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

Implementation

factory AnalysisSetContextRootsParams.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(
      jsonPath,
      "'analysis.setContextRoots params'",
      json,
    );
  }
  List<ContextRoot> roots;
  if (json case {'roots': var encodedRoots}) {
    roots = jsonDecoder.decodeList(
      '$jsonPath.roots',
      encodedRoots,
      (String jsonPath, Object? json) => ContextRoot.fromJson(
        jsonDecoder,
        jsonPath,
        json,
        clientUriConverter: clientUriConverter,
      ),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'roots'", json);
  }
  return AnalysisSetContextRootsParams(roots);
}