@@ -211,9 +211,8 @@ class CompletionItemResolutionInfo implements ToJsonable {
211
211
);
212
212
213
213
static CompletionItemResolutionInfo fromJson (Map <String , Object ?> json) {
214
- if (DartNotImportedCompletionResolutionInfo .canParse (
215
- json, nullLspJsonReporter)) {
216
- return DartNotImportedCompletionResolutionInfo .fromJson (json);
214
+ if (DartCompletionResolutionInfo .canParse (json, nullLspJsonReporter)) {
215
+ return DartCompletionResolutionInfo .fromJson (json);
217
216
}
218
217
if (PubPackageCompletionItemResolutionInfo .canParse (
219
218
json, nullLspJsonReporter)) {
@@ -247,79 +246,30 @@ class CompletionItemResolutionInfo implements ToJsonable {
247
246
String toString () => jsonEncoder.convert (toJson ());
248
247
}
249
248
250
- class DartDiagnosticServer implements ToJsonable {
251
- static const jsonHandler = LspJsonHandler (
252
- DartDiagnosticServer .canParse,
253
- DartDiagnosticServer .fromJson,
254
- );
255
-
256
- DartDiagnosticServer ({
257
- required this .port,
258
- });
259
- static DartDiagnosticServer fromJson (Map <String , Object ?> json) {
260
- final portJson = json['port' ];
261
- final port = portJson as int ;
262
- return DartDiagnosticServer (
263
- port: port,
264
- );
265
- }
266
-
267
- final int port;
268
-
269
- @override
270
- Map <String , Object ?> toJson () {
271
- var result = < String , Object ? > {};
272
- result['port' ] = port;
273
- return result;
274
- }
275
-
276
- static bool canParse (Object ? obj, LspJsonReporter reporter) {
277
- if (obj is Map <String , Object ?>) {
278
- return _canParseInt (obj, reporter, 'port' ,
279
- allowsUndefined: false , allowsNull: false );
280
- } else {
281
- reporter.reportError ('must be of type DartDiagnosticServer' );
282
- return false ;
283
- }
284
- }
285
-
286
- @override
287
- bool operator == (Object other) {
288
- return other is DartDiagnosticServer &&
289
- other.runtimeType == DartDiagnosticServer &&
290
- port == other.port;
291
- }
292
-
293
- @override
294
- int get hashCode => port.hashCode;
295
-
296
- @override
297
- String toString () => jsonEncoder.convert (toJson ());
298
- }
299
-
300
- class DartNotImportedCompletionResolutionInfo
249
+ class DartCompletionResolutionInfo
301
250
implements CompletionItemResolutionInfo , ToJsonable {
302
251
static const jsonHandler = LspJsonHandler (
303
- DartNotImportedCompletionResolutionInfo .canParse,
304
- DartNotImportedCompletionResolutionInfo .fromJson,
252
+ DartCompletionResolutionInfo .canParse,
253
+ DartCompletionResolutionInfo .fromJson,
305
254
);
306
255
307
- DartNotImportedCompletionResolutionInfo ({
256
+ DartCompletionResolutionInfo ({
308
257
required this .file,
309
- required this .libraryUri ,
258
+ required this .importUris ,
310
259
this .ref,
311
260
});
312
- static DartNotImportedCompletionResolutionInfo fromJson (
313
- Map <String , Object ?> json) {
261
+ static DartCompletionResolutionInfo fromJson (Map <String , Object ?> json) {
314
262
final fileJson = json['file' ];
315
263
final file = fileJson as String ;
316
- final libraryUriJson = json['libraryUri' ];
317
- final libraryUri = libraryUriJson as String ;
264
+ final importUrisJson = json['importUris' ];
265
+ final importUris = (importUrisJson as List <Object ?>)
266
+ .map ((item) => item as String )
267
+ .toList ();
318
268
final refJson = json['ref' ];
319
269
final ref = refJson as String ? ;
320
- return DartNotImportedCompletionResolutionInfo (
270
+ return DartCompletionResolutionInfo (
321
271
file: file,
322
- libraryUri : libraryUri ,
272
+ importUris : importUris ,
323
273
ref: ref,
324
274
);
325
275
}
@@ -329,8 +279,8 @@ class DartNotImportedCompletionResolutionInfo
329
279
/// This is used to compute where to add the import.
330
280
final String file;
331
281
332
- /// The URI to be imported if this completion is selected.
333
- final String libraryUri ;
282
+ /// The URIs to be imported if this completion is selected.
283
+ final List < String > importUris ;
334
284
335
285
/// The ElementLocation of the item being completed.
336
286
///
@@ -341,7 +291,7 @@ class DartNotImportedCompletionResolutionInfo
341
291
Map <String , Object ?> toJson () {
342
292
var result = < String , Object ? > {};
343
293
result['file' ] = file;
344
- result['libraryUri ' ] = libraryUri ;
294
+ result['importUris ' ] = importUris ;
345
295
if (ref != null ) {
346
296
result['ref' ] = ref;
347
297
}
@@ -354,39 +304,89 @@ class DartNotImportedCompletionResolutionInfo
354
304
allowsUndefined: false , allowsNull: false )) {
355
305
return false ;
356
306
}
357
- if (! _canParseString (obj, reporter, 'libraryUri ' ,
307
+ if (! _canParseListString (obj, reporter, 'importUris ' ,
358
308
allowsUndefined: false , allowsNull: false )) {
359
309
return false ;
360
310
}
361
311
return _canParseString (obj, reporter, 'ref' ,
362
312
allowsUndefined: true , allowsNull: false );
363
313
} else {
364
- reporter.reportError (
365
- 'must be of type DartNotImportedCompletionResolutionInfo' );
314
+ reporter.reportError ('must be of type DartCompletionResolutionInfo' );
366
315
return false ;
367
316
}
368
317
}
369
318
370
319
@override
371
320
bool operator == (Object other) {
372
- return other is DartNotImportedCompletionResolutionInfo &&
373
- other.runtimeType == DartNotImportedCompletionResolutionInfo &&
321
+ return other is DartCompletionResolutionInfo &&
322
+ other.runtimeType == DartCompletionResolutionInfo &&
374
323
file == other.file &&
375
- libraryUri == other.libraryUri &&
324
+ listEqual (
325
+ importUris, other.importUris, (String a, String b) => a == b) &&
376
326
ref == other.ref;
377
327
}
378
328
379
329
@override
380
330
int get hashCode => Object .hash (
381
331
file,
382
- libraryUri ,
332
+ lspHashCode (importUris) ,
383
333
ref,
384
334
);
385
335
386
336
@override
387
337
String toString () => jsonEncoder.convert (toJson ());
388
338
}
389
339
340
+ class DartDiagnosticServer implements ToJsonable {
341
+ static const jsonHandler = LspJsonHandler (
342
+ DartDiagnosticServer .canParse,
343
+ DartDiagnosticServer .fromJson,
344
+ );
345
+
346
+ DartDiagnosticServer ({
347
+ required this .port,
348
+ });
349
+ static DartDiagnosticServer fromJson (Map <String , Object ?> json) {
350
+ final portJson = json['port' ];
351
+ final port = portJson as int ;
352
+ return DartDiagnosticServer (
353
+ port: port,
354
+ );
355
+ }
356
+
357
+ final int port;
358
+
359
+ @override
360
+ Map <String , Object ?> toJson () {
361
+ var result = < String , Object ? > {};
362
+ result['port' ] = port;
363
+ return result;
364
+ }
365
+
366
+ static bool canParse (Object ? obj, LspJsonReporter reporter) {
367
+ if (obj is Map <String , Object ?>) {
368
+ return _canParseInt (obj, reporter, 'port' ,
369
+ allowsUndefined: false , allowsNull: false );
370
+ } else {
371
+ reporter.reportError ('must be of type DartDiagnosticServer' );
372
+ return false ;
373
+ }
374
+ }
375
+
376
+ @override
377
+ bool operator == (Object other) {
378
+ return other is DartDiagnosticServer &&
379
+ other.runtimeType == DartDiagnosticServer &&
380
+ port == other.port;
381
+ }
382
+
383
+ @override
384
+ int get hashCode => port.hashCode;
385
+
386
+ @override
387
+ String toString () => jsonEncoder.convert (toJson ());
388
+ }
389
+
390
390
class Element implements ToJsonable {
391
391
static const jsonHandler = LspJsonHandler (
392
392
Element .canParse,
@@ -2396,6 +2396,32 @@ bool _canParseListOutline(
2396
2396
return true ;
2397
2397
}
2398
2398
2399
+ bool _canParseListString (
2400
+ Map <String , Object ?> map, LspJsonReporter reporter, String fieldName,
2401
+ {required bool allowsUndefined, required bool allowsNull}) {
2402
+ reporter.push (fieldName);
2403
+ try {
2404
+ if (! allowsUndefined && ! map.containsKey (fieldName)) {
2405
+ reporter.reportError ('must not be undefined' );
2406
+ return false ;
2407
+ }
2408
+ final value = map[fieldName];
2409
+ final nullCheck = allowsNull || allowsUndefined;
2410
+ if (! nullCheck && value == null ) {
2411
+ reporter.reportError ('must not be null' );
2412
+ return false ;
2413
+ }
2414
+ if ((! nullCheck || value != null ) &&
2415
+ (value is ! List <Object ?> || value.any ((item) => item is ! String ))) {
2416
+ reporter.reportError ('must be of type List<String>' );
2417
+ return false ;
2418
+ }
2419
+ } finally {
2420
+ reporter.pop ();
2421
+ }
2422
+ return true ;
2423
+ }
2424
+
2399
2425
bool _canParseLiteral (
2400
2426
Map <String , Object ?> map, LspJsonReporter reporter, String fieldName,
2401
2427
{required bool allowsUndefined,
0 commit comments