| 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 | 3 |
| 4 library engine.sdk; | 4 library engine.sdk; |
| 5 | 5 |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 import 'dart:uri'; | 7 import 'dart:uri'; |
| 8 import 'java_core.dart'; | 8 import 'java_core.dart'; |
| 9 import 'java_io.dart'; |
| 9 import 'java_engine.dart'; | 10 import 'java_engine.dart'; |
| 10 import 'package:analyzer-experimental/src/generated/source.dart'; | 11 import 'java_engine_io.dart'; |
| 12 import 'package:analyzer-experimental/src/generated/source_io.dart'; |
| 11 import 'package:analyzer-experimental/src/generated/error.dart'; | 13 import 'package:analyzer-experimental/src/generated/error.dart'; |
| 12 import 'package:analyzer-experimental/src/generated/scanner.dart'; | 14 import 'package:analyzer-experimental/src/generated/scanner.dart'; |
| 13 import 'package:analyzer-experimental/src/generated/parser.dart'; | 15 import 'package:analyzer-experimental/src/generated/parser.dart'; |
| 14 import 'package:analyzer-experimental/src/generated/ast.dart'; | 16 import 'package:analyzer-experimental/src/generated/ast.dart'; |
| 15 import 'package:analyzer-experimental/src/generated/engine.dart' show AnalysisEn
gine; | 17 import 'package:analyzer-experimental/src/generated/engine.dart' show AnalysisEn
gine; |
| 16 | 18 |
| 17 /** | 19 /** |
| 18 * Represents a single library in the SDK | 20 * Represents a single library in the SDK |
| 19 */ | 21 */ |
| 20 abstract class SdkLibrary { | 22 abstract class SdkLibrary { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 * @return {@code true} if this library can be used for both client and server
. | 55 * @return {@code true} if this library can be used for both client and server
. |
| 54 */ | 56 */ |
| 55 bool isShared(); | 57 bool isShared(); |
| 56 /** | 58 /** |
| 57 * Return {@code true} if this library can be run on the VM. | 59 * Return {@code true} if this library can be run on the VM. |
| 58 * @return {@code true} if this library can be run on the VM | 60 * @return {@code true} if this library can be run on the VM |
| 59 */ | 61 */ |
| 60 bool isVmLibrary(); | 62 bool isVmLibrary(); |
| 61 } | 63 } |
| 62 /** | 64 /** |
| 65 * Instances of the class {@code SdkLibrary} represent the information known abo
ut a single library |
| 66 * within the SDK. |
| 67 */ |
| 68 class SdkLibraryImpl implements SdkLibrary { |
| 69 /** |
| 70 * The short name of the library. This is the name used after {@code dart:} in
a URI. |
| 71 */ |
| 72 String _shortName = null; |
| 73 /** |
| 74 * The path to the file defining the library. The path is relative to the {@co
de lib} directory |
| 75 * within the SDK. |
| 76 */ |
| 77 String _path = null; |
| 78 /** |
| 79 * The name of the category containing the library. Unless otherwise specified
in the libraries |
| 80 * file all libraries are assumed to be shared between server and client. |
| 81 */ |
| 82 String _category = "Shared"; |
| 83 /** |
| 84 * A flag indicating whether the library is documented. |
| 85 */ |
| 86 bool _documented = true; |
| 87 /** |
| 88 * A flag indicating whether the library is an implementation library. |
| 89 */ |
| 90 bool _implementation = false; |
| 91 /** |
| 92 * An encoding of which platforms this library is intended to work on. |
| 93 */ |
| 94 int _platforms = 0; |
| 95 /** |
| 96 * The bit mask used to access the bit representing the flag indicating whethe
r a library is |
| 97 * intended to work on the dart2js platform. |
| 98 */ |
| 99 static int DART2JS_PLATFORM = 1; |
| 100 /** |
| 101 * The bit mask used to access the bit representing the flag indicating whethe
r a library is |
| 102 * intended to work on the VM platform. |
| 103 */ |
| 104 static int VM_PLATFORM = 2; |
| 105 /** |
| 106 * Initialize a newly created library to represent the library with the given
name. |
| 107 * @param name the short name of the library |
| 108 */ |
| 109 SdkLibraryImpl(String name) { |
| 110 this._shortName = name; |
| 111 } |
| 112 String get category => _category; |
| 113 String get path => _path; |
| 114 String get shortName => _shortName; |
| 115 bool isDart2JsLibrary() => (_platforms & DART2JS_PLATFORM) != 0; |
| 116 bool isDocumented() => _documented; |
| 117 bool isImplementation() => _implementation; |
| 118 /** |
| 119 * Return {@code true} if library can be used for both client and server |
| 120 */ |
| 121 bool isShared() => _category == "Shared"; |
| 122 /** |
| 123 * Return {@code true} if this library can be run on the VM. |
| 124 * @return {@code true} if this library can be run on the VM |
| 125 */ |
| 126 bool isVmLibrary() => (_platforms & VM_PLATFORM) != 0; |
| 127 /** |
| 128 * Set the name of the category containing the library to the given name. |
| 129 * @param category the name of the category containing the library |
| 130 */ |
| 131 void set category(String category2) { |
| 132 this._category = category2; |
| 133 } |
| 134 /** |
| 135 * Record that this library can be compiled to JavaScript by dart2js. |
| 136 */ |
| 137 void setDart2JsLibrary() { |
| 138 _platforms |= DART2JS_PLATFORM; |
| 139 } |
| 140 /** |
| 141 * Set whether the library is documented to match the given value. |
| 142 * @param documented {@code true} if the library is documented |
| 143 */ |
| 144 void set documented(bool documented2) { |
| 145 this._documented = documented2; |
| 146 } |
| 147 /** |
| 148 * Set whether the library is an implementation library to match the given val
ue. |
| 149 * @param implementation {@code true} if the library is an implementation libr
ary |
| 150 */ |
| 151 void set implementation(bool implementation2) { |
| 152 this._implementation = implementation2; |
| 153 } |
| 154 /** |
| 155 * Set the path to the file defining the library to the given path. The path i
s relative to the{@code lib} directory within the SDK. |
| 156 * @param path the path to the file defining the library |
| 157 */ |
| 158 void set path(String path2) { |
| 159 this._path = path2; |
| 160 } |
| 161 /** |
| 162 * Record that this library can be run on the VM. |
| 163 */ |
| 164 void setVmLibrary() { |
| 165 _platforms |= VM_PLATFORM; |
| 166 } |
| 167 } |
| 168 /** |
| 169 * Instances of the class {@code SdkLibrariesReader} read and parse the librarie
s file |
| 170 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries i
n an SDK. The |
| 171 * library information is represented as a Dart file containing a single top-lev
el variable whose |
| 172 * value is a const map. The keys of the map are the names of libraries defined
in the SDK and the |
| 173 * values in the map are info objects defining the library. For example, a subse
t of a typical SDK |
| 174 * might have a libraries file that looks like the following: |
| 175 * <pre> |
| 176 * final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> { |
| 177 * // Used by VM applications |
| 178 * "builtin" : const LibraryInfo( |
| 179 * "builtin/builtin_runtime.dart", |
| 180 * category: "Server", |
| 181 * platforms: VM_PLATFORM), |
| 182 * "compiler" : const LibraryInfo( |
| 183 * "compiler/compiler.dart", |
| 184 * category: "Tools", |
| 185 * platforms: 0), |
| 186 * }; |
| 187 * </pre> |
| 188 */ |
| 189 class SdkLibrariesReader { |
| 190 /** |
| 191 * Return the library map read from the given source. |
| 192 * @return the library map read from the given source |
| 193 */ |
| 194 LibraryMap readFrom(File librariesFile, String libraryFileContents) { |
| 195 List<bool> foundError = [false]; |
| 196 AnalysisErrorListener errorListener = new AnalysisErrorListener_5(foundError
); |
| 197 Source source = new FileBasedSource.con2(null, librariesFile, false); |
| 198 StringScanner scanner = new StringScanner(source, libraryFileContents, error
Listener); |
| 199 Parser parser = new Parser(source, errorListener); |
| 200 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); |
| 201 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li
braryBuilder(); |
| 202 if (!foundError[0]) { |
| 203 unit.accept(libraryBuilder); |
| 204 } |
| 205 return libraryBuilder.librariesMap; |
| 206 } |
| 207 } |
| 208 class SdkLibrariesReader_LibraryBuilder extends RecursiveASTVisitor<Object> { |
| 209 /** |
| 210 * The prefix added to the name of a library to form the URI used in code to r
eference the |
| 211 * library. |
| 212 */ |
| 213 static String _LIBRARY_PREFIX = "dart:"; |
| 214 /** |
| 215 * The name of the optional parameter used to indicate whether the library is
an implementation |
| 216 * library. |
| 217 */ |
| 218 static String _IMPLEMENTATION = "implementation"; |
| 219 /** |
| 220 * The name of the optional parameter used to indicate whether the library is
documented. |
| 221 */ |
| 222 static String _DOCUMENTED = "documented"; |
| 223 /** |
| 224 * The name of the optional parameter used to specify the category of the libr
ary. |
| 225 */ |
| 226 static String _CATEGORY = "category"; |
| 227 /** |
| 228 * The name of the optional parameter used to specify the platforms on which t
he library can be |
| 229 * used. |
| 230 */ |
| 231 static String _PLATFORMS = "platforms"; |
| 232 /** |
| 233 * The value of the {@link #PLATFORMS platforms} parameter used to specify tha
t the library can |
| 234 * be used on the VM. |
| 235 */ |
| 236 static String _VM_PLATFORM = "VM_PLATFORM"; |
| 237 /** |
| 238 * The library map that is populated by visiting the AST structure parsed from
the contents of |
| 239 * the libraries file. |
| 240 */ |
| 241 LibraryMap _librariesMap = new LibraryMap(); |
| 242 /** |
| 243 * Return the library map that was populated by visiting the AST structure par
sed from the |
| 244 * contents of the libraries file. |
| 245 * @return the library map describing the contents of the SDK |
| 246 */ |
| 247 LibraryMap get librariesMap => _librariesMap; |
| 248 Object visitMapLiteralEntry(MapLiteralEntry node) { |
| 249 String libraryName = null; |
| 250 Expression key3 = node.key; |
| 251 if (key3 is SimpleStringLiteral) { |
| 252 libraryName = "${_LIBRARY_PREFIX}${((key3 as SimpleStringLiteral)).value}"
; |
| 253 } |
| 254 Expression value9 = node.value; |
| 255 if (value9 is InstanceCreationExpression) { |
| 256 SdkLibraryImpl library = new SdkLibraryImpl(libraryName); |
| 257 List<Expression> arguments6 = ((value9 as InstanceCreationExpression)).arg
umentList.arguments; |
| 258 for (Expression argument in arguments6) { |
| 259 if (argument is SimpleStringLiteral) { |
| 260 library.path = ((argument as SimpleStringLiteral)).value; |
| 261 } else if (argument is NamedExpression) { |
| 262 String name19 = ((argument as NamedExpression)).name.label.name; |
| 263 Expression expression15 = ((argument as NamedExpression)).expression; |
| 264 if (name19 == _CATEGORY) { |
| 265 library.category = ((expression15 as SimpleStringLiteral)).value; |
| 266 } else if (name19 == _IMPLEMENTATION) { |
| 267 library.implementation = ((expression15 as BooleanLiteral)).value; |
| 268 } else if (name19 == _DOCUMENTED) { |
| 269 library.documented = ((expression15 as BooleanLiteral)).value; |
| 270 } else if (name19 == _PLATFORMS) { |
| 271 if (expression15 is SimpleIdentifier) { |
| 272 String identifier = ((expression15 as SimpleIdentifier)).name; |
| 273 if (identifier == _VM_PLATFORM) { |
| 274 library.setVmLibrary(); |
| 275 } else { |
| 276 library.setDart2JsLibrary(); |
| 277 } |
| 278 } |
| 279 } |
| 280 } |
| 281 } |
| 282 _librariesMap.setLibrary(libraryName, library); |
| 283 } |
| 284 return null; |
| 285 } |
| 286 } |
| 287 class AnalysisErrorListener_5 implements AnalysisErrorListener { |
| 288 List<bool> foundError; |
| 289 AnalysisErrorListener_5(this.foundError); |
| 290 void onError(AnalysisError error) { |
| 291 foundError[0] = true; |
| 292 } |
| 293 } |
| 294 /** |
| 63 * Instances of the class {@code LibraryMap} map Dart library URI's to the {@lin
k SdkLibraryImpllibrary}. | 295 * Instances of the class {@code LibraryMap} map Dart library URI's to the {@lin
k SdkLibraryImpllibrary}. |
| 64 */ | 296 */ |
| 65 class LibraryMap { | 297 class LibraryMap { |
| 66 /** | 298 /** |
| 67 * A table mapping Dart library URI's to the library. | 299 * A table mapping Dart library URI's to the library. |
| 68 */ | 300 */ |
| 69 Map<String, SdkLibraryImpl> _libraryMap = new Map<String, SdkLibraryImpl>(); | 301 Map<String, SdkLibraryImpl> _libraryMap = new Map<String, SdkLibraryImpl>(); |
| 70 /** | 302 /** |
| 71 * Initialize a newly created library map to be empty. | 303 * Initialize a newly created library map to be empty. |
| 72 */ | 304 */ |
| (...skipping 27 matching lines...) Expand all Loading... |
| 100 * Return the number of library URI's for which a mapping is available. | 332 * Return the number of library URI's for which a mapping is available. |
| 101 * @return the number of library URI's for which a mapping is available | 333 * @return the number of library URI's for which a mapping is available |
| 102 */ | 334 */ |
| 103 int size() => _libraryMap.length; | 335 int size() => _libraryMap.length; |
| 104 } | 336 } |
| 105 /** | 337 /** |
| 106 * Instances of the class {@code DartSdk} represent a Dart SDK installed in a sp
ecified location. | 338 * Instances of the class {@code DartSdk} represent a Dart SDK installed in a sp
ecified location. |
| 107 */ | 339 */ |
| 108 class DartSdk { | 340 class DartSdk { |
| 109 /** | 341 /** |
| 342 * The short name of the dart SDK core library. |
| 343 */ |
| 344 static String DART_CORE = "dart:core"; |
| 345 /** |
| 110 * The short name of the dart SDK html library. | 346 * The short name of the dart SDK html library. |
| 111 */ | 347 */ |
| 112 static String DART_HTML = "dart:html"; | 348 static String DART_HTML = "dart:html"; |
| 113 /** | 349 /** |
| 114 * The directory containing the SDK. | 350 * The directory containing the SDK. |
| 115 */ | 351 */ |
| 116 File _sdkDirectory; | 352 File _sdkDirectory; |
| 117 /** | 353 /** |
| 118 * The revision number of this SDK, or {@code "0"} if the revision number cann
ot be discovered. | 354 * The revision number of this SDK, or {@code "0"} if the revision number cann
ot be discovered. |
| 119 */ | 355 */ |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 return new DartSdk(sdkDirectory); | 450 return new DartSdk(sdkDirectory); |
| 215 } | 451 } |
| 216 /** | 452 /** |
| 217 * Return the default directory for the Dart SDK, or {@code null} if the direc
tory cannot be | 453 * Return the default directory for the Dart SDK, or {@code null} if the direc
tory cannot be |
| 218 * determined (or does not exist). The default directory is provided by a {@li
nk System} property | 454 * determined (or does not exist). The default directory is provided by a {@li
nk System} property |
| 219 * named {@code com.google.dart.sdk}, or, if the property is not defined, an e
nvironment variable | 455 * named {@code com.google.dart.sdk}, or, if the property is not defined, an e
nvironment variable |
| 220 * named {@code DART_SDK}. | 456 * named {@code DART_SDK}. |
| 221 * @return the default directory for the Dart SDK | 457 * @return the default directory for the Dart SDK |
| 222 */ | 458 */ |
| 223 static File get defaultSdkDirectory { | 459 static File get defaultSdkDirectory { |
| 224 String sdkProperty = System.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NAME); | 460 String sdkProperty = JavaSystemIO.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NA
ME); |
| 225 if (sdkProperty == null) { | 461 if (sdkProperty == null) { |
| 226 sdkProperty = System.getenv(_DART_SDK_ENVIRONMENT_VARIABLE_NAME); | 462 sdkProperty = JavaSystemIO.getenv(_DART_SDK_ENVIRONMENT_VARIABLE_NAME); |
| 227 if (sdkProperty == null) { | 463 if (sdkProperty == null) { |
| 228 return null; | 464 return null; |
| 229 } | 465 } |
| 230 } | 466 } |
| 231 File sdkDirectory = new File(sdkProperty); | 467 File sdkDirectory = new File(sdkProperty); |
| 232 if (!sdkDirectory.existsSync()) { | 468 if (!sdkDirectory.existsSync()) { |
| 233 return null; | 469 return null; |
| 234 } | 470 } |
| 235 return sdkDirectory; | 471 return sdkDirectory; |
| 236 } | 472 } |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 } | 658 } |
| 423 } | 659 } |
| 424 /** | 660 /** |
| 425 * Initialize the state of the SDK. | 661 * Initialize the state of the SDK. |
| 426 */ | 662 */ |
| 427 void initializeSdk() { | 663 void initializeSdk() { |
| 428 if (!OSUtilities.isWindows()) { | 664 if (!OSUtilities.isWindows()) { |
| 429 ensureVmIsExecutable(); | 665 ensureVmIsExecutable(); |
| 430 } | 666 } |
| 431 } | 667 } |
| 432 } | |
| 433 /** | |
| 434 * Instances of the class {@code SdkLibrariesReader} read and parse the librarie
s file | |
| 435 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries i
n an SDK. The | |
| 436 * library information is represented as a Dart file containing a single top-lev
el variable whose | |
| 437 * value is a const map. The keys of the map are the names of libraries defined
in the SDK and the | |
| 438 * values in the map are info objects defining the library. For example, a subse
t of a typical SDK | |
| 439 * might have a libraries file that looks like the following: | |
| 440 * <pre> | |
| 441 * final Map<String, LibraryInfo> LIBRARIES = const <LibraryInfo> { | |
| 442 * // Used by VM applications | |
| 443 * "builtin" : const LibraryInfo( | |
| 444 * "builtin/builtin_runtime.dart", | |
| 445 * category: "Server", | |
| 446 * platforms: VM_PLATFORM), | |
| 447 * "compiler" : const LibraryInfo( | |
| 448 * "compiler/compiler.dart", | |
| 449 * category: "Tools", | |
| 450 * platforms: 0), | |
| 451 * }; | |
| 452 * </pre> | |
| 453 */ | |
| 454 class SdkLibrariesReader { | |
| 455 /** | |
| 456 * Return the library map read from the given source. | |
| 457 * @return the library map read from the given source | |
| 458 */ | |
| 459 LibraryMap readFrom(File librariesFile, String libraryFileContents) { | |
| 460 List<bool> foundError = [false]; | |
| 461 AnalysisErrorListener errorListener = new AnalysisErrorListener_3(foundError
); | |
| 462 Source source = new FileBasedSource.con2(null, librariesFile, false); | |
| 463 StringScanner scanner = new StringScanner(source, libraryFileContents, error
Listener); | |
| 464 Parser parser = new Parser(source, errorListener); | |
| 465 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); | |
| 466 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li
braryBuilder(); | |
| 467 if (!foundError[0]) { | |
| 468 unit.accept(libraryBuilder); | |
| 469 } | |
| 470 return libraryBuilder.librariesMap; | |
| 471 } | |
| 472 } | |
| 473 class SdkLibrariesReader_LibraryBuilder extends RecursiveASTVisitor<Object> { | |
| 474 /** | |
| 475 * The prefix added to the name of a library to form the URI used in code to r
eference the | |
| 476 * library. | |
| 477 */ | |
| 478 static String _LIBRARY_PREFIX = "dart:"; | |
| 479 /** | |
| 480 * The name of the optional parameter used to indicate whether the library is
an implementation | |
| 481 * library. | |
| 482 */ | |
| 483 static String _IMPLEMENTATION = "implementation"; | |
| 484 /** | |
| 485 * The name of the optional parameter used to indicate whether the library is
documented. | |
| 486 */ | |
| 487 static String _DOCUMENTED = "documented"; | |
| 488 /** | |
| 489 * The name of the optional parameter used to specify the category of the libr
ary. | |
| 490 */ | |
| 491 static String _CATEGORY = "category"; | |
| 492 /** | |
| 493 * The name of the optional parameter used to specify the platforms on which t
he library can be | |
| 494 * used. | |
| 495 */ | |
| 496 static String _PLATFORMS = "platforms"; | |
| 497 /** | |
| 498 * The value of the {@link #PLATFORMS platforms} parameter used to specify tha
t the library can | |
| 499 * be used on the VM. | |
| 500 */ | |
| 501 static String _VM_PLATFORM = "VM_PLATFORM"; | |
| 502 /** | |
| 503 * The library map that is populated by visiting the AST structure parsed from
the contents of | |
| 504 * the libraries file. | |
| 505 */ | |
| 506 LibraryMap _librariesMap = new LibraryMap(); | |
| 507 /** | |
| 508 * Return the library map that was populated by visiting the AST structure par
sed from the | |
| 509 * contents of the libraries file. | |
| 510 * @return the library map describing the contents of the SDK | |
| 511 */ | |
| 512 LibraryMap get librariesMap => _librariesMap; | |
| 513 Object visitMapLiteralEntry(MapLiteralEntry node) { | |
| 514 String libraryName = null; | |
| 515 Expression key3 = node.key; | |
| 516 if (key3 is SimpleStringLiteral) { | |
| 517 libraryName = "${_LIBRARY_PREFIX}${((key3 as SimpleStringLiteral)).value}"
; | |
| 518 } | |
| 519 Expression value8 = node.value; | |
| 520 if (value8 is InstanceCreationExpression) { | |
| 521 SdkLibraryImpl library = new SdkLibraryImpl(libraryName); | |
| 522 List<Expression> arguments6 = ((value8 as InstanceCreationExpression)).arg
umentList.arguments; | |
| 523 for (Expression argument in arguments6) { | |
| 524 if (argument is SimpleStringLiteral) { | |
| 525 library.path = ((argument as SimpleStringLiteral)).value; | |
| 526 } else if (argument is NamedExpression) { | |
| 527 String name18 = ((argument as NamedExpression)).name.label.name; | |
| 528 Expression expression15 = ((argument as NamedExpression)).expression; | |
| 529 if (name18 == _CATEGORY) { | |
| 530 library.category = ((expression15 as SimpleStringLiteral)).value; | |
| 531 } else if (name18 == _IMPLEMENTATION) { | |
| 532 library.implementation = ((expression15 as BooleanLiteral)).value; | |
| 533 } else if (name18 == _DOCUMENTED) { | |
| 534 library.documented = ((expression15 as BooleanLiteral)).value; | |
| 535 } else if (name18 == _PLATFORMS) { | |
| 536 if (expression15 is SimpleIdentifier) { | |
| 537 String identifier = ((expression15 as SimpleIdentifier)).name; | |
| 538 if (identifier == _VM_PLATFORM) { | |
| 539 library.setVmLibrary(); | |
| 540 } else { | |
| 541 library.setDart2JsLibrary(); | |
| 542 } | |
| 543 } | |
| 544 } | |
| 545 } | |
| 546 } | |
| 547 _librariesMap.setLibrary(libraryName, library); | |
| 548 } | |
| 549 return null; | |
| 550 } | |
| 551 } | |
| 552 class AnalysisErrorListener_3 implements AnalysisErrorListener { | |
| 553 List<bool> foundError; | |
| 554 AnalysisErrorListener_3(this.foundError); | |
| 555 void onError(AnalysisError error) { | |
| 556 foundError[0] = true; | |
| 557 } | |
| 558 } | |
| 559 /** | |
| 560 * Instances of the class {@code SdkLibrary} represent the information known abo
ut a single library | |
| 561 * within the SDK. | |
| 562 */ | |
| 563 class SdkLibraryImpl implements SdkLibrary { | |
| 564 /** | |
| 565 * The short name of the library. This is the name used after {@code dart:} in
a URI. | |
| 566 */ | |
| 567 String _shortName = null; | |
| 568 /** | |
| 569 * The path to the file defining the library. The path is relative to the {@co
de lib} directory | |
| 570 * within the SDK. | |
| 571 */ | |
| 572 String _path = null; | |
| 573 /** | |
| 574 * The name of the category containing the library. Unless otherwise specified
in the libraries | |
| 575 * file all libraries are assumed to be shared between server and client. | |
| 576 */ | |
| 577 String _category = "Shared"; | |
| 578 /** | |
| 579 * A flag indicating whether the library is documented. | |
| 580 */ | |
| 581 bool _documented = true; | |
| 582 /** | |
| 583 * A flag indicating whether the library is an implementation library. | |
| 584 */ | |
| 585 bool _implementation = false; | |
| 586 /** | |
| 587 * An encoding of which platforms this library is intended to work on. | |
| 588 */ | |
| 589 int _platforms = 0; | |
| 590 /** | |
| 591 * The bit mask used to access the bit representing the flag indicating whethe
r a library is | |
| 592 * intended to work on the dart2js platform. | |
| 593 */ | |
| 594 static int DART2JS_PLATFORM = 1; | |
| 595 /** | |
| 596 * The bit mask used to access the bit representing the flag indicating whethe
r a library is | |
| 597 * intended to work on the VM platform. | |
| 598 */ | |
| 599 static int VM_PLATFORM = 2; | |
| 600 /** | |
| 601 * Initialize a newly created library to represent the library with the given
name. | |
| 602 * @param name the short name of the library | |
| 603 */ | |
| 604 SdkLibraryImpl(String name) { | |
| 605 this._shortName = name; | |
| 606 } | |
| 607 String get category => _category; | |
| 608 String get path => _path; | |
| 609 String get shortName => _shortName; | |
| 610 bool isDart2JsLibrary() => (_platforms & DART2JS_PLATFORM) != 0; | |
| 611 bool isDocumented() => _documented; | |
| 612 bool isImplementation() => _implementation; | |
| 613 /** | |
| 614 * Return {@code true} if library can be used for both client and server | |
| 615 */ | |
| 616 bool isShared() => _category == "Shared"; | |
| 617 /** | |
| 618 * Return {@code true} if this library can be run on the VM. | |
| 619 * @return {@code true} if this library can be run on the VM | |
| 620 */ | |
| 621 bool isVmLibrary() => (_platforms & VM_PLATFORM) != 0; | |
| 622 /** | |
| 623 * Set the name of the category containing the library to the given name. | |
| 624 * @param category the name of the category containing the library | |
| 625 */ | |
| 626 void set category(String category2) { | |
| 627 this._category = category2; | |
| 628 } | |
| 629 /** | |
| 630 * Record that this library can be compiled to JavaScript by dart2js. | |
| 631 */ | |
| 632 void setDart2JsLibrary() { | |
| 633 _platforms |= DART2JS_PLATFORM; | |
| 634 } | |
| 635 /** | |
| 636 * Set whether the library is documented to match the given value. | |
| 637 * @param documented {@code true} if the library is documented | |
| 638 */ | |
| 639 void set documented(bool documented2) { | |
| 640 this._documented = documented2; | |
| 641 } | |
| 642 /** | |
| 643 * Set whether the library is an implementation library to match the given val
ue. | |
| 644 * @param implementation {@code true} if the library is an implementation libr
ary | |
| 645 */ | |
| 646 void set implementation(bool implementation2) { | |
| 647 this._implementation = implementation2; | |
| 648 } | |
| 649 /** | |
| 650 * Set the path to the file defining the library to the given path. The path i
s relative to the{@code lib} directory within the SDK. | |
| 651 * @param path the path to the file defining the library | |
| 652 */ | |
| 653 void set path(String path2) { | |
| 654 this._path = path2; | |
| 655 } | |
| 656 /** | |
| 657 * Record that this library can be run on the VM. | |
| 658 */ | |
| 659 void setVmLibrary() { | |
| 660 _platforms |= VM_PLATFORM; | |
| 661 } | |
| 662 } | 668 } |
| OLD | NEW |