Added an errors field to allow permissive mode to display the exceptions that are being ignored
Change-Id: Id8fd27a7882c6dd20854d055477af25d17de3582
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105440
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
diff --git a/pkg/analysis_server/lib/protocol/protocol_constants.dart b/pkg/analysis_server/lib/protocol/protocol_constants.dart
index de5bc20..2d93ddb 100644
--- a/pkg/analysis_server/lib/protocol/protocol_constants.dart
+++ b/pkg/analysis_server/lib/protocol/protocol_constants.dart
@@ -218,6 +218,7 @@
const String EDIT_REQUEST_ORGANIZE_DIRECTIVES_FILE = 'file';
const String EDIT_REQUEST_SORT_MEMBERS = 'edit.sortMembers';
const String EDIT_REQUEST_SORT_MEMBERS_FILE = 'file';
+const String EDIT_RESPONSE_DARTFIX_DETAILS = 'details';
const String EDIT_RESPONSE_DARTFIX_EDITS = 'edits';
const String EDIT_RESPONSE_DARTFIX_HAS_ERRORS = 'hasErrors';
const String EDIT_RESPONSE_DARTFIX_OTHER_SUGGESTIONS = 'otherSuggestions';
diff --git a/pkg/analysis_server/lib/protocol/protocol_generated.dart b/pkg/analysis_server/lib/protocol/protocol_generated.dart
index b928fa4..603016e 100644
--- a/pkg/analysis_server/lib/protocol/protocol_generated.dart
+++ b/pkg/analysis_server/lib/protocol/protocol_generated.dart
@@ -8222,6 +8222,7 @@
* "otherSuggestions": List<DartFixSuggestion>
* "hasErrors": bool
* "edits": List<SourceFileEdit>
+ * "details": optional List<String>
* }
*
* Clients may not extend, implement or mix-in this class.
@@ -8235,6 +8236,8 @@
List<SourceFileEdit> _edits;
+ List<String> _details;
+
/**
* A list of recommended changes that can be automatically made by applying
* the 'edits' included in this response.
@@ -8291,15 +8294,37 @@
this._edits = value;
}
+ /**
+ * Messages that should be displayed to the user that describe details of the
+ * fix generation. This could be details that users might want to explore
+ * before committing the changes to descriptions of exceptions that were
+ * thrown but that did not stop the fixes from being produced. The list will
+ * be omitted if it is empty.
+ */
+ List<String> get details => _details;
+
+ /**
+ * Messages that should be displayed to the user that describe details of the
+ * fix generation. This could be details that users might want to explore
+ * before committing the changes to descriptions of exceptions that were
+ * thrown but that did not stop the fixes from being produced. The list will
+ * be omitted if it is empty.
+ */
+ void set details(List<String> value) {
+ this._details = value;
+ }
+
EditDartfixResult(
List<DartFixSuggestion> suggestions,
List<DartFixSuggestion> otherSuggestions,
bool hasErrors,
- List<SourceFileEdit> edits) {
+ List<SourceFileEdit> edits,
+ {List<String> details}) {
this.suggestions = suggestions;
this.otherSuggestions = otherSuggestions;
this.hasErrors = hasErrors;
this.edits = edits;
+ this.details = details;
}
factory EditDartfixResult.fromJson(
@@ -8345,8 +8370,14 @@
} else {
throw jsonDecoder.mismatch(jsonPath, "edits");
}
+ List<String> details;
+ if (json.containsKey("details")) {
+ details = jsonDecoder.decodeList(
+ jsonPath + ".details", json["details"], jsonDecoder.decodeString);
+ }
return new EditDartfixResult(
- suggestions, otherSuggestions, hasErrors, edits);
+ suggestions, otherSuggestions, hasErrors, edits,
+ details: details);
} else {
throw jsonDecoder.mismatch(jsonPath, "edit.dartfix result", json);
}
@@ -8370,6 +8401,9 @@
result["hasErrors"] = hasErrors;
result["edits"] =
edits.map((SourceFileEdit value) => value.toJson()).toList();
+ if (details != null) {
+ result["details"] = details;
+ }
return result;
}
@@ -8390,7 +8424,8 @@
(DartFixSuggestion a, DartFixSuggestion b) => a == b) &&
hasErrors == other.hasErrors &&
listEqual(edits, other.edits,
- (SourceFileEdit a, SourceFileEdit b) => a == b);
+ (SourceFileEdit a, SourceFileEdit b) => a == b) &&
+ listEqual(details, other.details, (String a, String b) => a == b);
}
return false;
}
@@ -8402,6 +8437,7 @@
hash = JenkinsSmiHash.combine(hash, otherSuggestions.hashCode);
hash = JenkinsSmiHash.combine(hash, hasErrors.hashCode);
hash = JenkinsSmiHash.combine(hash, edits.hashCode);
+ hash = JenkinsSmiHash.combine(hash, details.hashCode);
return JenkinsSmiHash.finish(hash);
}
}
diff --git a/pkg/analysis_server/test/integration/support/integration_test_methods.dart b/pkg/analysis_server/test/integration/support/integration_test_methods.dart
index 65c2ca5..d14ee38 100644
--- a/pkg/analysis_server/test/integration/support/integration_test_methods.dart
+++ b/pkg/analysis_server/test/integration/support/integration_test_methods.dart
@@ -1775,6 +1775,14 @@
* edits: List<SourceFileEdit>
*
* A list of source edits to apply the recommended changes.
+ *
+ * details: List<String> (optional)
+ *
+ * Messages that should be displayed to the user that describe details of
+ * the fix generation. This could be details that users might want to
+ * explore before committing the changes to descriptions of exceptions that
+ * were thrown but that did not stop the fixes from being produced. The
+ * list will be omitted if it is empty.
*/
Future<EditDartfixResult> sendEditDartfix(List<String> included,
{List<String> includedFixes,
diff --git a/pkg/analysis_server/test/integration/support/protocol_matchers.dart b/pkg/analysis_server/test/integration/support/protocol_matchers.dart
index 5e03f54..2dc3198 100644
--- a/pkg/analysis_server/test/integration/support/protocol_matchers.dart
+++ b/pkg/analysis_server/test/integration/support/protocol_matchers.dart
@@ -2456,6 +2456,7 @@
* "otherSuggestions": List<DartFixSuggestion>
* "hasErrors": bool
* "edits": List<SourceFileEdit>
+ * "details": optional List<String>
* }
*/
final Matcher isEditDartfixResult =
@@ -2464,6 +2465,8 @@
"otherSuggestions": isListOf(isDartFixSuggestion),
"hasErrors": isBool,
"edits": isListOf(isSourceFileEdit)
+ }, optionalFields: {
+ "details": isListOf(isString)
}));
/**
diff --git a/pkg/analysis_server/tool/spec/spec_input.html b/pkg/analysis_server/tool/spec/spec_input.html
index f28b7b6..81ad119 100644
--- a/pkg/analysis_server/tool/spec/spec_input.html
+++ b/pkg/analysis_server/tool/spec/spec_input.html
@@ -2253,6 +2253,18 @@
A list of source edits to apply the recommended changes.
</p>
</field>
+ <field name="details" optional="true">
+ <list>
+ <ref>String</ref>
+ </list>
+ <p>
+ Messages that should be displayed to the user that describe details of
+ the fix generation. This could be details that users might want to
+ explore before committing the changes to descriptions of exceptions
+ that were thrown but that did not stop the fixes from being produced.
+ The list will be omitted if it is empty.
+ </p>
+ </field>
</result>
</request>
<request method="getFixes">
diff --git a/pkg/analysis_server_client/lib/src/protocol/protocol_constants.dart b/pkg/analysis_server_client/lib/src/protocol/protocol_constants.dart
index de5bc20..2d93ddb 100644
--- a/pkg/analysis_server_client/lib/src/protocol/protocol_constants.dart
+++ b/pkg/analysis_server_client/lib/src/protocol/protocol_constants.dart
@@ -218,6 +218,7 @@
const String EDIT_REQUEST_ORGANIZE_DIRECTIVES_FILE = 'file';
const String EDIT_REQUEST_SORT_MEMBERS = 'edit.sortMembers';
const String EDIT_REQUEST_SORT_MEMBERS_FILE = 'file';
+const String EDIT_RESPONSE_DARTFIX_DETAILS = 'details';
const String EDIT_RESPONSE_DARTFIX_EDITS = 'edits';
const String EDIT_RESPONSE_DARTFIX_HAS_ERRORS = 'hasErrors';
const String EDIT_RESPONSE_DARTFIX_OTHER_SUGGESTIONS = 'otherSuggestions';
diff --git a/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart b/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart
index 4365a8e..af0e154 100644
--- a/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart
+++ b/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart
@@ -8222,6 +8222,7 @@
* "otherSuggestions": List<DartFixSuggestion>
* "hasErrors": bool
* "edits": List<SourceFileEdit>
+ * "details": optional List<String>
* }
*
* Clients may not extend, implement or mix-in this class.
@@ -8235,6 +8236,8 @@
List<SourceFileEdit> _edits;
+ List<String> _details;
+
/**
* A list of recommended changes that can be automatically made by applying
* the 'edits' included in this response.
@@ -8291,15 +8294,37 @@
this._edits = value;
}
+ /**
+ * Messages that should be displayed to the user that describe details of the
+ * fix generation. This could be details that users might want to explore
+ * before committing the changes to descriptions of exceptions that were
+ * thrown but that did not stop the fixes from being produced. The list will
+ * be omitted if it is empty.
+ */
+ List<String> get details => _details;
+
+ /**
+ * Messages that should be displayed to the user that describe details of the
+ * fix generation. This could be details that users might want to explore
+ * before committing the changes to descriptions of exceptions that were
+ * thrown but that did not stop the fixes from being produced. The list will
+ * be omitted if it is empty.
+ */
+ void set details(List<String> value) {
+ this._details = value;
+ }
+
EditDartfixResult(
List<DartFixSuggestion> suggestions,
List<DartFixSuggestion> otherSuggestions,
bool hasErrors,
- List<SourceFileEdit> edits) {
+ List<SourceFileEdit> edits,
+ {List<String> details}) {
this.suggestions = suggestions;
this.otherSuggestions = otherSuggestions;
this.hasErrors = hasErrors;
this.edits = edits;
+ this.details = details;
}
factory EditDartfixResult.fromJson(
@@ -8345,8 +8370,14 @@
} else {
throw jsonDecoder.mismatch(jsonPath, "edits");
}
+ List<String> details;
+ if (json.containsKey("details")) {
+ details = jsonDecoder.decodeList(
+ jsonPath + ".details", json["details"], jsonDecoder.decodeString);
+ }
return new EditDartfixResult(
- suggestions, otherSuggestions, hasErrors, edits);
+ suggestions, otherSuggestions, hasErrors, edits,
+ details: details);
} else {
throw jsonDecoder.mismatch(jsonPath, "edit.dartfix result", json);
}
@@ -8370,6 +8401,9 @@
result["hasErrors"] = hasErrors;
result["edits"] =
edits.map((SourceFileEdit value) => value.toJson()).toList();
+ if (details != null) {
+ result["details"] = details;
+ }
return result;
}
@@ -8390,7 +8424,8 @@
(DartFixSuggestion a, DartFixSuggestion b) => a == b) &&
hasErrors == other.hasErrors &&
listEqual(edits, other.edits,
- (SourceFileEdit a, SourceFileEdit b) => a == b);
+ (SourceFileEdit a, SourceFileEdit b) => a == b) &&
+ listEqual(details, other.details, (String a, String b) => a == b);
}
return false;
}
@@ -8402,6 +8437,7 @@
hash = JenkinsSmiHash.combine(hash, otherSuggestions.hashCode);
hash = JenkinsSmiHash.combine(hash, hasErrors.hashCode);
hash = JenkinsSmiHash.combine(hash, edits.hashCode);
+ hash = JenkinsSmiHash.combine(hash, details.hashCode);
return JenkinsSmiHash.finish(hash);
}
}