| 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 |
| 4 library engine.sdk; | 4 library engine.sdk; |
| 5 | 5 |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 import 'dart:uri'; | 7 import 'dart:uri'; |
| 8 import 'java_core.dart'; | 8 import 'java_core.dart'; |
| 9 import 'java_io.dart'; | 9 import 'java_io.dart'; |
| 10 import 'java_engine.dart'; | 10 import 'java_engine.dart'; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 * category: "Tools", | 184 * category: "Tools", |
| 185 * platforms: 0), | 185 * platforms: 0), |
| 186 * }; | 186 * }; |
| 187 * </pre> | 187 * </pre> |
| 188 */ | 188 */ |
| 189 class SdkLibrariesReader { | 189 class SdkLibrariesReader { |
| 190 /** | 190 /** |
| 191 * Return the library map read from the given source. | 191 * Return the library map read from the given source. |
| 192 * @return the library map read from the given source | 192 * @return the library map read from the given source |
| 193 */ | 193 */ |
| 194 LibraryMap readFrom(File librariesFile, String libraryFileContents) { | 194 LibraryMap readFrom(JavaFile librariesFile, String libraryFileContents) { |
| 195 List<bool> foundError = [false]; | 195 List<bool> foundError = [false]; |
| 196 AnalysisErrorListener errorListener = new AnalysisErrorListener_5(foundError
); | 196 AnalysisErrorListener errorListener = new AnalysisErrorListener_5(foundError
); |
| 197 Source source = new FileBasedSource.con2(null, librariesFile, false); | 197 Source source = new FileBasedSource.con2(null, librariesFile, false); |
| 198 StringScanner scanner = new StringScanner(source, libraryFileContents, error
Listener); | 198 StringScanner scanner = new StringScanner(source, libraryFileContents, error
Listener); |
| 199 Parser parser = new Parser(source, errorListener); | 199 Parser parser = new Parser(source, errorListener); |
| 200 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); | 200 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); |
| 201 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li
braryBuilder(); | 201 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li
braryBuilder(); |
| 202 if (!foundError[0]) { | 202 if (!foundError[0]) { |
| 203 unit.accept(libraryBuilder); | 203 unit.accept(libraryBuilder); |
| 204 } | 204 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 * The short name of the dart SDK core library. | 342 * The short name of the dart SDK core library. |
| 343 */ | 343 */ |
| 344 static String DART_CORE = "dart:core"; | 344 static String DART_CORE = "dart:core"; |
| 345 /** | 345 /** |
| 346 * The short name of the dart SDK html library. | 346 * The short name of the dart SDK html library. |
| 347 */ | 347 */ |
| 348 static String DART_HTML = "dart:html"; | 348 static String DART_HTML = "dart:html"; |
| 349 /** | 349 /** |
| 350 * The directory containing the SDK. | 350 * The directory containing the SDK. |
| 351 */ | 351 */ |
| 352 File _sdkDirectory; | 352 JavaFile _sdkDirectory; |
| 353 /** | 353 /** |
| 354 * The revision number of this SDK, or {@code "0"} if the revision number cann
ot be discovered. | 354 * The revision number of this SDK, or {@code "0"} if the revision number cann
ot be discovered. |
| 355 */ | 355 */ |
| 356 String _sdkVersion; | 356 String _sdkVersion; |
| 357 /** | 357 /** |
| 358 * The file containing the Dartium executable. | 358 * The file containing the Dartium executable. |
| 359 */ | 359 */ |
| 360 File _dartiumExecutable; | 360 JavaFile _dartiumExecutable; |
| 361 /** | 361 /** |
| 362 * The file containing the VM executable. | 362 * The file containing the VM executable. |
| 363 */ | 363 */ |
| 364 File _vmExecutable; | 364 JavaFile _vmExecutable; |
| 365 /** | 365 /** |
| 366 * A mapping from Dart library URI's to the library represented by that URI. | 366 * A mapping from Dart library URI's to the library represented by that URI. |
| 367 */ | 367 */ |
| 368 LibraryMap _libraryMap; | 368 LibraryMap _libraryMap; |
| 369 /** | 369 /** |
| 370 * The name of the directory within the SDK directory that contains executable
s. | 370 * The name of the directory within the SDK directory that contains executable
s. |
| 371 */ | 371 */ |
| 372 static String _BIN_DIRECTORY_NAME = "bin"; | 372 static String _BIN_DIRECTORY_NAME = "bin"; |
| 373 /** | 373 /** |
| 374 * The name of the directory within the SDK directory that contains Chromium. | 374 * The name of the directory within the SDK directory that contains Chromium. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 /** | 436 /** |
| 437 * The name of the file containing the VM executable on non-Windows operating
systems. | 437 * The name of the file containing the VM executable on non-Windows operating
systems. |
| 438 */ | 438 */ |
| 439 static String _VM_EXECUTABLE_NAME = "dart"; | 439 static String _VM_EXECUTABLE_NAME = "dart"; |
| 440 /** | 440 /** |
| 441 * Return the default Dart SDK, or {@code null} if the directory containing th
e default SDK cannot | 441 * Return the default Dart SDK, or {@code null} if the directory containing th
e default SDK cannot |
| 442 * be determined (or does not exist). | 442 * be determined (or does not exist). |
| 443 * @return the default Dart SDK | 443 * @return the default Dart SDK |
| 444 */ | 444 */ |
| 445 static DartSdk get defaultSdk { | 445 static DartSdk get defaultSdk { |
| 446 File sdkDirectory = defaultSdkDirectory; | 446 JavaFile sdkDirectory = defaultSdkDirectory; |
| 447 if (sdkDirectory == null) { | 447 if (sdkDirectory == null) { |
| 448 return null; | 448 return null; |
| 449 } | 449 } |
| 450 return new DartSdk(sdkDirectory); | 450 return new DartSdk(sdkDirectory); |
| 451 } | 451 } |
| 452 /** | 452 /** |
| 453 * Return the default directory for the Dart SDK, or {@code null} if the direc
tory cannot be | 453 * Return the default directory for the Dart SDK, or {@code null} if the direc
tory cannot be |
| 454 * determined (or does not exist). The default directory is provided by a {@li
nk System} property | 454 * determined (or does not exist). The default directory is provided by a {@li
nk System} property |
| 455 * named {@code com.google.dart.sdk}, or, if the property is not defined, an e
nvironment variable | 455 * named {@code com.google.dart.sdk}, or, if the property is not defined, an e
nvironment variable |
| 456 * named {@code DART_SDK}. | 456 * named {@code DART_SDK}. |
| 457 * @return the default directory for the Dart SDK | 457 * @return the default directory for the Dart SDK |
| 458 */ | 458 */ |
| 459 static File get defaultSdkDirectory { | 459 static JavaFile get defaultSdkDirectory { |
| 460 String sdkProperty = JavaSystemIO.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NA
ME); | 460 String sdkProperty = JavaSystemIO.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NA
ME); |
| 461 if (sdkProperty == null) { | 461 if (sdkProperty == null) { |
| 462 sdkProperty = JavaSystemIO.getenv(_DART_SDK_ENVIRONMENT_VARIABLE_NAME); | 462 sdkProperty = JavaSystemIO.getenv(_DART_SDK_ENVIRONMENT_VARIABLE_NAME); |
| 463 if (sdkProperty == null) { | 463 if (sdkProperty == null) { |
| 464 return null; | 464 return null; |
| 465 } | 465 } |
| 466 } | 466 } |
| 467 File sdkDirectory = new File(sdkProperty); | 467 JavaFile sdkDirectory = new JavaFile(sdkProperty); |
| 468 if (!sdkDirectory.existsSync()) { | 468 if (!sdkDirectory.exists()) { |
| 469 return null; | 469 return null; |
| 470 } | 470 } |
| 471 return sdkDirectory; | 471 return sdkDirectory; |
| 472 } | 472 } |
| 473 /** | 473 /** |
| 474 * Initialize a newly created SDK to represent the Dart SDK installed in the g
iven directory. | 474 * Initialize a newly created SDK to represent the Dart SDK installed in the g
iven directory. |
| 475 * @param sdkDirectory the directory containing the SDK | 475 * @param sdkDirectory the directory containing the SDK |
| 476 */ | 476 */ |
| 477 DartSdk(File sdkDirectory) { | 477 DartSdk(JavaFile sdkDirectory) { |
| 478 this._sdkDirectory = getAbsoluteFile(sdkDirectory); | 478 this._sdkDirectory = sdkDirectory.getAbsoluteFile(); |
| 479 initializeSdk(); | 479 initializeSdk(); |
| 480 initializeLibraryMap(); | 480 initializeLibraryMap(); |
| 481 } | 481 } |
| 482 /** | 482 /** |
| 483 * Return the file containing the Dartium executable, or {@code null} if it do
es not exist. | 483 * Return the file containing the Dartium executable, or {@code null} if it do
es not exist. |
| 484 * @return the file containing the Dartium executable | 484 * @return the file containing the Dartium executable |
| 485 */ | 485 */ |
| 486 File get dartiumExecutable { | 486 JavaFile get dartiumExecutable { |
| 487 { | 487 { |
| 488 if (_dartiumExecutable == null) { | 488 if (_dartiumExecutable == null) { |
| 489 File file = newRelativeFile(_sdkDirectory, dartiumBinaryName); | 489 JavaFile file = new JavaFile.relative(_sdkDirectory, dartiumBinaryName); |
| 490 if (file.existsSync()) { | 490 if (file.exists()) { |
| 491 _dartiumExecutable = file; | 491 _dartiumExecutable = file; |
| 492 } | 492 } |
| 493 } | 493 } |
| 494 } | 494 } |
| 495 return _dartiumExecutable; | 495 return _dartiumExecutable; |
| 496 } | 496 } |
| 497 /** | 497 /** |
| 498 * Return the directory where dartium can be found in the Dart SDK (the direct
ory that will be the | 498 * Return the directory where dartium can be found in the Dart SDK (the direct
ory that will be the |
| 499 * working directory is Dartium is invoked without changing the default). | 499 * working directory is Dartium is invoked without changing the default). |
| 500 * @return the directory where dartium can be found | 500 * @return the directory where dartium can be found |
| 501 */ | 501 */ |
| 502 File get dartiumWorkingDirectory { | 502 JavaFile get dartiumWorkingDirectory { |
| 503 if (OSUtilities.isWindows() || OSUtilities.isMac()) { | 503 if (OSUtilities.isWindows() || OSUtilities.isMac()) { |
| 504 return _sdkDirectory; | 504 return _sdkDirectory; |
| 505 } else { | 505 } else { |
| 506 return newRelativeFile(_sdkDirectory, _CHROMIUM_DIRECTORY_NAME); | 506 return new JavaFile.relative(_sdkDirectory, _CHROMIUM_DIRECTORY_NAME); |
| 507 } | 507 } |
| 508 } | 508 } |
| 509 /** | 509 /** |
| 510 * Return the directory containing the SDK. | 510 * Return the directory containing the SDK. |
| 511 * @return the directory containing the SDK | 511 * @return the directory containing the SDK |
| 512 */ | 512 */ |
| 513 File get directory => _sdkDirectory; | 513 JavaFile get directory => _sdkDirectory; |
| 514 /** | 514 /** |
| 515 * Return the directory containing documentation for the SDK. | 515 * Return the directory containing documentation for the SDK. |
| 516 * @return the SDK's documentation directory | 516 * @return the SDK's documentation directory |
| 517 */ | 517 */ |
| 518 File get docDirectory => newRelativeFile(_sdkDirectory, _DOCS_DIRECTORY_NAME); | 518 JavaFile get docDirectory => new JavaFile.relative(_sdkDirectory, _DOCS_DIRECT
ORY_NAME); |
| 519 /** | 519 /** |
| 520 * Return the auxiliary documentation file for the given library, or {@code nu
ll} if no such file | 520 * Return the auxiliary documentation file for the given library, or {@code nu
ll} if no such file |
| 521 * exists. | 521 * exists. |
| 522 * @param libraryName the name of the library associated with the documentatio
n file to be | 522 * @param libraryName the name of the library associated with the documentatio
n file to be |
| 523 * returned | 523 * returned |
| 524 * @return the auxiliary documentation file for the library | 524 * @return the auxiliary documentation file for the library |
| 525 */ | 525 */ |
| 526 File getDocFileFor(String libraryName) { | 526 JavaFile getDocFileFor(String libraryName) { |
| 527 File dir = docDirectory; | 527 JavaFile dir = docDirectory; |
| 528 if (!dir.existsSync()) { | 528 if (!dir.exists()) { |
| 529 return null; | 529 return null; |
| 530 } | 530 } |
| 531 File libDir = newRelativeFile(dir, libraryName); | 531 JavaFile libDir = new JavaFile.relative(dir, libraryName); |
| 532 File docFile = newRelativeFile(libDir, "${libraryName}${_DOC_FILE_SUFFIX}"); | 532 JavaFile docFile = new JavaFile.relative(libDir, "${libraryName}${_DOC_FILE_
SUFFIX}"); |
| 533 if (docFile.existsSync()) { | 533 if (docFile.exists()) { |
| 534 return docFile; | 534 return docFile; |
| 535 } | 535 } |
| 536 return null; | 536 return null; |
| 537 } | 537 } |
| 538 /** | 538 /** |
| 539 * Return the directory within the SDK directory that contains the libraries. | 539 * Return the directory within the SDK directory that contains the libraries. |
| 540 * @return the directory that contains the libraries | 540 * @return the directory that contains the libraries |
| 541 */ | 541 */ |
| 542 File get libraryDirectory => newRelativeFile(_sdkDirectory, _LIB_DIRECTORY_NAM
E); | 542 JavaFile get libraryDirectory => new JavaFile.relative(_sdkDirectory, _LIB_DIR
ECTORY_NAME); |
| 543 /** | 543 /** |
| 544 * Return the directory within the SDK directory that contains the packages. | 544 * Return the directory within the SDK directory that contains the packages. |
| 545 * @return the directory that contains the packages | 545 * @return the directory that contains the packages |
| 546 */ | 546 */ |
| 547 File get packageDirectory => newRelativeFile(directory, _PKG_DIRECTORY_NAME); | 547 JavaFile get packageDirectory => new JavaFile.relative(directory, _PKG_DIRECTO
RY_NAME); |
| 548 /** | 548 /** |
| 549 * Return an array containing all of the libraries defined in this SDK. | 549 * Return an array containing all of the libraries defined in this SDK. |
| 550 * @return the libraries defined in this SDK | 550 * @return the libraries defined in this SDK |
| 551 */ | 551 */ |
| 552 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries; | 552 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries; |
| 553 /** | 553 /** |
| 554 * Return the revision number of this SDK, or {@code "0"} if the revision numb
er cannot be | 554 * Return the revision number of this SDK, or {@code "0"} if the revision numb
er cannot be |
| 555 * discovered. | 555 * discovered. |
| 556 * @return the revision number of this SDK | 556 * @return the revision number of this SDK |
| 557 */ | 557 */ |
| 558 String get sdkVersion { | 558 String get sdkVersion { |
| 559 { | 559 { |
| 560 if (_sdkVersion == null) { | 560 if (_sdkVersion == null) { |
| 561 _sdkVersion = _DEFAULT_VERSION; | 561 _sdkVersion = _DEFAULT_VERSION; |
| 562 File revisionFile = newRelativeFile(_sdkDirectory, _REVISION_FILE_NAME); | 562 JavaFile revisionFile = new JavaFile.relative(_sdkDirectory, _REVISION_F
ILE_NAME); |
| 563 try { | 563 try { |
| 564 String revision = revisionFile.readAsStringSync(); | 564 String revision = revisionFile.readAsStringSync(); |
| 565 if (revision != null) { | 565 if (revision != null) { |
| 566 _sdkVersion = revision; | 566 _sdkVersion = revision; |
| 567 } | 567 } |
| 568 } on IOException catch (exception) { | 568 } on IOException catch (exception) { |
| 569 } | 569 } |
| 570 } | 570 } |
| 571 } | 571 } |
| 572 return _sdkVersion; | 572 return _sdkVersion; |
| 573 } | 573 } |
| 574 /** | 574 /** |
| 575 * Return an array containing the library URI's for the libraries defined in t
his SDK. | 575 * Return an array containing the library URI's for the libraries defined in t
his SDK. |
| 576 * @return the library URI's for the libraries defined in this SDK | 576 * @return the library URI's for the libraries defined in this SDK |
| 577 */ | 577 */ |
| 578 List<String> get uris => _libraryMap.uris; | 578 List<String> get uris => _libraryMap.uris; |
| 579 /** | 579 /** |
| 580 * Return the file containing the VM executable, or {@code null} if it does no
t exist. | 580 * Return the file containing the VM executable, or {@code null} if it does no
t exist. |
| 581 * @return the file containing the VM executable | 581 * @return the file containing the VM executable |
| 582 */ | 582 */ |
| 583 File get vmExecutable { | 583 JavaFile get vmExecutable { |
| 584 { | 584 { |
| 585 if (_vmExecutable == null) { | 585 if (_vmExecutable == null) { |
| 586 File file = newRelativeFile(newRelativeFile(_sdkDirectory, _BIN_DIRECTOR
Y_NAME), binaryName); | 586 JavaFile file = new JavaFile.relative(new JavaFile.relative(_sdkDirector
y, _BIN_DIRECTORY_NAME), binaryName); |
| 587 if (file.existsSync()) { | 587 if (file.exists()) { |
| 588 _vmExecutable = file; | 588 _vmExecutable = file; |
| 589 } | 589 } |
| 590 } | 590 } |
| 591 } | 591 } |
| 592 return _vmExecutable; | 592 return _vmExecutable; |
| 593 } | 593 } |
| 594 /** | 594 /** |
| 595 * Return {@code true} if this SDK includes documentation. | 595 * Return {@code true} if this SDK includes documentation. |
| 596 * @return {@code true} if this installation of the SDK has documentation | 596 * @return {@code true} if this installation of the SDK has documentation |
| 597 */ | 597 */ |
| 598 bool hasDocumentation() => docDirectory.existsSync(); | 598 bool hasDocumentation() => docDirectory.exists(); |
| 599 /** | 599 /** |
| 600 * Return {@code true} if the Dartium binary is available. | 600 * Return {@code true} if the Dartium binary is available. |
| 601 * @return {@code true} if the Dartium binary is available | 601 * @return {@code true} if the Dartium binary is available |
| 602 */ | 602 */ |
| 603 bool isDartiumInstalled() => dartiumExecutable != null; | 603 bool isDartiumInstalled() => dartiumExecutable != null; |
| 604 /** | 604 /** |
| 605 * Return the file representing the library with the given {@code dart:} URI,
or {@code null} if | 605 * Return the file representing the library with the given {@code dart:} URI,
or {@code null} if |
| 606 * the given URI does not denote a library in this SDK. | 606 * the given URI does not denote a library in this SDK. |
| 607 * @param dartUri the URI of the library to be returned | 607 * @param dartUri the URI of the library to be returned |
| 608 * @return the file representing the specified library | 608 * @return the file representing the specified library |
| 609 */ | 609 */ |
| 610 File mapDartUri(String dartUri) { | 610 JavaFile mapDartUri(String dartUri) { |
| 611 SdkLibrary library = _libraryMap.getLibrary(dartUri); | 611 SdkLibrary library = _libraryMap.getLibrary(dartUri); |
| 612 if (library == null) { | 612 if (library == null) { |
| 613 return null; | 613 return null; |
| 614 } | 614 } |
| 615 return newRelativeFile(libraryDirectory, library.path); | 615 return new JavaFile.relative(libraryDirectory, library.path); |
| 616 } | 616 } |
| 617 /** | 617 /** |
| 618 * Ensure that the dart VM is executable. If it is not, make it executable and
log that it was | 618 * Ensure that the dart VM is executable. If it is not, make it executable and
log that it was |
| 619 * necessary for us to do so. | 619 * necessary for us to do so. |
| 620 */ | 620 */ |
| 621 void ensureVmIsExecutable() { | 621 void ensureVmIsExecutable() { |
| 622 } | 622 } |
| 623 /** | 623 /** |
| 624 * Return the name of the file containing the VM executable. | 624 * Return the name of the file containing the VM executable. |
| 625 * @return the name of the file containing the VM executable | 625 * @return the name of the file containing the VM executable |
| (...skipping 16 matching lines...) Expand all Loading... |
| 642 return _DARTIUM_EXECUTABLE_NAME_MAC; | 642 return _DARTIUM_EXECUTABLE_NAME_MAC; |
| 643 } else { | 643 } else { |
| 644 return _DARTIUM_EXECUTABLE_NAME_LINUX; | 644 return _DARTIUM_EXECUTABLE_NAME_LINUX; |
| 645 } | 645 } |
| 646 } | 646 } |
| 647 /** | 647 /** |
| 648 * Read all of the configuration files to initialize the library maps. | 648 * Read all of the configuration files to initialize the library maps. |
| 649 */ | 649 */ |
| 650 void initializeLibraryMap() { | 650 void initializeLibraryMap() { |
| 651 try { | 651 try { |
| 652 File librariesFile = newRelativeFile(newRelativeFile(libraryDirectory, _IN
TERNAL_DIR), _LIBRARIES_FILE); | 652 JavaFile librariesFile = new JavaFile.relative(new JavaFile.relative(libra
ryDirectory, _INTERNAL_DIR), _LIBRARIES_FILE); |
| 653 String contents = librariesFile.readAsStringSync(); | 653 String contents = librariesFile.readAsStringSync(); |
| 654 _libraryMap = new SdkLibrariesReader().readFrom(librariesFile, contents); | 654 _libraryMap = new SdkLibrariesReader().readFrom(librariesFile, contents); |
| 655 } on JavaException catch (exception) { | 655 } on JavaException catch (exception) { |
| 656 AnalysisEngine.instance.logger.logError3(exception); | 656 AnalysisEngine.instance.logger.logError3(exception); |
| 657 _libraryMap = new LibraryMap(); | 657 _libraryMap = new LibraryMap(); |
| 658 } | 658 } |
| 659 } | 659 } |
| 660 /** | 660 /** |
| 661 * Initialize the state of the SDK. | 661 * Initialize the state of the SDK. |
| 662 */ | 662 */ |
| 663 void initializeSdk() { | 663 void initializeSdk() { |
| 664 if (!OSUtilities.isWindows()) { | 664 if (!OSUtilities.isWindows()) { |
| 665 ensureVmIsExecutable(); | 665 ensureVmIsExecutable(); |
| 666 } | 666 } |
| 667 } | 667 } |
| 668 } | 668 } |
| OLD | NEW |