From dd83ded1e9f0e670de0d6dbd8effd75ab15ea490 Mon Sep 17 00:00:00 2001
From: Brian Wilkerson
Date: Mon, 16 Sep 2019 22:51:21 +0000
Subject: [PATCH] Add output directory field to dartfix API
Change-Id: Ia2dc3e4d3a458f43e9f2b0c1a25418f10931920c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117442
Commit-Queue: Brian Wilkerson
Reviewed-by: Samuel Rawlins
---
.../lib/protocol/protocol_constants.dart | 1 +
.../lib/protocol/protocol_generated.dart | 40 +++++++++++++++++--
.../support/integration_test_methods.dart | 13 +++++-
.../support/protocol_matchers.dart | 4 +-
.../spec/generated/java/AnalysisServer.java | 6 ++-
pkg/analysis_server/tool/spec/spec_input.html | 10 +++++
.../lib/src/protocol/protocol_constants.dart | 1 +
.../lib/src/protocol/protocol_generated.dart | 40 +++++++++++++++++--
8 files changed, 105 insertions(+), 10 deletions(-)
diff --git a/pkg/analysis_server/lib/protocol/protocol_constants.dart b/pkg/analysis_server/lib/protocol/protocol_constants.dart
index 686011c5490..55a65710f94 100644
--- a/pkg/analysis_server/lib/protocol/protocol_constants.dart
+++ b/pkg/analysis_server/lib/protocol/protocol_constants.dart
@@ -172,6 +172,7 @@ const String EDIT_REQUEST_DARTFIX_INCLUDE_PEDANTIC_FIXES =
'includePedanticFixes';
const String EDIT_REQUEST_DARTFIX_INCLUDE_REQUIRED_FIXES =
'includeRequiredFixes';
+const String EDIT_REQUEST_DARTFIX_OUTPUT_DIR = 'outputDir';
const String EDIT_REQUEST_FORMAT = 'edit.format';
const String EDIT_REQUEST_FORMAT_FILE = 'file';
const String EDIT_REQUEST_FORMAT_LINE_LENGTH = 'lineLength';
diff --git a/pkg/analysis_server/lib/protocol/protocol_generated.dart b/pkg/analysis_server/lib/protocol/protocol_generated.dart
index 46ed75f63de..74a13446f5a 100644
--- a/pkg/analysis_server/lib/protocol/protocol_generated.dart
+++ b/pkg/analysis_server/lib/protocol/protocol_generated.dart
@@ -7964,6 +7964,7 @@ class DiagnosticGetServerPortResult implements ResponseResult {
* "includePedanticFixes": optional bool
* "includeRequiredFixes": optional bool
* "excludedFixes": optional List
+ * "outputDir": optional FilePath
* }
*
* Clients may not extend, implement or mix-in this class.
@@ -7979,6 +7980,8 @@ class EditDartfixParams implements RequestParams {
List _excludedFixes;
+ String _outputDir;
+
/**
* A list of the files and directories for which edits should be suggested.
*
@@ -8066,16 +8069,36 @@ class EditDartfixParams implements RequestParams {
this._excludedFixes = value;
}
+ /**
+ * The absolute and normalized path to a directory to which non-nullability
+ * migration output will be written. The output is only produced if the
+ * non-nullable fix is included. Files in the directory might be overwritten,
+ * but no previously existing files will be deleted.
+ */
+ String get outputDir => _outputDir;
+
+ /**
+ * The absolute and normalized path to a directory to which non-nullability
+ * migration output will be written. The output is only produced if the
+ * non-nullable fix is included. Files in the directory might be overwritten,
+ * but no previously existing files will be deleted.
+ */
+ void set outputDir(String value) {
+ this._outputDir = value;
+ }
+
EditDartfixParams(List included,
{List includedFixes,
bool includePedanticFixes,
bool includeRequiredFixes,
- List excludedFixes}) {
+ List excludedFixes,
+ String outputDir}) {
this.included = included;
this.includedFixes = includedFixes;
this.includePedanticFixes = includePedanticFixes;
this.includeRequiredFixes = includeRequiredFixes;
this.excludedFixes = excludedFixes;
+ this.outputDir = outputDir;
}
factory EditDartfixParams.fromJson(
@@ -8111,11 +8134,17 @@ class EditDartfixParams implements RequestParams {
excludedFixes = jsonDecoder.decodeList(jsonPath + ".excludedFixes",
json["excludedFixes"], jsonDecoder.decodeString);
}
+ String outputDir;
+ if (json.containsKey("outputDir")) {
+ outputDir = jsonDecoder.decodeString(
+ jsonPath + ".outputDir", json["outputDir"]);
+ }
return new EditDartfixParams(included,
includedFixes: includedFixes,
includePedanticFixes: includePedanticFixes,
includeRequiredFixes: includeRequiredFixes,
- excludedFixes: excludedFixes);
+ excludedFixes: excludedFixes,
+ outputDir: outputDir);
} else {
throw jsonDecoder.mismatch(jsonPath, "edit.dartfix params", json);
}
@@ -8142,6 +8171,9 @@ class EditDartfixParams implements RequestParams {
if (excludedFixes != null) {
result["excludedFixes"] = excludedFixes;
}
+ if (outputDir != null) {
+ result["outputDir"] = outputDir;
+ }
return result;
}
@@ -8163,7 +8195,8 @@ class EditDartfixParams implements RequestParams {
includePedanticFixes == other.includePedanticFixes &&
includeRequiredFixes == other.includeRequiredFixes &&
listEqual(excludedFixes, other.excludedFixes,
- (String a, String b) => a == b);
+ (String a, String b) => a == b) &&
+ outputDir == other.outputDir;
}
return false;
}
@@ -8176,6 +8209,7 @@ class EditDartfixParams implements RequestParams {
hash = JenkinsSmiHash.combine(hash, includePedanticFixes.hashCode);
hash = JenkinsSmiHash.combine(hash, includeRequiredFixes.hashCode);
hash = JenkinsSmiHash.combine(hash, excludedFixes.hashCode);
+ hash = JenkinsSmiHash.combine(hash, outputDir.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 1440fe362c2..1425c1d9ace 100644
--- a/pkg/analysis_server/test/integration/support/integration_test_methods.dart
+++ b/pkg/analysis_server/test/integration/support/integration_test_methods.dart
@@ -1773,6 +1773,13 @@ abstract class IntegrationTestMixin {
* If a name is specified that does not match the name of a known fix, an
* error of type UNKNOWN_FIX will be generated.
*
+ * outputDir: FilePath (optional)
+ *
+ * The absolute and normalized path to a directory to which non-nullability
+ * migration output will be written. The output is only produced if the
+ * non-nullable fix is included. Files in the directory might be
+ * overwritten, but no previously existing files will be deleted.
+ *
* Returns
*
* suggestions: List
@@ -1806,12 +1813,14 @@ abstract class IntegrationTestMixin {
{List includedFixes,
bool includePedanticFixes,
bool includeRequiredFixes,
- List excludedFixes}) async {
+ List excludedFixes,
+ String outputDir}) async {
var params = new EditDartfixParams(included,
includedFixes: includedFixes,
includePedanticFixes: includePedanticFixes,
includeRequiredFixes: includeRequiredFixes,
- excludedFixes: excludedFixes)
+ excludedFixes: excludedFixes,
+ outputDir: outputDir)
.toJson();
var result = await server.send("edit.dartfix", params);
ResponseDecoder decoder = new ResponseDecoder(null);
diff --git a/pkg/analysis_server/test/integration/support/protocol_matchers.dart b/pkg/analysis_server/test/integration/support/protocol_matchers.dart
index 61edec11849..4fd9c457577 100644
--- a/pkg/analysis_server/test/integration/support/protocol_matchers.dart
+++ b/pkg/analysis_server/test/integration/support/protocol_matchers.dart
@@ -2561,6 +2561,7 @@ final Matcher isDiagnosticGetServerPortResult = new LazyMatcher(() =>
* "includePedanticFixes": optional bool
* "includeRequiredFixes": optional bool
* "excludedFixes": optional List
+ * "outputDir": optional FilePath
* }
*/
final Matcher isEditDartfixParams =
@@ -2570,7 +2571,8 @@ final Matcher isEditDartfixParams =
"includedFixes": isListOf(isString),
"includePedanticFixes": isBool,
"includeRequiredFixes": isBool,
- "excludedFixes": isListOf(isString)
+ "excludedFixes": isListOf(isString),
+ "outputDir": isFilePath
}));
/**
diff --git a/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java b/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java
index 4132f314059..f4e31708938 100644
--- a/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java
+++ b/pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java
@@ -498,8 +498,12 @@ public interface AnalysisServer {
* @param excludedFixes A list of names indicating which fixes should not be applied. If a name is
* specified that does not match the name of a known fix, an error of type UNKNOWN_FIX will
* be generated.
+ * @param outputDir The absolute and normalized path to a directory to which non-nullability
+ * migration output will be written. The output is only produced if the non-nullable fix is
+ * included. Files in the directory might be overwritten, but no previously existing files
+ * will be deleted.
*/
- public void edit_dartfix(List included, List includedFixes, boolean includePedanticFixes, boolean includeRequiredFixes, List excludedFixes, DartfixConsumer consumer);
+ public void edit_dartfix(List included, List includedFixes, boolean includePedanticFixes, boolean includeRequiredFixes, List excludedFixes, String outputDir, DartfixConsumer consumer);
/**
* {@code edit.format}
diff --git a/pkg/analysis_server/tool/spec/spec_input.html b/pkg/analysis_server/tool/spec/spec_input.html
index 712bdc46d27..f74c90d2cc3 100644
--- a/pkg/analysis_server/tool/spec/spec_input.html
+++ b/pkg/analysis_server/tool/spec/spec_input.html
@@ -2235,6 +2235,16 @@
an error of type UNKNOWN_FIX will be generated.
+
+ [FilePath]
+
+ The absolute and normalized path to a directory to which
+ non-nullability migration output will be written. The output is only
+ produced if the non-nullable fix is included. Files in the directory
+ might be overwritten, but no previously existing files will be
+ deleted.
+
+
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 686011c5490..55a65710f94 100644
--- a/pkg/analysis_server_client/lib/src/protocol/protocol_constants.dart
+++ b/pkg/analysis_server_client/lib/src/protocol/protocol_constants.dart
@@ -172,6 +172,7 @@ const String EDIT_REQUEST_DARTFIX_INCLUDE_PEDANTIC_FIXES =
'includePedanticFixes';
const String EDIT_REQUEST_DARTFIX_INCLUDE_REQUIRED_FIXES =
'includeRequiredFixes';
+const String EDIT_REQUEST_DARTFIX_OUTPUT_DIR = 'outputDir';
const String EDIT_REQUEST_FORMAT = 'edit.format';
const String EDIT_REQUEST_FORMAT_FILE = 'file';
const String EDIT_REQUEST_FORMAT_LINE_LENGTH = 'lineLength';
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 d0c24a3c1e0..e0495b8a5b1 100644
--- a/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart
+++ b/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart
@@ -7964,6 +7964,7 @@ class DiagnosticGetServerPortResult implements ResponseResult {
* "includePedanticFixes": optional bool
* "includeRequiredFixes": optional bool
* "excludedFixes": optional List
+ * "outputDir": optional FilePath
* }
*
* Clients may not extend, implement or mix-in this class.
@@ -7979,6 +7980,8 @@ class EditDartfixParams implements RequestParams {
List _excludedFixes;
+ String _outputDir;
+
/**
* A list of the files and directories for which edits should be suggested.
*
@@ -8066,16 +8069,36 @@ class EditDartfixParams implements RequestParams {
this._excludedFixes = value;
}
+ /**
+ * The absolute and normalized path to a directory to which non-nullability
+ * migration output will be written. The output is only produced if the
+ * non-nullable fix is included. Files in the directory might be overwritten,
+ * but no previously existing files will be deleted.
+ */
+ String get outputDir => _outputDir;
+
+ /**
+ * The absolute and normalized path to a directory to which non-nullability
+ * migration output will be written. The output is only produced if the
+ * non-nullable fix is included. Files in the directory might be overwritten,
+ * but no previously existing files will be deleted.
+ */
+ void set outputDir(String value) {
+ this._outputDir = value;
+ }
+
EditDartfixParams(List included,
{List includedFixes,
bool includePedanticFixes,
bool includeRequiredFixes,
- List excludedFixes}) {
+ List excludedFixes,
+ String outputDir}) {
this.included = included;
this.includedFixes = includedFixes;
this.includePedanticFixes = includePedanticFixes;
this.includeRequiredFixes = includeRequiredFixes;
this.excludedFixes = excludedFixes;
+ this.outputDir = outputDir;
}
factory EditDartfixParams.fromJson(
@@ -8111,11 +8134,17 @@ class EditDartfixParams implements RequestParams {
excludedFixes = jsonDecoder.decodeList(jsonPath + ".excludedFixes",
json["excludedFixes"], jsonDecoder.decodeString);
}
+ String outputDir;
+ if (json.containsKey("outputDir")) {
+ outputDir = jsonDecoder.decodeString(
+ jsonPath + ".outputDir", json["outputDir"]);
+ }
return new EditDartfixParams(included,
includedFixes: includedFixes,
includePedanticFixes: includePedanticFixes,
includeRequiredFixes: includeRequiredFixes,
- excludedFixes: excludedFixes);
+ excludedFixes: excludedFixes,
+ outputDir: outputDir);
} else {
throw jsonDecoder.mismatch(jsonPath, "edit.dartfix params", json);
}
@@ -8142,6 +8171,9 @@ class EditDartfixParams implements RequestParams {
if (excludedFixes != null) {
result["excludedFixes"] = excludedFixes;
}
+ if (outputDir != null) {
+ result["outputDir"] = outputDir;
+ }
return result;
}
@@ -8163,7 +8195,8 @@ class EditDartfixParams implements RequestParams {
includePedanticFixes == other.includePedanticFixes &&
includeRequiredFixes == other.includeRequiredFixes &&
listEqual(excludedFixes, other.excludedFixes,
- (String a, String b) => a == b);
+ (String a, String b) => a == b) &&
+ outputDir == other.outputDir;
}
return false;
}
@@ -8176,6 +8209,7 @@ class EditDartfixParams implements RequestParams {
hash = JenkinsSmiHash.combine(hash, includePedanticFixes.hashCode);
hash = JenkinsSmiHash.combine(hash, includeRequiredFixes.hashCode);
hash = JenkinsSmiHash.combine(hash, excludedFixes.hashCode);
+ hash = JenkinsSmiHash.combine(hash, outputDir.hashCode);
return JenkinsSmiHash.finish(hash);
}
}