diff --git a/pkg/analysis_server_client/lib/protocol.dart b/pkg/analysis_server_client/lib/protocol.dart index 197e49ce8b015..ca508e8bea831 100644 --- a/pkg/analysis_server_client/lib/protocol.dart +++ b/pkg/analysis_server_client/lib/protocol.dart @@ -5,4 +5,6 @@ export 'package:analysis_server_client/src/protocol/protocol_base.dart'; export 'package:analysis_server_client/src/protocol/protocol_common.dart'; export 'package:analysis_server_client/src/protocol/protocol_constants.dart'; +export 'package:analysis_server_client/src/protocol/protocol_internal.dart' + show ResponseDecoder; export 'package:analysis_server_client/src/protocol/protocol_generated.dart'; diff --git a/pkg/dartfix/lib/src/driver.dart b/pkg/dartfix/lib/src/driver.dart index 8e0706e749255..80b6c11d10599 100644 --- a/pkg/dartfix/lib/src/driver.dart +++ b/pkg/dartfix/lib/src/driver.dart @@ -5,10 +5,7 @@ import 'dart:async'; import 'dart:io' show File, Directory; -import 'package:analysis_server/protocol/protocol_constants.dart'; -import 'package:analysis_server/protocol/protocol_generated.dart'; -import 'package:analysis_server/src/protocol/protocol_internal.dart'; -import 'package:analyzer_plugin/protocol/protocol_common.dart'; +import 'package:analysis_server_client/protocol.dart'; import 'package:cli_util/cli_logging.dart'; import 'package:dartfix/src/context.dart'; import 'package:dartfix/src/options.dart'; diff --git a/pkg/dartfix/lib/src/options.dart b/pkg/dartfix/lib/src/options.dart index 70af515ccd42e..bd510252011a5 100644 --- a/pkg/dartfix/lib/src/options.dart +++ b/pkg/dartfix/lib/src/options.dart @@ -2,7 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:analyzer/src/util/sdk.dart'; +import 'dart:io'; + import 'package:dartfix/src/context.dart'; import 'package:args/args.dart'; import 'package:cli_util/cli_logging.dart'; @@ -14,7 +15,7 @@ class Options { Logger logger; List targets; - String sdkPath; + final String sdkPath; final bool force; final bool overwrite; final bool verbose; @@ -79,15 +80,16 @@ class Options { context.exit(1); } - // Infer the Dart SDK location - options.sdkPath = getSdkPath(args); + // Validate the Dart SDK location String sdkPath = options.sdkPath; if (sdkPath == null) { logger.stderr('No Dart SDK found.'); _showUsage(parser, logger); + context.exit(15); } if (!context.exists(sdkPath)) { logger.stderr('Invalid Dart SDK path: $sdkPath'); + _showUsage(parser, logger); context.exit(15); } @@ -128,7 +130,8 @@ class Options { force = results[forceOption] as bool, overwrite = results[overwriteOption] as bool, verbose = results[_verboseOption] as bool, - useColor = results.wasParsed('color') ? results['color'] as bool : null; + useColor = results.wasParsed('color') ? results['color'] as bool : null, + sdkPath = _getSdkPath(); String makeAbsoluteAndNormalize(String target) { if (!path.isAbsolute(target)) { @@ -137,6 +140,12 @@ class Options { return path.normalize(target); } + static String _getSdkPath() { + return Platform.environment['DART_SDK'] != null + ? Platform.environment['DART_SDK'] + : path.dirname(path.dirname(Platform.resolvedExecutable)); + } + static _showUsage(ArgParser parser, Logger logger) { logger.stderr('Usage: $_binaryName [options...] '); logger.stderr(''); diff --git a/pkg/dartfix/pubspec.yaml b/pkg/dartfix/pubspec.yaml index e14ae2f2445c4..2349956bf0d4f 100644 --- a/pkg/dartfix/pubspec.yaml +++ b/pkg/dartfix/pubspec.yaml @@ -7,13 +7,10 @@ description: environment: sdk: '>=2.0.0 <3.0.0' dependencies: - #TODO(danrubel) depend upon analysis_server_client rather than analysis_server - # once analysis_server_client has been updated. - analysis_server: any - analyzer: ^0.33.0 - analyzer_plugin: any + analysis_server_client: ^2.0.0 args: any cli_util: any path: any dev_dependencies: + analyzer: ^0.33.0 test: ^1.3.0