| 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'; |
| 11 import 'java_io.dart'; | 11 import 'java_io.dart'; |
| 12 import 'java_engine_io.dart'; | 12 import 'java_engine_io.dart'; |
| 13 import 'source_io.dart'; | 13 import 'source_io.dart'; |
| 14 import 'error.dart'; | 14 import 'error.dart'; |
| 15 import 'scanner.dart'; | 15 import 'scanner.dart'; |
| 16 import 'ast.dart'; | 16 import 'ast.dart'; |
| 17 import 'parser.dart'; | 17 import 'parser.dart'; |
| 18 import 'sdk.dart'; | 18 import 'sdk.dart'; |
| 19 import 'engine.dart'; | 19 import 'engine.dart'; |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Instances of the class `DirectoryBasedDartSdk` represent a Dart SDK installed
in a | 22 * Instances of the class `DirectoryBasedDartSdk` represent a Dart SDK installed
in a |
| 23 * specified directory. | 23 * specified directory. Typical Dart SDK layout is something like... |
| 24 * |
| 25 * <pre> |
| 26 * dart-sdk/ |
| 27 * bin/ |
| 28 * dart[.exe] <-- VM |
| 29 * lib/ |
| 30 * core/ |
| 31 * core.dart |
| 32 * ... other core library files ... |
| 33 * ... other libraries ... |
| 34 * util/ |
| 35 * ... Dart utilities ... |
| 36 * Chromium/ <-- Dartium typically exists in a sibling directory |
| 37 * </pre> |
| 24 */ | 38 */ |
| 25 class DirectoryBasedDartSdk implements DartSdk { | 39 class DirectoryBasedDartSdk implements DartSdk { |
| 26 /** | 40 /** |
| 27 * The [AnalysisContext] which is used for all of the sources in this [DartSdk
]. | 41 * The [AnalysisContext] which is used for all of the sources in this [DartSdk
]. |
| 28 */ | 42 */ |
| 29 InternalAnalysisContext _analysisContext; | 43 InternalAnalysisContext _analysisContext; |
| 30 | 44 |
| 31 /** | 45 /** |
| 32 * The directory containing the SDK. | 46 * The directory containing the SDK. |
| 33 */ | 47 */ |
| 34 JavaFile _sdkDirectory; | 48 JavaFile _sdkDirectory; |
| 35 | 49 |
| 36 /** | 50 /** |
| 37 * The revision number of this SDK, or `"0"` if the revision number cannot be
discovered. | 51 * The revision number of this SDK, or `"0"` if the revision number cannot be
discovered. |
| 38 */ | 52 */ |
| 39 String _sdkVersion; | 53 String _sdkVersion; |
| 40 | 54 |
| 41 /** | 55 /** |
| 56 * The file containing the dart2js executable. |
| 57 */ |
| 58 JavaFile _dart2jsExecutable; |
| 59 |
| 60 /** |
| 61 * The file containing the dart formatter executable. |
| 62 */ |
| 63 JavaFile _dartFmtExecutable; |
| 64 |
| 65 /** |
| 42 * The file containing the Dartium executable. | 66 * The file containing the Dartium executable. |
| 43 */ | 67 */ |
| 44 JavaFile _dartiumExecutable; | 68 JavaFile _dartiumExecutable; |
| 45 | 69 |
| 46 /** | 70 /** |
| 71 * The file containing the pub executable. |
| 72 */ |
| 73 JavaFile _pubExecutable; |
| 74 |
| 75 /** |
| 47 * The file containing the VM executable. | 76 * The file containing the VM executable. |
| 48 */ | 77 */ |
| 49 JavaFile _vmExecutable; | 78 JavaFile _vmExecutable; |
| 50 | 79 |
| 51 /** | 80 /** |
| 52 * A mapping from Dart library URI's to the library represented by that URI. | 81 * A mapping from Dart library URI's to the library represented by that URI. |
| 53 */ | 82 */ |
| 54 LibraryMap _libraryMap; | 83 LibraryMap _libraryMap; |
| 55 | 84 |
| 56 /** | 85 /** |
| 57 * The name of the directory within the SDK directory that contains executable
s. | 86 * The name of the directory within the SDK directory that contains executable
s. |
| 58 */ | 87 */ |
| 59 static String _BIN_DIRECTORY_NAME = "bin"; | 88 static String _BIN_DIRECTORY_NAME = "bin"; |
| 60 | 89 |
| 61 /** | 90 /** |
| 62 * The name of the directory within the SDK directory that contains Chromium. | 91 * The name of the directory on Mac that contains dartium. |
| 63 */ | 92 */ |
| 64 static String _CHROMIUM_DIRECTORY_NAME = "chromium"; | 93 static String _DARTIUM_DIRECTORY_NAME_MAC = "Chromium.app"; |
| 94 |
| 95 /** |
| 96 * The name of the directory on non-Mac that contains dartium. |
| 97 */ |
| 98 static String _DARTIUM_DIRECTORY_NAME = "chromium"; |
| 99 |
| 100 /** |
| 101 * The name of the dart2js executable on non-windows operating systems. |
| 102 */ |
| 103 static String _DART2JS_EXECUTABLE_NAME = "dart2js"; |
| 104 |
| 105 /** |
| 106 * The name of the file containing the dart2js executable on Windows. |
| 107 */ |
| 108 static String _DART2JS_EXECUTABLE_NAME_WIN = "dart2js.bat"; |
| 109 |
| 110 /** |
| 111 * The name of the dart formatter executable on non-windows operating systems. |
| 112 */ |
| 113 static String _DARTFMT_EXECUTABLE_NAME = "dartfmt"; |
| 114 |
| 115 /** |
| 116 * The name of the dart formatter executable on windows operating systems. |
| 117 */ |
| 118 static String _DARTFMT_EXECUTABLE_NAME_WIN = "dartfmt.bat"; |
| 65 | 119 |
| 66 /** | 120 /** |
| 67 * The name of the file containing the Dartium executable on Linux. | 121 * The name of the file containing the Dartium executable on Linux. |
| 68 */ | 122 */ |
| 69 static String _DARTIUM_EXECUTABLE_NAME_LINUX = "chrome"; | 123 static String _DARTIUM_EXECUTABLE_NAME_LINUX = "chrome"; |
| 70 | 124 |
| 71 /** | 125 /** |
| 72 * The name of the file containing the Dartium executable on Macintosh. | 126 * The name of the file containing the Dartium executable on Macintosh. |
| 73 */ | 127 */ |
| 74 static String _DARTIUM_EXECUTABLE_NAME_MAC = "Chromium.app/Contents/MacOS/Chro
mium"; | 128 static String _DARTIUM_EXECUTABLE_NAME_MAC = "Chromium.app/Contents/MacOS/Chro
mium"; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 * The name of the pub executable on windows. | 169 * The name of the pub executable on windows. |
| 116 */ | 170 */ |
| 117 static String _PUB_EXECUTABLE_NAME_WIN = "pub.bat"; | 171 static String _PUB_EXECUTABLE_NAME_WIN = "pub.bat"; |
| 118 | 172 |
| 119 /** | 173 /** |
| 120 * The name of the pub executable on non-windows operating systems. | 174 * The name of the pub executable on non-windows operating systems. |
| 121 */ | 175 */ |
| 122 static String _PUB_EXECUTABLE_NAME = "pub"; | 176 static String _PUB_EXECUTABLE_NAME = "pub"; |
| 123 | 177 |
| 124 /** | 178 /** |
| 125 * The name of the file within the SDK directory that contains the revision nu
mber of the SDK. | 179 * The name of the file within the SDK directory that contains the version num
ber of the SDK. |
| 126 */ | 180 */ |
| 127 static String _REVISION_FILE_NAME = "revision"; | 181 static String _VERSION_FILE_NAME = "version"; |
| 128 | 182 |
| 129 /** | 183 /** |
| 130 * The name of the file containing the VM executable on the Windows operating
system. | 184 * The name of the file containing the VM executable on the Windows operating
system. |
| 131 */ | 185 */ |
| 132 static String _VM_EXECUTABLE_NAME_WIN = "dart.exe"; | 186 static String _VM_EXECUTABLE_NAME_WIN = "dart.exe"; |
| 133 | 187 |
| 134 /** | 188 /** |
| 135 * The name of the file containing the VM executable on non-Windows operating
systems. | 189 * The name of the file containing the VM executable on non-Windows operating
systems. |
| 136 */ | 190 */ |
| 137 static String _VM_EXECUTABLE_NAME = "dart"; | 191 static String _VM_EXECUTABLE_NAME = "dart"; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 224 } |
| 171 | 225 |
| 172 /** | 226 /** |
| 173 * Initialize a newly created SDK to represent the Dart SDK installed in the g
iven directory. | 227 * Initialize a newly created SDK to represent the Dart SDK installed in the g
iven directory. |
| 174 * | 228 * |
| 175 * @param sdkDirectory the directory containing the SDK | 229 * @param sdkDirectory the directory containing the SDK |
| 176 * @param useDart2jsPaths `true` if the dart2js path should be used when it is
available | 230 * @param useDart2jsPaths `true` if the dart2js path should be used when it is
available |
| 177 */ | 231 */ |
| 178 DirectoryBasedDartSdk(JavaFile sdkDirectory, [bool useDart2jsPaths = false]) { | 232 DirectoryBasedDartSdk(JavaFile sdkDirectory, [bool useDart2jsPaths = false]) { |
| 179 this._sdkDirectory = sdkDirectory.getAbsoluteFile(); | 233 this._sdkDirectory = sdkDirectory.getAbsoluteFile(); |
| 180 _initializeSdk(); | 234 _libraryMap = initialLibraryMap(useDart2jsPaths); |
| 181 _initializeLibraryMap(useDart2jsPaths); | |
| 182 _analysisContext = new AnalysisContextImpl(); | 235 _analysisContext = new AnalysisContextImpl(); |
| 183 _analysisContext.sourceFactory = new SourceFactory([new DartUriResolver(this
)]); | 236 _analysisContext.sourceFactory = new SourceFactory([new DartUriResolver(this
)]); |
| 184 List<String> uris = this.uris; | 237 List<String> uris = this.uris; |
| 185 ChangeSet changeSet = new ChangeSet(); | 238 ChangeSet changeSet = new ChangeSet(); |
| 186 for (String uri in uris) { | 239 for (String uri in uris) { |
| 187 changeSet.addedSource(_analysisContext.sourceFactory.forUri(uri)); | 240 changeSet.addedSource(_analysisContext.sourceFactory.forUri(uri)); |
| 188 } | 241 } |
| 189 _analysisContext.applyChanges(changeSet); | 242 _analysisContext.applyChanges(changeSet); |
| 190 } | 243 } |
| 191 | 244 |
| 192 @override | 245 @override |
| 193 Source fromEncoding(UriKind kind, Uri uri) => new FileBasedSource.con2(new Jav
aFile.fromUri(uri), kind); | 246 Source fromEncoding(UriKind kind, Uri uri) => new FileBasedSource.con2(new Jav
aFile.fromUri(uri), kind); |
| 194 | 247 |
| 195 @override | 248 @override |
| 196 AnalysisContext get context => _analysisContext; | 249 AnalysisContext get context => _analysisContext; |
| 197 | 250 |
| 198 /** | 251 /** |
| 252 * Return the file containing the dart2js executable, or `null` if it does not
exist. |
| 253 * |
| 254 * @return the file containing the dart2js executable |
| 255 */ |
| 256 JavaFile get dart2JsExecutable { |
| 257 if (_dart2jsExecutable == null) { |
| 258 _dart2jsExecutable = _verifyExecutable(new JavaFile.relative(new JavaFile.
relative(_sdkDirectory, _BIN_DIRECTORY_NAME), OSUtilities.isWindows() ? _DART2JS
_EXECUTABLE_NAME_WIN : _DART2JS_EXECUTABLE_NAME)); |
| 259 } |
| 260 return _dart2jsExecutable; |
| 261 } |
| 262 |
| 263 /** |
| 264 * Return the file containing the dart formatter executable, or `null` if it d
oes not exist. |
| 265 * |
| 266 * @return the file containing the dart formatter executable |
| 267 */ |
| 268 JavaFile get dartFmtExecutable { |
| 269 if (_dartFmtExecutable == null) { |
| 270 _dartFmtExecutable = _verifyExecutable(new JavaFile.relative(new JavaFile.
relative(_sdkDirectory, _BIN_DIRECTORY_NAME), OSUtilities.isWindows() ? _DARTFMT
_EXECUTABLE_NAME_WIN : _DARTFMT_EXECUTABLE_NAME)); |
| 271 } |
| 272 return _dartFmtExecutable; |
| 273 } |
| 274 |
| 275 /** |
| 199 * Return the file containing the Dartium executable, or `null` if it does not
exist. | 276 * Return the file containing the Dartium executable, or `null` if it does not
exist. |
| 200 * | 277 * |
| 201 * @return the file containing the Dartium executable | 278 * @return the file containing the Dartium executable |
| 202 */ | 279 */ |
| 203 JavaFile get dartiumExecutable { | 280 JavaFile get dartiumExecutable { |
| 204 if (_dartiumExecutable == null) { | 281 if (_dartiumExecutable == null) { |
| 205 JavaFile file = new JavaFile.relative(dartiumWorkingDirectory, dartiumBina
ryName); | 282 _dartiumExecutable = _verifyExecutable(new JavaFile.relative(dartiumWorkin
gDirectory, dartiumBinaryName)); |
| 206 if (file.exists()) { | |
| 207 _dartiumExecutable = file; | |
| 208 } | |
| 209 } | 283 } |
| 210 return _dartiumExecutable; | 284 return _dartiumExecutable; |
| 211 } | 285 } |
| 212 | 286 |
| 213 /** | 287 /** |
| 214 * Return the directory where dartium can be found in the Dart SDK (the direct
ory that will be the | 288 * Return the directory where dartium can be found (the directory that will be
the working |
| 215 * working directory is Dartium is invoked without changing the default). | 289 * directory is Dartium is invoked without changing the default). |
| 216 * | 290 * |
| 217 * @return the directory where dartium can be found | 291 * @return the directory where dartium can be found |
| 218 */ | 292 */ |
| 219 JavaFile get dartiumWorkingDirectory => new JavaFile.relative(_sdkDirectory.ge
tParentFile(), _CHROMIUM_DIRECTORY_NAME); | 293 JavaFile get dartiumWorkingDirectory => getDartiumWorkingDirectory(_sdkDirecto
ry.getParentFile()); |
| 294 |
| 295 /** |
| 296 * Return the directory where dartium can be found (the directory that will be
the working |
| 297 * directory is Dartium is invoked without changing the default). |
| 298 * |
| 299 * @param installDir the installation directory |
| 300 * @return the directory where dartium can be found |
| 301 */ |
| 302 JavaFile getDartiumWorkingDirectory(JavaFile installDir) => new JavaFile.relat
ive(installDir, _DARTIUM_DIRECTORY_NAME); |
| 220 | 303 |
| 221 /** | 304 /** |
| 222 * Return the directory containing the SDK. | 305 * Return the directory containing the SDK. |
| 223 * | 306 * |
| 224 * @return the directory containing the SDK | 307 * @return the directory containing the SDK |
| 225 */ | 308 */ |
| 226 JavaFile get directory => _sdkDirectory; | 309 JavaFile get directory => _sdkDirectory; |
| 227 | 310 |
| 228 /** | 311 /** |
| 229 * Return the directory containing documentation for the SDK. | 312 * Return the directory containing documentation for the SDK. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 259 * @return the directory that contains the libraries | 342 * @return the directory that contains the libraries |
| 260 */ | 343 */ |
| 261 JavaFile get libraryDirectory => new JavaFile.relative(_sdkDirectory, _LIB_DIR
ECTORY_NAME); | 344 JavaFile get libraryDirectory => new JavaFile.relative(_sdkDirectory, _LIB_DIR
ECTORY_NAME); |
| 262 | 345 |
| 263 /** | 346 /** |
| 264 * Return the file containing the Pub executable, or `null` if it does not exi
st. | 347 * Return the file containing the Pub executable, or `null` if it does not exi
st. |
| 265 * | 348 * |
| 266 * @return the file containing the Pub executable | 349 * @return the file containing the Pub executable |
| 267 */ | 350 */ |
| 268 JavaFile get pubExecutable { | 351 JavaFile get pubExecutable { |
| 269 String pubBinaryName = OSUtilities.isWindows() ? _PUB_EXECUTABLE_NAME_WIN :
_PUB_EXECUTABLE_NAME; | 352 if (_pubExecutable == null) { |
| 270 JavaFile file = new JavaFile.relative(new JavaFile.relative(_sdkDirectory, _
BIN_DIRECTORY_NAME), pubBinaryName); | 353 _pubExecutable = _verifyExecutable(new JavaFile.relative(new JavaFile.rela
tive(_sdkDirectory, _BIN_DIRECTORY_NAME), OSUtilities.isWindows() ? _PUB_EXECUTA
BLE_NAME_WIN : _PUB_EXECUTABLE_NAME)); |
| 271 return file.exists() ? file : null; | 354 } |
| 355 return _pubExecutable; |
| 272 } | 356 } |
| 273 | 357 |
| 274 @override | 358 @override |
| 275 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries; | 359 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries; |
| 276 | 360 |
| 277 @override | 361 @override |
| 278 SdkLibrary getSdkLibrary(String dartUri) => _libraryMap.getLibrary(dartUri); | 362 SdkLibrary getSdkLibrary(String dartUri) => _libraryMap.getLibrary(dartUri); |
| 279 | 363 |
| 280 /** | 364 /** |
| 281 * Return the revision number of this SDK, or `"0"` if the revision number can
not be | 365 * Return the revision number of this SDK, or `"0"` if the revision number can
not be |
| 282 * discovered. | 366 * discovered. |
| 283 * | 367 * |
| 284 * @return the revision number of this SDK | 368 * @return the revision number of this SDK |
| 285 */ | 369 */ |
| 286 @override | 370 @override |
| 287 String get sdkVersion { | 371 String get sdkVersion { |
| 288 if (_sdkVersion == null) { | 372 if (_sdkVersion == null) { |
| 289 _sdkVersion = DartSdk.DEFAULT_VERSION; | 373 _sdkVersion = DartSdk.DEFAULT_VERSION; |
| 290 JavaFile revisionFile = new JavaFile.relative(_sdkDirectory, _REVISION_FIL
E_NAME); | 374 JavaFile revisionFile = new JavaFile.relative(_sdkDirectory, _VERSION_FILE
_NAME); |
| 291 try { | 375 try { |
| 292 String revision = revisionFile.readAsStringSync(); | 376 String revision = revisionFile.readAsStringSync(); |
| 293 if (revision != null) { | 377 if (revision != null) { |
| 294 _sdkVersion = revision; | 378 _sdkVersion = revision.trim(); |
| 295 } | 379 } |
| 296 } on JavaIOException catch (exception) { | 380 } on JavaIOException catch (exception) { |
| 297 } | 381 } |
| 298 } | 382 } |
| 299 return _sdkVersion; | 383 return _sdkVersion; |
| 300 } | 384 } |
| 301 | 385 |
| 302 /** | 386 /** |
| 303 * Return an array containing the library URI's for the libraries defined in t
his SDK. | 387 * Return an array containing the library URI's for the libraries defined in t
his SDK. |
| 304 * | 388 * |
| 305 * @return the library URI's for the libraries defined in this SDK | 389 * @return the library URI's for the libraries defined in this SDK |
| 306 */ | 390 */ |
| 307 @override | 391 @override |
| 308 List<String> get uris => _libraryMap.uris; | 392 List<String> get uris => _libraryMap.uris; |
| 309 | 393 |
| 310 /** | 394 /** |
| 311 * Return the file containing the VM executable, or `null` if it does not exis
t. | 395 * Return the file containing the VM executable, or `null` if it does not exis
t. |
| 312 * | 396 * |
| 313 * @return the file containing the VM executable | 397 * @return the file containing the VM executable |
| 314 */ | 398 */ |
| 315 JavaFile get vmExecutable { | 399 JavaFile get vmExecutable { |
| 316 if (_vmExecutable == null) { | 400 if (_vmExecutable == null) { |
| 317 JavaFile file = new JavaFile.relative(new JavaFile.relative(_sdkDirectory,
_BIN_DIRECTORY_NAME), vmBinaryName); | 401 _vmExecutable = _verifyExecutable(new JavaFile.relative(new JavaFile.relat
ive(_sdkDirectory, _BIN_DIRECTORY_NAME), vmBinaryName)); |
| 318 if (file.exists()) { | |
| 319 _vmExecutable = file; | |
| 320 } | |
| 321 } | 402 } |
| 322 return _vmExecutable; | 403 return _vmExecutable; |
| 323 } | 404 } |
| 324 | 405 |
| 325 /** | 406 /** |
| 326 * Return `true` if this SDK includes documentation. | 407 * Return `true` if this SDK includes documentation. |
| 327 * | 408 * |
| 328 * @return `true` if this installation of the SDK has documentation | 409 * @return `true` if this installation of the SDK has documentation |
| 329 */ | 410 */ |
| 330 bool get hasDocumentation => docDirectory.exists(); | 411 bool get hasDocumentation => docDirectory.exists(); |
| 331 | 412 |
| 332 /** | 413 /** |
| 333 * Return `true` if the Dartium binary is available. | 414 * Return `true` if the Dartium binary is available. |
| 334 * | 415 * |
| 335 * @return `true` if the Dartium binary is available | 416 * @return `true` if the Dartium binary is available |
| 336 */ | 417 */ |
| 337 bool get isDartiumInstalled => dartiumExecutable != null; | 418 bool get isDartiumInstalled => dartiumExecutable != null; |
| 338 | 419 |
| 339 @override | 420 @override |
| 340 Source mapDartUri(String dartUri) { | 421 Source mapDartUri(String dartUri) { |
| 341 SdkLibrary library = getSdkLibrary(dartUri); | 422 SdkLibrary library = getSdkLibrary(dartUri); |
| 342 if (library == null) { | 423 if (library == null) { |
| 343 return null; | 424 return null; |
| 344 } | 425 } |
| 345 return new FileBasedSource.con2(new JavaFile.relative(libraryDirectory, libr
ary.path), UriKind.DART_URI); | 426 return new FileBasedSource.con2(new JavaFile.relative(libraryDirectory, libr
ary.path), UriKind.DART_URI); |
| 346 } | 427 } |
| 347 | 428 |
| 348 /** | 429 /** |
| 430 * Read all of the configuration files to initialize the library maps. |
| 431 * |
| 432 * @param useDart2jsPaths `true` if the dart2js path should be used when it is
available |
| 433 * @return the initialized library map |
| 434 */ |
| 435 LibraryMap initialLibraryMap(bool useDart2jsPaths) { |
| 436 JavaFile librariesFile = new JavaFile.relative(new JavaFile.relative(library
Directory, _INTERNAL_DIR), _LIBRARIES_FILE); |
| 437 try { |
| 438 String contents = librariesFile.readAsStringSync(); |
| 439 return new SdkLibrariesReader(useDart2jsPaths).readFromFile(librariesFile,
contents); |
| 440 } on JavaException catch (exception) { |
| 441 AnalysisEngine.instance.logger.logError2("Could not initialize the library
map from ${librariesFile.getAbsolutePath()}", exception); |
| 442 return new LibraryMap(); |
| 443 } |
| 444 } |
| 445 |
| 446 /** |
| 349 * Ensure that the dart VM is executable. If it is not, make it executable and
log that it was | 447 * 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. | 448 * necessary for us to do so. |
| 351 */ | 449 */ |
| 352 void _ensureVmIsExecutable() { | 450 void _ensureVmIsExecutable() { |
| 353 } | 451 } |
| 354 | 452 |
| 355 /** | 453 /** |
| 356 * Return the name of the file containing the Dartium executable. | 454 * Return the name of the file containing the Dartium executable. |
| 357 * | 455 * |
| 358 * @return the name of the file containing the Dartium executable | 456 * @return the name of the file containing the Dartium executable |
| (...skipping 15 matching lines...) Expand all Loading... |
| 374 */ | 472 */ |
| 375 String get vmBinaryName { | 473 String get vmBinaryName { |
| 376 if (OSUtilities.isWindows()) { | 474 if (OSUtilities.isWindows()) { |
| 377 return _VM_EXECUTABLE_NAME_WIN; | 475 return _VM_EXECUTABLE_NAME_WIN; |
| 378 } else { | 476 } else { |
| 379 return _VM_EXECUTABLE_NAME; | 477 return _VM_EXECUTABLE_NAME; |
| 380 } | 478 } |
| 381 } | 479 } |
| 382 | 480 |
| 383 /** | 481 /** |
| 384 * Read all of the configuration files to initialize the library maps. | 482 * Verify that the given executable file exists and is executable. |
| 385 * | 483 * |
| 386 * @param useDart2jsPaths `true` if the dart2js path should be used when it is
available | 484 * @param file the binary file |
| 485 * @return the file if it exists and is executable, else `null` |
| 387 */ | 486 */ |
| 388 void _initializeLibraryMap(bool useDart2jsPaths) { | 487 JavaFile _verifyExecutable(JavaFile file) => file.isExecutable() ? file : null
; |
| 389 JavaFile librariesFile = new JavaFile.relative(new JavaFile.relative(library
Directory, _INTERNAL_DIR), _LIBRARIES_FILE); | |
| 390 try { | |
| 391 String contents = librariesFile.readAsStringSync(); | |
| 392 _libraryMap = new SdkLibrariesReader(useDart2jsPaths).readFromFile(librari
esFile, contents); | |
| 393 } on JavaException catch (exception) { | |
| 394 AnalysisEngine.instance.logger.logError2("Could not initialize the library
map from ${librariesFile.getAbsolutePath()}", exception); | |
| 395 _libraryMap = new LibraryMap(); | |
| 396 } | |
| 397 } | |
| 398 | |
| 399 /** | |
| 400 * Initialize the state of the SDK. | |
| 401 */ | |
| 402 void _initializeSdk() { | |
| 403 if (!OSUtilities.isWindows()) { | |
| 404 _ensureVmIsExecutable(); | |
| 405 } | |
| 406 } | |
| 407 } | 488 } |
| 408 | 489 |
| 409 /** | 490 /** |
| 410 * Instances of the class `SdkLibrariesReader` read and parse the libraries file | 491 * Instances of the class `SdkLibrariesReader` read and parse the libraries file |
| 411 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries i
n an SDK. The | 492 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries i
n an SDK. The |
| 412 * library information is represented as a Dart file containing a single top-lev
el variable whose | 493 * library information is represented as a Dart file containing a single top-lev
el variable whose |
| 413 * value is a const map. The keys of the map are the names of libraries defined
in the SDK and the | 494 * value is a const map. The keys of the map are the names of libraries defined
in the SDK and the |
| 414 * values in the map are info objects defining the library. For example, a subse
t of a typical SDK | 495 * values in the map are info objects defining the library. For example, a subse
t of a typical SDK |
| 415 * might have a libraries file that looks like the following: | 496 * might have a libraries file that looks like the following: |
| 416 * | 497 * |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 Parser parser = new Parser(source, errorListener); | 546 Parser parser = new Parser(source, errorListener); |
| 466 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); | 547 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); |
| 467 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li
braryBuilder(_useDart2jsPaths); | 548 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li
braryBuilder(_useDart2jsPaths); |
| 468 // If any syntactic errors were found then don't try to visit the AST struct
ure. | 549 // If any syntactic errors were found then don't try to visit the AST struct
ure. |
| 469 if (!errorListener.errorReported) { | 550 if (!errorListener.errorReported) { |
| 470 unit.accept(libraryBuilder); | 551 unit.accept(libraryBuilder); |
| 471 } | 552 } |
| 472 return libraryBuilder.librariesMap; | 553 return libraryBuilder.librariesMap; |
| 473 } | 554 } |
| 474 } | 555 } |
| OLD | NEW |