| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.sdk.io; | 8 library engine.sdk.io; |
| 9 | 9 |
| 10 import 'java_core.dart'; | 10 import 'java_core.dart'; |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 _analysisContext = new AnalysisContextImpl(); | 183 _analysisContext = new AnalysisContextImpl(); |
| 184 _analysisContext.sourceFactory = new SourceFactory.con2([new DartUriResolver
(this)]); | 184 _analysisContext.sourceFactory = new SourceFactory.con2([new DartUriResolver
(this)]); |
| 185 List<String> uris = this.uris; | 185 List<String> uris = this.uris; |
| 186 ChangeSet changeSet = new ChangeSet(); | 186 ChangeSet changeSet = new ChangeSet(); |
| 187 for (String uri in uris) { | 187 for (String uri in uris) { |
| 188 changeSet.added(_analysisContext.sourceFactory.forUri(uri)); | 188 changeSet.added(_analysisContext.sourceFactory.forUri(uri)); |
| 189 } | 189 } |
| 190 _analysisContext.applyChanges(changeSet); | 190 _analysisContext.applyChanges(changeSet); |
| 191 } | 191 } |
| 192 | 192 |
| 193 /** | |
| 194 * Initialize a newly created SDK to represent the Dart SDK installed in the g
iven directory. | |
| 195 * | |
| 196 * Added in order to test AnalysisContextImpl2. | |
| 197 * | |
| 198 * @param sdkDirectory the directory containing the SDK | |
| 199 */ | |
| 200 DirectoryBasedDartSdk.con1(JavaFile sdkDirectory, bool ignored) { | |
| 201 this._sdkDirectory = sdkDirectory.getAbsoluteFile(); | |
| 202 initializeSdk(); | |
| 203 initializeLibraryMap(); | |
| 204 _analysisContext = new AnalysisContextImpl(); | |
| 205 _analysisContext.sourceFactory = new SourceFactory.con2([new DartUriResolver
(this)]); | |
| 206 List<String> uris = this.uris; | |
| 207 ChangeSet changeSet = new ChangeSet(); | |
| 208 for (String uri in uris) { | |
| 209 changeSet.added(_analysisContext.sourceFactory.forUri(uri)); | |
| 210 } | |
| 211 _analysisContext.applyChanges(changeSet); | |
| 212 } | |
| 213 | |
| 214 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) => new F
ileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), kind); | 193 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) => new F
ileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), kind); |
| 215 | 194 |
| 216 AnalysisContext get context => _analysisContext; | 195 AnalysisContext get context => _analysisContext; |
| 217 | 196 |
| 218 /** | 197 /** |
| 219 * Return the file containing the Dartium executable, or `null` if it does not
exist. | 198 * Return the file containing the Dartium executable, or `null` if it does not
exist. |
| 220 * | 199 * |
| 221 * @return the file containing the Dartium executable | 200 * @return the file containing the Dartium executable |
| 222 */ | 201 */ |
| 223 JavaFile get dartiumExecutable { | 202 JavaFile get dartiumExecutable { |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 Scanner scanner = new Scanner(source, new CharSequenceReader(new CharSequenc
e(libraryFileContents)), errorListener); | 451 Scanner scanner = new Scanner(source, new CharSequenceReader(new CharSequenc
e(libraryFileContents)), errorListener); |
| 473 Parser parser = new Parser(source, errorListener); | 452 Parser parser = new Parser(source, errorListener); |
| 474 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); | 453 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); |
| 475 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li
braryBuilder(); | 454 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li
braryBuilder(); |
| 476 // If any syntactic errors were found then don't try to visit the AST struct
ure. | 455 // If any syntactic errors were found then don't try to visit the AST struct
ure. |
| 477 if (!errorListener.errorReported) { | 456 if (!errorListener.errorReported) { |
| 478 unit.accept(libraryBuilder); | 457 unit.accept(libraryBuilder); |
| 479 } | 458 } |
| 480 return libraryBuilder.librariesMap; | 459 return libraryBuilder.librariesMap; |
| 481 } | 460 } |
| 482 } | |
| 483 | |
| 484 class SdkLibrariesReader_LibraryBuilder extends RecursiveASTVisitor<Object> { | |
| 485 /** | |
| 486 * The prefix added to the name of a library to form the URI used in code to r
eference the | |
| 487 * library. | |
| 488 */ | |
| 489 static String _LIBRARY_PREFIX = "dart:"; | |
| 490 | |
| 491 /** | |
| 492 * The name of the optional parameter used to indicate whether the library is
an implementation | |
| 493 * library. | |
| 494 */ | |
| 495 static String _IMPLEMENTATION = "implementation"; | |
| 496 | |
| 497 /** | |
| 498 * The name of the optional parameter used to indicate whether the library is
documented. | |
| 499 */ | |
| 500 static String _DOCUMENTED = "documented"; | |
| 501 | |
| 502 /** | |
| 503 * The name of the optional parameter used to specify the category of the libr
ary. | |
| 504 */ | |
| 505 static String _CATEGORY = "category"; | |
| 506 | |
| 507 /** | |
| 508 * The name of the optional parameter used to specify the platforms on which t
he library can be | |
| 509 * used. | |
| 510 */ | |
| 511 static String _PLATFORMS = "platforms"; | |
| 512 | |
| 513 /** | |
| 514 * The value of the [PLATFORMS] parameter used to specify that the library can | |
| 515 * be used on the VM. | |
| 516 */ | |
| 517 static String _VM_PLATFORM = "VM_PLATFORM"; | |
| 518 | |
| 519 /** | |
| 520 * The library map that is populated by visiting the AST structure parsed from
the contents of | |
| 521 * the libraries file. | |
| 522 */ | |
| 523 final LibraryMap librariesMap = new LibraryMap(); | |
| 524 | |
| 525 Object visitMapLiteralEntry(MapLiteralEntry node) { | |
| 526 String libraryName = null; | |
| 527 Expression key = node.key; | |
| 528 if (key is SimpleStringLiteral) { | |
| 529 libraryName = "${_LIBRARY_PREFIX}${key.value}"; | |
| 530 } | |
| 531 Expression value = node.value; | |
| 532 if (value is InstanceCreationExpression) { | |
| 533 SdkLibraryImpl library = new SdkLibraryImpl(libraryName); | |
| 534 List<Expression> arguments = value.argumentList.arguments; | |
| 535 for (Expression argument in arguments) { | |
| 536 if (argument is SimpleStringLiteral) { | |
| 537 library.path = argument.value; | |
| 538 } else if (argument is NamedExpression) { | |
| 539 String name = argument.name.label.name; | |
| 540 Expression expression = argument.expression; | |
| 541 if (name == _CATEGORY) { | |
| 542 library.category = (expression as SimpleStringLiteral).value; | |
| 543 } else if (name == _IMPLEMENTATION) { | |
| 544 library.implementation = (expression as BooleanLiteral).value; | |
| 545 } else if (name == _DOCUMENTED) { | |
| 546 library.documented = (expression as BooleanLiteral).value; | |
| 547 } else if (name == _PLATFORMS) { | |
| 548 if (expression is SimpleIdentifier) { | |
| 549 String identifier = expression.name; | |
| 550 if (identifier == _VM_PLATFORM) { | |
| 551 library.setVmLibrary(); | |
| 552 } else { | |
| 553 library.setDart2JsLibrary(); | |
| 554 } | |
| 555 } | |
| 556 } | |
| 557 } | |
| 558 } | |
| 559 librariesMap.setLibrary(libraryName, library); | |
| 560 } | |
| 561 return null; | |
| 562 } | |
| 563 } | 461 } |
| OLD | NEW |