Skip to content

Commit

Permalink
Remove dartfix dependencies on analysis server
Browse files Browse the repository at this point in the history
This replaces dartfix dependencies on ...
* analysis_server
* analyzer (except for testing)
* analyzer_plugins

... with a dependency on analysis_server_client.

Change-Id: If511de69333e925ae082fa06c5114188c3c405b1
Reviewed-on: https://dart-review.googlesource.com/c/81342
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
  • Loading branch information
Dan Rubel authored and commit-bot@chromium.org committed Oct 24, 2018
1 parent 8a5405f commit b8fd29e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
2 changes: 2 additions & 0 deletions pkg/analysis_server_client/lib/protocol.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
5 changes: 1 addition & 4 deletions pkg/dartfix/lib/src/driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
19 changes: 14 additions & 5 deletions pkg/dartfix/lib/src/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -14,7 +15,7 @@ class Options {
Logger logger;

List<String> targets;
String sdkPath;
final String sdkPath;
final bool force;
final bool overwrite;
final bool verbose;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)) {
Expand All @@ -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...] <directory paths>');
logger.stderr('');
Expand Down
7 changes: 2 additions & 5 deletions pkg/dartfix/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b8fd29e

Please sign in to comment.