Skip to content

Commit

Permalink
expose a 'hasFix' field on analyzer diagnostics (#3127)
Browse files Browse the repository at this point in the history
* expose a 'hasFix' field on analyzer diagnostics

* fix test expectations
  • Loading branch information
devoncarew authored Jan 22, 2025
1 parent 9328ed0 commit d788f8f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkgs/dart_services/lib/src/analysis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ class AnalysisServerWrapper {
),
);
}).toList(),
hasFix: error.hasFix,
);

return issue;
Expand Down
3 changes: 2 additions & 1 deletion pkgs/dart_services/test/analysis_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});
Expand Down
6 changes: 6 additions & 0 deletions pkgs/dartpad_shared/lib/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ class AnalysisIssue {
final String? url;
final List<DiagnosticMessage>? 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,
Expand All @@ -54,6 +59,7 @@ class AnalysisIssue {
this.correction,
this.url,
this.contextMessages,
this.hasFix,
});

factory AnalysisIssue.fromJson(Map<String, Object?> json) =>
Expand Down
2 changes: 2 additions & 0 deletions pkgs/dartpad_shared/lib/model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d788f8f

Please sign in to comment.