| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer_cli.src.options; | 5 library analyzer_cli.src.options; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:analyzer_cli/src/driver.dart'; | 9 import 'package:analyzer_cli/src/driver.dart'; |
| 10 import 'package:args/args.dart'; | 10 import 'package:args/args.dart'; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 if (sdkDir != null) { | 139 if (sdkDir != null) { |
| 140 options.dartSdkPath = sdkDir.path; | 140 options.dartSdkPath = sdkDir.path; |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 var sdkPath = options.dartSdkPath; | 144 var sdkPath = options.dartSdkPath; |
| 145 | 145 |
| 146 // Check that SDK is specified. | 146 // Check that SDK is specified. |
| 147 if (sdkPath == null) { | 147 if (sdkPath == null) { |
| 148 printAndFail('No Dart SDK found.'); | 148 printAndFail('No Dart SDK found.'); |
| 149 return null; // Only reachable in testing. |
| 149 } | 150 } |
| 150 // Check that SDK is existing directory. | 151 // Check that SDK is existing directory. |
| 151 if (!(new Directory(sdkPath)).existsSync()) { | 152 if (!(new Directory(sdkPath)).existsSync()) { |
| 152 printAndFail('Invalid Dart SDK path: $sdkPath'); | 153 printAndFail('Invalid Dart SDK path: $sdkPath'); |
| 154 return null; // Only reachable in testing. |
| 153 } | 155 } |
| 154 } | 156 } |
| 155 | 157 |
| 156 // Check package config. | 158 // Check package config. |
| 157 { | 159 { |
| 158 if (options.packageRootPath != null && | 160 if (options.packageRootPath != null && |
| 159 options.packageConfigPath != null) { | 161 options.packageConfigPath != null) { |
| 160 printAndFail("Cannot specify both '--package-root' and '--packages."); | 162 printAndFail("Cannot specify both '--package-root' and '--packages."); |
| 163 return null; // Only reachable in testing. |
| 161 } | 164 } |
| 162 } | 165 } |
| 163 | 166 |
| 164 // OK. Report deprecated options. | 167 // OK. Report deprecated options. |
| 165 if (options.enableNullAwareOperators) { | 168 if (options.enableNullAwareOperators) { |
| 166 errorSink.writeln( | 169 errorSink.writeln( |
| 167 "Info: Option '--enable-null-aware-operators' is no longer needed. " | 170 "Info: Option '--enable-null-aware-operators' is no longer needed. " |
| 168 "Null aware operators are supported by default."); | 171 "Null aware operators are supported by default."); |
| 169 } | 172 } |
| 170 | 173 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 | 487 |
| 485 int _getNextFlagIndex(args, i) { | 488 int _getNextFlagIndex(args, i) { |
| 486 for (; i < args.length; ++i) { | 489 for (; i < args.length; ++i) { |
| 487 if (args[i].startsWith('--')) { | 490 if (args[i].startsWith('--')) { |
| 488 return i; | 491 return i; |
| 489 } | 492 } |
| 490 } | 493 } |
| 491 return i; | 494 return i; |
| 492 } | 495 } |
| 493 } | 496 } |
| OLD | NEW |