| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.src.generated.sdk; | 5 library analyzer.src.generated.sdk; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
| 11 import 'package:analyzer/src/generated/engine.dart' | 11 import 'package:analyzer/src/generated/engine.dart' |
| 12 show AnalysisContext, AnalysisOptions; | 12 show AnalysisContext, AnalysisOptions, AnalysisOptionsImpl; |
| 13 import 'package:analyzer/src/generated/source.dart' show Source; | 13 import 'package:analyzer/src/generated/source.dart' show Source; |
| 14 import 'package:analyzer/src/generated/utilities_general.dart'; | 14 import 'package:analyzer/src/generated/utilities_general.dart'; |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * A function used to create a new DartSdk with the given [options]. If the | 17 * A function used to create a new DartSdk with the given [options]. If the |
| 18 * passed [options] are `null`, then default options are used. | 18 * passed [options] are `null`, then default options are used. |
| 19 */ | 19 */ |
| 20 typedef DartSdk SdkCreator(AnalysisOptions options); | 20 typedef DartSdk SdkCreator(AnalysisOptions options); |
| 21 | 21 |
| 22 /** | 22 /** |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 * created. | 129 * created. |
| 130 */ | 130 */ |
| 131 DartSdk get anySdk { | 131 DartSdk get anySdk { |
| 132 if (sdkMap.isEmpty) { | 132 if (sdkMap.isEmpty) { |
| 133 return null; | 133 return null; |
| 134 } | 134 } |
| 135 return sdkMap.values.first; | 135 return sdkMap.values.first; |
| 136 } | 136 } |
| 137 | 137 |
| 138 /** | 138 /** |
| 139 * Return a list of the descriptors of the SDKs that are currently being |
| 140 * managed. |
| 141 */ |
| 142 List<SdkDescription> get sdkDescriptors => sdkMap.keys.toList(); |
| 143 |
| 144 /** |
| 139 * Return the Dart SDK that is appropriate for the given analysis [options]. | 145 * Return the Dart SDK that is appropriate for the given analysis [options]. |
| 140 * If such an SDK has not yet been created, then the [sdkCreator] will be | 146 * If such an SDK has not yet been created, then the [sdkCreator] will be |
| 141 * invoked to create it. | 147 * invoked to create it. |
| 142 */ | 148 */ |
| 143 DartSdk getSdk(SdkDescription description, DartSdk ifAbsent()) { | 149 DartSdk getSdk(SdkDescription description, DartSdk ifAbsent()) { |
| 144 return sdkMap.putIfAbsent(description, ifAbsent); | 150 return sdkMap.putIfAbsent(description, ifAbsent); |
| 145 } | 151 } |
| 146 | 152 |
| 147 /** | 153 /** |
| 148 * Return the Dart SDK that is appropriate for the given analysis [options]. | 154 * Return the Dart SDK that is appropriate for the given analysis [options]. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 246 } |
| 241 for (int i = 0; i < length; i++) { | 247 for (int i = 0; i < length; i++) { |
| 242 if (other.paths[i] != paths[i]) { | 248 if (other.paths[i] != paths[i]) { |
| 243 return false; | 249 return false; |
| 244 } | 250 } |
| 245 } | 251 } |
| 246 return true; | 252 return true; |
| 247 } | 253 } |
| 248 return false; | 254 return false; |
| 249 } | 255 } |
| 256 |
| 257 @override |
| 258 String toString() { |
| 259 StringBuffer buffer = new StringBuffer(); |
| 260 bool needsSeparator = false; |
| 261 void add(String optionName) { |
| 262 if (needsSeparator) { |
| 263 buffer.write(', '); |
| 264 } |
| 265 buffer.write(optionName); |
| 266 needsSeparator = true; |
| 267 } |
| 268 for (String path in paths) { |
| 269 add(path); |
| 270 } |
| 271 if (needsSeparator) { |
| 272 buffer.write(' '); |
| 273 } |
| 274 buffer.write('('); |
| 275 buffer.write(AnalysisOptionsImpl |
| 276 .decodeCrossContextOptions(options.encodeCrossContextOptions())); |
| 277 buffer.write(')'); |
| 278 return buffer.toString(); |
| 279 } |
| 250 } | 280 } |
| 251 | 281 |
| 252 class SdkLibrariesReader_LibraryBuilder extends RecursiveAstVisitor<Object> { | 282 class SdkLibrariesReader_LibraryBuilder extends RecursiveAstVisitor<Object> { |
| 253 /** | 283 /** |
| 254 * The prefix added to the name of a library to form the URI used in code to | 284 * The prefix added to the name of a library to form the URI used in code to |
| 255 * reference the library. | 285 * reference the library. |
| 256 */ | 286 */ |
| 257 static String _LIBRARY_PREFIX = "dart:"; | 287 static String _LIBRARY_PREFIX = "dart:"; |
| 258 | 288 |
| 259 /** | 289 /** |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 _platforms |= DART2JS_PLATFORM; | 549 _platforms |= DART2JS_PLATFORM; |
| 520 } | 550 } |
| 521 | 551 |
| 522 /** | 552 /** |
| 523 * Record that this library can be run on the VM. | 553 * Record that this library can be run on the VM. |
| 524 */ | 554 */ |
| 525 void setVmLibrary() { | 555 void setVmLibrary() { |
| 526 _platforms |= VM_PLATFORM; | 556 _platforms |= VM_PLATFORM; |
| 527 } | 557 } |
| 528 } | 558 } |
| OLD | NEW |