ExecutionGetSuggestionsParams.fromJson constructor
ExecutionGetSuggestionsParams.fromJson(
- JsonDecoder jsonDecoder,
- String jsonPath,
- Object? json
)
Implementation
factory ExecutionGetSuggestionsParams.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
json ??= {};
if (json is Map) {
String code;
if (json.containsKey('code')) {
code = jsonDecoder.decodeString('$jsonPath.code', json['code']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'code');
}
int offset;
if (json.containsKey('offset')) {
offset = jsonDecoder.decodeInt('$jsonPath.offset', json['offset']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'offset');
}
String contextFile;
if (json.containsKey('contextFile')) {
contextFile = jsonDecoder.decodeString(
'$jsonPath.contextFile', json['contextFile']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'contextFile');
}
int contextOffset;
if (json.containsKey('contextOffset')) {
contextOffset = jsonDecoder.decodeInt(
'$jsonPath.contextOffset', json['contextOffset']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'contextOffset');
}
List<RuntimeCompletionVariable> variables;
if (json.containsKey('variables')) {
variables = jsonDecoder.decodeList(
'$jsonPath.variables',
json['variables'],
(String jsonPath, Object? json) =>
RuntimeCompletionVariable.fromJson(
jsonDecoder, jsonPath, json));
} else {
throw jsonDecoder.mismatch(jsonPath, 'variables');
}
List<RuntimeCompletionExpression>? expressions;
if (json.containsKey('expressions')) {
expressions = jsonDecoder.decodeList(
'$jsonPath.expressions',
json['expressions'],
(String jsonPath, Object? json) =>
RuntimeCompletionExpression.fromJson(
jsonDecoder, jsonPath, json));
}
return ExecutionGetSuggestionsParams(
code, offset, contextFile, contextOffset, variables,
expressions: expressions);
} else {
throw jsonDecoder.mismatch(
jsonPath, 'execution.getSuggestions params', json);
}
}