OLD | NEW |
(Empty) | |
| 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. |
| 3 |
| 4 library engine.sdk; |
| 5 |
| 6 import 'dart:io'; |
| 7 import 'dart:uri'; |
| 8 import 'java_core.dart'; |
| 9 import 'java_engine.dart'; |
| 10 import 'package:analyzer-experimental/src/generated/source.dart'; |
| 11 import 'package:analyzer-experimental/src/generated/error.dart'; |
| 12 import 'package:analyzer-experimental/src/generated/scanner.dart'; |
| 13 import 'package:analyzer-experimental/src/generated/parser.dart'; |
| 14 import 'package:analyzer-experimental/src/generated/ast.dart'; |
| 15 import 'package:analyzer-experimental/src/generated/engine.dart' show AnalysisEn
gine; |
| 16 |
| 17 /** |
| 18 * Represents a single library in the SDK |
| 19 */ |
| 20 abstract class SdkLibrary { |
| 21 /** |
| 22 * Return the name of the category containing the library. |
| 23 * @return the name of the category containing the library |
| 24 */ |
| 25 String get category; |
| 26 /** |
| 27 * Return the path to the file defining the library. The path is relative to t
he {@code lib}directory within the SDK. |
| 28 * @return the path to the file defining the library |
| 29 */ |
| 30 String get path; |
| 31 /** |
| 32 * Return the short name of the library. This is the name used after {@code da
rt:} in a URI. |
| 33 * @return the short name of the library |
| 34 */ |
| 35 String get shortName; |
| 36 /** |
| 37 * Return {@code true} if this library can be compiled to JavaScript by dart2j
s. |
| 38 * @return {@code true} if this library can be compiled to JavaScript by dart2
js |
| 39 */ |
| 40 bool isDart2JsLibrary(); |
| 41 /** |
| 42 * Return {@code true} if the library is documented. |
| 43 * @return {@code true} if the library is documented |
| 44 */ |
| 45 bool isDocumented(); |
| 46 /** |
| 47 * Return {@code true} if the library is an implementation library. |
| 48 * @return {@code true} if the library is an implementation library |
| 49 */ |
| 50 bool isImplementation(); |
| 51 /** |
| 52 * Return {@code true} if library can be used for both client and server. |
| 53 * @return {@code true} if this library can be used for both client and server
. |
| 54 */ |
| 55 bool isShared(); |
| 56 /** |
| 57 * 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 |
| 59 */ |
| 60 bool isVmLibrary(); |
| 61 } |
| 62 /** |
| 63 * Instances of the class {@code LibraryMap} map Dart library URI's to the {@lin
k SdkLibraryImpllibrary}. |
| 64 */ |
| 65 class LibraryMap { |
| 66 /** |
| 67 * A table mapping Dart library URI's to the library. |
| 68 */ |
| 69 Map<String, SdkLibraryImpl> _libraryMap = new Map<String, SdkLibraryImpl>(); |
| 70 /** |
| 71 * Initialize a newly created library map to be empty. |
| 72 */ |
| 73 LibraryMap() : super() { |
| 74 } |
| 75 /** |
| 76 * Return the library with the given URI, or {@code null} if the URI does not
map to a library. |
| 77 * @param dartUri the URI of the library to be returned |
| 78 * @return the library with the given URI |
| 79 */ |
| 80 SdkLibrary getLibrary(String dartUri) => _libraryMap[dartUri]; |
| 81 /** |
| 82 * Return an array containing all the sdk libraries {@link SdkLibraryImpl} in
the mapping |
| 83 * @return the sdk libraries in the mapping |
| 84 */ |
| 85 List<SdkLibrary> get sdkLibraries => new List.from(_libraryMap.values); |
| 86 /** |
| 87 * Return an array containing the library URI's for which a mapping is availab
le. |
| 88 * @return the library URI's for which a mapping is available |
| 89 */ |
| 90 List<String> get uris => new List.from(_libraryMap.keys.toSet()); |
| 91 /** |
| 92 * Return the library with the given URI, or {@code null} if the URI does not
map to a library. |
| 93 * @param dartUri the URI of the library to be returned |
| 94 * @param library the library with the given URI |
| 95 */ |
| 96 void setLibrary(String dartUri, SdkLibraryImpl library) { |
| 97 _libraryMap[dartUri] = library; |
| 98 } |
| 99 /** |
| 100 * 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 |
| 102 */ |
| 103 int size() => _libraryMap.length; |
| 104 } |
| 105 /** |
| 106 * Instances of the class {@code DartSdk} represent a Dart SDK installed in a sp
ecified location. |
| 107 */ |
| 108 class DartSdk { |
| 109 /** |
| 110 * The short name of the dart SDK html library. |
| 111 */ |
| 112 static String DART_HTML = "dart:html"; |
| 113 /** |
| 114 * The directory containing the SDK. |
| 115 */ |
| 116 File _sdkDirectory; |
| 117 /** |
| 118 * The revision number of this SDK, or {@code "0"} if the revision number cann
ot be discovered. |
| 119 */ |
| 120 String _sdkVersion; |
| 121 /** |
| 122 * The file containing the Dartium executable. |
| 123 */ |
| 124 File _dartiumExecutable; |
| 125 /** |
| 126 * The file containing the VM executable. |
| 127 */ |
| 128 File _vmExecutable; |
| 129 /** |
| 130 * A mapping from Dart library URI's to the library represented by that URI. |
| 131 */ |
| 132 LibraryMap _libraryMap; |
| 133 /** |
| 134 * The name of the directory within the SDK directory that contains executable
s. |
| 135 */ |
| 136 static String _BIN_DIRECTORY_NAME = "bin"; |
| 137 /** |
| 138 * The name of the directory within the SDK directory that contains Chromium. |
| 139 */ |
| 140 static String _CHROMIUM_DIRECTORY_NAME = "chromium"; |
| 141 /** |
| 142 * The name of the environment variable whose value is the path to the default
Dart SDK directory. |
| 143 */ |
| 144 static String _DART_SDK_ENVIRONMENT_VARIABLE_NAME = "DART_SDK"; |
| 145 /** |
| 146 * The name of the file containing the Dartium executable on Linux. |
| 147 */ |
| 148 static String _DARTIUM_EXECUTABLE_NAME_LINUX = "chromium/chrome"; |
| 149 /** |
| 150 * The name of the file containing the Dartium executable on Macintosh. |
| 151 */ |
| 152 static String _DARTIUM_EXECUTABLE_NAME_MAC = "Chromium.app/Contents/MacOS/Chro
mium"; |
| 153 /** |
| 154 * The name of the file containing the Dartium executable on Windows. |
| 155 */ |
| 156 static String _DARTIUM_EXECUTABLE_NAME_WIN = "chromium/Chrome.exe"; |
| 157 /** |
| 158 * The name of the {@link System} property whose value is the path to the defa
ult Dart SDK |
| 159 * directory. |
| 160 */ |
| 161 static String _DEFAULT_DIRECTORY_PROPERTY_NAME = "com.google.dart.sdk"; |
| 162 /** |
| 163 * The version number that is returned when the real version number could not
be determined. |
| 164 */ |
| 165 static String _DEFAULT_VERSION = "0"; |
| 166 /** |
| 167 * The name of the directory within the SDK directory that contains documentat
ion for the |
| 168 * libraries. |
| 169 */ |
| 170 static String _DOCS_DIRECTORY_NAME = "docs"; |
| 171 /** |
| 172 * The suffix added to the name of a library to derive the name of the file co
ntaining the |
| 173 * documentation for that library. |
| 174 */ |
| 175 static String _DOC_FILE_SUFFIX = "_api.json"; |
| 176 /** |
| 177 * The name of the directory within the SDK directory that contains the librar
ies file. |
| 178 */ |
| 179 static String _INTERNAL_DIR = "_internal"; |
| 180 /** |
| 181 * The name of the directory within the SDK directory that contains the librar
ies. |
| 182 */ |
| 183 static String _LIB_DIRECTORY_NAME = "lib"; |
| 184 /** |
| 185 * The name of the libraries file. |
| 186 */ |
| 187 static String _LIBRARIES_FILE = "libraries.dart"; |
| 188 /** |
| 189 * The name of the directory within the SDK directory that contains the packag
es. |
| 190 */ |
| 191 static String _PKG_DIRECTORY_NAME = "pkg"; |
| 192 /** |
| 193 * The name of the file within the SDK directory that contains the revision nu
mber of the SDK. |
| 194 */ |
| 195 static String _REVISION_FILE_NAME = "revision"; |
| 196 /** |
| 197 * The name of the file containing the VM executable on the Windows operating
system. |
| 198 */ |
| 199 static String _VM_EXECUTABLE_NAME_WIN = "dart.exe"; |
| 200 /** |
| 201 * The name of the file containing the VM executable on non-Windows operating
systems. |
| 202 */ |
| 203 static String _VM_EXECUTABLE_NAME = "dart"; |
| 204 /** |
| 205 * Return the default Dart SDK, or {@code null} if the directory containing th
e default SDK cannot |
| 206 * be determined (or does not exist). |
| 207 * @return the default Dart SDK |
| 208 */ |
| 209 static DartSdk get defaultSdk { |
| 210 File sdkDirectory = defaultSdkDirectory; |
| 211 if (sdkDirectory == null) { |
| 212 return null; |
| 213 } |
| 214 return new DartSdk(sdkDirectory); |
| 215 } |
| 216 /** |
| 217 * 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 |
| 219 * named {@code com.google.dart.sdk}, or, if the property is not defined, an e
nvironment variable |
| 220 * named {@code DART_SDK}. |
| 221 * @return the default directory for the Dart SDK |
| 222 */ |
| 223 static File get defaultSdkDirectory { |
| 224 String sdkProperty = System.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NAME); |
| 225 if (sdkProperty == null) { |
| 226 sdkProperty = System.getenv(_DART_SDK_ENVIRONMENT_VARIABLE_NAME); |
| 227 if (sdkProperty == null) { |
| 228 return null; |
| 229 } |
| 230 } |
| 231 File sdkDirectory = new File(sdkProperty); |
| 232 if (!sdkDirectory.existsSync()) { |
| 233 return null; |
| 234 } |
| 235 return sdkDirectory; |
| 236 } |
| 237 /** |
| 238 * Initialize a newly created SDK to represent the Dart SDK installed in the g
iven directory. |
| 239 * @param sdkDirectory the directory containing the SDK |
| 240 */ |
| 241 DartSdk(File sdkDirectory) { |
| 242 this._sdkDirectory = getAbsoluteFile(sdkDirectory); |
| 243 initializeSdk(); |
| 244 initializeLibraryMap(); |
| 245 } |
| 246 /** |
| 247 * Return the file containing the Dartium executable, or {@code null} if it do
es not exist. |
| 248 * @return the file containing the Dartium executable |
| 249 */ |
| 250 File get dartiumExecutable { |
| 251 { |
| 252 if (_dartiumExecutable == null) { |
| 253 File file = newRelativeFile(_sdkDirectory, dartiumBinaryName); |
| 254 if (file.existsSync()) { |
| 255 _dartiumExecutable = file; |
| 256 } |
| 257 } |
| 258 } |
| 259 return _dartiumExecutable; |
| 260 } |
| 261 /** |
| 262 * Return the directory where dartium can be found in the Dart SDK (the direct
ory that will be the |
| 263 * working directory is Dartium is invoked without changing the default). |
| 264 * @return the directory where dartium can be found |
| 265 */ |
| 266 File get dartiumWorkingDirectory { |
| 267 if (OSUtilities.isWindows() || OSUtilities.isMac()) { |
| 268 return _sdkDirectory; |
| 269 } else { |
| 270 return newRelativeFile(_sdkDirectory, _CHROMIUM_DIRECTORY_NAME); |
| 271 } |
| 272 } |
| 273 /** |
| 274 * Return the directory containing the SDK. |
| 275 * @return the directory containing the SDK |
| 276 */ |
| 277 File get directory => _sdkDirectory; |
| 278 /** |
| 279 * Return the directory containing documentation for the SDK. |
| 280 * @return the SDK's documentation directory |
| 281 */ |
| 282 File get docDirectory => newRelativeFile(_sdkDirectory, _DOCS_DIRECTORY_NAME); |
| 283 /** |
| 284 * Return the auxiliary documentation file for the given library, or {@code nu
ll} if no such file |
| 285 * exists. |
| 286 * @param libraryName the name of the library associated with the documentatio
n file to be |
| 287 * returned |
| 288 * @return the auxiliary documentation file for the library |
| 289 */ |
| 290 File getDocFileFor(String libraryName) { |
| 291 File dir = docDirectory; |
| 292 if (!dir.existsSync()) { |
| 293 return null; |
| 294 } |
| 295 File libDir = newRelativeFile(dir, libraryName); |
| 296 File docFile = newRelativeFile(libDir, "${libraryName}${_DOC_FILE_SUFFIX}"); |
| 297 if (docFile.existsSync()) { |
| 298 return docFile; |
| 299 } |
| 300 return null; |
| 301 } |
| 302 /** |
| 303 * Return the directory within the SDK directory that contains the libraries. |
| 304 * @return the directory that contains the libraries |
| 305 */ |
| 306 File get libraryDirectory => newRelativeFile(_sdkDirectory, _LIB_DIRECTORY_NAM
E); |
| 307 /** |
| 308 * Return the directory within the SDK directory that contains the packages. |
| 309 * @return the directory that contains the packages |
| 310 */ |
| 311 File get packageDirectory => newRelativeFile(directory, _PKG_DIRECTORY_NAME); |
| 312 /** |
| 313 * Return an array containing all of the libraries defined in this SDK. |
| 314 * @return the libraries defined in this SDK |
| 315 */ |
| 316 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries; |
| 317 /** |
| 318 * Return the revision number of this SDK, or {@code "0"} if the revision numb
er cannot be |
| 319 * discovered. |
| 320 * @return the revision number of this SDK |
| 321 */ |
| 322 String get sdkVersion { |
| 323 { |
| 324 if (_sdkVersion == null) { |
| 325 _sdkVersion = _DEFAULT_VERSION; |
| 326 File revisionFile = newRelativeFile(_sdkDirectory, _REVISION_FILE_NAME); |
| 327 try { |
| 328 String revision = revisionFile.readAsStringSync(); |
| 329 if (revision != null) { |
| 330 _sdkVersion = revision; |
| 331 } |
| 332 } on IOException catch (exception) { |
| 333 } |
| 334 } |
| 335 } |
| 336 return _sdkVersion; |
| 337 } |
| 338 /** |
| 339 * Return an array containing the library URI's for the libraries defined in t
his SDK. |
| 340 * @return the library URI's for the libraries defined in this SDK |
| 341 */ |
| 342 List<String> get uris => _libraryMap.uris; |
| 343 /** |
| 344 * Return the file containing the VM executable, or {@code null} if it does no
t exist. |
| 345 * @return the file containing the VM executable |
| 346 */ |
| 347 File get vmExecutable { |
| 348 { |
| 349 if (_vmExecutable == null) { |
| 350 File file = newRelativeFile(newRelativeFile(_sdkDirectory, _BIN_DIRECTOR
Y_NAME), binaryName); |
| 351 if (file.existsSync()) { |
| 352 _vmExecutable = file; |
| 353 } |
| 354 } |
| 355 } |
| 356 return _vmExecutable; |
| 357 } |
| 358 /** |
| 359 * Return {@code true} if this SDK includes documentation. |
| 360 * @return {@code true} if this installation of the SDK has documentation |
| 361 */ |
| 362 bool hasDocumentation() => docDirectory.existsSync(); |
| 363 /** |
| 364 * Return {@code true} if the Dartium binary is available. |
| 365 * @return {@code true} if the Dartium binary is available |
| 366 */ |
| 367 bool isDartiumInstalled() => dartiumExecutable != null; |
| 368 /** |
| 369 * Return the file representing the library with the given {@code dart:} URI,
or {@code null} if |
| 370 * the given URI does not denote a library in this SDK. |
| 371 * @param dartUri the URI of the library to be returned |
| 372 * @return the file representing the specified library |
| 373 */ |
| 374 File mapDartUri(String dartUri) { |
| 375 SdkLibrary library = _libraryMap.getLibrary(dartUri); |
| 376 if (library == null) { |
| 377 return null; |
| 378 } |
| 379 return newRelativeFile(libraryDirectory, library.path); |
| 380 } |
| 381 /** |
| 382 * Ensure that the dart VM is executable. If it is not, make it executable and
log that it was |
| 383 * necessary for us to do so. |
| 384 */ |
| 385 void ensureVmIsExecutable() { |
| 386 } |
| 387 /** |
| 388 * Return the name of the file containing the VM executable. |
| 389 * @return the name of the file containing the VM executable |
| 390 */ |
| 391 String get binaryName { |
| 392 if (OSUtilities.isWindows()) { |
| 393 return _VM_EXECUTABLE_NAME_WIN; |
| 394 } else { |
| 395 return _VM_EXECUTABLE_NAME; |
| 396 } |
| 397 } |
| 398 /** |
| 399 * Return the name of the file containing the Dartium executable. |
| 400 * @return the name of the file containing the Dartium executable |
| 401 */ |
| 402 String get dartiumBinaryName { |
| 403 if (OSUtilities.isWindows()) { |
| 404 return _DARTIUM_EXECUTABLE_NAME_WIN; |
| 405 } else if (OSUtilities.isMac()) { |
| 406 return _DARTIUM_EXECUTABLE_NAME_MAC; |
| 407 } else { |
| 408 return _DARTIUM_EXECUTABLE_NAME_LINUX; |
| 409 } |
| 410 } |
| 411 /** |
| 412 * Read all of the configuration files to initialize the library maps. |
| 413 */ |
| 414 void initializeLibraryMap() { |
| 415 try { |
| 416 File librariesFile = newRelativeFile(newRelativeFile(libraryDirectory, _IN
TERNAL_DIR), _LIBRARIES_FILE); |
| 417 String contents = librariesFile.readAsStringSync(); |
| 418 _libraryMap = new SdkLibrariesReader().readFrom(librariesFile, contents); |
| 419 } on JavaException catch (exception) { |
| 420 AnalysisEngine.instance.logger.logError3(exception); |
| 421 _libraryMap = new LibraryMap(); |
| 422 } |
| 423 } |
| 424 /** |
| 425 * Initialize the state of the SDK. |
| 426 */ |
| 427 void initializeSdk() { |
| 428 if (!OSUtilities.isWindows()) { |
| 429 ensureVmIsExecutable(); |
| 430 } |
| 431 } |
| 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 } |
OLD | NEW |