| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 |
| 3 library engine.sdk.io; | 4 library engine.sdk.io; |
| 5 |
| 4 import 'java_core.dart'; | 6 import 'java_core.dart'; |
| 5 import 'java_io.dart'; | 7 import 'java_io.dart'; |
| 6 import 'java_engine_io.dart'; | 8 import 'java_engine_io.dart'; |
| 7 import 'source_io.dart'; | 9 import 'source_io.dart'; |
| 8 import 'error.dart'; | 10 import 'error.dart'; |
| 9 import 'scanner.dart'; | 11 import 'scanner.dart'; |
| 10 import 'ast.dart'; | 12 import 'ast.dart'; |
| 11 import 'parser.dart'; | 13 import 'parser.dart'; |
| 12 import 'sdk.dart'; | 14 import 'sdk.dart'; |
| 13 import 'engine.dart'; | 15 import 'engine.dart'; |
| 16 |
| 14 /** | 17 /** |
| 15 * Instances of the class `DirectoryBasedDartSdk` represent a Dart SDK installed
in a | 18 * Instances of the class `DirectoryBasedDartSdk` represent a Dart SDK installed
in a |
| 16 * specified directory. | 19 * specified directory. |
| 17 * | 20 * |
| 18 * @coverage dart.engine.sdk | 21 * @coverage dart.engine.sdk |
| 19 */ | 22 */ |
| 20 class DirectoryBasedDartSdk implements DartSdk { | 23 class DirectoryBasedDartSdk implements DartSdk { |
| 21 | |
| 22 /** | 24 /** |
| 23 * The [AnalysisContext] which is used for all of the sources in this [DartSdk
]. | 25 * The [AnalysisContext] which is used for all of the sources in this [DartSdk
]. |
| 24 */ | 26 */ |
| 25 InternalAnalysisContext _analysisContext; | 27 InternalAnalysisContext _analysisContext; |
| 26 | 28 |
| 27 /** | 29 /** |
| 28 * The directory containing the SDK. | 30 * The directory containing the SDK. |
| 29 */ | 31 */ |
| 30 JavaFile directory; | 32 JavaFile directory; |
| 31 | 33 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 initializeLibraryMap(); | 224 initializeLibraryMap(); |
| 223 _analysisContext = new AnalysisContextImpl(); | 225 _analysisContext = new AnalysisContextImpl(); |
| 224 _analysisContext.sourceFactory = new SourceFactory.con2([new DartUriResolver
(this)]); | 226 _analysisContext.sourceFactory = new SourceFactory.con2([new DartUriResolver
(this)]); |
| 225 List<String> uris = this.uris; | 227 List<String> uris = this.uris; |
| 226 ChangeSet changeSet = new ChangeSet(); | 228 ChangeSet changeSet = new ChangeSet(); |
| 227 for (String uri in uris) { | 229 for (String uri in uris) { |
| 228 changeSet.added(_analysisContext.sourceFactory.forUri(uri)); | 230 changeSet.added(_analysisContext.sourceFactory.forUri(uri)); |
| 229 } | 231 } |
| 230 _analysisContext.applyChanges(changeSet); | 232 _analysisContext.applyChanges(changeSet); |
| 231 } | 233 } |
| 234 |
| 232 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) => new F
ileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), kind); | 235 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) => new F
ileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), kind); |
| 236 |
| 233 AnalysisContext get context => _analysisContext; | 237 AnalysisContext get context => _analysisContext; |
| 234 | 238 |
| 235 /** | 239 /** |
| 236 * Return the file containing the Dartium executable, or `null` if it does not
exist. | 240 * Return the file containing the Dartium executable, or `null` if it does not
exist. |
| 237 * | 241 * |
| 238 * @return the file containing the Dartium executable | 242 * @return the file containing the Dartium executable |
| 239 */ | 243 */ |
| 240 JavaFile get dartiumExecutable { | 244 JavaFile get dartiumExecutable { |
| 241 { | 245 { |
| 242 if (_dartiumExecutable == null) { | 246 if (_dartiumExecutable == null) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 /** | 299 /** |
| 296 * Return the file containing the Pub executable, or `null` if it does not exi
st. | 300 * Return the file containing the Pub executable, or `null` if it does not exi
st. |
| 297 * | 301 * |
| 298 * @return the file containing the Pub executable | 302 * @return the file containing the Pub executable |
| 299 */ | 303 */ |
| 300 JavaFile get pubExecutable { | 304 JavaFile get pubExecutable { |
| 301 String pubBinaryName = OSUtilities.isWindows() ? _PUB_EXECUTABLE_NAME_WIN :
_PUB_EXECUTABLE_NAME; | 305 String pubBinaryName = OSUtilities.isWindows() ? _PUB_EXECUTABLE_NAME_WIN :
_PUB_EXECUTABLE_NAME; |
| 302 JavaFile file = new JavaFile.relative(new JavaFile.relative(directory, _BIN_
DIRECTORY_NAME), pubBinaryName); | 306 JavaFile file = new JavaFile.relative(new JavaFile.relative(directory, _BIN_
DIRECTORY_NAME), pubBinaryName); |
| 303 return file.exists() ? file : null; | 307 return file.exists() ? file : null; |
| 304 } | 308 } |
| 309 |
| 305 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries; | 310 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries; |
| 311 |
| 306 SdkLibrary getSdkLibrary(String dartUri) => _libraryMap.getLibrary(dartUri); | 312 SdkLibrary getSdkLibrary(String dartUri) => _libraryMap.getLibrary(dartUri); |
| 307 | 313 |
| 308 /** | 314 /** |
| 309 * Return the revision number of this SDK, or `"0"` if the revision number can
not be | 315 * Return the revision number of this SDK, or `"0"` if the revision number can
not be |
| 310 * discovered. | 316 * discovered. |
| 311 * | 317 * |
| 312 * @return the revision number of this SDK | 318 * @return the revision number of this SDK |
| 313 */ | 319 */ |
| 314 String get sdkVersion { | 320 String get sdkVersion { |
| 315 { | 321 { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 * @return `true` if this installation of the SDK has documentation | 364 * @return `true` if this installation of the SDK has documentation |
| 359 */ | 365 */ |
| 360 bool hasDocumentation() => docDirectory.exists(); | 366 bool hasDocumentation() => docDirectory.exists(); |
| 361 | 367 |
| 362 /** | 368 /** |
| 363 * Return `true` if the Dartium binary is available. | 369 * Return `true` if the Dartium binary is available. |
| 364 * | 370 * |
| 365 * @return `true` if the Dartium binary is available | 371 * @return `true` if the Dartium binary is available |
| 366 */ | 372 */ |
| 367 bool get isDartiumInstalled => dartiumExecutable != null; | 373 bool get isDartiumInstalled => dartiumExecutable != null; |
| 374 |
| 368 Source mapDartUri(String dartUri) { | 375 Source mapDartUri(String dartUri) { |
| 369 SdkLibrary library = getSdkLibrary(dartUri); | 376 SdkLibrary library = getSdkLibrary(dartUri); |
| 370 if (library == null) { | 377 if (library == null) { |
| 371 return null; | 378 return null; |
| 372 } | 379 } |
| 373 return new FileBasedSource.con2(_analysisContext.sourceFactory.contentCache,
new JavaFile.relative(libraryDirectory, library.path), UriKind.DART_URI); | 380 return new FileBasedSource.con2(_analysisContext.sourceFactory.contentCache,
new JavaFile.relative(libraryDirectory, library.path), UriKind.DART_URI); |
| 374 } | 381 } |
| 375 | 382 |
| 376 /** | 383 /** |
| 377 * Ensure that the dart VM is executable. If it is not, make it executable and
log that it was | 384 * Ensure that the dart VM is executable. If it is not, make it executable and
log that it was |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 | 431 |
| 425 /** | 432 /** |
| 426 * Initialize the state of the SDK. | 433 * Initialize the state of the SDK. |
| 427 */ | 434 */ |
| 428 void initializeSdk() { | 435 void initializeSdk() { |
| 429 if (!OSUtilities.isWindows()) { | 436 if (!OSUtilities.isWindows()) { |
| 430 ensureVmIsExecutable(); | 437 ensureVmIsExecutable(); |
| 431 } | 438 } |
| 432 } | 439 } |
| 433 } | 440 } |
| 441 |
| 434 /** | 442 /** |
| 435 * Instances of the class `SdkLibrariesReader` read and parse the libraries file | 443 * Instances of the class `SdkLibrariesReader` read and parse the libraries file |
| 436 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries i
n an SDK. The | 444 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries i
n an SDK. The |
| 437 * library information is represented as a Dart file containing a single top-lev
el variable whose | 445 * library information is represented as a Dart file containing a single top-lev
el variable whose |
| 438 * value is a const map. The keys of the map are the names of libraries defined
in the SDK and the | 446 * value is a const map. The keys of the map are the names of libraries defined
in the SDK and the |
| 439 * values in the map are info objects defining the library. For example, a subse
t of a typical SDK | 447 * values in the map are info objects defining the library. For example, a subse
t of a typical SDK |
| 440 * might have a libraries file that looks like the following: | 448 * might have a libraries file that looks like the following: |
| 441 * | 449 * |
| 442 * <pre> | 450 * <pre> |
| 443 * final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> { | 451 * final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> { |
| 444 * // Used by VM applications | 452 * // Used by VM applications |
| 445 * "builtin" : const LibraryInfo( | 453 * "builtin" : const LibraryInfo( |
| 446 * "builtin/builtin_runtime.dart", | 454 * "builtin/builtin_runtime.dart", |
| 447 * category: "Server", | 455 * category: "Server", |
| 448 * platforms: VM_PLATFORM), | 456 * platforms: VM_PLATFORM), |
| 449 * | 457 * |
| 450 * "compiler" : const LibraryInfo( | 458 * "compiler" : const LibraryInfo( |
| 451 * "compiler/compiler.dart", | 459 * "compiler/compiler.dart", |
| 452 * category: "Tools", | 460 * category: "Tools", |
| 453 * platforms: 0), | 461 * platforms: 0), |
| 454 * }; | 462 * }; |
| 455 * </pre> | 463 * </pre> |
| 456 * | 464 * |
| 457 * @coverage dart.engine.sdk | 465 * @coverage dart.engine.sdk |
| 458 */ | 466 */ |
| 459 class SdkLibrariesReader { | 467 class SdkLibrariesReader { |
| 460 | |
| 461 /** | 468 /** |
| 462 * Return the library map read from the given source. | 469 * Return the library map read from the given source. |
| 463 * | 470 * |
| 464 * @return the library map read from the given source | 471 * @return the library map read from the given source |
| 465 */ | 472 */ |
| 466 LibraryMap readFrom(JavaFile librariesFile, String libraryFileContents) { | 473 LibraryMap readFrom(JavaFile librariesFile, String libraryFileContents) { |
| 467 List<bool> foundError = [false]; | 474 List<bool> foundError = [false]; |
| 468 AnalysisErrorListener errorListener = new AnalysisErrorListener_10(foundErro
r); | 475 AnalysisErrorListener errorListener = new AnalysisErrorListener_11(foundErro
r); |
| 469 Source source = new FileBasedSource.con2(null, librariesFile, UriKind.FILE_U
RI); | 476 Source source = new FileBasedSource.con2(null, librariesFile, UriKind.FILE_U
RI); |
| 470 Scanner scanner = new Scanner(source, new CharSequenceReader(new CharSequenc
e(libraryFileContents)), errorListener); | 477 Scanner scanner = new Scanner(source, new CharSequenceReader(new CharSequenc
e(libraryFileContents)), errorListener); |
| 471 Parser parser = new Parser(source, errorListener); | 478 Parser parser = new Parser(source, errorListener); |
| 472 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); | 479 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); |
| 473 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li
braryBuilder(); | 480 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li
braryBuilder(); |
| 474 if (!foundError[0]) { | 481 if (!foundError[0]) { |
| 475 unit.accept(libraryBuilder); | 482 unit.accept(libraryBuilder); |
| 476 } | 483 } |
| 477 return libraryBuilder.librariesMap; | 484 return libraryBuilder.librariesMap; |
| 478 } | 485 } |
| 479 } | 486 } |
| 487 |
| 480 class SdkLibrariesReader_LibraryBuilder extends RecursiveASTVisitor<Object> { | 488 class SdkLibrariesReader_LibraryBuilder extends RecursiveASTVisitor<Object> { |
| 481 | |
| 482 /** | 489 /** |
| 483 * The prefix added to the name of a library to form the URI used in code to r
eference the | 490 * The prefix added to the name of a library to form the URI used in code to r
eference the |
| 484 * library. | 491 * library. |
| 485 */ | 492 */ |
| 486 static String _LIBRARY_PREFIX = "dart:"; | 493 static String _LIBRARY_PREFIX = "dart:"; |
| 487 | 494 |
| 488 /** | 495 /** |
| 489 * The name of the optional parameter used to indicate whether the library is
an implementation | 496 * The name of the optional parameter used to indicate whether the library is
an implementation |
| 490 * library. | 497 * library. |
| 491 */ | 498 */ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 511 * The value of the [PLATFORMS] parameter used to specify that the library can | 518 * The value of the [PLATFORMS] parameter used to specify that the library can |
| 512 * be used on the VM. | 519 * be used on the VM. |
| 513 */ | 520 */ |
| 514 static String _VM_PLATFORM = "VM_PLATFORM"; | 521 static String _VM_PLATFORM = "VM_PLATFORM"; |
| 515 | 522 |
| 516 /** | 523 /** |
| 517 * The library map that is populated by visiting the AST structure parsed from
the contents of | 524 * The library map that is populated by visiting the AST structure parsed from
the contents of |
| 518 * the libraries file. | 525 * the libraries file. |
| 519 */ | 526 */ |
| 520 final LibraryMap librariesMap = new LibraryMap(); | 527 final LibraryMap librariesMap = new LibraryMap(); |
| 528 |
| 521 Object visitMapLiteralEntry(MapLiteralEntry node) { | 529 Object visitMapLiteralEntry(MapLiteralEntry node) { |
| 522 String libraryName = null; | 530 String libraryName = null; |
| 523 Expression key = node.key; | 531 Expression key = node.key; |
| 524 if (key is SimpleStringLiteral) { | 532 if (key is SimpleStringLiteral) { |
| 525 libraryName = "${_LIBRARY_PREFIX}${((key as SimpleStringLiteral)).value}"; | 533 libraryName = "${_LIBRARY_PREFIX}${(key as SimpleStringLiteral).value}"; |
| 526 } | 534 } |
| 527 Expression value = node.value; | 535 Expression value = node.value; |
| 528 if (value is InstanceCreationExpression) { | 536 if (value is InstanceCreationExpression) { |
| 529 SdkLibraryImpl library = new SdkLibraryImpl(libraryName); | 537 SdkLibraryImpl library = new SdkLibraryImpl(libraryName); |
| 530 List<Expression> arguments = ((value as InstanceCreationExpression)).argum
entList.arguments; | 538 List<Expression> arguments = (value as InstanceCreationExpression).argumen
tList.arguments; |
| 531 for (Expression argument in arguments) { | 539 for (Expression argument in arguments) { |
| 532 if (argument is SimpleStringLiteral) { | 540 if (argument is SimpleStringLiteral) { |
| 533 library.path = ((argument as SimpleStringLiteral)).value; | 541 library.path = (argument as SimpleStringLiteral).value; |
| 534 } else if (argument is NamedExpression) { | 542 } else if (argument is NamedExpression) { |
| 535 String name = ((argument as NamedExpression)).name.label.name; | 543 String name = (argument as NamedExpression).name.label.name; |
| 536 Expression expression = ((argument as NamedExpression)).expression; | 544 Expression expression = (argument as NamedExpression).expression; |
| 537 if (name == _CATEGORY) { | 545 if (name == _CATEGORY) { |
| 538 library.category = ((expression as SimpleStringLiteral)).value; | 546 library.category = (expression as SimpleStringLiteral).value; |
| 539 } else if (name == _IMPLEMENTATION) { | 547 } else if (name == _IMPLEMENTATION) { |
| 540 library.implementation = ((expression as BooleanLiteral)).value; | 548 library.implementation = (expression as BooleanLiteral).value; |
| 541 } else if (name == _DOCUMENTED) { | 549 } else if (name == _DOCUMENTED) { |
| 542 library.documented = ((expression as BooleanLiteral)).value; | 550 library.documented = (expression as BooleanLiteral).value; |
| 543 } else if (name == _PLATFORMS) { | 551 } else if (name == _PLATFORMS) { |
| 544 if (expression is SimpleIdentifier) { | 552 if (expression is SimpleIdentifier) { |
| 545 String identifier = ((expression as SimpleIdentifier)).name; | 553 String identifier = (expression as SimpleIdentifier).name; |
| 546 if (identifier == _VM_PLATFORM) { | 554 if (identifier == _VM_PLATFORM) { |
| 547 library.setVmLibrary(); | 555 library.setVmLibrary(); |
| 548 } else { | 556 } else { |
| 549 library.setDart2JsLibrary(); | 557 library.setDart2JsLibrary(); |
| 550 } | 558 } |
| 551 } | 559 } |
| 552 } | 560 } |
| 553 } | 561 } |
| 554 } | 562 } |
| 555 librariesMap.setLibrary(libraryName, library); | 563 librariesMap.setLibrary(libraryName, library); |
| 556 } | 564 } |
| 557 return null; | 565 return null; |
| 558 } | 566 } |
| 559 } | 567 } |
| 560 class AnalysisErrorListener_10 implements AnalysisErrorListener { | 568 |
| 569 class AnalysisErrorListener_11 implements AnalysisErrorListener { |
| 561 List<bool> foundError; | 570 List<bool> foundError; |
| 562 AnalysisErrorListener_10(this.foundError); | 571 |
| 572 AnalysisErrorListener_11(this.foundError); |
| 573 |
| 563 void onError(AnalysisError error) { | 574 void onError(AnalysisError error) { |
| 564 foundError[0] = true; | 575 if (error != null && error.errorCode.type != ErrorType.TODO) { |
| 576 foundError[0] = true; |
| 577 } |
| 565 } | 578 } |
| 566 } | 579 } |
| OLD | NEW |