Chromium Code Reviews| Index: lib/src/dart_sdk.dart |
| diff --git a/lib/src/dart_sdk.dart b/lib/src/dart_sdk.dart |
| index 339d4576dc5180f892ddb654a6c64a87277e47f7..6155f8676b0b61b13208e5ce2b2ff2bd0c530407 100644 |
| --- a/lib/src/dart_sdk.dart |
| +++ b/lib/src/dart_sdk.dart |
| @@ -5,13 +5,14 @@ |
| library code_transformers.src.dart_sdk; |
| import 'dart:convert' as convert; |
| -import 'dart:io' show File, Link, Platform, Process; |
| +import 'dart:io' show Directory, File, Link, Platform, Process; |
|
jakemac
2015/02/05 23:22:22
Looks like only Directory is needed any more here.
pquitslund
2015/02/05 23:36:48
Check! Cleaned up imports. I left the Directory
|
| import 'package:path/path.dart' as path; |
| import 'package:analyzer/src/generated/engine.dart'; |
| import 'package:analyzer/src/generated/java_io.dart'; |
| import 'package:analyzer/src/generated/sdk.dart'; |
| import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; |
| import 'package:analyzer/src/generated/source.dart'; |
| +import 'package:cli_util/cli_util.dart' as cli_util; |
| /// Attempts to provide the current Dart SDK directory. |
| @@ -20,43 +21,8 @@ import 'package:analyzer/src/generated/source.dart'; |
| /// |
| /// Note that this may not be correct when executing outside of `pub`. |
| String get dartSdkDirectory { |
| - |
| - bool isSdkDir(String dirname) => |
| - new File(path.join(dirname, 'lib', '_internal', 'libraries.dart')) |
| - .existsSync(); |
| - |
| - String executable = Platform.executable; |
| - if (path.split(executable).length == 1) { |
| - // TODO(blois): make this cross-platform. |
| - // HACK: A single part, hope it's on the path. |
| - executable = Process.runSync('which', ['dart'], |
| - stdoutEncoding: convert.UTF8).stdout.trim(); |
| - // In case Dart is symlinked (e.g. homebrew on Mac) follow symbolic links. |
| - var link = new Link(executable); |
| - if (link.existsSync()) { |
| - executable = link.resolveSymbolicLinksSync(); |
| - } |
| - var sdkDir = path.dirname(path.dirname(executable)); |
| - if (isSdkDir(sdkDir)) return sdkDir; |
| - } |
| - |
| - var dartDir = path.dirname(path.absolute(executable)); |
| - // If there's a sub-dir named dart-sdk then we're most likely executing from |
| - // a dart enlistment build directory. |
| - if (isSdkDir(path.join(dartDir, 'dart-sdk'))) { |
| - return path.join(dartDir, 'dart-sdk'); |
| - } |
| - // If we can find libraries.dart then it's the root of the SDK. |
| - if (isSdkDir(dartDir)) return dartDir; |
| - |
| - var parts = path.split(dartDir); |
| - // If the dart executable is within the sdk dir then get the root. |
| - if (parts.contains('dart-sdk')) { |
| - var dartSdkDir = path.joinAll(parts.take(parts.indexOf('dart-sdk') + 1)); |
| - if (isSdkDir(dartSdkDir)) return dartSdkDir; |
| - } |
| - |
| - return null; |
| + Directory sdkDir = cli_util.getSdkDir(); |
| + return sdkDir != null ? sdkDir.path : null; |
| } |
| /// Sources that are annotated with a source uri, so it is easy to resolve how |