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

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

Issue 189803004: Translate private Java members to private Dart members. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks Created 6 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
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.source.io; 8 library engine.source.io;
9 9
10 import 'source.dart'; 10 import 'source.dart';
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 return null; 262 return null;
263 } else { 263 } else {
264 // <pkgName>/<relPath> 264 // <pkgName>/<relPath>
265 pkgName = path.substring(0, index); 265 pkgName = path.substring(0, index);
266 relPath = path.substring(index + 1); 266 relPath = path.substring(index + 1);
267 } 267 }
268 for (JavaFile packagesDirectory in _packagesDirectories) { 268 for (JavaFile packagesDirectory in _packagesDirectories) {
269 JavaFile resolvedFile = new JavaFile.relative(packagesDirectory, path); 269 JavaFile resolvedFile = new JavaFile.relative(packagesDirectory, path);
270 if (resolvedFile.exists()) { 270 if (resolvedFile.exists()) {
271 JavaFile canonicalFile = getCanonicalFile(packagesDirectory, pkgName, re lPath); 271 JavaFile canonicalFile = getCanonicalFile(packagesDirectory, pkgName, re lPath);
272 UriKind uriKind = isSelfReference(packagesDirectory, canonicalFile) ? Ur iKind.PACKAGE_SELF_URI : UriKind.PACKAGE_URI; 272 UriKind uriKind = _isSelfReference(packagesDirectory, canonicalFile) ? U riKind.PACKAGE_SELF_URI : UriKind.PACKAGE_URI;
273 return new FileBasedSource.con2(canonicalFile, uriKind); 273 return new FileBasedSource.con2(canonicalFile, uriKind);
274 } 274 }
275 } 275 }
276 return new FileBasedSource.con2(getCanonicalFile(_packagesDirectories[0], pk gName, relPath), UriKind.PACKAGE_URI); 276 return new FileBasedSource.con2(getCanonicalFile(_packagesDirectories[0], pk gName, relPath), UriKind.PACKAGE_URI);
277 } 277 }
278 278
279 Uri restoreAbsolute(Source source) { 279 Uri restoreAbsolute(Source source) {
280 if (source is FileBasedSource) { 280 if (source is FileBasedSource) {
281 String sourcePath = source.file.getPath(); 281 String sourcePath = source.file.getPath();
282 for (JavaFile packagesDirectory in _packagesDirectories) { 282 for (JavaFile packagesDirectory in _packagesDirectories) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 AnalysisEngine.instance.logger.logError2("Canonical failed: ${pkgDir}", e); 319 AnalysisEngine.instance.logger.logError2("Canonical failed: ${pkgDir}", e);
320 } 320 }
321 } 321 }
322 return new JavaFile.relative(pkgDir, relPath.replaceAll('/', new String.from CharCode(JavaFile.separatorChar))); 322 return new JavaFile.relative(pkgDir, relPath.replaceAll('/', new String.from CharCode(JavaFile.separatorChar)));
323 } 323 }
324 324
325 /** 325 /**
326 * @return `true` if "file" was found in "packagesDir", and it is part of the "lib" folder 326 * @return `true` if "file" was found in "packagesDir", and it is part of the "lib" folder
327 * of the application that contains in this "packagesDir". 327 * of the application that contains in this "packagesDir".
328 */ 328 */
329 bool isSelfReference(JavaFile packagesDir, JavaFile file) { 329 bool _isSelfReference(JavaFile packagesDir, JavaFile file) {
330 JavaFile rootDir = packagesDir.getParentFile(); 330 JavaFile rootDir = packagesDir.getParentFile();
331 if (rootDir == null) { 331 if (rootDir == null) {
332 return false; 332 return false;
333 } 333 }
334 String rootPath = rootDir.getAbsolutePath(); 334 String rootPath = rootDir.getAbsolutePath();
335 String filePath = file.getAbsolutePath(); 335 String filePath = file.getAbsolutePath();
336 return filePath.startsWith("${rootPath}/lib"); 336 return filePath.startsWith("${rootPath}/lib");
337 } 337 }
338 } 338 }
339 339
340 /** 340 /**
341 * Instances of the class [DirectoryBasedSourceContainer] represent a source con tainer that 341 * Instances of the class [DirectoryBasedSourceContainer] represent a source con tainer that
342 * contains all sources within a given directory. 342 * contains all sources within a given directory.
343 */ 343 */
344 class DirectoryBasedSourceContainer implements SourceContainer { 344 class DirectoryBasedSourceContainer implements SourceContainer {
345 /** 345 /**
346 * Append the system file separator to the given path unless the path already ends with a 346 * Append the system file separator to the given path unless the path already ends with a
347 * separator. 347 * separator.
348 * 348 *
349 * @param path the path to which the file separator is to be added 349 * @param path the path to which the file separator is to be added
350 * @return a path that ends with the system file separator 350 * @return a path that ends with the system file separator
351 */ 351 */
352 static String appendFileSeparator(String path) { 352 static String _appendFileSeparator(String path) {
353 if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) == JavaFile.separatorChar) { 353 if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) == JavaFile.separatorChar) {
354 return path; 354 return path;
355 } 355 }
356 return "${path}${JavaFile.separator}"; 356 return "${path}${JavaFile.separator}";
357 } 357 }
358 358
359 /** 359 /**
360 * The container's path (not `null`). 360 * The container's path (not `null`).
361 */ 361 */
362 String _path; 362 String _path;
363 363
364 /** 364 /**
365 * Construct a container representing the specified directory and containing a ny sources whose 365 * Construct a container representing the specified directory and containing a ny sources whose
366 * [Source#getFullName] starts with the directory's path. This is a convenienc e method, 366 * [Source#getFullName] starts with the directory's path. This is a convenienc e method,
367 * fully equivalent to [DirectoryBasedSourceContainer#DirectoryBasedSourceCont ainer] 367 * fully equivalent to [DirectoryBasedSourceContainer#DirectoryBasedSourceCont ainer]
368 * . 368 * .
369 * 369 *
370 * @param directory the directory (not `null`) 370 * @param directory the directory (not `null`)
371 */ 371 */
372 DirectoryBasedSourceContainer.con1(JavaFile directory) : this.con2(directory.g etPath()); 372 DirectoryBasedSourceContainer.con1(JavaFile directory) : this.con2(directory.g etPath());
373 373
374 /** 374 /**
375 * Construct a container representing the specified path and containing any so urces whose 375 * Construct a container representing the specified path and containing any so urces whose
376 * [Source#getFullName] starts with the specified path. 376 * [Source#getFullName] starts with the specified path.
377 * 377 *
378 * @param path the path (not `null` and not empty) 378 * @param path the path (not `null` and not empty)
379 */ 379 */
380 DirectoryBasedSourceContainer.con2(String path) { 380 DirectoryBasedSourceContainer.con2(String path) {
381 this._path = appendFileSeparator(path); 381 this._path = _appendFileSeparator(path);
382 } 382 }
383 383
384 bool contains(Source source) => source.fullName.startsWith(_path); 384 bool contains(Source source) => source.fullName.startsWith(_path);
385 385
386 bool operator ==(Object obj) => (obj is DirectoryBasedSourceContainer) && obj. path == path; 386 bool operator ==(Object obj) => (obj is DirectoryBasedSourceContainer) && obj. path == path;
387 387
388 /** 388 /**
389 * Answer the receiver's path, used to determine if a source is contained in t he receiver. 389 * Answer the receiver's path, used to determine if a source is contained in t he receiver.
390 * 390 *
391 * @return the path (not `null`, not empty) 391 * @return the path (not `null`, not empty)
(...skipping 29 matching lines...) Expand all
421 return null; 421 return null;
422 } 422 }
423 423
424 Source resolveAbsolute(Uri uri) { 424 Source resolveAbsolute(Uri uri) {
425 if (!isFileUri(uri)) { 425 if (!isFileUri(uri)) {
426 return null; 426 return null;
427 } 427 }
428 return new FileBasedSource.con1(new JavaFile.fromUri(uri)); 428 return new FileBasedSource.con1(new JavaFile.fromUri(uri));
429 } 429 }
430 } 430 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/source.dart ('k') | pkg/analyzer/lib/src/generated/utilities_collection.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698