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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 return null; | 169 return null; |
170 } | 170 } |
171 return sdkDirectory; | 171 return sdkDirectory; |
172 } | 172 } |
173 | 173 |
174 /** | 174 /** |
175 * Initialize a newly created SDK to represent the Dart SDK installed in the g
iven directory. | 175 * Initialize a newly created SDK to represent the Dart SDK installed in the g
iven directory. |
176 * | 176 * |
177 * @param sdkDirectory the directory containing the SDK | 177 * @param sdkDirectory the directory containing the SDK |
178 */ | 178 */ |
179 DirectoryBasedDartSdk(JavaFile sdkDirectory) { | 179 DirectoryBasedDartSdk(JavaFile sdkDirectory) : this.con1(sdkDirectory, false); |
| 180 |
| 181 /** |
| 182 * Initialize a newly created SDK to represent the Dart SDK installed in the g
iven directory. |
| 183 * |
| 184 * @param sdkDirectory the directory containing the SDK |
| 185 * @param useDart2jsPaths `true` if the dart2js path should be used when it is
available |
| 186 */ |
| 187 DirectoryBasedDartSdk.con1(JavaFile sdkDirectory, bool useDart2jsPaths) { |
180 this._sdkDirectory = sdkDirectory.getAbsoluteFile(); | 188 this._sdkDirectory = sdkDirectory.getAbsoluteFile(); |
181 initializeSdk(); | 189 initializeSdk(); |
182 initializeLibraryMap(); | 190 initializeLibraryMap(useDart2jsPaths); |
183 _analysisContext = new AnalysisContextImpl(); | 191 _analysisContext = new AnalysisContextImpl(); |
184 _analysisContext.sourceFactory = new SourceFactory.con2([new DartUriResolver
(this)]); | 192 _analysisContext.sourceFactory = new SourceFactory([new DartUriResolver(this
)]); |
185 List<String> uris = this.uris; | 193 List<String> uris = this.uris; |
186 ChangeSet changeSet = new ChangeSet(); | 194 ChangeSet changeSet = new ChangeSet(); |
187 for (String uri in uris) { | 195 for (String uri in uris) { |
188 changeSet.added(_analysisContext.sourceFactory.forUri(uri)); | 196 changeSet.added(_analysisContext.sourceFactory.forUri(uri)); |
189 } | 197 } |
190 _analysisContext.applyChanges(changeSet); | 198 _analysisContext.applyChanges(changeSet); |
191 } | 199 } |
192 | 200 |
193 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) => new F
ileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), kind); | 201 Source fromEncoding(UriKind kind, Uri uri) => new FileBasedSource.con2(new Jav
aFile.fromUri(uri), kind); |
194 | 202 |
195 AnalysisContext get context => _analysisContext; | 203 AnalysisContext get context => _analysisContext; |
196 | 204 |
197 /** | 205 /** |
198 * Return the file containing the Dartium executable, or `null` if it does not
exist. | 206 * Return the file containing the Dartium executable, or `null` if it does not
exist. |
199 * | 207 * |
200 * @return the file containing the Dartium executable | 208 * @return the file containing the Dartium executable |
201 */ | 209 */ |
202 JavaFile get dartiumExecutable { | 210 JavaFile get dartiumExecutable { |
203 { | 211 { |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 * | 343 * |
336 * @return `true` if the Dartium binary is available | 344 * @return `true` if the Dartium binary is available |
337 */ | 345 */ |
338 bool get isDartiumInstalled => dartiumExecutable != null; | 346 bool get isDartiumInstalled => dartiumExecutable != null; |
339 | 347 |
340 Source mapDartUri(String dartUri) { | 348 Source mapDartUri(String dartUri) { |
341 SdkLibrary library = getSdkLibrary(dartUri); | 349 SdkLibrary library = getSdkLibrary(dartUri); |
342 if (library == null) { | 350 if (library == null) { |
343 return null; | 351 return null; |
344 } | 352 } |
345 return new FileBasedSource.con2(_analysisContext.sourceFactory.contentCache,
new JavaFile.relative(libraryDirectory, library.path), UriKind.DART_URI); | 353 return new FileBasedSource.con2(new JavaFile.relative(libraryDirectory, libr
ary.path), UriKind.DART_URI); |
346 } | 354 } |
347 | 355 |
348 /** | 356 /** |
349 * Ensure that the dart VM is executable. If it is not, make it executable and
log that it was | 357 * Ensure that the dart VM is executable. If it is not, make it executable and
log that it was |
350 * necessary for us to do so. | 358 * necessary for us to do so. |
351 */ | 359 */ |
352 void ensureVmIsExecutable() { | 360 void ensureVmIsExecutable() { |
353 } | 361 } |
354 | 362 |
355 /** | 363 /** |
(...skipping 19 matching lines...) Expand all Loading... |
375 String get vmBinaryName { | 383 String get vmBinaryName { |
376 if (OSUtilities.isWindows()) { | 384 if (OSUtilities.isWindows()) { |
377 return _VM_EXECUTABLE_NAME_WIN; | 385 return _VM_EXECUTABLE_NAME_WIN; |
378 } else { | 386 } else { |
379 return _VM_EXECUTABLE_NAME; | 387 return _VM_EXECUTABLE_NAME; |
380 } | 388 } |
381 } | 389 } |
382 | 390 |
383 /** | 391 /** |
384 * Read all of the configuration files to initialize the library maps. | 392 * Read all of the configuration files to initialize the library maps. |
| 393 * |
| 394 * @param useDart2jsPaths `true` if the dart2js path should be used when it is
available |
385 */ | 395 */ |
386 void initializeLibraryMap() { | 396 void initializeLibraryMap(bool useDart2jsPaths) { |
387 JavaFile librariesFile = new JavaFile.relative(new JavaFile.relative(library
Directory, _INTERNAL_DIR), _LIBRARIES_FILE); | 397 JavaFile librariesFile = new JavaFile.relative(new JavaFile.relative(library
Directory, _INTERNAL_DIR), _LIBRARIES_FILE); |
388 try { | 398 try { |
389 String contents = librariesFile.readAsStringSync(); | 399 String contents = librariesFile.readAsStringSync(); |
390 _libraryMap = new SdkLibrariesReader().readFrom(librariesFile, contents); | 400 _libraryMap = new SdkLibrariesReader(useDart2jsPaths).readFrom(librariesFi
le, contents); |
391 } on JavaException catch (exception) { | 401 } on JavaException catch (exception) { |
392 AnalysisEngine.instance.logger.logError2("Could not initialize the library
map from ${librariesFile.getAbsolutePath()}", exception); | 402 AnalysisEngine.instance.logger.logError2("Could not initialize the library
map from ${librariesFile.getAbsolutePath()}", exception); |
393 _libraryMap = new LibraryMap(); | 403 _libraryMap = new LibraryMap(); |
394 } | 404 } |
395 } | 405 } |
396 | 406 |
397 /** | 407 /** |
398 * Initialize the state of the SDK. | 408 * Initialize the state of the SDK. |
399 */ | 409 */ |
400 void initializeSdk() { | 410 void initializeSdk() { |
(...skipping 23 matching lines...) Expand all Loading... |
424 * "compiler/compiler.dart", | 434 * "compiler/compiler.dart", |
425 * category: "Tools", | 435 * category: "Tools", |
426 * platforms: 0), | 436 * platforms: 0), |
427 * }; | 437 * }; |
428 * </pre> | 438 * </pre> |
429 * | 439 * |
430 * @coverage dart.engine.sdk | 440 * @coverage dart.engine.sdk |
431 */ | 441 */ |
432 class SdkLibrariesReader { | 442 class SdkLibrariesReader { |
433 /** | 443 /** |
| 444 * A flag indicating whether the dart2js path should be used when it is availa
ble. |
| 445 */ |
| 446 bool _useDart2jsPaths = false; |
| 447 |
| 448 /** |
| 449 * Initialize a newly created library reader to use the dart2js path if the gi
ven value is |
| 450 * `true`. |
| 451 * |
| 452 * @param useDart2jsPaths `true` if the dart2js path should be used when it is
available |
| 453 */ |
| 454 SdkLibrariesReader(bool useDart2jsPaths) { |
| 455 this._useDart2jsPaths = useDart2jsPaths; |
| 456 } |
| 457 |
| 458 /** |
434 * Return the library map read from the given source. | 459 * Return the library map read from the given source. |
435 * | 460 * |
436 * @param file the [File] of the library file | 461 * @param file the [File] of the library file |
437 * @param libraryFileContents the contents from the library file | 462 * @param libraryFileContents the contents from the library file |
438 * @return the library map read from the given source | 463 * @return the library map read from the given source |
439 */ | 464 */ |
440 LibraryMap readFrom(JavaFile file, String libraryFileContents) => readFrom2(ne
w FileBasedSource.con2(null, file, UriKind.FILE_URI), libraryFileContents); | 465 LibraryMap readFrom(JavaFile file, String libraryFileContents) => readFrom2(ne
w FileBasedSource.con2(file, UriKind.FILE_URI), libraryFileContents); |
441 | 466 |
442 /** | 467 /** |
443 * Return the library map read from the given source. | 468 * Return the library map read from the given source. |
444 * | 469 * |
445 * @param source the source of the library file | 470 * @param source the source of the library file |
446 * @param libraryFileContents the contents from the library file | 471 * @param libraryFileContents the contents from the library file |
447 * @return the library map read from the given source | 472 * @return the library map read from the given source |
448 */ | 473 */ |
449 LibraryMap readFrom2(Source source, String libraryFileContents) { | 474 LibraryMap readFrom2(Source source, String libraryFileContents) { |
450 BooleanErrorListener errorListener = new BooleanErrorListener(); | 475 BooleanErrorListener errorListener = new BooleanErrorListener(); |
451 Scanner scanner = new Scanner(source, new CharSequenceReader(libraryFileCont
ents), errorListener); | 476 Scanner scanner = new Scanner(source, new CharSequenceReader(libraryFileCont
ents), errorListener); |
452 Parser parser = new Parser(source, errorListener); | 477 Parser parser = new Parser(source, errorListener); |
453 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); | 478 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); |
454 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li
braryBuilder(); | 479 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li
braryBuilder(_useDart2jsPaths); |
455 // If any syntactic errors were found then don't try to visit the AST struct
ure. | 480 // If any syntactic errors were found then don't try to visit the AST struct
ure. |
456 if (!errorListener.errorReported) { | 481 if (!errorListener.errorReported) { |
457 unit.accept(libraryBuilder); | 482 unit.accept(libraryBuilder); |
458 } | 483 } |
459 return libraryBuilder.librariesMap; | 484 return libraryBuilder.librariesMap; |
460 } | 485 } |
461 } | 486 } |
OLD | NEW |