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

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

Issue 23769004: java2dart improvement - use field if getter/setter are trivial. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 library engine.sdk.io; 3 library engine.sdk.io;
4 import 'java_core.dart'; 4 import 'java_core.dart';
5 import 'java_io.dart'; 5 import 'java_io.dart';
6 import 'java_engine_io.dart'; 6 import 'java_engine_io.dart';
7 import 'source_io.dart'; 7 import 'source_io.dart';
8 import 'error.dart'; 8 import 'error.dart';
9 import 'scanner.dart'; 9 import 'scanner.dart';
10 import 'ast.dart'; 10 import 'ast.dart';
11 import 'parser.dart'; 11 import 'parser.dart';
12 import 'sdk.dart'; 12 import 'sdk.dart';
13 import 'engine.dart'; 13 import 'engine.dart';
14 /** 14 /**
15 * Instances of the class `DirectoryBasedDartSdk` represent a Dart SDK installed in a 15 * Instances of the class `DirectoryBasedDartSdk` represent a Dart SDK installed in a
16 * specified directory. 16 * specified directory.
17 * 17 *
18 * @coverage dart.engine.sdk 18 * @coverage dart.engine.sdk
19 */ 19 */
20 class DirectoryBasedDartSdk implements DartSdk { 20 class DirectoryBasedDartSdk implements DartSdk {
21 21
22 /** 22 /**
23 * The [AnalysisContext] which is used for all of the sources in this [DartSdk ]. 23 * The [AnalysisContext] which is used for all of the sources in this [DartSdk ].
24 */ 24 */
25 InternalAnalysisContext _analysisContext; 25 InternalAnalysisContext _analysisContext;
26 26
27 /** 27 /**
28 * The directory containing the SDK. 28 * The directory containing the SDK.
29 */ 29 */
30 JavaFile _sdkDirectory; 30 JavaFile directory;
31 31
32 /** 32 /**
33 * The revision number of this SDK, or `"0"` if the revision number cannot be discovered. 33 * The revision number of this SDK, or `"0"` if the revision number cannot be discovered.
34 */ 34 */
35 String _sdkVersion; 35 String _sdkVersion;
36 36
37 /** 37 /**
38 * The file containing the Dartium executable. 38 * The file containing the Dartium executable.
39 */ 39 */
40 JavaFile _dartiumExecutable; 40 JavaFile _dartiumExecutable;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 189 }
190 return sdkDirectory; 190 return sdkDirectory;
191 } 191 }
192 192
193 /** 193 /**
194 * Initialize a newly created SDK to represent the Dart SDK installed in the g iven directory. 194 * Initialize a newly created SDK to represent the Dart SDK installed in the g iven directory.
195 * 195 *
196 * @param sdkDirectory the directory containing the SDK 196 * @param sdkDirectory the directory containing the SDK
197 */ 197 */
198 DirectoryBasedDartSdk(JavaFile sdkDirectory) { 198 DirectoryBasedDartSdk(JavaFile sdkDirectory) {
199 this._sdkDirectory = sdkDirectory.getAbsoluteFile(); 199 this.directory = sdkDirectory.getAbsoluteFile();
200 initializeSdk(); 200 initializeSdk();
201 initializeLibraryMap(); 201 initializeLibraryMap();
202 if (AnalysisEngine.instance.useExperimentalContext) { 202 if (AnalysisEngine.instance.useExperimentalContext) {
203 _analysisContext = new AnalysisContextImpl2(); 203 _analysisContext = new AnalysisContextImpl2();
204 } else { 204 } else {
205 _analysisContext = new AnalysisContextImpl(); 205 _analysisContext = new AnalysisContextImpl();
206 } 206 }
207 _analysisContext.sourceFactory = new SourceFactory.con2([new DartUriResolver (this)]); 207 _analysisContext.sourceFactory = new SourceFactory.con2([new DartUriResolver (this)]);
208 List<String> uris = this.uris; 208 List<String> uris = this.uris;
209 ChangeSet changeSet = new ChangeSet(); 209 ChangeSet changeSet = new ChangeSet();
210 for (String uri in uris) { 210 for (String uri in uris) {
211 changeSet.added(_analysisContext.sourceFactory.forUri(uri)); 211 changeSet.added(_analysisContext.sourceFactory.forUri(uri));
212 } 212 }
213 _analysisContext.applyChanges(changeSet); 213 _analysisContext.applyChanges(changeSet);
214 } 214 }
215 215
216 /** 216 /**
217 * Initialize a newly created SDK to represent the Dart SDK installed in the g iven directory. 217 * Initialize a newly created SDK to represent the Dart SDK installed in the g iven directory.
218 * 218 *
219 * Added in order to test AnalysisContextImpl2. 219 * Added in order to test AnalysisContextImpl2.
220 * 220 *
221 * @param sdkDirectory the directory containing the SDK 221 * @param sdkDirectory the directory containing the SDK
222 */ 222 */
223 DirectoryBasedDartSdk.con1(JavaFile sdkDirectory, bool ignored) { 223 DirectoryBasedDartSdk.con1(JavaFile sdkDirectory, bool ignored) {
224 this._sdkDirectory = sdkDirectory.getAbsoluteFile(); 224 this.directory = sdkDirectory.getAbsoluteFile();
225 initializeSdk(); 225 initializeSdk();
226 initializeLibraryMap(); 226 initializeLibraryMap();
227 _analysisContext = new AnalysisContextImpl2(); 227 _analysisContext = new AnalysisContextImpl2();
228 _analysisContext.sourceFactory = new SourceFactory.con2([new DartUriResolver (this)]); 228 _analysisContext.sourceFactory = new SourceFactory.con2([new DartUriResolver (this)]);
229 List<String> uris = this.uris; 229 List<String> uris = this.uris;
230 ChangeSet changeSet = new ChangeSet(); 230 ChangeSet changeSet = new ChangeSet();
231 for (String uri in uris) { 231 for (String uri in uris) {
232 changeSet.added(_analysisContext.sourceFactory.forUri(uri)); 232 changeSet.added(_analysisContext.sourceFactory.forUri(uri));
233 } 233 }
234 _analysisContext.applyChanges(changeSet); 234 _analysisContext.applyChanges(changeSet);
(...skipping 17 matching lines...) Expand all
252 } 252 }
253 return _dartiumExecutable; 253 return _dartiumExecutable;
254 } 254 }
255 255
256 /** 256 /**
257 * Return the directory where dartium can be found in the Dart SDK (the direct ory that will be the 257 * Return the directory where dartium can be found in the Dart SDK (the direct ory that will be the
258 * working directory is Dartium is invoked without changing the default). 258 * working directory is Dartium is invoked without changing the default).
259 * 259 *
260 * @return the directory where dartium can be found 260 * @return the directory where dartium can be found
261 */ 261 */
262 JavaFile get dartiumWorkingDirectory => new JavaFile.relative(_sdkDirectory.ge tParentFile(), _CHROMIUM_DIRECTORY_NAME); 262 JavaFile get dartiumWorkingDirectory => new JavaFile.relative(directory.getPar entFile(), _CHROMIUM_DIRECTORY_NAME);
263
264 /**
265 * Return the directory containing the SDK.
266 *
267 * @return the directory containing the SDK
268 */
269 JavaFile get directory => _sdkDirectory;
270 263
271 /** 264 /**
272 * Return the directory containing documentation for the SDK. 265 * Return the directory containing documentation for the SDK.
273 * 266 *
274 * @return the SDK's documentation directory 267 * @return the SDK's documentation directory
275 */ 268 */
276 JavaFile get docDirectory => new JavaFile.relative(_sdkDirectory, _DOCS_DIRECT ORY_NAME); 269 JavaFile get docDirectory => new JavaFile.relative(directory, _DOCS_DIRECTORY_ NAME);
277 270
278 /** 271 /**
279 * Return the auxiliary documentation file for the given library, or `null` if no such file 272 * Return the auxiliary documentation file for the given library, or `null` if no such file
280 * exists. 273 * exists.
281 * 274 *
282 * @param libraryName the name of the library associated with the documentatio n file to be 275 * @param libraryName the name of the library associated with the documentatio n file to be
283 * returned 276 * returned
284 * @return the auxiliary documentation file for the library 277 * @return the auxiliary documentation file for the library
285 */ 278 */
286 JavaFile getDocFileFor(String libraryName) { 279 JavaFile getDocFileFor(String libraryName) {
287 JavaFile dir = docDirectory; 280 JavaFile dir = docDirectory;
288 if (!dir.exists()) { 281 if (!dir.exists()) {
289 return null; 282 return null;
290 } 283 }
291 JavaFile libDir = new JavaFile.relative(dir, libraryName); 284 JavaFile libDir = new JavaFile.relative(dir, libraryName);
292 JavaFile docFile = new JavaFile.relative(libDir, "${libraryName}${_DOC_FILE_ SUFFIX}"); 285 JavaFile docFile = new JavaFile.relative(libDir, "${libraryName}${_DOC_FILE_ SUFFIX}");
293 if (docFile.exists()) { 286 if (docFile.exists()) {
294 return docFile; 287 return docFile;
295 } 288 }
296 return null; 289 return null;
297 } 290 }
298 291
299 /** 292 /**
300 * Return the directory within the SDK directory that contains the libraries. 293 * Return the directory within the SDK directory that contains the libraries.
301 * 294 *
302 * @return the directory that contains the libraries 295 * @return the directory that contains the libraries
303 */ 296 */
304 JavaFile get libraryDirectory => new JavaFile.relative(_sdkDirectory, _LIB_DIR ECTORY_NAME); 297 JavaFile get libraryDirectory => new JavaFile.relative(directory, _LIB_DIRECTO RY_NAME);
305 298
306 /** 299 /**
307 * Return the file containing the Pub executable, or `null` if it does not exi st. 300 * Return the file containing the Pub executable, or `null` if it does not exi st.
308 * 301 *
309 * @return the file containing the Pub executable 302 * @return the file containing the Pub executable
310 */ 303 */
311 JavaFile get pubExecutable { 304 JavaFile get pubExecutable {
312 String pubBinaryName = OSUtilities.isWindows() ? _PUB_EXECUTABLE_NAME_WIN : _PUB_EXECUTABLE_NAME; 305 String pubBinaryName = OSUtilities.isWindows() ? _PUB_EXECUTABLE_NAME_WIN : _PUB_EXECUTABLE_NAME;
313 JavaFile file = new JavaFile.relative(new JavaFile.relative(_sdkDirectory, _ BIN_DIRECTORY_NAME), pubBinaryName); 306 JavaFile file = new JavaFile.relative(new JavaFile.relative(directory, _BIN_ DIRECTORY_NAME), pubBinaryName);
314 return file.exists() ? file : null; 307 return file.exists() ? file : null;
315 } 308 }
316 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries; 309 List<SdkLibrary> get sdkLibraries => _libraryMap.sdkLibraries;
317 SdkLibrary getSdkLibrary(String dartUri) => _libraryMap.getLibrary(dartUri); 310 SdkLibrary getSdkLibrary(String dartUri) => _libraryMap.getLibrary(dartUri);
318 311
319 /** 312 /**
320 * Return the revision number of this SDK, or `"0"` if the revision number can not be 313 * Return the revision number of this SDK, or `"0"` if the revision number can not be
321 * discovered. 314 * discovered.
322 * 315 *
323 * @return the revision number of this SDK 316 * @return the revision number of this SDK
324 */ 317 */
325 String get sdkVersion { 318 String get sdkVersion {
326 { 319 {
327 if (_sdkVersion == null) { 320 if (_sdkVersion == null) {
328 _sdkVersion = DartSdk.DEFAULT_VERSION; 321 _sdkVersion = DartSdk.DEFAULT_VERSION;
329 JavaFile revisionFile = new JavaFile.relative(_sdkDirectory, _REVISION_F ILE_NAME); 322 JavaFile revisionFile = new JavaFile.relative(directory, _REVISION_FILE_ NAME);
330 try { 323 try {
331 String revision = revisionFile.readAsStringSync(); 324 String revision = revisionFile.readAsStringSync();
332 if (revision != null) { 325 if (revision != null) {
333 _sdkVersion = revision; 326 _sdkVersion = revision;
334 } 327 }
335 } on JavaIOException catch (exception) { 328 } on JavaIOException catch (exception) {
336 } 329 }
337 } 330 }
338 } 331 }
339 return _sdkVersion; 332 return _sdkVersion;
340 } 333 }
341 334
342 /** 335 /**
343 * Return an array containing the library URI's for the libraries defined in t his SDK. 336 * Return an array containing the library URI's for the libraries defined in t his SDK.
344 * 337 *
345 * @return the library URI's for the libraries defined in this SDK 338 * @return the library URI's for the libraries defined in this SDK
346 */ 339 */
347 List<String> get uris => _libraryMap.uris; 340 List<String> get uris => _libraryMap.uris;
348 341
349 /** 342 /**
350 * Return the file containing the VM executable, or `null` if it does not exis t. 343 * Return the file containing the VM executable, or `null` if it does not exis t.
351 * 344 *
352 * @return the file containing the VM executable 345 * @return the file containing the VM executable
353 */ 346 */
354 JavaFile get vmExecutable { 347 JavaFile get vmExecutable {
355 { 348 {
356 if (_vmExecutable == null) { 349 if (_vmExecutable == null) {
357 JavaFile file = new JavaFile.relative(new JavaFile.relative(_sdkDirector y, _BIN_DIRECTORY_NAME), vmBinaryName); 350 JavaFile file = new JavaFile.relative(new JavaFile.relative(directory, _ BIN_DIRECTORY_NAME), vmBinaryName);
358 if (file.exists()) { 351 if (file.exists()) {
359 _vmExecutable = file; 352 _vmExecutable = file;
360 } 353 }
361 } 354 }
362 } 355 }
363 return _vmExecutable; 356 return _vmExecutable;
364 } 357 }
365 358
366 /** 359 /**
367 * Return `true` if this SDK includes documentation. 360 * Return `true` if this SDK includes documentation.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 /** 514 /**
522 * The value of the [PLATFORMS] parameter used to specify that the library can 515 * The value of the [PLATFORMS] parameter used to specify that the library can
523 * be used on the VM. 516 * be used on the VM.
524 */ 517 */
525 static String _VM_PLATFORM = "VM_PLATFORM"; 518 static String _VM_PLATFORM = "VM_PLATFORM";
526 519
527 /** 520 /**
528 * The library map that is populated by visiting the AST structure parsed from the contents of 521 * The library map that is populated by visiting the AST structure parsed from the contents of
529 * the libraries file. 522 * the libraries file.
530 */ 523 */
531 LibraryMap _librariesMap = new LibraryMap(); 524 final LibraryMap librariesMap = new LibraryMap();
532
533 /**
534 * Return the library map that was populated by visiting the AST structure par sed from the
535 * contents of the libraries file.
536 *
537 * @return the library map describing the contents of the SDK
538 */
539 LibraryMap get librariesMap => _librariesMap;
540 Object visitMapLiteralEntry(MapLiteralEntry node) { 525 Object visitMapLiteralEntry(MapLiteralEntry node) {
541 String libraryName = null; 526 String libraryName = null;
542 Expression key = node.key; 527 Expression key = node.key;
543 if (key is SimpleStringLiteral) { 528 if (key is SimpleStringLiteral) {
544 libraryName = "${_LIBRARY_PREFIX}${((key as SimpleStringLiteral)).value}"; 529 libraryName = "${_LIBRARY_PREFIX}${((key as SimpleStringLiteral)).value}";
545 } 530 }
546 Expression value = node.value; 531 Expression value = node.value;
547 if (value is InstanceCreationExpression) { 532 if (value is InstanceCreationExpression) {
548 SdkLibraryImpl library = new SdkLibraryImpl(libraryName); 533 SdkLibraryImpl library = new SdkLibraryImpl(libraryName);
549 List<Expression> arguments = ((value as InstanceCreationExpression)).argum entList.arguments; 534 List<Expression> arguments = ((value as InstanceCreationExpression)).argum entList.arguments;
(...skipping 14 matching lines...) Expand all
564 String identifier = ((expression as SimpleIdentifier)).name; 549 String identifier = ((expression as SimpleIdentifier)).name;
565 if (identifier == _VM_PLATFORM) { 550 if (identifier == _VM_PLATFORM) {
566 library.setVmLibrary(); 551 library.setVmLibrary();
567 } else { 552 } else {
568 library.setDart2JsLibrary(); 553 library.setDart2JsLibrary();
569 } 554 }
570 } 555 }
571 } 556 }
572 } 557 }
573 } 558 }
574 _librariesMap.setLibrary(libraryName, library); 559 librariesMap.setLibrary(libraryName, library);
575 } 560 }
576 return null; 561 return null;
577 } 562 }
578 } 563 }
579 class AnalysisErrorListener_9 implements AnalysisErrorListener { 564 class AnalysisErrorListener_9 implements AnalysisErrorListener {
580 List<bool> foundError; 565 List<bool> foundError;
581 AnalysisErrorListener_9(this.foundError); 566 AnalysisErrorListener_9(this.foundError);
582 void onError(AnalysisError error) { 567 void onError(AnalysisError error) {
583 foundError[0] = true; 568 foundError[0] = true;
584 } 569 }
585 } 570 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698