Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: pkg/analyzer_experimental/lib/src/generated/sdk_io.dart

Issue 14308011: New Analysis Engine snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_io.dart';
10 import 'java_engine.dart'; 10 import 'java_engine.dart';
11 import 'java_engine_io.dart'; 11 import 'java_engine_io.dart';
12 import 'source_io.dart'; 12 import 'source_io.dart';
13 import 'error.dart'; 13 import 'error.dart';
14 import 'scanner.dart'; 14 import 'scanner.dart';
15 import 'ast.dart';
15 import 'parser.dart'; 16 import 'parser.dart';
16 import 'ast.dart'; 17 import 'sdk.dart';
17 import 'package:analyzer_experimental/src/generated/engine.dart' show AnalysisEn gine; 18 import 'engine.dart';
18 19
19 /** 20 /**
20 * Represents a single library in the SDK 21 * Instances of the class {@code DirectoryBasedDartSdk} represent a Dart SDK ins talled in a
21 */ 22 * specified directory.
22 abstract class SdkLibrary {
23 /**
24 * Return the name of the category containing the library.
25 * @return the name of the category containing the library
26 */
27 String get category;
28 /**
29 * Return the path to the file defining the library. The path is relative to t he {@code lib}directory within the SDK.
30 * @return the path to the file defining the library
31 */
32 String get path;
33 /**
34 * Return the short name of the library. This is the name used after {@code da rt:} in a URI.
35 * @return the short name of the library
36 */
37 String get shortName;
38 /**
39 * Return {@code true} if this library can be compiled to JavaScript by dart2j s.
40 * @return {@code true} if this library can be compiled to JavaScript by dart2 js
41 */
42 bool isDart2JsLibrary();
43 /**
44 * Return {@code true} if the library is documented.
45 * @return {@code true} if the library is documented
46 */
47 bool isDocumented();
48 /**
49 * Return {@code true} if the library is an implementation library.
50 * @return {@code true} if the library is an implementation library
51 */
52 bool isImplementation();
53 /**
54 * Return {@code true} if library can be used for both client and server.
55 * @return {@code true} if this library can be used for both client and server .
56 */
57 bool isShared();
58 /**
59 * 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
61 */
62 bool isVmLibrary();
63 }
64 /**
65 * Instances of the class {@code SdkLibrary} represent the information known abo ut a single library
66 * within the SDK.
67 * @coverage dart.engine.sdk 23 * @coverage dart.engine.sdk
68 */ 24 */
69 class SdkLibraryImpl implements SdkLibrary { 25 class DirectoryBasedDartSdk implements DartSdk {
70 /** 26 /**
71 * The short name of the library. This is the name used after {@code dart:} in a URI. 27 * The {@link AnalysisContext} which is used for all of the sources in this {@ link DartSdk}.
72 */ 28 */
73 String _shortName = null; 29 InternalAnalysisContext _analysisContext;
74 /**
75 * The path to the file defining the library. The path is relative to the {@co de lib} directory
76 * within the SDK.
77 */
78 String _path = null;
79 /**
80 * The name of the category containing the library. Unless otherwise specified in the libraries
81 * file all libraries are assumed to be shared between server and client.
82 */
83 String _category = "Shared";
84 /**
85 * A flag indicating whether the library is documented.
86 */
87 bool _documented = true;
88 /**
89 * A flag indicating whether the library is an implementation library.
90 */
91 bool _implementation = false;
92 /**
93 * An encoding of which platforms this library is intended to work on.
94 */
95 int _platforms = 0;
96 /**
97 * The bit mask used to access the bit representing the flag indicating whethe r a library is
98 * intended to work on the dart2js platform.
99 */
100 static int DART2JS_PLATFORM = 1;
101 /**
102 * The bit mask used to access the bit representing the flag indicating whethe r a library is
103 * intended to work on the VM platform.
104 */
105 static int VM_PLATFORM = 2;
106 /**
107 * Initialize a newly created library to represent the library with the given name.
108 * @param name the short name of the library
109 */
110 SdkLibraryImpl(String name) {
111 this._shortName = name;
112 }
113 String get category => _category;
114 String get path => _path;
115 String get shortName => _shortName;
116 bool isDart2JsLibrary() => (_platforms & DART2JS_PLATFORM) != 0;
117 bool isDocumented() => _documented;
118 bool isImplementation() => _implementation;
119 /**
120 * Return {@code true} if library can be used for both client and server
121 */
122 bool isShared() => _category == "Shared";
123 /**
124 * Return {@code true} if this library can be run on the VM.
125 * @return {@code true} if this library can be run on the VM
126 */
127 bool isVmLibrary() => (_platforms & VM_PLATFORM) != 0;
128 /**
129 * Set the name of the category containing the library to the given name.
130 * @param category the name of the category containing the library
131 */
132 void set category(String category2) {
133 this._category = category2;
134 }
135 /**
136 * Record that this library can be compiled to JavaScript by dart2js.
137 */
138 void setDart2JsLibrary() {
139 _platforms |= DART2JS_PLATFORM;
140 }
141 /**
142 * Set whether the library is documented to match the given value.
143 * @param documented {@code true} if the library is documented
144 */
145 void set documented(bool documented2) {
146 this._documented = documented2;
147 }
148 /**
149 * Set whether the library is an implementation library to match the given val ue.
150 * @param implementation {@code true} if the library is an implementation libr ary
151 */
152 void set implementation(bool implementation2) {
153 this._implementation = implementation2;
154 }
155 /**
156 * 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.
157 * @param path the path to the file defining the library
158 */
159 void set path(String path2) {
160 this._path = path2;
161 }
162 /**
163 * Record that this library can be run on the VM.
164 */
165 void setVmLibrary() {
166 _platforms |= VM_PLATFORM;
167 }
168 }
169 /**
170 * Instances of the class {@code SdkLibrariesReader} read and parse the librarie s file
171 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries i n an SDK. The
172 * library information is represented as a Dart file containing a single top-lev el variable whose
173 * value is a const map. The keys of the map are the names of libraries defined in the SDK and the
174 * values in the map are info objects defining the library. For example, a subse t of a typical SDK
175 * might have a libraries file that looks like the following:
176 * <pre>
177 * final Map&lt;String, LibraryInfo&gt; LIBRARIES = const &lt;LibraryInfo&gt; {
178 * // Used by VM applications
179 * "builtin" : const LibraryInfo(
180 * "builtin/builtin_runtime.dart",
181 * category: "Server",
182 * platforms: VM_PLATFORM),
183 * "compiler" : const LibraryInfo(
184 * "compiler/compiler.dart",
185 * category: "Tools",
186 * platforms: 0),
187 * };
188 * </pre>
189 * @coverage dart.engine.sdk
190 */
191 class SdkLibrariesReader {
192 /**
193 * Return the library map read from the given source.
194 * @return the library map read from the given source
195 */
196 LibraryMap readFrom(JavaFile librariesFile, String libraryFileContents) {
197 List<bool> foundError = [false];
198 AnalysisErrorListener errorListener = new AnalysisErrorListener_7(foundError );
199 Source source = new FileBasedSource.con2(null, librariesFile, false);
200 StringScanner scanner = new StringScanner(source, libraryFileContents, error Listener);
201 Parser parser = new Parser(source, errorListener);
202 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize());
203 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li braryBuilder();
204 if (!foundError[0]) {
205 unit.accept(libraryBuilder);
206 }
207 return libraryBuilder.librariesMap;
208 }
209 }
210 class SdkLibrariesReader_LibraryBuilder extends RecursiveASTVisitor<Object> {
211 /**
212 * The prefix added to the name of a library to form the URI used in code to r eference the
213 * library.
214 */
215 static String _LIBRARY_PREFIX = "dart:";
216 /**
217 * The name of the optional parameter used to indicate whether the library is an implementation
218 * library.
219 */
220 static String _IMPLEMENTATION = "implementation";
221 /**
222 * The name of the optional parameter used to indicate whether the library is documented.
223 */
224 static String _DOCUMENTED = "documented";
225 /**
226 * The name of the optional parameter used to specify the category of the libr ary.
227 */
228 static String _CATEGORY = "category";
229 /**
230 * The name of the optional parameter used to specify the platforms on which t he library can be
231 * used.
232 */
233 static String _PLATFORMS = "platforms";
234 /**
235 * The value of the {@link #PLATFORMS platforms} parameter used to specify tha t the library can
236 * be used on the VM.
237 */
238 static String _VM_PLATFORM = "VM_PLATFORM";
239 /**
240 * The library map that is populated by visiting the AST structure parsed from the contents of
241 * the libraries file.
242 */
243 LibraryMap _librariesMap = new LibraryMap();
244 /**
245 * Return the library map that was populated by visiting the AST structure par sed from the
246 * contents of the libraries file.
247 * @return the library map describing the contents of the SDK
248 */
249 LibraryMap get librariesMap => _librariesMap;
250 Object visitMapLiteralEntry(MapLiteralEntry node) {
251 String libraryName = null;
252 Expression key3 = node.key;
253 if (key3 is SimpleStringLiteral) {
254 libraryName = "${_LIBRARY_PREFIX}${((key3 as SimpleStringLiteral)).value}" ;
255 }
256 Expression value9 = node.value;
257 if (value9 is InstanceCreationExpression) {
258 SdkLibraryImpl library = new SdkLibraryImpl(libraryName);
259 List<Expression> arguments7 = ((value9 as InstanceCreationExpression)).arg umentList.arguments;
260 for (Expression argument in arguments7) {
261 if (argument is SimpleStringLiteral) {
262 library.path = ((argument as SimpleStringLiteral)).value;
263 } else if (argument is NamedExpression) {
264 String name20 = ((argument as NamedExpression)).name.label.name;
265 Expression expression15 = ((argument as NamedExpression)).expression;
266 if (name20 == _CATEGORY) {
267 library.category = ((expression15 as SimpleStringLiteral)).value;
268 } else if (name20 == _IMPLEMENTATION) {
269 library.implementation = ((expression15 as BooleanLiteral)).value;
270 } else if (name20 == _DOCUMENTED) {
271 library.documented = ((expression15 as BooleanLiteral)).value;
272 } else if (name20 == _PLATFORMS) {
273 if (expression15 is SimpleIdentifier) {
274 String identifier = ((expression15 as SimpleIdentifier)).name;
275 if (identifier == _VM_PLATFORM) {
276 library.setVmLibrary();
277 } else {
278 library.setDart2JsLibrary();
279 }
280 }
281 }
282 }
283 }
284 _librariesMap.setLibrary(libraryName, library);
285 }
286 return null;
287 }
288 }
289 class AnalysisErrorListener_7 implements AnalysisErrorListener {
290 List<bool> foundError;
291 AnalysisErrorListener_7(this.foundError);
292 void onError(AnalysisError error) {
293 foundError[0] = true;
294 }
295 }
296 /**
297 * Instances of the class {@code LibraryMap} map Dart library URI's to the {@lin k SdkLibraryImpllibrary}.
298 * @coverage dart.engine.sdk
299 */
300 class LibraryMap {
301 /**
302 * A table mapping Dart library URI's to the library.
303 */
304 Map<String, SdkLibraryImpl> _libraryMap = new Map<String, SdkLibraryImpl>();
305 /**
306 * Initialize a newly created library map to be empty.
307 */
308 LibraryMap() : super() {
309 }
310 /**
311 * Return the library with the given URI, or {@code null} if the URI does not map to a library.
312 * @param dartUri the URI of the library to be returned
313 * @return the library with the given URI
314 */
315 SdkLibrary getLibrary(String dartUri) => _libraryMap[dartUri];
316 /**
317 * Return an array containing all the sdk libraries {@link SdkLibraryImpl} in the mapping
318 * @return the sdk libraries in the mapping
319 */
320 List<SdkLibrary> get sdkLibraries => new List.from(_libraryMap.values);
321 /**
322 * Return an array containing the library URI's for which a mapping is availab le.
323 * @return the library URI's for which a mapping is available
324 */
325 List<String> get uris => new List.from(_libraryMap.keys.toSet());
326 /**
327 * Return the library with the given URI, or {@code null} if the URI does not map to a library.
328 * @param dartUri the URI of the library to be returned
329 * @param library the library with the given URI
330 */
331 void setLibrary(String dartUri, SdkLibraryImpl library) {
332 _libraryMap[dartUri] = library;
333 }
334 /**
335 * Return the number of library URI's for which a mapping is available.
336 * @return the number of library URI's for which a mapping is available
337 */
338 int size() => _libraryMap.length;
339 }
340 /**
341 * Instances of the class {@code DartSdk} represent a Dart SDK installed in a sp ecified location.
342 * @coverage dart.engine.sdk
343 */
344 class DartSdk {
345 /**
346 * The short name of the dart SDK core library.
347 */
348 static String DART_CORE = "dart:core";
349 /**
350 * The short name of the dart SDK html library.
351 */
352 static String DART_HTML = "dart:html";
353 /** 30 /**
354 * The directory containing the SDK. 31 * The directory containing the SDK.
355 */ 32 */
356 JavaFile _sdkDirectory; 33 JavaFile _sdkDirectory;
357 /** 34 /**
358 * The revision number of this SDK, or {@code "0"} if the revision number cann ot be discovered. 35 * The revision number of this SDK, or {@code "0"} if the revision number cann ot be discovered.
359 */ 36 */
360 String _sdkVersion; 37 String _sdkVersion;
361 /** 38 /**
362 * The file containing the Dartium executable. 39 * The file containing the Dartium executable.
(...skipping 15 matching lines...) Expand all
378 * The name of the directory within the SDK directory that contains Chromium. 55 * The name of the directory within the SDK directory that contains Chromium.
379 */ 56 */
380 static String _CHROMIUM_DIRECTORY_NAME = "chromium"; 57 static String _CHROMIUM_DIRECTORY_NAME = "chromium";
381 /** 58 /**
382 * The name of the environment variable whose value is the path to the default Dart SDK directory. 59 * The name of the environment variable whose value is the path to the default Dart SDK directory.
383 */ 60 */
384 static String _DART_SDK_ENVIRONMENT_VARIABLE_NAME = "DART_SDK"; 61 static String _DART_SDK_ENVIRONMENT_VARIABLE_NAME = "DART_SDK";
385 /** 62 /**
386 * The name of the file containing the Dartium executable on Linux. 63 * The name of the file containing the Dartium executable on Linux.
387 */ 64 */
388 static String _DARTIUM_EXECUTABLE_NAME_LINUX = "chromium/chrome"; 65 static String _DARTIUM_EXECUTABLE_NAME_LINUX = "chrome";
389 /** 66 /**
390 * The name of the file containing the Dartium executable on Macintosh. 67 * The name of the file containing the Dartium executable on Macintosh.
391 */ 68 */
392 static String _DARTIUM_EXECUTABLE_NAME_MAC = "Chromium.app/Contents/MacOS/Chro mium"; 69 static String _DARTIUM_EXECUTABLE_NAME_MAC = "Chromium.app/Contents/MacOS/Chro mium";
393 /** 70 /**
394 * The name of the file containing the Dartium executable on Windows. 71 * The name of the file containing the Dartium executable on Windows.
395 */ 72 */
396 static String _DARTIUM_EXECUTABLE_NAME_WIN = "chromium/Chrome.exe"; 73 static String _DARTIUM_EXECUTABLE_NAME_WIN = "Chrome.exe";
397 /** 74 /**
398 * The name of the {@link System} property whose value is the path to the defa ult Dart SDK 75 * The name of the {@link System} property whose value is the path to the defa ult Dart SDK
399 * directory. 76 * directory.
400 */ 77 */
401 static String _DEFAULT_DIRECTORY_PROPERTY_NAME = "com.google.dart.sdk"; 78 static String _DEFAULT_DIRECTORY_PROPERTY_NAME = "com.google.dart.sdk";
402 /** 79 /**
403 * The version number that is returned when the real version number could not be determined. 80 * The version number that is returned when the real version number could not be determined.
404 */ 81 */
405 static String _DEFAULT_VERSION = "0"; 82 static String _DEFAULT_VERSION = "0";
406 /** 83 /**
(...skipping 12 matching lines...) Expand all
419 static String _INTERNAL_DIR = "_internal"; 96 static String _INTERNAL_DIR = "_internal";
420 /** 97 /**
421 * The name of the directory within the SDK directory that contains the librar ies. 98 * The name of the directory within the SDK directory that contains the librar ies.
422 */ 99 */
423 static String _LIB_DIRECTORY_NAME = "lib"; 100 static String _LIB_DIRECTORY_NAME = "lib";
424 /** 101 /**
425 * The name of the libraries file. 102 * The name of the libraries file.
426 */ 103 */
427 static String _LIBRARIES_FILE = "libraries.dart"; 104 static String _LIBRARIES_FILE = "libraries.dart";
428 /** 105 /**
429 * The name of the directory within the SDK directory that contains the packag es.
430 */
431 static String _PKG_DIRECTORY_NAME = "pkg";
432 /**
433 * The name of the file within the SDK directory that contains the revision nu mber of the SDK. 106 * The name of the file within the SDK directory that contains the revision nu mber of the SDK.
434 */ 107 */
435 static String _REVISION_FILE_NAME = "revision"; 108 static String _REVISION_FILE_NAME = "revision";
436 /** 109 /**
437 * The name of the file containing the VM executable on the Windows operating system. 110 * The name of the file containing the VM executable on the Windows operating system.
438 */ 111 */
439 static String _VM_EXECUTABLE_NAME_WIN = "dart.exe"; 112 static String _VM_EXECUTABLE_NAME_WIN = "dart.exe";
440 /** 113 /**
441 * The name of the file containing the VM executable on non-Windows operating systems. 114 * The name of the file containing the VM executable on non-Windows operating systems.
442 */ 115 */
443 static String _VM_EXECUTABLE_NAME = "dart"; 116 static String _VM_EXECUTABLE_NAME = "dart";
444 /** 117 /**
445 * Return the default Dart SDK, or {@code null} if the directory containing th e default SDK cannot 118 * Return the default Dart SDK, or {@code null} if the directory containing th e default SDK cannot
446 * be determined (or does not exist). 119 * be determined (or does not exist).
447 * @return the default Dart SDK 120 * @return the default Dart SDK
448 */ 121 */
449 static DartSdk get defaultSdk { 122 static DirectoryBasedDartSdk get defaultSdk {
450 JavaFile sdkDirectory = defaultSdkDirectory; 123 JavaFile sdkDirectory = defaultSdkDirectory;
451 if (sdkDirectory == null) { 124 if (sdkDirectory == null) {
452 return null; 125 return null;
453 } 126 }
454 return new DartSdk(sdkDirectory); 127 return new DirectoryBasedDartSdk(sdkDirectory);
455 } 128 }
456 /** 129 /**
457 * Return the default directory for the Dart SDK, or {@code null} if the direc tory cannot be 130 * Return the default directory for the Dart SDK, or {@code null} if the direc tory cannot be
458 * determined (or does not exist). The default directory is provided by a {@li nk System} property 131 * determined (or does not exist). The default directory is provided by a {@li nk System} property
459 * named {@code com.google.dart.sdk}, or, if the property is not defined, an e nvironment variable 132 * named {@code com.google.dart.sdk}, or, if the property is not defined, an e nvironment variable
460 * named {@code DART_SDK}. 133 * named {@code DART_SDK}.
461 * @return the default directory for the Dart SDK 134 * @return the default directory for the Dart SDK
462 */ 135 */
463 static JavaFile get defaultSdkDirectory { 136 static JavaFile get defaultSdkDirectory {
464 String sdkProperty = JavaSystemIO.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NA ME); 137 String sdkProperty = JavaSystemIO.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NA ME);
465 if (sdkProperty == null) { 138 if (sdkProperty == null) {
466 sdkProperty = JavaSystemIO.getenv(_DART_SDK_ENVIRONMENT_VARIABLE_NAME); 139 sdkProperty = JavaSystemIO.getenv(_DART_SDK_ENVIRONMENT_VARIABLE_NAME);
467 if (sdkProperty == null) { 140 if (sdkProperty == null) {
468 return null; 141 return null;
469 } 142 }
470 } 143 }
471 JavaFile sdkDirectory = new JavaFile(sdkProperty); 144 JavaFile sdkDirectory = new JavaFile(sdkProperty);
472 if (!sdkDirectory.exists()) { 145 if (!sdkDirectory.exists()) {
473 return null; 146 return null;
474 } 147 }
475 return sdkDirectory; 148 return sdkDirectory;
476 } 149 }
477 /** 150 /**
478 * Initialize a newly created SDK to represent the Dart SDK installed in the g iven directory. 151 * Initialize a newly created SDK to represent the Dart SDK installed in the g iven directory.
479 * @param sdkDirectory the directory containing the SDK 152 * @param sdkDirectory the directory containing the SDK
480 */ 153 */
481 DartSdk(JavaFile sdkDirectory) { 154 DirectoryBasedDartSdk(JavaFile sdkDirectory) {
482 this._sdkDirectory = sdkDirectory.getAbsoluteFile(); 155 this._sdkDirectory = sdkDirectory.getAbsoluteFile();
483 initializeSdk(); 156 initializeSdk();
484 initializeLibraryMap(); 157 initializeLibraryMap();
158 _analysisContext = new AnalysisContextImpl();
159 _analysisContext.sourceFactory = new SourceFactory.con2([new DartUriResolver (this)]);
160 List<String> uris2 = uris;
161 ChangeSet changeSet = new ChangeSet();
162 for (String uri in uris2) {
163 changeSet.added(_analysisContext.sourceFactory.forUri(uri));
164 }
165 _analysisContext.applyChanges(changeSet);
485 } 166 }
167 AnalysisContext get context => _analysisContext;
486 /** 168 /**
487 * Return the file containing the Dartium executable, or {@code null} if it do es not exist. 169 * Return the file containing the Dartium executable, or {@code null} if it do es not exist.
488 * @return the file containing the Dartium executable 170 * @return the file containing the Dartium executable
489 */ 171 */
490 JavaFile get dartiumExecutable { 172 JavaFile get dartiumExecutable {
491 { 173 {
492 if (_dartiumExecutable == null) { 174 if (_dartiumExecutable == null) {
493 JavaFile file = new JavaFile.relative(_sdkDirectory, dartiumBinaryName); 175 JavaFile file = new JavaFile.relative(dartiumWorkingDirectory, dartiumBi naryName);
494 if (file.exists()) { 176 if (file.exists()) {
495 _dartiumExecutable = file; 177 _dartiumExecutable = file;
496 } 178 }
497 } 179 }
498 } 180 }
499 return _dartiumExecutable; 181 return _dartiumExecutable;
500 } 182 }
501 /** 183 /**
502 * Return the directory where dartium can be found in the Dart SDK (the direct ory that will be the 184 * Return the directory where dartium can be found in the Dart SDK (the direct ory that will be the
503 * working directory is Dartium is invoked without changing the default). 185 * working directory is Dartium is invoked without changing the default).
504 * @return the directory where dartium can be found 186 * @return the directory where dartium can be found
505 */ 187 */
506 JavaFile get dartiumWorkingDirectory { 188 JavaFile get dartiumWorkingDirectory => new JavaFile.relative(_sdkDirectory.ge tParentFile(), _CHROMIUM_DIRECTORY_NAME);
507 if (OSUtilities.isWindows() || OSUtilities.isMac()) {
508 return _sdkDirectory;
509 } else {
510 return new JavaFile.relative(_sdkDirectory, _CHROMIUM_DIRECTORY_NAME);
511 }
512 }
513 /** 189 /**
514 * Return the directory containing the SDK. 190 * Return the directory containing the SDK.
515 * @return the directory containing the SDK 191 * @return the directory containing the SDK
516 */ 192 */
517 JavaFile get directory => _sdkDirectory; 193 JavaFile get directory => _sdkDirectory;
518 /** 194 /**
519 * Return the directory containing documentation for the SDK. 195 * Return the directory containing documentation for the SDK.
520 * @return the SDK's documentation directory 196 * @return the SDK's documentation directory
521 */ 197 */
522 JavaFile get docDirectory => new JavaFile.relative(_sdkDirectory, _DOCS_DIRECT ORY_NAME); 198 JavaFile get docDirectory => new JavaFile.relative(_sdkDirectory, _DOCS_DIRECT ORY_NAME);
(...skipping 14 matching lines...) Expand all
537 if (docFile.exists()) { 213 if (docFile.exists()) {
538 return docFile; 214 return docFile;
539 } 215 }
540 return null; 216 return null;
541 } 217 }
542 /** 218 /**
543 * Return the directory within the SDK directory that contains the libraries. 219 * Return the directory within the SDK directory that contains the libraries.
544 * @return the directory that contains the libraries 220 * @return the directory that contains the libraries
545 */ 221 */
546 JavaFile get libraryDirectory => new JavaFile.relative(_sdkDirectory, _LIB_DIR ECTORY_NAME); 222 JavaFile get libraryDirectory => new JavaFile.relative(_sdkDirectory, _LIB_DIR ECTORY_NAME);
547 /**
548 * Return the directory within the SDK directory that contains the packages.
549 * @return the directory that contains the packages
550 */
551 JavaFile get packageDirectory => new JavaFile.relative(directory, _PKG_DIRECTO RY_NAME);
552 /**
553 * Return an array containing all of the libraries defined in this SDK.
554 * @return the libraries defined in this SDK
555 */
556 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries; 223 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries;
557 /** 224 /**
558 * Return the revision number of this SDK, or {@code "0"} if the revision numb er cannot be 225 * Return the revision number of this SDK, or {@code "0"} if the revision numb er cannot be
559 * discovered. 226 * discovered.
560 * @return the revision number of this SDK 227 * @return the revision number of this SDK
561 */ 228 */
562 String get sdkVersion { 229 String get sdkVersion {
563 { 230 {
564 if (_sdkVersion == null) { 231 if (_sdkVersion == null) {
565 _sdkVersion = _DEFAULT_VERSION; 232 _sdkVersion = _DEFAULT_VERSION;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 /** 265 /**
599 * Return {@code true} if this SDK includes documentation. 266 * Return {@code true} if this SDK includes documentation.
600 * @return {@code true} if this installation of the SDK has documentation 267 * @return {@code true} if this installation of the SDK has documentation
601 */ 268 */
602 bool hasDocumentation() => docDirectory.exists(); 269 bool hasDocumentation() => docDirectory.exists();
603 /** 270 /**
604 * Return {@code true} if the Dartium binary is available. 271 * Return {@code true} if the Dartium binary is available.
605 * @return {@code true} if the Dartium binary is available 272 * @return {@code true} if the Dartium binary is available
606 */ 273 */
607 bool isDartiumInstalled() => dartiumExecutable != null; 274 bool isDartiumInstalled() => dartiumExecutable != null;
608 /** 275 Source mapDartUri(ContentCache contentCache, String dartUri) {
609 * Return the file representing the library with the given {@code dart:} URI, or {@code null} if
610 * the given URI does not denote a library in this SDK.
611 * @param dartUri the URI of the library to be returned
612 * @return the file representing the specified library
613 */
614 JavaFile mapDartUri(String dartUri) {
615 SdkLibrary library = _libraryMap.getLibrary(dartUri); 276 SdkLibrary library = _libraryMap.getLibrary(dartUri);
616 if (library == null) { 277 if (library == null) {
617 return null; 278 return null;
618 } 279 }
619 return new JavaFile.relative(libraryDirectory, library.path); 280 return new FileBasedSource.con2(contentCache, new JavaFile.relative(libraryD irectory, library.path), true);
620 } 281 }
621 /** 282 /**
622 * Ensure that the dart VM is executable. If it is not, make it executable and log that it was 283 * Ensure that the dart VM is executable. If it is not, make it executable and log that it was
623 * necessary for us to do so. 284 * necessary for us to do so.
624 */ 285 */
625 void ensureVmIsExecutable() { 286 void ensureVmIsExecutable() {
626 } 287 }
627 /** 288 /**
628 * Return the name of the file containing the VM executable. 289 * Return the name of the file containing the VM executable.
629 * @return the name of the file containing the VM executable 290 * @return the name of the file containing the VM executable
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 } 323 }
663 } 324 }
664 /** 325 /**
665 * Initialize the state of the SDK. 326 * Initialize the state of the SDK.
666 */ 327 */
667 void initializeSdk() { 328 void initializeSdk() {
668 if (!OSUtilities.isWindows()) { 329 if (!OSUtilities.isWindows()) {
669 ensureVmIsExecutable(); 330 ensureVmIsExecutable();
670 } 331 }
671 } 332 }
333 }
334 /**
335 * Instances of the class {@code SdkLibrariesReader} read and parse the librarie s file
336 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries i n an SDK. The
337 * library information is represented as a Dart file containing a single top-lev el variable whose
338 * value is a const map. The keys of the map are the names of libraries defined in the SDK and the
339 * values in the map are info objects defining the library. For example, a subse t of a typical SDK
340 * might have a libraries file that looks like the following:
341 * <pre>
342 * final Map&lt;String, LibraryInfo&gt; LIBRARIES = const &lt;LibraryInfo&gt; {
343 * // Used by VM applications
344 * "builtin" : const LibraryInfo(
345 * "builtin/builtin_runtime.dart",
346 * category: "Server",
347 * platforms: VM_PLATFORM),
348 * "compiler" : const LibraryInfo(
349 * "compiler/compiler.dart",
350 * category: "Tools",
351 * platforms: 0),
352 * };
353 * </pre>
354 * @coverage dart.engine.sdk
355 */
356 class SdkLibrariesReader {
357 /**
358 * Return the library map read from the given source.
359 * @return the library map read from the given source
360 */
361 LibraryMap readFrom(JavaFile librariesFile, String libraryFileContents) {
362 List<bool> foundError = [false];
363 AnalysisErrorListener errorListener = new AnalysisErrorListener_10(foundErro r);
364 Source source = new FileBasedSource.con2(null, librariesFile, false);
365 StringScanner scanner = new StringScanner(source, libraryFileContents, error Listener);
366 Parser parser = new Parser(source, errorListener);
367 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize());
368 SdkLibrariesReader_LibraryBuilder libraryBuilder = new SdkLibrariesReader_Li braryBuilder();
369 if (!foundError[0]) {
370 unit.accept(libraryBuilder);
371 }
372 return libraryBuilder.librariesMap;
373 }
374 }
375 class SdkLibrariesReader_LibraryBuilder extends RecursiveASTVisitor<Object> {
376 /**
377 * The prefix added to the name of a library to form the URI used in code to r eference the
378 * library.
379 */
380 static String _LIBRARY_PREFIX = "dart:";
381 /**
382 * The name of the optional parameter used to indicate whether the library is an implementation
383 * library.
384 */
385 static String _IMPLEMENTATION = "implementation";
386 /**
387 * The name of the optional parameter used to indicate whether the library is documented.
388 */
389 static String _DOCUMENTED = "documented";
390 /**
391 * The name of the optional parameter used to specify the category of the libr ary.
392 */
393 static String _CATEGORY = "category";
394 /**
395 * The name of the optional parameter used to specify the platforms on which t he library can be
396 * used.
397 */
398 static String _PLATFORMS = "platforms";
399 /**
400 * The value of the {@link #PLATFORMS platforms} parameter used to specify tha t the library can
401 * be used on the VM.
402 */
403 static String _VM_PLATFORM = "VM_PLATFORM";
404 /**
405 * The library map that is populated by visiting the AST structure parsed from the contents of
406 * the libraries file.
407 */
408 LibraryMap _librariesMap = new LibraryMap();
409 /**
410 * Return the library map that was populated by visiting the AST structure par sed from the
411 * contents of the libraries file.
412 * @return the library map describing the contents of the SDK
413 */
414 LibraryMap get librariesMap => _librariesMap;
415 Object visitMapLiteralEntry(MapLiteralEntry node) {
416 String libraryName = null;
417 Expression key3 = node.key;
418 if (key3 is SimpleStringLiteral) {
419 libraryName = "${_LIBRARY_PREFIX}${((key3 as SimpleStringLiteral)).value}" ;
420 }
421 Expression value10 = node.value;
422 if (value10 is InstanceCreationExpression) {
423 SdkLibraryImpl library = new SdkLibraryImpl(libraryName);
424 List<Expression> arguments8 = ((value10 as InstanceCreationExpression)).ar gumentList.arguments;
425 for (Expression argument in arguments8) {
426 if (argument is SimpleStringLiteral) {
427 library.path = ((argument as SimpleStringLiteral)).value;
428 } else if (argument is NamedExpression) {
429 String name23 = ((argument as NamedExpression)).name.label.name;
430 Expression expression15 = ((argument as NamedExpression)).expression;
431 if (name23 == _CATEGORY) {
432 library.category = ((expression15 as SimpleStringLiteral)).value;
433 } else if (name23 == _IMPLEMENTATION) {
434 library.implementation = ((expression15 as BooleanLiteral)).value;
435 } else if (name23 == _DOCUMENTED) {
436 library.documented = ((expression15 as BooleanLiteral)).value;
437 } else if (name23 == _PLATFORMS) {
438 if (expression15 is SimpleIdentifier) {
439 String identifier = ((expression15 as SimpleIdentifier)).name;
440 if (identifier == _VM_PLATFORM) {
441 library.setVmLibrary();
442 } else {
443 library.setDart2JsLibrary();
444 }
445 }
446 }
447 }
448 }
449 _librariesMap.setLibrary(libraryName, library);
450 }
451 return null;
452 }
453 }
454 class AnalysisErrorListener_10 implements AnalysisErrorListener {
455 List<bool> foundError;
456 AnalysisErrorListener_10(this.foundError);
457 void onError(AnalysisError error) {
458 foundError[0] = true;
459 }
672 } 460 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/lib/src/generated/sdk.dart ('k') | pkg/analyzer_experimental/lib/src/generated/source.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698