mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Add a flag to the bulk fix protocol to support testing
I think it makes more sense for the server to read the config file than for `dart fix` to read it and then pass the data to server as part of the protocol, which it would effectively need to be parsed a second time. But I don't want config files to be used outside of test mode, so I added the flag to the protocol. Let me know if you can think of a better approach. Change-Id: I1c53bc995272451247e84914f2cd6b75a837ee1e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180082 Reviewed-by: Phil Quitslund <pquitslund@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
dce8fcda1b
commit
3621c6a02f
8 changed files with 104 additions and 10 deletions
|
@ -166,6 +166,7 @@ const String DIAGNOSTIC_RESPONSE_GET_DIAGNOSTICS_CONTEXTS = 'contexts';
|
|||
const String DIAGNOSTIC_RESPONSE_GET_SERVER_PORT_PORT = 'port';
|
||||
const String EDIT_REQUEST_BULK_FIXES = 'edit.bulkFixes';
|
||||
const String EDIT_REQUEST_BULK_FIXES_INCLUDED = 'included';
|
||||
const String EDIT_REQUEST_BULK_FIXES_IN_TEST_MODE = 'inTestMode';
|
||||
const String EDIT_REQUEST_DARTFIX = 'edit.dartfix';
|
||||
const String EDIT_REQUEST_DARTFIX_EXCLUDED_FIXES = 'excludedFixes';
|
||||
const String EDIT_REQUEST_DARTFIX_INCLUDED = 'included';
|
||||
|
|
|
@ -7301,12 +7301,15 @@ class DiagnosticGetServerPortResult implements ResponseResult {
|
|||
///
|
||||
/// {
|
||||
/// "included": List<FilePath>
|
||||
/// "inTestMode": optional bool
|
||||
/// }
|
||||
///
|
||||
/// Clients may not extend, implement or mix-in this class.
|
||||
class EditBulkFixesParams implements RequestParams {
|
||||
List<String> _included;
|
||||
|
||||
bool _inTestMode;
|
||||
|
||||
/// A list of the files and directories for which edits should be suggested.
|
||||
///
|
||||
/// If a request is made with a path that is invalid, e.g. is not absolute
|
||||
|
@ -7330,8 +7333,27 @@ class EditBulkFixesParams implements RequestParams {
|
|||
_included = value;
|
||||
}
|
||||
|
||||
EditBulkFixesParams(List<String> included) {
|
||||
/// A flag indicating whether the bulk fixes are being run in test mode. The
|
||||
/// only difference is that in test mode the fix processor will look for a
|
||||
/// configuration file that can modify the content of the data file used to
|
||||
/// compute the fixes when data-driven fixes are being considered.
|
||||
///
|
||||
/// If this field is omitted the flag defaults to false.
|
||||
bool get inTestMode => _inTestMode;
|
||||
|
||||
/// A flag indicating whether the bulk fixes are being run in test mode. The
|
||||
/// only difference is that in test mode the fix processor will look for a
|
||||
/// configuration file that can modify the content of the data file used to
|
||||
/// compute the fixes when data-driven fixes are being considered.
|
||||
///
|
||||
/// If this field is omitted the flag defaults to false.
|
||||
set inTestMode(bool value) {
|
||||
_inTestMode = value;
|
||||
}
|
||||
|
||||
EditBulkFixesParams(List<String> included, {bool inTestMode}) {
|
||||
this.included = included;
|
||||
this.inTestMode = inTestMode;
|
||||
}
|
||||
|
||||
factory EditBulkFixesParams.fromJson(
|
||||
|
@ -7345,7 +7367,12 @@ class EditBulkFixesParams implements RequestParams {
|
|||
} else {
|
||||
throw jsonDecoder.mismatch(jsonPath, 'included');
|
||||
}
|
||||
return EditBulkFixesParams(included);
|
||||
bool inTestMode;
|
||||
if (json.containsKey('inTestMode')) {
|
||||
inTestMode = jsonDecoder.decodeBool(
|
||||
jsonPath + '.inTestMode', json['inTestMode']);
|
||||
}
|
||||
return EditBulkFixesParams(included, inTestMode: inTestMode);
|
||||
} else {
|
||||
throw jsonDecoder.mismatch(jsonPath, 'edit.bulkFixes params', json);
|
||||
}
|
||||
|
@ -7360,6 +7387,9 @@ class EditBulkFixesParams implements RequestParams {
|
|||
Map<String, dynamic> toJson() {
|
||||
var result = <String, dynamic>{};
|
||||
result['included'] = included;
|
||||
if (inTestMode != null) {
|
||||
result['inTestMode'] = inTestMode;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -7375,7 +7405,8 @@ class EditBulkFixesParams implements RequestParams {
|
|||
bool operator ==(other) {
|
||||
if (other is EditBulkFixesParams) {
|
||||
return listEqual(
|
||||
included, other.included, (String a, String b) => a == b);
|
||||
included, other.included, (String a, String b) => a == b) &&
|
||||
inTestMode == other.inTestMode;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -7384,6 +7415,7 @@ class EditBulkFixesParams implements RequestParams {
|
|||
int get hashCode {
|
||||
var hash = 0;
|
||||
hash = JenkinsSmiHash.combine(hash, included.hashCode);
|
||||
hash = JenkinsSmiHash.combine(hash, inTestMode.hashCode);
|
||||
return JenkinsSmiHash.finish(hash);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1582,6 +1582,15 @@ abstract class IntegrationTestMixin {
|
|||
/// analysis.setAnalysisRoots), an error of type FILE_NOT_ANALYZED will be
|
||||
/// generated.
|
||||
///
|
||||
/// inTestMode: bool (optional)
|
||||
///
|
||||
/// A flag indicating whether the bulk fixes are being run in test mode.
|
||||
/// The only difference is that in test mode the fix processor will look
|
||||
/// for a configuration file that can modify the content of the data file
|
||||
/// used to compute the fixes when data-driven fixes are being considered.
|
||||
///
|
||||
/// If this field is omitted the flag defaults to false.
|
||||
///
|
||||
/// Returns
|
||||
///
|
||||
/// edits: List<SourceFileEdit>
|
||||
|
@ -1592,8 +1601,9 @@ abstract class IntegrationTestMixin {
|
|||
///
|
||||
/// Details that summarize the fixes associated with the recommended
|
||||
/// changes.
|
||||
Future<EditBulkFixesResult> sendEditBulkFixes(List<String> included) async {
|
||||
var params = EditBulkFixesParams(included).toJson();
|
||||
Future<EditBulkFixesResult> sendEditBulkFixes(List<String> included,
|
||||
{bool inTestMode}) async {
|
||||
var params = EditBulkFixesParams(included, inTestMode: inTestMode).toJson();
|
||||
var result = await server.send('edit.bulkFixes', params);
|
||||
var decoder = ResponseDecoder(null);
|
||||
return EditBulkFixesResult.fromJson(decoder, 'result', result);
|
||||
|
|
|
@ -2241,9 +2241,11 @@ final Matcher isDiagnosticGetServerPortResult = LazyMatcher(() =>
|
|||
///
|
||||
/// {
|
||||
/// "included": List<FilePath>
|
||||
/// "inTestMode": optional bool
|
||||
/// }
|
||||
final Matcher isEditBulkFixesParams = LazyMatcher(() => MatchesJsonObject(
|
||||
'edit.bulkFixes params', {'included': isListOf(isFilePath)}));
|
||||
'edit.bulkFixes params', {'included': isListOf(isFilePath)},
|
||||
optionalFields: {'inTestMode': isBool}));
|
||||
|
||||
/// edit.bulkFixes result
|
||||
///
|
||||
|
|
|
@ -481,8 +481,12 @@ public interface AnalysisServer {
|
|||
* file which does not exist, or which is not currently subject to analysis (e.g. because
|
||||
* it is not associated with any analysis root specified to analysis.setAnalysisRoots), an
|
||||
* error of type FILE_NOT_ANALYZED will be generated.
|
||||
* @param inTestMode A flag indicating whether the bulk fixes are being run in test mode. The only
|
||||
* difference is that in test mode the fix processor will look for a configuration file
|
||||
* that can modify the content of the data file used to compute the fixes when data-driven
|
||||
* fixes are being considered. If this field is omitted the flag defaults to false.
|
||||
*/
|
||||
public void edit_bulkFixes(List<String> included, BulkFixesConsumer consumer);
|
||||
public void edit_bulkFixes(List<String> included, boolean inTestMode, BulkFixesConsumer consumer);
|
||||
|
||||
/**
|
||||
* {@code edit.dartfix}
|
||||
|
|
|
@ -2191,6 +2191,18 @@
|
|||
<tt>FILE_NOT_ANALYZED</tt> will be generated.
|
||||
</p>
|
||||
</field>
|
||||
<field name="inTestMode" optional="true">
|
||||
<ref>bool</ref>
|
||||
<p>
|
||||
A flag indicating whether the bulk fixes are being run in test mode.
|
||||
The only difference is that in test mode the fix processor will look
|
||||
for a configuration file that can modify the content of the data file
|
||||
used to compute the fixes when data-driven fixes are being considered.
|
||||
</p>
|
||||
<p>
|
||||
If this field is omitted the flag defaults to <tt>false</tt>.
|
||||
</p>
|
||||
</field>
|
||||
</params>
|
||||
<result>
|
||||
<field name="edits">
|
||||
|
|
|
@ -166,6 +166,7 @@ const String DIAGNOSTIC_RESPONSE_GET_DIAGNOSTICS_CONTEXTS = 'contexts';
|
|||
const String DIAGNOSTIC_RESPONSE_GET_SERVER_PORT_PORT = 'port';
|
||||
const String EDIT_REQUEST_BULK_FIXES = 'edit.bulkFixes';
|
||||
const String EDIT_REQUEST_BULK_FIXES_INCLUDED = 'included';
|
||||
const String EDIT_REQUEST_BULK_FIXES_IN_TEST_MODE = 'inTestMode';
|
||||
const String EDIT_REQUEST_DARTFIX = 'edit.dartfix';
|
||||
const String EDIT_REQUEST_DARTFIX_EXCLUDED_FIXES = 'excludedFixes';
|
||||
const String EDIT_REQUEST_DARTFIX_INCLUDED = 'included';
|
||||
|
|
|
@ -7301,12 +7301,15 @@ class DiagnosticGetServerPortResult implements ResponseResult {
|
|||
///
|
||||
/// {
|
||||
/// "included": List<FilePath>
|
||||
/// "inTestMode": optional bool
|
||||
/// }
|
||||
///
|
||||
/// Clients may not extend, implement or mix-in this class.
|
||||
class EditBulkFixesParams implements RequestParams {
|
||||
List<String> _included;
|
||||
|
||||
bool _inTestMode;
|
||||
|
||||
/// A list of the files and directories for which edits should be suggested.
|
||||
///
|
||||
/// If a request is made with a path that is invalid, e.g. is not absolute
|
||||
|
@ -7330,8 +7333,27 @@ class EditBulkFixesParams implements RequestParams {
|
|||
_included = value;
|
||||
}
|
||||
|
||||
EditBulkFixesParams(List<String> included) {
|
||||
/// A flag indicating whether the bulk fixes are being run in test mode. The
|
||||
/// only difference is that in test mode the fix processor will look for a
|
||||
/// configuration file that can modify the content of the data file used to
|
||||
/// compute the fixes when data-driven fixes are being considered.
|
||||
///
|
||||
/// If this field is omitted the flag defaults to false.
|
||||
bool get inTestMode => _inTestMode;
|
||||
|
||||
/// A flag indicating whether the bulk fixes are being run in test mode. The
|
||||
/// only difference is that in test mode the fix processor will look for a
|
||||
/// configuration file that can modify the content of the data file used to
|
||||
/// compute the fixes when data-driven fixes are being considered.
|
||||
///
|
||||
/// If this field is omitted the flag defaults to false.
|
||||
set inTestMode(bool value) {
|
||||
_inTestMode = value;
|
||||
}
|
||||
|
||||
EditBulkFixesParams(List<String> included, {bool inTestMode}) {
|
||||
this.included = included;
|
||||
this.inTestMode = inTestMode;
|
||||
}
|
||||
|
||||
factory EditBulkFixesParams.fromJson(
|
||||
|
@ -7345,7 +7367,12 @@ class EditBulkFixesParams implements RequestParams {
|
|||
} else {
|
||||
throw jsonDecoder.mismatch(jsonPath, 'included');
|
||||
}
|
||||
return EditBulkFixesParams(included);
|
||||
bool inTestMode;
|
||||
if (json.containsKey('inTestMode')) {
|
||||
inTestMode = jsonDecoder.decodeBool(
|
||||
jsonPath + '.inTestMode', json['inTestMode']);
|
||||
}
|
||||
return EditBulkFixesParams(included, inTestMode: inTestMode);
|
||||
} else {
|
||||
throw jsonDecoder.mismatch(jsonPath, 'edit.bulkFixes params', json);
|
||||
}
|
||||
|
@ -7360,6 +7387,9 @@ class EditBulkFixesParams implements RequestParams {
|
|||
Map<String, dynamic> toJson() {
|
||||
var result = <String, dynamic>{};
|
||||
result['included'] = included;
|
||||
if (inTestMode != null) {
|
||||
result['inTestMode'] = inTestMode;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -7375,7 +7405,8 @@ class EditBulkFixesParams implements RequestParams {
|
|||
bool operator ==(other) {
|
||||
if (other is EditBulkFixesParams) {
|
||||
return listEqual(
|
||||
included, other.included, (String a, String b) => a == b);
|
||||
included, other.included, (String a, String b) => a == b) &&
|
||||
inTestMode == other.inTestMode;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -7384,6 +7415,7 @@ class EditBulkFixesParams implements RequestParams {
|
|||
int get hashCode {
|
||||
var hash = 0;
|
||||
hash = JenkinsSmiHash.combine(hash, included.hashCode);
|
||||
hash = JenkinsSmiHash.combine(hash, inTestMode.hashCode);
|
||||
return JenkinsSmiHash.finish(hash);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue