CompletionResultsParams.fromJson constructor
CompletionResultsParams.fromJson(
- JsonDecoder jsonDecoder,
- String jsonPath,
- Object? json
)
Implementation
factory CompletionResultsParams.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
json ??= {};
if (json is Map) {
String id;
if (json.containsKey('id')) {
id = jsonDecoder.decodeString('$jsonPath.id', json['id']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'id');
}
int replacementOffset;
if (json.containsKey('replacementOffset')) {
replacementOffset = jsonDecoder.decodeInt(
'$jsonPath.replacementOffset', json['replacementOffset']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'replacementOffset');
}
int replacementLength;
if (json.containsKey('replacementLength')) {
replacementLength = jsonDecoder.decodeInt(
'$jsonPath.replacementLength', json['replacementLength']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'replacementLength');
}
List<CompletionSuggestion> results;
if (json.containsKey('results')) {
results = jsonDecoder.decodeList(
'$jsonPath.results',
json['results'],
(String jsonPath, Object? json) =>
CompletionSuggestion.fromJson(jsonDecoder, jsonPath, json));
} else {
throw jsonDecoder.mismatch(jsonPath, 'results');
}
bool isLast;
if (json.containsKey('isLast')) {
isLast = jsonDecoder.decodeBool('$jsonPath.isLast', json['isLast']);
} else {
throw jsonDecoder.mismatch(jsonPath, 'isLast');
}
String? libraryFile;
if (json.containsKey('libraryFile')) {
libraryFile = jsonDecoder.decodeString(
'$jsonPath.libraryFile', json['libraryFile']);
}
List<IncludedSuggestionSet>? includedSuggestionSets;
if (json.containsKey('includedSuggestionSets')) {
includedSuggestionSets = jsonDecoder.decodeList(
'$jsonPath.includedSuggestionSets',
json['includedSuggestionSets'],
(String jsonPath, Object? json) =>
IncludedSuggestionSet.fromJson(jsonDecoder, jsonPath, json));
}
List<ElementKind>? includedElementKinds;
if (json.containsKey('includedElementKinds')) {
includedElementKinds = jsonDecoder.decodeList(
'$jsonPath.includedElementKinds',
json['includedElementKinds'],
(String jsonPath, Object? json) =>
ElementKind.fromJson(jsonDecoder, jsonPath, json));
}
List<IncludedSuggestionRelevanceTag>? includedSuggestionRelevanceTags;
if (json.containsKey('includedSuggestionRelevanceTags')) {
includedSuggestionRelevanceTags = jsonDecoder.decodeList(
'$jsonPath.includedSuggestionRelevanceTags',
json['includedSuggestionRelevanceTags'],
(String jsonPath, Object? json) =>
IncludedSuggestionRelevanceTag.fromJson(
jsonDecoder, jsonPath, json));
}
return CompletionResultsParams(
id, replacementOffset, replacementLength, results, isLast,
libraryFile: libraryFile,
includedSuggestionSets: includedSuggestionSets,
includedElementKinds: includedElementKinds,
includedSuggestionRelevanceTags: includedSuggestionRelevanceTags);
} else {
throw jsonDecoder.mismatch(jsonPath, 'completion.results params', json);
}
}