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

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

Issue 1004543003: Comment clean-up in sdk model (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.sdk.io; 8 library engine.sdk.io;
9 9
10 import 'dart:io'; 10 import 'dart:io';
11 11
12 import 'package:analyzer/src/generated/java_engine.dart'; 12 import 'package:analyzer/src/generated/java_engine.dart';
13 13
14 import 'ast.dart'; 14 import 'ast.dart';
15 import 'engine.dart'; 15 import 'engine.dart';
16 import 'error.dart'; 16 import 'error.dart';
17 import 'java_core.dart'; 17 import 'java_core.dart';
18 import 'java_engine_io.dart'; 18 import 'java_engine_io.dart';
19 import 'java_io.dart'; 19 import 'java_io.dart';
20 import 'parser.dart'; 20 import 'parser.dart';
21 import 'scanner.dart'; 21 import 'scanner.dart';
22 import 'sdk.dart'; 22 import 'sdk.dart';
23 import 'source_io.dart'; 23 import 'source_io.dart';
24 24
25 /** 25 /**
26 * Instances of the class `DirectoryBasedDartSdk` represent a Dart SDK installed in a 26 * A Dart SDK installed in a specified directory. Typical Dart SDK layout is
27 * specified directory. Typical Dart SDK layout is something like... 27 * something like...
28 * 28 *
29 * <pre> 29 * dart-sdk/
30 * dart-sdk/ 30 * bin/
31 * bin/ 31 * dart[.exe] <-- VM
32 * dart[.exe] <-- VM 32 * lib/
33 * lib/ 33 * core/
34 * core/ 34 * core.dart
35 * core.dart 35 * ... other core library files ...
36 * ... other core library files ... 36 * ... other libraries ...
37 * ... other libraries ... 37 * util/
38 * util/ 38 * ... Dart utilities ...
39 * ... Dart utilities ... 39 * Chromium/ <-- Dartium typically exists in a sibling directory
40 * Chromium/ <-- Dartium typically exists in a sibling directory
41 * </pre>
42 */ 40 */
43 class DirectoryBasedDartSdk implements DartSdk { 41 class DirectoryBasedDartSdk implements DartSdk {
44 /** 42 /**
45 * The default SDK, or `null` if the default SDK either has not yet been creat ed or cannot 43 * The default SDK, or `null` if the default SDK either has not yet been
46 * be created for some reason. 44 * created or cannot be created for some reason.
47 */ 45 */
48 static DirectoryBasedDartSdk _DEFAULT_SDK; 46 static DirectoryBasedDartSdk _DEFAULT_SDK;
49 47
50 /** 48 /**
51 * The name of the directory within the SDK directory that contains executable s. 49 * The name of the directory within the SDK directory that contains
50 * executables.
52 */ 51 */
53 static String _BIN_DIRECTORY_NAME = "bin"; 52 static String _BIN_DIRECTORY_NAME = "bin";
54 53
55 /** 54 /**
56 * The name of the directory on non-Mac that contains dartium. 55 * The name of the directory on non-Mac that contains dartium.
57 */ 56 */
58 static String _DARTIUM_DIRECTORY_NAME = "chromium"; 57 static String _DARTIUM_DIRECTORY_NAME = "chromium";
59 58
60 /** 59 /**
61 * The name of the dart2js executable on non-windows operating systems. 60 * The name of the dart2js executable on non-windows operating systems.
(...skipping 25 matching lines...) Expand all
87 */ 86 */
88 static String _DARTIUM_EXECUTABLE_NAME_MAC = 87 static String _DARTIUM_EXECUTABLE_NAME_MAC =
89 "Chromium.app/Contents/MacOS/Chromium"; 88 "Chromium.app/Contents/MacOS/Chromium";
90 89
91 /** 90 /**
92 * The name of the file containing the Dartium executable on Windows. 91 * The name of the file containing the Dartium executable on Windows.
93 */ 92 */
94 static String _DARTIUM_EXECUTABLE_NAME_WIN = "Chrome.exe"; 93 static String _DARTIUM_EXECUTABLE_NAME_WIN = "Chrome.exe";
95 94
96 /** 95 /**
97 * The name of the [System] property whose value is the path to the default Da rt SDK 96 * The name of the [System] property whose value is the path to the default
98 * directory. 97 * Dart SDK directory.
99 */ 98 */
100 static String _DEFAULT_DIRECTORY_PROPERTY_NAME = "com.google.dart.sdk"; 99 static String _DEFAULT_DIRECTORY_PROPERTY_NAME = "com.google.dart.sdk";
101 100
102 /** 101 /**
103 * The name of the directory within the SDK directory that contains documentat ion for the 102 * The name of the directory within the SDK directory that contains
104 * libraries. 103 * documentation for the libraries.
105 */ 104 */
106 static String _DOCS_DIRECTORY_NAME = "docs"; 105 static String _DOCS_DIRECTORY_NAME = "docs";
107 106
108 /** 107 /**
109 * The suffix added to the name of a library to derive the name of the file co ntaining the 108 * The suffix added to the name of a library to derive the name of the file
110 * documentation for that library. 109 * containing the documentation for that library.
111 */ 110 */
112 static String _DOC_FILE_SUFFIX = "_api.json"; 111 static String _DOC_FILE_SUFFIX = "_api.json";
113 112
114 /** 113 /**
115 * The name of the directory within the SDK directory that contains the librar ies file. 114 * The name of the directory within the SDK directory that contains the
115 * libraries file.
116 */ 116 */
117 static String _INTERNAL_DIR = "_internal"; 117 static String _INTERNAL_DIR = "_internal";
118 118
119 /** 119 /**
120 * The name of the directory within the SDK directory that contains the librar ies. 120 * The name of the directory within the SDK directory that contains the
121 * libraries.
121 */ 122 */
122 static String _LIB_DIRECTORY_NAME = "lib"; 123 static String _LIB_DIRECTORY_NAME = "lib";
123 124
124 /** 125 /**
125 * The name of the libraries file. 126 * The name of the libraries file.
126 */ 127 */
127 static String _LIBRARIES_FILE = "libraries.dart"; 128 static String _LIBRARIES_FILE = "libraries.dart";
128 129
129 /** 130 /**
130 * The name of the pub executable on windows. 131 * The name of the pub executable on windows.
131 */ 132 */
132 static String _PUB_EXECUTABLE_NAME_WIN = "pub.bat"; 133 static String _PUB_EXECUTABLE_NAME_WIN = "pub.bat";
133 134
134 /** 135 /**
135 * The name of the pub executable on non-windows operating systems. 136 * The name of the pub executable on non-windows operating systems.
136 */ 137 */
137 static String _PUB_EXECUTABLE_NAME = "pub"; 138 static String _PUB_EXECUTABLE_NAME = "pub";
138 139
139 /** 140 /**
140 * The name of the file within the SDK directory that contains the version num ber of the SDK. 141 * The name of the file within the SDK directory that contains the version
142 * number of the SDK.
141 */ 143 */
142 static String _VERSION_FILE_NAME = "version"; 144 static String _VERSION_FILE_NAME = "version";
143 145
144 /** 146 /**
145 * The name of the file containing the VM executable on the Windows operating system. 147 * The name of the file containing the VM executable on the Windows operating
148 * system.
146 */ 149 */
147 static String _VM_EXECUTABLE_NAME_WIN = "dart.exe"; 150 static String _VM_EXECUTABLE_NAME_WIN = "dart.exe";
148 151
149 /** 152 /**
150 * The name of the file containing the VM executable on non-Windows operating systems. 153 * The name of the file containing the VM executable on non-Windows operating
154 * systems.
151 */ 155 */
152 static String _VM_EXECUTABLE_NAME = "dart"; 156 static String _VM_EXECUTABLE_NAME = "dart";
153 157
154 /** 158 /**
155 * Return the default Dart SDK, or `null` if the directory containing the defa ult SDK cannot 159 * Return the default Dart SDK, or `null` if the directory containing the
156 * be determined (or does not exist). 160 * default SDK cannot be determined (or does not exist).
157 *
158 * @return the default Dart SDK
159 */ 161 */
160 static DirectoryBasedDartSdk get defaultSdk { 162 static DirectoryBasedDartSdk get defaultSdk {
161 if (_DEFAULT_SDK == null) { 163 if (_DEFAULT_SDK == null) {
162 JavaFile sdkDirectory = defaultSdkDirectory; 164 JavaFile sdkDirectory = defaultSdkDirectory;
163 if (sdkDirectory == null) { 165 if (sdkDirectory == null) {
164 return null; 166 return null;
165 } 167 }
166 _DEFAULT_SDK = new DirectoryBasedDartSdk(sdkDirectory); 168 _DEFAULT_SDK = new DirectoryBasedDartSdk(sdkDirectory);
167 } 169 }
168 return _DEFAULT_SDK; 170 return _DEFAULT_SDK;
169 } 171 }
170 172
171 /** 173 /**
172 * Return the default directory for the Dart SDK, or `null` if the directory c annot be 174 * Return the default directory for the Dart SDK, or `null` if the directory
173 * determined (or does not exist). The default directory is provided by a [Sys tem] property 175 * cannot be determined (or does not exist). The default directory is provided
174 * named `com.google.dart.sdk`. 176 * by a system property named `com.google.dart.sdk`.
175 *
176 * @return the default directory for the Dart SDK
177 */ 177 */
178 static JavaFile get defaultSdkDirectory { 178 static JavaFile get defaultSdkDirectory {
179 String sdkProperty = 179 String sdkProperty =
180 JavaSystemIO.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NAME); 180 JavaSystemIO.getProperty(_DEFAULT_DIRECTORY_PROPERTY_NAME);
181 if (sdkProperty == null) { 181 if (sdkProperty == null) {
182 return null; 182 return null;
183 } 183 }
184 JavaFile sdkDirectory = new JavaFile(sdkProperty); 184 JavaFile sdkDirectory = new JavaFile(sdkProperty);
185 if (!sdkDirectory.exists()) { 185 if (!sdkDirectory.exists()) {
186 return null; 186 return null;
187 } 187 }
188 return sdkDirectory; 188 return sdkDirectory;
189 } 189 }
190 190
191 /** 191 /**
192 * The [AnalysisContext] which is used for all of the sources in this [DartSdk ]. 192 * The [AnalysisContext] which is used for all of the sources in this sdk.
193 */ 193 */
194 InternalAnalysisContext _analysisContext; 194 InternalAnalysisContext _analysisContext;
195 195
196 /** 196 /**
197 * The directory containing the SDK. 197 * The directory containing the SDK.
198 */ 198 */
199 JavaFile _sdkDirectory; 199 JavaFile _sdkDirectory;
200 200
201 /** 201 /**
202 * The revision number of this SDK, or `"0"` if the revision number cannot be discovered. 202 * The revision number of this SDK, or `"0"` if the revision number cannot be
203 * discovered.
203 */ 204 */
204 String _sdkVersion; 205 String _sdkVersion;
205 206
206 /** 207 /**
207 * The file containing the dart2js executable. 208 * The file containing the dart2js executable.
208 */ 209 */
209 JavaFile _dart2jsExecutable; 210 JavaFile _dart2jsExecutable;
210 211
211 /** 212 /**
212 * The file containing the dart formatter executable. 213 * The file containing the dart formatter executable.
(...skipping 14 matching lines...) Expand all
227 * The file containing the VM executable. 228 * The file containing the VM executable.
228 */ 229 */
229 JavaFile _vmExecutable; 230 JavaFile _vmExecutable;
230 231
231 /** 232 /**
232 * A mapping from Dart library URI's to the library represented by that URI. 233 * A mapping from Dart library URI's to the library represented by that URI.
233 */ 234 */
234 LibraryMap _libraryMap; 235 LibraryMap _libraryMap;
235 236
236 /** 237 /**
237 * Initialize a newly created SDK to represent the Dart SDK installed in the g iven directory. 238 * Initialize a newly created SDK to represent the Dart SDK installed in the
238 * 239 * [sdkDirectory]. The flag [useDart2jsPaths] is `true` if the dart2js path
239 * @param sdkDirectory the directory containing the SDK 240 * should be used when it is available
240 * @param useDart2jsPaths `true` if the dart2js path should be used when it is available
241 */ 241 */
242 DirectoryBasedDartSdk(JavaFile sdkDirectory, [bool useDart2jsPaths = false]) { 242 DirectoryBasedDartSdk(JavaFile sdkDirectory, [bool useDart2jsPaths = false]) {
243 this._sdkDirectory = sdkDirectory.getAbsoluteFile(); 243 this._sdkDirectory = sdkDirectory.getAbsoluteFile();
244 _libraryMap = initialLibraryMap(useDart2jsPaths); 244 _libraryMap = initialLibraryMap(useDart2jsPaths);
245 } 245 }
246 246
247 @override 247 @override
248 AnalysisContext get context { 248 AnalysisContext get context {
249 if (_analysisContext == null) { 249 if (_analysisContext == null) {
250 _analysisContext = new SdkAnalysisContext(); 250 _analysisContext = new SdkAnalysisContext();
251 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]); 251 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]);
252 _analysisContext.sourceFactory = factory; 252 _analysisContext.sourceFactory = factory;
253 List<String> uris = this.uris; 253 List<String> uris = this.uris;
254 ChangeSet changeSet = new ChangeSet(); 254 ChangeSet changeSet = new ChangeSet();
255 for (String uri in uris) { 255 for (String uri in uris) {
256 changeSet.addedSource(factory.forUri(uri)); 256 changeSet.addedSource(factory.forUri(uri));
257 } 257 }
258 _analysisContext.applyChanges(changeSet); 258 _analysisContext.applyChanges(changeSet);
259 } 259 }
260 return _analysisContext; 260 return _analysisContext;
261 } 261 }
262 262
263 /** 263 /**
264 * Return the file containing the dart2js executable, or `null` if it does not exist. 264 * Return the file containing the dart2js executable, or `null` if it does not
265 * 265 * exist.
266 * @return the file containing the dart2js executable
267 */ 266 */
268 JavaFile get dart2JsExecutable { 267 JavaFile get dart2JsExecutable {
269 if (_dart2jsExecutable == null) { 268 if (_dart2jsExecutable == null) {
270 _dart2jsExecutable = _verifyExecutable(new JavaFile.relative( 269 _dart2jsExecutable = _verifyExecutable(new JavaFile.relative(
271 new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME), 270 new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME),
272 OSUtilities.isWindows() 271 OSUtilities.isWindows()
273 ? _DART2JS_EXECUTABLE_NAME_WIN 272 ? _DART2JS_EXECUTABLE_NAME_WIN
274 : _DART2JS_EXECUTABLE_NAME)); 273 : _DART2JS_EXECUTABLE_NAME));
275 } 274 }
276 return _dart2jsExecutable; 275 return _dart2jsExecutable;
277 } 276 }
278 277
279 /** 278 /**
280 * Return the file containing the dart formatter executable, or `null` if it d oes not exist. 279 * Return the file containing the dart formatter executable, or `null` if it
281 * 280 * does not exist.
282 * @return the file containing the dart formatter executable
283 */ 281 */
284 JavaFile get dartFmtExecutable { 282 JavaFile get dartFmtExecutable {
285 if (_dartFmtExecutable == null) { 283 if (_dartFmtExecutable == null) {
286 _dartFmtExecutable = _verifyExecutable(new JavaFile.relative( 284 _dartFmtExecutable = _verifyExecutable(new JavaFile.relative(
287 new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME), 285 new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME),
288 OSUtilities.isWindows() 286 OSUtilities.isWindows()
289 ? _DARTFMT_EXECUTABLE_NAME_WIN 287 ? _DARTFMT_EXECUTABLE_NAME_WIN
290 : _DARTFMT_EXECUTABLE_NAME)); 288 : _DARTFMT_EXECUTABLE_NAME));
291 } 289 }
292 return _dartFmtExecutable; 290 return _dartFmtExecutable;
293 } 291 }
294 292
295 /** 293 /**
296 * Return the name of the file containing the Dartium executable. 294 * Return the name of the file containing the Dartium executable.
297 *
298 * @return the name of the file containing the Dartium executable
299 */ 295 */
300 String get dartiumBinaryName { 296 String get dartiumBinaryName {
301 if (OSUtilities.isWindows()) { 297 if (OSUtilities.isWindows()) {
302 return _DARTIUM_EXECUTABLE_NAME_WIN; 298 return _DARTIUM_EXECUTABLE_NAME_WIN;
303 } else if (OSUtilities.isMac()) { 299 } else if (OSUtilities.isMac()) {
304 return _DARTIUM_EXECUTABLE_NAME_MAC; 300 return _DARTIUM_EXECUTABLE_NAME_MAC;
305 } else { 301 } else {
306 return _DARTIUM_EXECUTABLE_NAME_LINUX; 302 return _DARTIUM_EXECUTABLE_NAME_LINUX;
307 } 303 }
308 } 304 }
309 305
310 /** 306 /**
311 * Return the file containing the Dartium executable, or `null` if it does not exist. 307 * Return the file containing the Dartium executable, or `null` if it does not
312 * 308 * exist.
313 * @return the file containing the Dartium executable
314 */ 309 */
315 JavaFile get dartiumExecutable { 310 JavaFile get dartiumExecutable {
316 if (_dartiumExecutable == null) { 311 if (_dartiumExecutable == null) {
317 _dartiumExecutable = _verifyExecutable( 312 _dartiumExecutable = _verifyExecutable(
318 new JavaFile.relative(dartiumWorkingDirectory, dartiumBinaryName)); 313 new JavaFile.relative(dartiumWorkingDirectory, dartiumBinaryName));
319 } 314 }
320 return _dartiumExecutable; 315 return _dartiumExecutable;
321 } 316 }
322 317
323 /** 318 /**
324 * Return the directory where dartium can be found (the directory that will be the working 319 * Return the directory where dartium can be found (the directory that will be
325 * directory is Dartium is invoked without changing the default). 320 * the working directory is Dartium is invoked without changing the default).
326 *
327 * @return the directory where dartium can be found
328 */ 321 */
329 JavaFile get dartiumWorkingDirectory => 322 JavaFile get dartiumWorkingDirectory =>
330 getDartiumWorkingDirectory(_sdkDirectory.getParentFile()); 323 getDartiumWorkingDirectory(_sdkDirectory.getParentFile());
331 324
332 /** 325 /**
333 * Return the directory containing the SDK. 326 * Return the directory containing the SDK.
334 *
335 * @return the directory containing the SDK
336 */ 327 */
337 JavaFile get directory => _sdkDirectory; 328 JavaFile get directory => _sdkDirectory;
338 329
339 /** 330 /**
340 * Return the directory containing documentation for the SDK. 331 * Return the directory containing documentation for the SDK.
341 *
342 * @return the SDK's documentation directory
343 */ 332 */
344 JavaFile get docDirectory => 333 JavaFile get docDirectory =>
345 new JavaFile.relative(_sdkDirectory, _DOCS_DIRECTORY_NAME); 334 new JavaFile.relative(_sdkDirectory, _DOCS_DIRECTORY_NAME);
346 335
347 /** 336 /**
348 * Return `true` if this SDK includes documentation. 337 * Return `true` if this SDK includes documentation.
349 *
350 * @return `true` if this installation of the SDK has documentation
351 */ 338 */
352 bool get hasDocumentation => docDirectory.exists(); 339 bool get hasDocumentation => docDirectory.exists();
353 340
354 /** 341 /**
355 * Return `true` if the Dartium binary is available. 342 * Return `true` if the Dartium binary is available.
356 *
357 * @return `true` if the Dartium binary is available
358 */ 343 */
359 bool get isDartiumInstalled => dartiumExecutable != null; 344 bool get isDartiumInstalled => dartiumExecutable != null;
360 345
361 /** 346 /**
362 * Return the directory within the SDK directory that contains the libraries. 347 * Return the directory within the SDK directory that contains the libraries.
363 *
364 * @return the directory that contains the libraries
365 */ 348 */
366 JavaFile get libraryDirectory => 349 JavaFile get libraryDirectory =>
367 new JavaFile.relative(_sdkDirectory, _LIB_DIRECTORY_NAME); 350 new JavaFile.relative(_sdkDirectory, _LIB_DIRECTORY_NAME);
368 351
369 /** 352 /**
370 * Return the file containing the Pub executable, or `null` if it does not exi st. 353 * Return the file containing the Pub executable, or `null` if it does not exi st.
371 *
372 * @return the file containing the Pub executable
373 */ 354 */
374 JavaFile get pubExecutable { 355 JavaFile get pubExecutable {
375 if (_pubExecutable == null) { 356 if (_pubExecutable == null) {
376 _pubExecutable = _verifyExecutable(new JavaFile.relative( 357 _pubExecutable = _verifyExecutable(new JavaFile.relative(
377 new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME), OSUtilities 358 new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME), OSUtilities
378 .isWindows() ? _PUB_EXECUTABLE_NAME_WIN : _PUB_EXECUTABLE_NAME)); 359 .isWindows() ? _PUB_EXECUTABLE_NAME_WIN : _PUB_EXECUTABLE_NAME));
379 } 360 }
380 return _pubExecutable; 361 return _pubExecutable;
381 } 362 }
382 363
383 @override 364 @override
384 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries; 365 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries;
385 366
386 /** 367 /**
387 * Return the revision number of this SDK, or `"0"` if the revision number can not be 368 * Return the revision number of this SDK, or `"0"` if the revision number
388 * discovered. 369 * cannot be discovered.
389 *
390 * @return the revision number of this SDK
391 */ 370 */
392 @override 371 @override
393 String get sdkVersion { 372 String get sdkVersion {
394 if (_sdkVersion == null) { 373 if (_sdkVersion == null) {
395 _sdkVersion = DartSdk.DEFAULT_VERSION; 374 _sdkVersion = DartSdk.DEFAULT_VERSION;
396 JavaFile revisionFile = 375 JavaFile revisionFile =
397 new JavaFile.relative(_sdkDirectory, _VERSION_FILE_NAME); 376 new JavaFile.relative(_sdkDirectory, _VERSION_FILE_NAME);
398 try { 377 try {
399 String revision = revisionFile.readAsStringSync(); 378 String revision = revisionFile.readAsStringSync();
400 if (revision != null) { 379 if (revision != null) {
401 _sdkVersion = revision.trim(); 380 _sdkVersion = revision.trim();
402 } 381 }
403 } on FileSystemException catch (exception) { 382 } on FileSystemException catch (exception) {
404 // Fall through to return the default. 383 // Fall through to return the default.
405 } 384 }
406 } 385 }
407 return _sdkVersion; 386 return _sdkVersion;
408 } 387 }
409 388
410 /**
411 * Return an array containing the library URI's for the libraries defined in t his SDK.
412 *
413 * @return the library URI's for the libraries defined in this SDK
414 */
415 @override 389 @override
416 List<String> get uris => _libraryMap.uris; 390 List<String> get uris => _libraryMap.uris;
417 391
418 /** 392 /**
419 * Return the name of the file containing the VM executable. 393 * Return the name of the file containing the VM executable.
420 *
421 * @return the name of the file containing the VM executable
422 */ 394 */
423 String get vmBinaryName { 395 String get vmBinaryName {
424 if (OSUtilities.isWindows()) { 396 if (OSUtilities.isWindows()) {
425 return _VM_EXECUTABLE_NAME_WIN; 397 return _VM_EXECUTABLE_NAME_WIN;
426 } else { 398 } else {
427 return _VM_EXECUTABLE_NAME; 399 return _VM_EXECUTABLE_NAME;
428 } 400 }
429 } 401 }
430 402
431 /** 403 /**
432 * Return the file containing the VM executable, or `null` if it does not exis t. 404 * Return the file containing the VM executable, or `null` if it does not
433 * 405 * exist.
434 * @return the file containing the VM executable
435 */ 406 */
436 JavaFile get vmExecutable { 407 JavaFile get vmExecutable {
437 if (_vmExecutable == null) { 408 if (_vmExecutable == null) {
438 _vmExecutable = _verifyExecutable(new JavaFile.relative( 409 _vmExecutable = _verifyExecutable(new JavaFile.relative(
439 new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME), 410 new JavaFile.relative(_sdkDirectory, _BIN_DIRECTORY_NAME),
440 vmBinaryName)); 411 vmBinaryName));
441 } 412 }
442 return _vmExecutable; 413 return _vmExecutable;
443 } 414 }
444 415
(...skipping 30 matching lines...) Expand all
475 "Failed to create URI: $path", 446 "Failed to create URI: $path",
476 new CaughtException(exception, stackTrace)); 447 new CaughtException(exception, stackTrace));
477 return null; 448 return null;
478 } 449 }
479 } 450 }
480 } 451 }
481 return null; 452 return null;
482 } 453 }
483 454
484 /** 455 /**
485 * Return the directory where dartium can be found (the directory that will be the working 456 * Return the directory where dartium can be found (the directory that will be
486 * directory is Dartium is invoked without changing the default). 457 * the working directory if Dartium is invoked without changing the default),
487 * 458 * assuming that the Editor was installed in the [installDir].
488 * @param installDir the installation directory
489 * @return the directory where dartium can be found
490 */ 459 */
491 JavaFile getDartiumWorkingDirectory(JavaFile installDir) => 460 JavaFile getDartiumWorkingDirectory(JavaFile installDir) =>
492 new JavaFile.relative(installDir, _DARTIUM_DIRECTORY_NAME); 461 new JavaFile.relative(installDir, _DARTIUM_DIRECTORY_NAME);
493 462
494 /** 463 /**
495 * Return the auxiliary documentation file for the given library, or `null` if no such file 464 * Return the auxiliary documentation file for the library with the given
496 * exists. 465 * [libraryName], or `null` if no such file exists.
497 *
498 * @param libraryName the name of the library associated with the documentatio n file to be
499 * returned
500 * @return the auxiliary documentation file for the library
501 */ 466 */
502 JavaFile getDocFileFor(String libraryName) { 467 JavaFile getDocFileFor(String libraryName) {
503 JavaFile dir = docDirectory; 468 JavaFile dir = docDirectory;
504 if (!dir.exists()) { 469 if (!dir.exists()) {
505 return null; 470 return null;
506 } 471 }
507 JavaFile libDir = new JavaFile.relative(dir, libraryName); 472 JavaFile libDir = new JavaFile.relative(dir, libraryName);
508 JavaFile docFile = 473 JavaFile docFile =
509 new JavaFile.relative(libDir, "$libraryName$_DOC_FILE_SUFFIX"); 474 new JavaFile.relative(libDir, "$libraryName$_DOC_FILE_SUFFIX");
510 if (docFile.exists()) { 475 if (docFile.exists()) {
511 return docFile; 476 return docFile;
512 } 477 }
513 return null; 478 return null;
514 } 479 }
515 480
516 @override 481 @override
517 SdkLibrary getSdkLibrary(String dartUri) => _libraryMap.getLibrary(dartUri); 482 SdkLibrary getSdkLibrary(String dartUri) => _libraryMap.getLibrary(dartUri);
518 483
519 /** 484 /**
520 * Read all of the configuration files to initialize the library maps. 485 * Read all of the configuration files to initialize the library maps. The
521 * 486 * flag [useDart2jsPaths] is `true` if the dart2js path should be used when it
522 * @param useDart2jsPaths `true` if the dart2js path should be used when it is available 487 * is available. Return the initialized library map.
523 * @return the initialized library map
524 */ 488 */
525 LibraryMap initialLibraryMap(bool useDart2jsPaths) { 489 LibraryMap initialLibraryMap(bool useDart2jsPaths) {
526 JavaFile librariesFile = new JavaFile.relative( 490 JavaFile librariesFile = new JavaFile.relative(
527 new JavaFile.relative(libraryDirectory, _INTERNAL_DIR), 491 new JavaFile.relative(libraryDirectory, _INTERNAL_DIR),
528 _LIBRARIES_FILE); 492 _LIBRARIES_FILE);
529 try { 493 try {
530 String contents = librariesFile.readAsStringSync(); 494 String contents = librariesFile.readAsStringSync();
531 return new SdkLibrariesReader(useDart2jsPaths).readFromFile( 495 return new SdkLibrariesReader(useDart2jsPaths).readFromFile(
532 librariesFile, contents); 496 librariesFile, contents);
533 } catch (exception, stackTrace) { 497 } catch (exception, stackTrace) {
(...skipping 26 matching lines...) Expand all
560 file = file.getParentFile(); 524 file = file.getParentFile();
561 file = new JavaFile.relative(file, relativePath); 525 file = new JavaFile.relative(file, relativePath);
562 } 526 }
563 return new FileBasedSource.con2(parseUriWithException(dartUri), file); 527 return new FileBasedSource.con2(parseUriWithException(dartUri), file);
564 } on URISyntaxException catch (exception) { 528 } on URISyntaxException catch (exception) {
565 return null; 529 return null;
566 } 530 }
567 } 531 }
568 532
569 /** 533 /**
570 * Verify that the given executable file exists and is executable. 534 * Return the given [file] if it exists and is executable, or `null` if it
571 * 535 * does not exist or is not executable.
572 * @param file the binary file
573 * @return the file if it exists and is executable, else `null`
574 */ 536 */
575 JavaFile _verifyExecutable(JavaFile file) => 537 JavaFile _verifyExecutable(JavaFile file) =>
576 file.isExecutable() ? file : null; 538 file.isExecutable() ? file : null;
577 } 539 }
578 540
579 /** 541 /**
580 * Instances of the class `SdkLibrariesReader` read and parse the libraries file 542 * An object used to read and parse the libraries file
581 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries i n an SDK. The 543 * (dart-sdk/lib/_internal/libraries.dart) for information about the libraries
582 * library information is represented as a Dart file containing a single top-lev el variable whose 544 * in an SDK. The library information is represented as a Dart file containing a
583 * value is a const map. The keys of the map are the names of libraries defined in the SDK and the 545 * single top-level variable whose value is a const map. The keys of the map are
584 * values in the map are info objects defining the library. For example, a subse t of a typical SDK 546 * the names of libraries defined in the SDK and the values in the map are info
585 * might have a libraries file that looks like the following: 547 * objects defining the library. For example, a subset of a typical SDK might
548 * have a libraries file that looks like the following:
586 * 549 *
587 * <pre> 550 * final Map&lt;String, LibraryInfo&gt; LIBRARIES = const &lt;LibraryInfo&gt ; {
588 * final Map&lt;String, LibraryInfo&gt; LIBRARIES = const &lt;LibraryInfo&gt; { 551 * // Used by VM applications
589 * // Used by VM applications 552 * "builtin" : const LibraryInfo(
590 * "builtin" : const LibraryInfo( 553 * "builtin/builtin_runtime.dart",
591 * "builtin/builtin_runtime.dart", 554 * category: "Server",
592 * category: "Server", 555 * platforms: VM_PLATFORM),
593 * platforms: VM_PLATFORM),
594 * 556 *
595 * "compiler" : const LibraryInfo( 557 * "compiler" : const LibraryInfo(
596 * "compiler/compiler.dart", 558 * "compiler/compiler.dart",
597 * category: "Tools", 559 * category: "Tools",
598 * platforms: 0), 560 * platforms: 0),
599 * }; 561 * };
600 * </pre>
601 */ 562 */
602 class SdkLibrariesReader { 563 class SdkLibrariesReader {
603 /** 564 /**
604 * A flag indicating whether the dart2js path should be used when it is availa ble. 565 * A flag indicating whether the dart2js path should be used when it is
566 * available.
605 */ 567 */
606 final bool _useDart2jsPaths; 568 final bool _useDart2jsPaths;
607 569
608 /** 570 /**
609 * Initialize a newly created library reader to use the dart2js path if the gi ven value is 571 * Initialize a newly created library reader to use the dart2js path if
610 * `true`. 572 * [_useDart2jsPaths] is `true`.
611 *
612 * @param useDart2jsPaths `true` if the dart2js path should be used when it is available
613 */ 573 */
614 SdkLibrariesReader(this._useDart2jsPaths); 574 SdkLibrariesReader(this._useDart2jsPaths);
615 575
616 /** 576 /**
617 * Return the library map read from the given source. 577 * Return the library map read from the given [file], given that the content
618 * 578 * of the file is already known to be [libraryFileContents].
619 * @param file the [File] of the library file
620 * @param libraryFileContents the contents from the library file
621 * @return the library map read from the given source
622 */ 579 */
623 LibraryMap readFromFile(JavaFile file, String libraryFileContents) => 580 LibraryMap readFromFile(JavaFile file, String libraryFileContents) =>
624 readFromSource(new FileBasedSource.con1(file), libraryFileContents); 581 readFromSource(new FileBasedSource.con1(file), libraryFileContents);
625 582
626 /** 583 /**
627 * Return the library map read from the given source. 584 * Return the library map read from the given [source], given that the content
628 * 585 * of the file is already known to be [libraryFileContents].
629 * @param source the source of the library file
630 * @param libraryFileContents the contents from the library file
631 * @return the library map read from the given source
632 */ 586 */
633 LibraryMap readFromSource(Source source, String libraryFileContents) { 587 LibraryMap readFromSource(Source source, String libraryFileContents) {
634 BooleanErrorListener errorListener = new BooleanErrorListener(); 588 BooleanErrorListener errorListener = new BooleanErrorListener();
635 Scanner scanner = new Scanner( 589 Scanner scanner = new Scanner(
636 source, new CharSequenceReader(libraryFileContents), errorListener); 590 source, new CharSequenceReader(libraryFileContents), errorListener);
637 Parser parser = new Parser(source, errorListener); 591 Parser parser = new Parser(source, errorListener);
638 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize()); 592 CompilationUnit unit = parser.parseCompilationUnit(scanner.tokenize());
639 SdkLibrariesReader_LibraryBuilder libraryBuilder = 593 SdkLibrariesReader_LibraryBuilder libraryBuilder =
640 new SdkLibrariesReader_LibraryBuilder(_useDart2jsPaths); 594 new SdkLibrariesReader_LibraryBuilder(_useDart2jsPaths);
641 // If any syntactic errors were found then don't try to visit the AST 595 // If any syntactic errors were found then don't try to visit the AST
642 // structure. 596 // structure.
643 if (!errorListener.errorReported) { 597 if (!errorListener.errorReported) {
644 unit.accept(libraryBuilder); 598 unit.accept(libraryBuilder);
645 } 599 }
646 return libraryBuilder.librariesMap; 600 return libraryBuilder.librariesMap;
647 } 601 }
648 } 602 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698