revise dartfix protocol version check
Change-Id: I655773791189dd5cf133ade8a48ed39ff48b6345
Reviewed-on: https://dart-review.googlesource.com/c/89402
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/dartfix/CHANGELOG.md b/pkg/dartfix/CHANGELOG.md
index 6fcede0..9ba3827 100644
--- a/pkg/dartfix/CHANGELOG.md
+++ b/pkg/dartfix/CHANGELOG.md
@@ -1,3 +1,6 @@
+# 0.1.4
+ * update protocol version constraints
+
# 0.1.3
* update SDK constraints
diff --git a/pkg/dartfix/lib/src/driver.dart b/pkg/dartfix/lib/src/driver.dart
index 1ccc556..7881d73 100644
--- a/pkg/dartfix/lib/src/driver.dart
+++ b/pkg/dartfix/lib/src/driver.dart
@@ -19,8 +19,6 @@
import 'package:pub_semver/pub_semver.dart';
class Driver {
- static final expectedProtocolVersion = new Version.parse('1.21.1');
-
Context context;
_Handler handler;
Logger logger;
@@ -219,9 +217,10 @@
@override
void onProtocolNotSupported(Version version) {
- logger.stderr('Expected protocol version ${Driver.expectedProtocolVersion},'
+ logger.stderr('Expected protocol version $PROTOCOL_VERSION,'
' but found $version');
- if (version > Driver.expectedProtocolVersion) {
+ final expectedVersion = Version.parse(PROTOCOL_VERSION);
+ if (version > expectedVersion) {
logger.stdout('''
This version of dartfix is incompatible with the current Dart SDK.
Try installing a newer version of dartfix by running
@@ -240,14 +239,6 @@
}
@override
- bool checkServerProtocolVersion(Version version) {
- // This overrides the default protocol version check to be more narrow
- // because the edit.dartfix protocol is experimental
- // and will continue to evolve.
- return version == Driver.expectedProtocolVersion;
- }
-
- @override
void onServerError(ServerErrorParams params) {
if (params.isFatal) {
logger.stderr('Fatal Server Error: ${params.message}');
diff --git a/pkg/dartfix/test/src/driver_test.dart b/pkg/dartfix/test/src/driver_test.dart
index 1aa5493..5801b0d 100644
--- a/pkg/dartfix/test/src/driver_test.dart
+++ b/pkg/dartfix/test/src/driver_test.dart
@@ -6,7 +6,6 @@
import 'package:analysis_server_client/protocol.dart';
import 'package:dartfix/src/driver.dart';
-import 'package:pub_semver/pub_semver.dart';
import 'package:test/test.dart';
import 'test_context.dart';
@@ -25,14 +24,6 @@
exampleDir = exampleFile.parent;
});
- test('protocol version', () {
- // The edit.dartfix protocol is experimental and will continue to evolve
- // an so dartfix will only work with this specific version of the protocol.
- // If the protocol changes, then a new version of both the
- // analysis_server_client and dartfix packages must be published.
- expect(new Version.parse(PROTOCOL_VERSION), Driver.expectedProtocolVersion);
- });
-
test('client version', () {
// The edit.dartfix protocol is experimental and will continue to evolve
// an so dartfix will only work with this specific version of the
diff --git a/pkg/dartfix/test/src/test_context.dart b/pkg/dartfix/test/src/test_context.dart
index 61faf26..63d9357 100644
--- a/pkg/dartfix/test/src/test_context.dart
+++ b/pkg/dartfix/test/src/test_context.dart
@@ -26,6 +26,9 @@
final int code;
TestExit(this.code);
+
+ @override
+ String toString() => 'TestExit($code)';
}
class TestLogger implements Logger {