| 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 library engine.sdk.io; | 3 library engine.sdk.io; |
| 4 import 'dart:io'; | 4 import 'dart:io'; |
| 5 import 'java_core.dart'; | 5 import 'java_core.dart'; |
| 6 import 'java_io.dart'; | 6 import 'java_io.dart'; |
| 7 import 'java_engine.dart'; | 7 import 'java_engine.dart'; |
| 8 import 'java_engine_io.dart'; | 8 import 'java_engine_io.dart'; |
| 9 import 'source_io.dart'; | 9 import 'source_io.dart'; |
| 10 import 'error.dart'; | 10 import 'error.dart'; |
| 11 import 'scanner.dart'; | 11 import 'scanner.dart'; |
| 12 import 'ast.dart'; | 12 import 'ast.dart'; |
| 13 import 'parser.dart'; | 13 import 'parser.dart'; |
| 14 import 'sdk.dart'; | 14 import 'sdk.dart'; |
| 15 import 'engine.dart'; | 15 import 'engine.dart'; |
| 16 /** | 16 /** |
| 17 * Instances of the class {@code DirectoryBasedDartSdk} represent a Dart SDK ins
talled in a | 17 * Instances of the class `DirectoryBasedDartSdk` represent a Dart SDK installed
in a |
| 18 * specified directory. | 18 * specified directory. |
| 19 * @coverage dart.engine.sdk | 19 * @coverage dart.engine.sdk |
| 20 */ | 20 */ |
| 21 class DirectoryBasedDartSdk implements DartSdk { | 21 class DirectoryBasedDartSdk implements DartSdk { |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * The {@link AnalysisContext} which is used for all of the sources in this {@
link DartSdk}. | 24 * The [AnalysisContext] which is used for all of the sources in this [DartSdk
]. |
| 25 */ | 25 */ |
| 26 InternalAnalysisContext _analysisContext; | 26 InternalAnalysisContext _analysisContext; |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * The directory containing the SDK. | 29 * The directory containing the SDK. |
| 30 */ | 30 */ |
| 31 JavaFile _sdkDirectory; | 31 JavaFile _sdkDirectory; |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * The revision number of this SDK, or {@code "0"} if the revision number cann
ot be discovered. | 34 * The revision number of this SDK, or `"0"` if the revision number cannot be
discovered. |
| 35 */ | 35 */ |
| 36 String _sdkVersion; | 36 String _sdkVersion; |
| 37 | 37 |
| 38 /** | 38 /** |
| 39 * The file containing the Dartium executable. | 39 * The file containing the Dartium executable. |
| 40 */ | 40 */ |
| 41 JavaFile _dartiumExecutable; | 41 JavaFile _dartiumExecutable; |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * The file containing the VM executable. | 44 * The file containing the VM executable. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 74 * The name of the file containing the Dartium executable on Macintosh. | 74 * The name of the file containing the Dartium executable on Macintosh. |
| 75 */ | 75 */ |
| 76 static String _DARTIUM_EXECUTABLE_NAME_MAC = "Chromium.app/Contents/MacOS/Chro
mium"; | 76 static String _DARTIUM_EXECUTABLE_NAME_MAC = "Chromium.app/Contents/MacOS/Chro
mium"; |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * The name of the file containing the Dartium executable on Windows. | 79 * The name of the file containing the Dartium executable on Windows. |
| 80 */ | 80 */ |
| 81 static String _DARTIUM_EXECUTABLE_NAME_WIN = "Chrome.exe"; | 81 static String _DARTIUM_EXECUTABLE_NAME_WIN = "Chrome.exe"; |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * The name of the {@link System} property whose value is the path to the defa
ult Dart SDK | 84 * The name of the [System] property whose value is the path to the default Da
rt SDK |
| 85 * directory. | 85 * directory. |
| 86 */ | 86 */ |
| 87 static String _DEFAULT_DIRECTORY_PROPERTY_NAME = "com.google.dart.sdk"; | 87 static String _DEFAULT_DIRECTORY_PROPERTY_NAME = "com.google.dart.sdk"; |
| 88 | 88 |
| 89 /** | 89 /** |
| 90 * The name of the directory within the SDK directory that contains documentat
ion for the | 90 * The name of the directory within the SDK directory that contains documentat
ion for the |
| 91 * libraries. | 91 * libraries. |
| 92 */ | 92 */ |
| 93 static String _DOCS_DIRECTORY_NAME = "docs"; | 93 static String _DOCS_DIRECTORY_NAME = "docs"; |
| 94 | 94 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 122 * The name of the file containing the VM executable on the Windows operating
system. | 122 * The name of the file containing the VM executable on the Windows operating
system. |
| 123 */ | 123 */ |
| 124 static String _VM_EXECUTABLE_NAME_WIN = "dart.exe"; | 124 static String _VM_EXECUTABLE_NAME_WIN = "dart.exe"; |
| 125 | 125 |
| 126 /** | 126 /** |
| 127 * The name of the file containing the VM executable on non-Windows operating
systems. | 127 * The name of the file containing the VM executable on non-Windows operating
systems. |
| 128 */ | 128 */ |
| 129 static String _VM_EXECUTABLE_NAME = "dart"; | 129 static String _VM_EXECUTABLE_NAME = "dart"; |
| 130 | 130 |
| 131 /** | 131 /** |
| 132 * Return the default Dart SDK, or {@code null} if the directory containing th
e default SDK cannot | 132 * Return the default Dart SDK, or `null` if the directory containing the defa
ult SDK cannot |
| 133 * be determined (or does not exist). | 133 * be determined (or does not exist). |
| 134 * @return the default Dart SDK | 134 * @return the default Dart SDK |
| 135 */ | 135 */ |
| 136 static DirectoryBasedDartSdk get defaultSdk { | 136 static DirectoryBasedDartSdk get defaultSdk { |
| 137 JavaFile sdkDirectory = defaultSdkDirectory; | 137 JavaFile sdkDirectory = defaultSdkDirectory; |
| 138 if (sdkDirectory == null) { | 138 if (sdkDirectory == null) { |
| 139 return null; | 139 return null; |
| 140 } | 140 } |
| 141 return new DirectoryBasedDartSdk(sdkDirectory); | 141 return new DirectoryBasedDartSdk(sdkDirectory); |
| 142 } | 142 } |
| 143 | 143 |
| 144 /** | 144 /** |
| 145 * Return the default directory for the Dart SDK, or {@code null} if the direc
tory cannot be | 145 * Return the default directory for the Dart SDK, or `null` if the directory c
annot be |
| 146 * determined (or does not exist). The default directory is provided by a {@li
nk System} property | 146 * determined (or does not exist). The default directory is provided by a [Sys
tem] property |
| 147 * named {@code com.google.dart.sdk}, or, if the property is not defined, an e
nvironment variable | 147 * named `com.google.dart.sdk`, or, if the property is not defined, an environ
ment variable |
| 148 * named {@code DART_SDK}. | 148 * named `DART_SDK`. |
| 149 * @return the default directory for the Dart SDK | 149 * @return the default directory for the Dart SDK |
| 150 */ | 150 */ |
| 151 static JavaFile get defaultSdkDirectory { | 151 static JavaFile get defaultSdkDirectory { |
| 152 String sdkProperty = JavaSystemIO.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NA
ME); | 152 String sdkProperty = JavaSystemIO.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NA
ME); |
| 153 if (sdkProperty == null) { | 153 if (sdkProperty == null) { |
| 154 sdkProperty = JavaSystemIO.getenv(_DART_SDK_ENVIRONMENT_VARIABLE_NAME); | 154 sdkProperty = JavaSystemIO.getenv(_DART_SDK_ENVIRONMENT_VARIABLE_NAME); |
| 155 if (sdkProperty == null) { | 155 if (sdkProperty == null) { |
| 156 return null; | 156 return null; |
| 157 } | 157 } |
| 158 } | 158 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 177 ChangeSet changeSet = new ChangeSet(); | 177 ChangeSet changeSet = new ChangeSet(); |
| 178 for (String uri in uris) { | 178 for (String uri in uris) { |
| 179 changeSet.added(_analysisContext.sourceFactory.forUri(uri)); | 179 changeSet.added(_analysisContext.sourceFactory.forUri(uri)); |
| 180 } | 180 } |
| 181 _analysisContext.applyChanges(changeSet); | 181 _analysisContext.applyChanges(changeSet); |
| 182 } | 182 } |
| 183 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) => new F
ileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), kind); | 183 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) => new F
ileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), kind); |
| 184 AnalysisContext get context => _analysisContext; | 184 AnalysisContext get context => _analysisContext; |
| 185 | 185 |
| 186 /** | 186 /** |
| 187 * Return the file containing the Dartium executable, or {@code null} if it do
es not exist. | 187 * Return the file containing the Dartium executable, or `null` if it does not
exist. |
| 188 * @return the file containing the Dartium executable | 188 * @return the file containing the Dartium executable |
| 189 */ | 189 */ |
| 190 JavaFile get dartiumExecutable { | 190 JavaFile get dartiumExecutable { |
| 191 { | 191 { |
| 192 if (_dartiumExecutable == null) { | 192 if (_dartiumExecutable == null) { |
| 193 JavaFile file = new JavaFile.relative(dartiumWorkingDirectory, dartiumBi
naryName); | 193 JavaFile file = new JavaFile.relative(dartiumWorkingDirectory, dartiumBi
naryName); |
| 194 if (file.exists()) { | 194 if (file.exists()) { |
| 195 _dartiumExecutable = file; | 195 _dartiumExecutable = file; |
| 196 } | 196 } |
| 197 } | 197 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 212 */ | 212 */ |
| 213 JavaFile get directory => _sdkDirectory; | 213 JavaFile get directory => _sdkDirectory; |
| 214 | 214 |
| 215 /** | 215 /** |
| 216 * Return the directory containing documentation for the SDK. | 216 * Return the directory containing documentation for the SDK. |
| 217 * @return the SDK's documentation directory | 217 * @return the SDK's documentation directory |
| 218 */ | 218 */ |
| 219 JavaFile get docDirectory => new JavaFile.relative(_sdkDirectory, _DOCS_DIRECT
ORY_NAME); | 219 JavaFile get docDirectory => new JavaFile.relative(_sdkDirectory, _DOCS_DIRECT
ORY_NAME); |
| 220 | 220 |
| 221 /** | 221 /** |
| 222 * Return the auxiliary documentation file for the given library, or {@code nu
ll} if no such file | 222 * Return the auxiliary documentation file for the given library, or `null` if
no such file |
| 223 * exists. | 223 * exists. |
| 224 * @param libraryName the name of the library associated with the documentatio
n file to be | 224 * @param libraryName the name of the library associated with the documentatio
n file to be |
| 225 * returned | 225 * returned |
| 226 * @return the auxiliary documentation file for the library | 226 * @return the auxiliary documentation file for the library |
| 227 */ | 227 */ |
| 228 JavaFile getDocFileFor(String libraryName) { | 228 JavaFile getDocFileFor(String libraryName) { |
| 229 JavaFile dir = docDirectory; | 229 JavaFile dir = docDirectory; |
| 230 if (!dir.exists()) { | 230 if (!dir.exists()) { |
| 231 return null; | 231 return null; |
| 232 } | 232 } |
| 233 JavaFile libDir = new JavaFile.relative(dir, libraryName); | 233 JavaFile libDir = new JavaFile.relative(dir, libraryName); |
| 234 JavaFile docFile = new JavaFile.relative(libDir, "${libraryName}${_DOC_FILE_
SUFFIX}"); | 234 JavaFile docFile = new JavaFile.relative(libDir, "${libraryName}${_DOC_FILE_
SUFFIX}"); |
| 235 if (docFile.exists()) { | 235 if (docFile.exists()) { |
| 236 return docFile; | 236 return docFile; |
| 237 } | 237 } |
| 238 return null; | 238 return null; |
| 239 } | 239 } |
| 240 | 240 |
| 241 /** | 241 /** |
| 242 * Return the directory within the SDK directory that contains the libraries. | 242 * Return the directory within the SDK directory that contains the libraries. |
| 243 * @return the directory that contains the libraries | 243 * @return the directory that contains the libraries |
| 244 */ | 244 */ |
| 245 JavaFile get libraryDirectory => new JavaFile.relative(_sdkDirectory, _LIB_DIR
ECTORY_NAME); | 245 JavaFile get libraryDirectory => new JavaFile.relative(_sdkDirectory, _LIB_DIR
ECTORY_NAME); |
| 246 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries; | 246 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries; |
| 247 SdkLibrary getSdkLibrary(String dartUri) => _libraryMap.getLibrary(dartUri); | 247 SdkLibrary getSdkLibrary(String dartUri) => _libraryMap.getLibrary(dartUri); |
| 248 | 248 |
| 249 /** | 249 /** |
| 250 * Return the revision number of this SDK, or {@code "0"} if the revision numb
er cannot be | 250 * Return the revision number of this SDK, or `"0"` if the revision number can
not be |
| 251 * discovered. | 251 * discovered. |
| 252 * @return the revision number of this SDK | 252 * @return the revision number of this SDK |
| 253 */ | 253 */ |
| 254 String get sdkVersion { | 254 String get sdkVersion { |
| 255 { | 255 { |
| 256 if (_sdkVersion == null) { | 256 if (_sdkVersion == null) { |
| 257 _sdkVersion = DartSdk.DEFAULT_VERSION; | 257 _sdkVersion = DartSdk.DEFAULT_VERSION; |
| 258 JavaFile revisionFile = new JavaFile.relative(_sdkDirectory, _REVISION_F
ILE_NAME); | 258 JavaFile revisionFile = new JavaFile.relative(_sdkDirectory, _REVISION_F
ILE_NAME); |
| 259 try { | 259 try { |
| 260 String revision = revisionFile.readAsStringSync(); | 260 String revision = revisionFile.readAsStringSync(); |
| 261 if (revision != null) { | 261 if (revision != null) { |
| 262 _sdkVersion = revision; | 262 _sdkVersion = revision; |
| 263 } | 263 } |
| 264 } on IOException catch (exception) { | 264 } on IOException catch (exception) { |
| 265 } | 265 } |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 return _sdkVersion; | 268 return _sdkVersion; |
| 269 } | 269 } |
| 270 | 270 |
| 271 /** | 271 /** |
| 272 * Return an array containing the library URI's for the libraries defined in t
his SDK. | 272 * Return an array containing the library URI's for the libraries defined in t
his SDK. |
| 273 * @return the library URI's for the libraries defined in this SDK | 273 * @return the library URI's for the libraries defined in this SDK |
| 274 */ | 274 */ |
| 275 List<String> get uris => _libraryMap.uris; | 275 List<String> get uris => _libraryMap.uris; |
| 276 | 276 |
| 277 /** | 277 /** |
| 278 * Return the file containing the VM executable, or {@code null} if it does no
t exist. | 278 * Return the file containing the VM executable, or `null` if it does not exis
t. |
| 279 * @return the file containing the VM executable | 279 * @return the file containing the VM executable |
| 280 */ | 280 */ |
| 281 JavaFile get vmExecutable { | 281 JavaFile get vmExecutable { |
| 282 { | 282 { |
| 283 if (_vmExecutable == null) { | 283 if (_vmExecutable == null) { |
| 284 JavaFile file = new JavaFile.relative(new JavaFile.relative(_sdkDirector
y, _BIN_DIRECTORY_NAME), binaryName); | 284 JavaFile file = new JavaFile.relative(new JavaFile.relative(_sdkDirector
y, _BIN_DIRECTORY_NAME), binaryName); |
| 285 if (file.exists()) { | 285 if (file.exists()) { |
| 286 _vmExecutable = file; | 286 _vmExecutable = file; |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 return _vmExecutable; | 290 return _vmExecutable; |
| 291 } | 291 } |
| 292 | 292 |
| 293 /** | 293 /** |
| 294 * Return {@code true} if this SDK includes documentation. | 294 * Return `true` if this SDK includes documentation. |
| 295 * @return {@code true} if this installation of the SDK has documentation | 295 * @return `true` if this installation of the SDK has documentation |
| 296 */ | 296 */ |
| 297 bool hasDocumentation() => docDirectory.exists(); | 297 bool hasDocumentation() => docDirectory.exists(); |
| 298 | 298 |
| 299 /** | 299 /** |
| 300 * Return {@code true} if the Dartium binary is available. | 300 * Return `true` if the Dartium binary is available. |
| 301 * @return {@code true} if the Dartium binary is available | 301 * @return `true` if the Dartium binary is available |
| 302 */ | 302 */ |
| 303 bool isDartiumInstalled() => dartiumExecutable != null; | 303 bool isDartiumInstalled() => dartiumExecutable != null; |
| 304 Source mapDartUri(ContentCache contentCache, String dartUri) { | 304 Source mapDartUri(ContentCache contentCache, String dartUri) { |
| 305 SdkLibrary library = getSdkLibrary(dartUri); | 305 SdkLibrary library = getSdkLibrary(dartUri); |
| 306 if (library == null) { | 306 if (library == null) { |
| 307 return null; | 307 return null; |
| 308 } | 308 } |
| 309 return new FileBasedSource.con2(contentCache, new JavaFile.relative(libraryD
irectory, library.path), UriKind.DART_URI); | 309 return new FileBasedSource.con2(contentCache, new JavaFile.relative(libraryD
irectory, library.path), UriKind.DART_URI); |
| 310 } | 310 } |
| 311 | 311 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 /** | 359 /** |
| 360 * Initialize the state of the SDK. | 360 * Initialize the state of the SDK. |
| 361 */ | 361 */ |
| 362 void initializeSdk() { | 362 void initializeSdk() { |
| 363 if (!OSUtilities.isWindows()) { | 363 if (!OSUtilities.isWindows()) { |
| 364 ensureVmIsExecutable(); | 364 ensureVmIsExecutable(); |
| 365 } | 365 } |
| 366 } | 366 } |
| 367 } | 367 } |
| 368 /** | 368 /** |
| 369 * Instances of the class {@code SdkLibrariesReader} read and parse the librarie
s file | 369 * Instances of the class `SdkLibrariesReader` read and parse the libraries file |
| 370 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries i
n an SDK. The | 370 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries i
n an SDK. The |
| 371 * library information is represented as a Dart file containing a single top-lev
el variable whose | 371 * library information is represented as a Dart file containing a single top-lev
el variable whose |
| 372 * value is a const map. The keys of the map are the names of libraries defined
in the SDK and the | 372 * value is a const map. The keys of the map are the names of libraries defined
in the SDK and the |
| 373 * values in the map are info objects defining the library. For example, a subse
t of a typical SDK | 373 * values in the map are info objects defining the library. For example, a subse
t of a typical SDK |
| 374 * might have a libraries file that looks like the following: | 374 * might have a libraries file that looks like the following: |
| 375 * <pre> | 375 * <pre> |
| 376 * final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> { | 376 * final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> { |
| 377 * // Used by VM applications | 377 * // Used by VM applications |
| 378 * "builtin" : const LibraryInfo( | 378 * "builtin" : const LibraryInfo( |
| 379 * "builtin/builtin_runtime.dart", | 379 * "builtin/builtin_runtime.dart", |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 */ | 431 */ |
| 432 static String _CATEGORY = "category"; | 432 static String _CATEGORY = "category"; |
| 433 | 433 |
| 434 /** | 434 /** |
| 435 * The name of the optional parameter used to specify the platforms on which t
he library can be | 435 * The name of the optional parameter used to specify the platforms on which t
he library can be |
| 436 * used. | 436 * used. |
| 437 */ | 437 */ |
| 438 static String _PLATFORMS = "platforms"; | 438 static String _PLATFORMS = "platforms"; |
| 439 | 439 |
| 440 /** | 440 /** |
| 441 * The value of the {@link #PLATFORMS platforms} parameter used to specify tha
t the library can | 441 * The value of the [PLATFORMS platforms] parameter used to specify that the l
ibrary can |
| 442 * be used on the VM. | 442 * be used on the VM. |
| 443 */ | 443 */ |
| 444 static String _VM_PLATFORM = "VM_PLATFORM"; | 444 static String _VM_PLATFORM = "VM_PLATFORM"; |
| 445 | 445 |
| 446 /** | 446 /** |
| 447 * The library map that is populated by visiting the AST structure parsed from
the contents of | 447 * The library map that is populated by visiting the AST structure parsed from
the contents of |
| 448 * the libraries file. | 448 * the libraries file. |
| 449 */ | 449 */ |
| 450 LibraryMap _librariesMap = new LibraryMap(); | 450 LibraryMap _librariesMap = new LibraryMap(); |
| 451 | 451 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 return null; | 494 return null; |
| 495 } | 495 } |
| 496 } | 496 } |
| 497 class AnalysisErrorListener_8 implements AnalysisErrorListener { | 497 class AnalysisErrorListener_8 implements AnalysisErrorListener { |
| 498 List<bool> foundError; | 498 List<bool> foundError; |
| 499 AnalysisErrorListener_8(this.foundError); | 499 AnalysisErrorListener_8(this.foundError); |
| 500 void onError(AnalysisError error) { | 500 void onError(AnalysisError error) { |
| 501 foundError[0] = true; | 501 foundError[0] = true; |
| 502 } | 502 } |
| 503 } | 503 } |
| OLD | NEW |