OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library engine.sdk.io; |
| 6 |
| 7 import 'dart:io'; |
| 8 |
| 9 import 'package:analyzer/src/context/context.dart' as newContext; |
| 10 import 'package:analyzer/src/generated/java_engine.dart'; |
| 11 |
| 12 import 'ast.dart'; |
| 13 import 'engine.dart'; |
| 14 import 'error.dart'; |
| 15 import 'java_core.dart'; |
| 16 import 'java_engine_io.dart'; |
| 17 import 'java_io.dart'; |
| 18 import 'parser.dart'; |
| 19 import 'scanner.dart'; |
| 20 import 'sdk.dart'; |
| 21 import 'source_io.dart'; |
| 22 |
| 23 /** |
| 24 * A Dart SDK installed in a specified directory. Typical Dart SDK layout is |
| 25 * something like... |
| 26 * |
| 27 * dart-sdk/ |
| 28 * bin/ |
| 29 * dart[.exe] <-- VM |
| 30 * lib/ |
| 31 * core/ |
| 32 * core.dart |
| 33 * ... other core library files ... |
| 34 * ... other libraries ... |
| 35 * util/ |
| 36 * ... Dart utilities ... |
| 37 * Chromium/ <-- Dartium typically exists in a sibling directory |
| 38 */ |
| 39 class DirectoryBasedDartSdk implements DartSdk { |
| 40 /** |
| 41 * The default SDK, or `null` if the default SDK either has not yet been |
| 42 * created or cannot be created for some reason. |
| 43 */ |
| 44 static DirectoryBasedDartSdk _DEFAULT_SDK; |
| 45 |
| 46 /** |
| 47 * The name of the directory within the SDK directory that contains |
| 48 * executables. |
| 49 */ |
| 50 static String _BIN_DIRECTORY_NAME = "bin"; |
| 51 |
| 52 /** |
| 53 * The name of the directory on non-Mac that contains dartium. |
| 54 */ |
| 55 static String _DARTIUM_DIRECTORY_NAME = "chromium"; |
| 56 |
| 57 /** |
| 58 * The name of the dart2js executable on non-windows operating systems. |
| 59 */ |
| 60 static String _DART2JS_EXECUTABLE_NAME = "dart2js"; |
| 61 |
| 62 /** |
| 63 * The name of the file containing the dart2js executable on Windows. |
| 64 */ |
| 65 static String _DART2JS_EXECUTABLE_NAME_WIN = "dart2js.bat"; |
| 66 |
| 67 /** |
| 68 * The name of the file containing the Dartium executable on Linux. |
| 69 */ |
| 70 static String _DARTIUM_EXECUTABLE_NAME_LINUX = "chrome"; |
| 71 |
| 72 /** |
| 73 * The name of the file containing the Dartium executable on Macintosh. |
| 74 */ |
| 75 static String _DARTIUM_EXECUTABLE_NAME_MAC = |
| 76 "Chromium.app/Contents/MacOS/Chromium"; |
| 77 |
| 78 /** |
| 79 * The name of the file containing the Dartium executable on Windows. |
| 80 */ |
| 81 static String _DARTIUM_EXECUTABLE_NAME_WIN = "Chrome.exe"; |
| 82 |
| 83 /** |
| 84 * The name of the [System] property whose value is the path to the default |
| 85 * Dart SDK directory. |
| 86 */ |
| 87 static String _DEFAULT_DIRECTORY_PROPERTY_NAME = "com.google.dart.sdk"; |
| 88 |
| 89 /** |
| 90 * The name of the directory within the SDK directory that contains |
| 91 * documentation for the libraries. |
| 92 */ |
| 93 static String _DOCS_DIRECTORY_NAME = "docs"; |
| 94 |
| 95 /** |
| 96 * The suffix added to the name of a library to derive the name of the file |
| 97 * containing the documentation for that library. |
| 98 */ |
| 99 static String _DOC_FILE_SUFFIX = "_api.json"; |
| 100 |
| 101 /** |
| 102 * The name of the directory within the SDK directory that contains the |
| 103 * sdk_library_metadata directory. |
| 104 */ |
| 105 static String _INTERNAL_DIR = "_internal"; |
| 106 |
| 107 /** |
| 108 * The name of the sdk_library_metadata directory that contains the package |
| 109 * holding the libraries.dart file. |
| 110 */ |
| 111 static String _SDK_LIBRARY_METADATA_DIR = "sdk_library_metadata"; |
| 112 |
| 113 /** |
| 114 * The name of the directory within the sdk_library_metadata that contains |
| 115 * libraries.dart. |
| 116 */ |
| 117 static String _SDK_LIBRARY_METADATA_LIB_DIR = "lib"; |
| 118 |
| 119 /** |
| 120 * The name of the directory within the SDK directory that contains the |
| 121 * libraries. |
| 122 */ |
| 123 static String _LIB_DIRECTORY_NAME = "lib"; |
| 124 |
| 125 /** |
| 126 * The name of the libraries file. |
| 127 */ |
| 128 static String _LIBRARIES_FILE = "libraries.dart"; |
| 129 |
| 130 /** |
| 131 * The name of the pub executable on windows. |
| 132 */ |
| 133 static String _PUB_EXECUTABLE_NAME_WIN = "pub.bat"; |
| 134 |
| 135 /** |
| 136 * The name of the pub executable on non-windows operating systems. |
| 137 */ |
| 138 static String _PUB_EXECUTABLE_NAME = "pub"; |
| 139 |
| 140 /** |
| 141 * The name of the file within the SDK directory that contains the version |
| 142 * number of the SDK. |
| 143 */ |
| 144 static String _VERSION_FILE_NAME = "version"; |
| 145 |
| 146 /** |
| 147 * The name of the file containing the VM executable on the Windows operating |
| 148 * system. |
| 149 */ |
| 150 static String _VM_EXECUTABLE_NAME_WIN = "dart.exe"; |
| 151 |
| 152 /** |
| 153 * The name of the file containing the VM executable on non-Windows operating |
| 154 * systems. |
| 155 */ |
| 156 static String _VM_EXECUTABLE_NAME = "dart"; |
| 157 |
| 158 /** |
| 159 * Return the default Dart SDK, or `null` if the directory containing the |
| 160 * default SDK cannot be determined (or does not exist). |
| 161 */ |
| 162 static DirectoryBasedDartSdk get defaultSdk { |
| 163 if (_DEFAULT_SDK == null) { |
| 164 JavaFile sdkDirectory = defaultSdkDirectory; |
| 165 if (sdkDirectory == null) { |
| 166 return null; |
| 167 } |
| 168 _DEFAULT_SDK = new DirectoryBasedDartSdk(sdkDirectory); |
| 169 } |
| 170 return _DEFAULT_SDK; |
| 171 } |
| 172 |
| 173 /** |
| 174 * Return the default directory for the Dart SDK, or `null` if the directory |
| 175 * cannot be determined (or does not exist). The default directory is provided |
| 176 * by a system property named `com.google.dart.sdk`. |
| 177 */ |
| 178 static JavaFile get defaultSdkDirectory { |
| 179 String sdkProperty = |
| 180 JavaSystemIO.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NAME); |
| 181 if (sdkProperty == null) { |
| 182 return null; |
| 183 } |
| 184 JavaFile sdkDirectory = new JavaFile(sdkProperty); |
| 185 if (!sdkDirectory.exists()) { |
| 186 return null; |
| 187 } |
| 188 return sdkDirectory; |
| 189 } |
| 190 |
| 191 /** |
| 192 * The [AnalysisContext] which is used for all of the sources in this sdk. |
| 193 */ |
| 194 InternalAnalysisContext _analysisContext; |
| 195 |
| 196 /** |
| 197 * The directory containing the SDK. |
| 198 */ |
| 199 JavaFile _sdkDirectory; |
| 200 |
| 201 /** |
| 202 * The revision number of this SDK, or `"0"` if the revision number cannot be |
| 203 * discovered. |
| 204 */ |
| 205 String _sdkVersion; |
| 206 |
| 207 /** |
| 208 * The file containing the dart2js executable. |
| 209 */ |
| 210 JavaFile _dart2jsExecutable; |
| 211 |
| 212 /** |
| 213 * The file containing the Dartium executable. |
| 214 */ |
| 215 JavaFile _dartiumExecutable; |
| 216 |
| 217 /** |
| 218 * The file containing the pub executable. |
| 219 */ |
| 220 JavaFile _pubExecutable; |
| 221 |
| 222 /** |
| 223 * The file containing the VM executable. |
| 224 */ |
| 225 JavaFile _vmExecutable; |
| 226 |
| 227 /** |
| 228 * A mapping from Dart library URI's to the library represented by that URI. |
| 229 */ |
| 230 LibraryMap _libraryMap; |
| 231 |
| 232 /** |
| 233 * Initialize a newly created SDK to represent the Dart SDK installed in the |
| 234 * [sdkDirectory]. The flag [useDart2jsPaths] is `true` if the dart2js path |
| 235 * should be used when it is available |
| 236 */ |
| 237 DirectoryBasedDartSdk(JavaFile sdkDirectory, [bool useDart2jsPaths = false]) { |
| 238 this._sdkDirectory = sdkDirectory.getAbsoluteFile(); |
| 239 _libraryMap = initialLibraryMap(useDart2jsPaths); |
| 240 } |
| 241 |
| 242 @override |
| 243 AnalysisContext get context { |
| 244 if (_analysisContext == null) { |
| 245 if (AnalysisEngine.instance.useTaskModel) { |
| 246 _analysisContext = new newContext.SdkAnalysisContext(); |
| 247 } else { |
| 248 _analysisContext = new SdkAnalysisContext(); |
| 249 } |
| 250 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]); |
| 251 _analysisContext.sourceFactory = factory; |
| 252 List<String> uris = this.uris; |
| 253 ChangeSet changeSet = new ChangeSet(); |
| 254 for (String uri in uris) { |
| 255 changeSet.addedSource(factory.forUri(uri)); |
| 256 } |
| 257 _analysisContext.applyChanges(changeSet); |
| 258 } |
| 259 return _analysisContext; |
| 260 } |
| 261 |
| 262 /** |
| 263 * Return the file containing the dart2js executable, or `null` if it does not |
| 264 * exist. |
| 265 */ |
| 266 JavaFile get dart2JsExecutable { |
| 267 if (_dart2jsExecutable == null) { |
| 268 _dart2jsExecutable = _verifyExecutable(new JavaFile.relative( |
| 269 new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME), |
| 270 OSUtilities.isWindows() |
| 271 ? _DART2JS_EXECUTABLE_NAME_WIN |
| 272 : _DART2JS_EXECUTABLE_NAME)); |
| 273 } |
| 274 return _dart2jsExecutable; |
| 275 } |
| 276 |
| 277 /** |
| 278 * Return the name of the file containing the Dartium executable. |
| 279 */ |
| 280 String get dartiumBinaryName { |
| 281 if (OSUtilities.isWindows()) { |
| 282 return _DARTIUM_EXECUTABLE_NAME_WIN; |
| 283 } else if (OSUtilities.isMac()) { |
| 284 return _DARTIUM_EXECUTABLE_NAME_MAC; |
| 285 } else { |
| 286 return _DARTIUM_EXECUTABLE_NAME_LINUX; |
| 287 } |
| 288 } |
| 289 |
| 290 /** |
| 291 * Return the file containing the Dartium executable, or `null` if it does not |
| 292 * exist. |
| 293 */ |
| 294 JavaFile get dartiumExecutable { |
| 295 if (_dartiumExecutable == null) { |
| 296 _dartiumExecutable = _verifyExecutable( |
| 297 new JavaFile.relative(dartiumWorkingDirectory, dartiumBinaryName)); |
| 298 } |
| 299 return _dartiumExecutable; |
| 300 } |
| 301 |
| 302 /** |
| 303 * Return the directory where dartium can be found (the directory that will be |
| 304 * the working directory is Dartium is invoked without changing the default). |
| 305 */ |
| 306 JavaFile get dartiumWorkingDirectory => |
| 307 getDartiumWorkingDirectory(_sdkDirectory.getParentFile()); |
| 308 |
| 309 /** |
| 310 * Return the directory containing the SDK. |
| 311 */ |
| 312 JavaFile get directory => _sdkDirectory; |
| 313 |
| 314 /** |
| 315 * Return the directory containing documentation for the SDK. |
| 316 */ |
| 317 JavaFile get docDirectory => |
| 318 new JavaFile.relative(_sdkDirectory, _DOCS_DIRECTORY_NAME); |
| 319 |
| 320 /** |
| 321 * Return `true` if this SDK includes documentation. |
| 322 */ |
| 323 bool get hasDocumentation => docDirectory.exists(); |
| 324 |
| 325 /** |
| 326 * Return `true` if the Dartium binary is available. |
| 327 */ |
| 328 bool get isDartiumInstalled => dartiumExecutable != null; |
| 329 |
| 330 /** |
| 331 * Return the directory within the SDK directory that contains the libraries. |
| 332 */ |
| 333 JavaFile get libraryDirectory => |
| 334 new JavaFile.relative(_sdkDirectory, _LIB_DIRECTORY_NAME); |
| 335 |
| 336 /** |
| 337 * Return the file containing the Pub executable, or `null` if it does not exi
st. |
| 338 */ |
| 339 JavaFile get pubExecutable { |
| 340 if (_pubExecutable == null) { |
| 341 _pubExecutable = _verifyExecutable(new JavaFile.relative( |
| 342 new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME), |
| 343 OSUtilities.isWindows() |
| 344 ? _PUB_EXECUTABLE_NAME_WIN |
| 345 : _PUB_EXECUTABLE_NAME)); |
| 346 } |
| 347 return _pubExecutable; |
| 348 } |
| 349 |
| 350 @override |
| 351 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries; |
| 352 |
| 353 /** |
| 354 * Return the revision number of this SDK, or `"0"` if the revision number |
| 355 * cannot be discovered. |
| 356 */ |
| 357 @override |
| 358 String get sdkVersion { |
| 359 if (_sdkVersion == null) { |
| 360 _sdkVersion = DartSdk.DEFAULT_VERSION; |
| 361 JavaFile revisionFile = |
| 362 new JavaFile.relative(_sdkDirectory, _VERSION_FILE_NAME); |
| 363 try { |
| 364 String revision = revisionFile.readAsStringSync(); |
| 365 if (revision != null) { |
| 366 _sdkVersion = revision.trim(); |
| 367 } |
| 368 } on FileSystemException { |
| 369 // Fall through to return the default. |
| 370 } |
| 371 } |
| 372 return _sdkVersion; |
| 373 } |
| 374 |
| 375 @override |
| 376 List<String> get uris => _libraryMap.uris; |
| 377 |
| 378 /** |
| 379 * Return the name of the file containing the VM executable. |
| 380 */ |
| 381 String get vmBinaryName { |
| 382 if (OSUtilities.isWindows()) { |
| 383 return _VM_EXECUTABLE_NAME_WIN; |
| 384 } else { |
| 385 return _VM_EXECUTABLE_NAME; |
| 386 } |
| 387 } |
| 388 |
| 389 /** |
| 390 * Return the file containing the VM executable, or `null` if it does not |
| 391 * exist. |
| 392 */ |
| 393 JavaFile get vmExecutable { |
| 394 if (_vmExecutable == null) { |
| 395 _vmExecutable = _verifyExecutable(new JavaFile.relative( |
| 396 new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME), |
| 397 vmBinaryName)); |
| 398 } |
| 399 return _vmExecutable; |
| 400 } |
| 401 |
| 402 /** |
| 403 * Determine the search order for trying to locate the [_LIBRARIES_FILE]. |
| 404 */ |
| 405 Iterable<JavaFile> get _libraryMapLocations sync* { |
| 406 yield new JavaFile.relative( |
| 407 new JavaFile.relative( |
| 408 new JavaFile.relative( |
| 409 new JavaFile.relative(libraryDirectory, _INTERNAL_DIR), |
| 410 _SDK_LIBRARY_METADATA_DIR), |
| 411 _SDK_LIBRARY_METADATA_LIB_DIR), |
| 412 _LIBRARIES_FILE); |
| 413 yield new JavaFile.relative( |
| 414 new JavaFile.relative(libraryDirectory, _INTERNAL_DIR), |
| 415 _LIBRARIES_FILE); |
| 416 } |
| 417 |
| 418 @override |
| 419 Source fromFileUri(Uri uri) { |
| 420 JavaFile file = new JavaFile.fromUri(uri); |
| 421 String filePath = file.getAbsolutePath(); |
| 422 String libPath = libraryDirectory.getAbsolutePath(); |
| 423 if (!filePath.startsWith("$libPath${JavaFile.separator}")) { |
| 424 return null; |
| 425 } |
| 426 filePath = filePath.substring(libPath.length + 1); |
| 427 for (SdkLibrary library in _libraryMap.sdkLibraries) { |
| 428 String libraryPath = library.path; |
| 429 if (filePath.replaceAll('\\', '/') == libraryPath) { |
| 430 String path = library.shortName; |
| 431 try { |
| 432 return new FileBasedSource(file, parseUriWithException(path)); |
| 433 } on URISyntaxException catch (exception, stackTrace) { |
| 434 AnalysisEngine.instance.logger.logInformation( |
| 435 "Failed to create URI: $path", |
| 436 new CaughtException(exception, stackTrace)); |
| 437 return null; |
| 438 } |
| 439 } |
| 440 libraryPath = new JavaFile(libraryPath).getParent(); |
| 441 if (filePath.startsWith("$libraryPath${JavaFile.separator}")) { |
| 442 String path = |
| 443 "${library.shortName}/${filePath.substring(libraryPath.length + 1)}"
; |
| 444 try { |
| 445 return new FileBasedSource(file, parseUriWithException(path)); |
| 446 } on URISyntaxException catch (exception, stackTrace) { |
| 447 AnalysisEngine.instance.logger.logInformation( |
| 448 "Failed to create URI: $path", |
| 449 new CaughtException(exception, stackTrace)); |
| 450 return null; |
| 451 } |
| 452 } |
| 453 } |
| 454 return null; |
| 455 } |
| 456 |
| 457 /** |
| 458 * Return the directory where dartium can be found (the directory that will be |
| 459 * the working directory if Dartium is invoked without changing the default), |
| 460 * assuming that the Editor was installed in the [installDir]. |
| 461 */ |
| 462 JavaFile getDartiumWorkingDirectory(JavaFile installDir) => |
| 463 new JavaFile.relative(installDir, _DARTIUM_DIRECTORY_NAME); |
| 464 |
| 465 /** |
| 466 * Return the auxiliary documentation file for the library with the given |
| 467 * [libraryName], or `null` if no such file exists. |
| 468 */ |
| 469 JavaFile getDocFileFor(String libraryName) { |
| 470 JavaFile dir = docDirectory; |
| 471 if (!dir.exists()) { |
| 472 return null; |
| 473 } |
| 474 JavaFile libDir = new JavaFile.relative(dir, libraryName); |
| 475 JavaFile docFile = |
| 476 new JavaFile.relative(libDir, "$libraryName$_DOC_FILE_SUFFIX"); |
| 477 if (docFile.exists()) { |
| 478 return docFile; |
| 479 } |
| 480 return null; |
| 481 } |
| 482 |
| 483 @override |
| 484 SdkLibrary getSdkLibrary(String dartUri) => _libraryMap.getLibrary(dartUri); |
| 485 |
| 486 /** |
| 487 * Read all of the configuration files to initialize the library maps. The |
| 488 * flag [useDart2jsPaths] is `true` if the dart2js path should be used when it |
| 489 * is available. Return the initialized library map. |
| 490 */ |
| 491 LibraryMap initialLibraryMap(bool useDart2jsPaths) { |
| 492 List<String> searchedPaths = <String>[]; |
| 493 var lastStackTrace = null; |
| 494 var lastException = null; |
| 495 for (JavaFile librariesFile in _libraryMapLocations) { |
| 496 try { |
| 497 String contents = librariesFile.readAsStringSync(); |
| 498 return new SdkLibrariesReader(useDart2jsPaths) |
| 499 .readFromFile(librariesFile, contents); |
| 500 } catch (exception, stackTrace) { |
| 501 searchedPaths.add(librariesFile.getAbsolutePath()); |
| 502 lastException = exception; |
| 503 lastStackTrace = stackTrace; |
| 504 } |
| 505 } |
| 506 AnalysisEngine.instance.logger.logError( |
| 507 "Could not initialize the library map from $searchedPaths", |
| 508 new CaughtException(lastException, lastStackTrace)); |
| 509 return new LibraryMap(); |
| 510 } |
| 511 |
| 512 @override |
| 513 Source mapDartUri(String dartUri) { |
| 514 String libraryName; |
| 515 String relativePath; |
| 516 int index = dartUri.indexOf('/'); |
| 517 if (index >= 0) { |
| 518 libraryName = dartUri.substring(0, index); |
| 519 relativePath = dartUri.substring(index + 1); |
| 520 } else { |
| 521 libraryName = dartUri; |
| 522 relativePath = ""; |
| 523 } |
| 524 SdkLibrary library = getSdkLibrary(libraryName); |
| 525 if (library == null) { |
| 526 return null; |
| 527 } |
| 528 try { |
| 529 JavaFile file = new JavaFile.relative(libraryDirectory, library.path); |
| 530 if (!relativePath.isEmpty) { |
| 531 file = file.getParentFile(); |
| 532 file = new JavaFile.relative(file, relativePath); |
| 533 } |
| 534 return new FileBasedSource(file, parseUriWithException(dartUri)); |
| 535 } on URISyntaxException { |
| 536 return null; |
| 537 } |
| 538 } |
| 539 |
| 540 /** |
| 541 * Return the given [file] if it exists and is executable, or `null` if it |
| 542 * does not exist or is not executable. |
| 543 */ |
| 544 JavaFile _verifyExecutable(JavaFile file) => |
| 545 file.isExecutable() ? file : null; |
| 546 } |
| 547 |
| 548 /** |
| 549 * An object used to read and parse the libraries file |
| 550 * (dart-sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart) for informat
ion |
| 551 * about the libraries in an SDK. The library information is represented as a |
| 552 * Dart file containing a single top-level variable whose value is a const map. |
| 553 * The keys of the map are the names of libraries defined in the SDK and the |
| 554 * values in the map are info objects defining the library. For example, a |
| 555 * subset of a typical SDK might have a libraries file that looks like the |
| 556 * following: |
| 557 * |
| 558 * final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> { |
| 559 * // Used by VM applications |
| 560 * "builtin" : const LibraryInfo( |
| 561 * "builtin/builtin_runtime.dart", |
| 562 * category: "Server", |
| 563 * platforms: VM_PLATFORM), |
| 564 * |
| 565 * "compiler" : const LibraryInfo( |
| 566 * "compiler/compiler.dart", |
| 567 * category: "Tools", |
| 568 * platforms: 0), |
| 569 * }; |
| 570 */ |
| 571 class SdkLibrariesReader { |
| 572 /** |
| 573 * A flag indicating whether the dart2js path should be used when it is |
| 574 * available. |
| 575 */ |
| 576 final bool _useDart2jsPaths; |
| 577 |
| 578 /** |
| 579 * Initialize a newly created library reader to use the dart2js path if |
| 580 * [_useDart2jsPaths] is `true`. |
| 581 */ |
| 582 SdkLibrariesReader(this._useDart2jsPaths); |
| 583 |
| 584 /** |
| 585 * Return the library map read from the given [file], given that the content |
| 586 * of the file is already known to be [libraryFileContents]. |
| 587 */ |
| 588 LibraryMap readFromFile(JavaFile file, String libraryFileContents) => |
| 589 readFromSource(new FileBasedSource(file), libraryFileContents); |
| 590 |
| 591 /** |
| 592 * Return the library map read from the given [source], given that the content |
| 593 * of the file is already known to be [libraryFileContents]. |
| 594 */ |
| 595 LibraryMap readFromSource(Source source, String libraryFileContents) { |
| 596 BooleanErrorListener errorListener = new BooleanErrorListener(); |
| 597 Scanner scanner = new Scanner( |
| 598 source, new CharSequenceReader(libraryFileContents), errorListener); |
| 599 Parser parser = new Parser(source, errorListener); |
| 600 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); |
| 601 SdkLibrariesReader_LibraryBuilder libraryBuilder = |
| 602 new SdkLibrariesReader_LibraryBuilder(_useDart2jsPaths); |
| 603 // If any syntactic errors were found then don't try to visit the AST |
| 604 // structure. |
| 605 if (!errorListener.errorReported) { |
| 606 unit.accept(libraryBuilder); |
| 607 } |
| 608 return libraryBuilder.librariesMap; |
| 609 } |
| 610 } |
OLD | NEW |