diff --git a/pkgs/dart_services/lib/src/analysis.dart b/pkgs/dart_services/lib/src/analysis.dart index ebbbb9241..585c4216d 100644 --- a/pkgs/dart_services/lib/src/analysis.dart +++ b/pkgs/dart_services/lib/src/analysis.dart @@ -285,6 +285,7 @@ class AnalysisServerWrapper { ), ); }).toList(), + hasFix: error.hasFix, ); return issue; diff --git a/pkgs/dart_services/test/analysis_test.dart b/pkgs/dart_services/test/analysis_test.dart index 499e04fc9..006a3f0c8 100644 --- a/pkgs/dart_services/test/analysis_test.dart +++ b/pkgs/dart_services/test/analysis_test.dart @@ -86,7 +86,8 @@ void defineTests() { test('Warn on deprecated web library imports', () async { final results = await analysisServer.analyze(deprecatedWebLibrary); - expect(results.issues, hasLength(1)); + // Expect one or two deprecation messages. + expect(results.issues, anyOf(hasLength(1), hasLength(2))); final issue = results.issues.first; expect(issue.message, contains('Deprecated core web library')); }); diff --git a/pkgs/dartpad_shared/lib/model.dart b/pkgs/dartpad_shared/lib/model.dart index d6ab5fc62..d70957e67 100644 --- a/pkgs/dartpad_shared/lib/model.dart +++ b/pkgs/dartpad_shared/lib/model.dart @@ -46,6 +46,11 @@ class AnalysisIssue { final String? url; final List? contextMessages; + /// A hint to indicate to interested clients that this error has an associated + /// fix (or fixes). The absence of this field implies there are not known to + /// be fixes. + final bool? hasFix; + AnalysisIssue({ required this.kind, required this.message, @@ -54,6 +59,7 @@ class AnalysisIssue { this.correction, this.url, this.contextMessages, + this.hasFix, }); factory AnalysisIssue.fromJson(Map json) => diff --git a/pkgs/dartpad_shared/lib/model.g.dart b/pkgs/dartpad_shared/lib/model.g.dart index 3be14016f..5e8dfacfb 100644 --- a/pkgs/dartpad_shared/lib/model.g.dart +++ b/pkgs/dartpad_shared/lib/model.g.dart @@ -38,6 +38,7 @@ AnalysisIssue _$AnalysisIssueFromJson(Map json) => code: json['code'] as String?, correction: json['correction'] as String?, url: json['url'] as String?, + hasFix: json['hasFix'] as bool?, contextMessages: (json['contextMessages'] as List?) ?.map((e) => DiagnosticMessage.fromJson(e as Map)) .toList(), @@ -51,6 +52,7 @@ Map _$AnalysisIssueToJson(AnalysisIssue instance) => 'code': instance.code, 'correction': instance.correction, 'url': instance.url, + 'hasFix': instance.hasFix, 'contextMessages': instance.contextMessages, };