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

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

Issue 681003002: Replace ${name} with $name where possible. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean up also implementation Created 6 years, 1 month 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 14 matching lines...) Expand all
25 * Append the system file separator to the given path unless the path already ends with a 25 * Append the system file separator to the given path unless the path already ends with a
26 * separator. 26 * separator.
27 * 27 *
28 * @param path the path to which the file separator is to be added 28 * @param path the path to which the file separator is to be added
29 * @return a path that ends with the system file separator 29 * @return a path that ends with the system file separator
30 */ 30 */
31 static String _appendFileSeparator(String path) { 31 static String _appendFileSeparator(String path) {
32 if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) == JavaFile.separatorChar) { 32 if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) == JavaFile.separatorChar) {
33 return path; 33 return path;
34 } 34 }
35 return "${path}${JavaFile.separator}"; 35 return "$path${JavaFile.separator}";
36 } 36 }
37 37
38 /** 38 /**
39 * The container's path (not `null`). 39 * The container's path (not `null`).
40 */ 40 */
41 String _path; 41 String _path;
42 42
43 /** 43 /**
44 * Construct a container representing the specified directory and containing a ny sources whose 44 * Construct a container representing the specified directory and containing a ny sources whose
45 * [Source#getFullName] starts with the directory's path. This is a convenienc e method, 45 * [Source#getFullName] starts with the directory's path. This is a convenienc e method,
(...skipping 24 matching lines...) Expand all
70 * Answer the receiver's path, used to determine if a source is contained in t he receiver. 70 * Answer the receiver's path, used to determine if a source is contained in t he receiver.
71 * 71 *
72 * @return the path (not `null`, not empty) 72 * @return the path (not `null`, not empty)
73 */ 73 */
74 String get path => _path; 74 String get path => _path;
75 75
76 @override 76 @override
77 int get hashCode => _path.hashCode; 77 int get hashCode => _path.hashCode;
78 78
79 @override 79 @override
80 String toString() => "SourceContainer[${_path}]"; 80 String toString() => "SourceContainer[$_path]";
81 } 81 }
82 82
83 /** 83 /**
84 * Instances of the class `FileBasedSource` implement a source that represents a file. 84 * Instances of the class `FileBasedSource` implement a source that represents a file.
85 */ 85 */
86 class FileBasedSource implements Source { 86 class FileBasedSource implements Source {
87 /** 87 /**
88 * The URI from which this source was originally derived. 88 * The URI from which this source was originally derived.
89 */ 89 */
90 final Uri uri; 90 final Uri uri;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 @override 169 @override
170 Uri resolveRelativeUri(Uri containedUri) { 170 Uri resolveRelativeUri(Uri containedUri) {
171 try { 171 try {
172 Uri baseUri = uri; 172 Uri baseUri = uri;
173 bool isOpaque = uri.isAbsolute && !uri.path.startsWith('/'); 173 bool isOpaque = uri.isAbsolute && !uri.path.startsWith('/');
174 if (isOpaque) { 174 if (isOpaque) {
175 String scheme = uri.scheme; 175 String scheme = uri.scheme;
176 String part = uri.path; 176 String part = uri.path;
177 if (scheme == DartUriResolver.DART_SCHEME && part.indexOf('/') < 0) { 177 if (scheme == DartUriResolver.DART_SCHEME && part.indexOf('/') < 0) {
178 part = "${part}/${part}.dart"; 178 part = "$part/$part.dart";
179 } 179 }
180 baseUri = parseUriWithException("${scheme}:/${part}"); 180 baseUri = parseUriWithException("$scheme:/$part");
181 } 181 }
182 Uri result = baseUri.resolveUri(containedUri); 182 Uri result = baseUri.resolveUri(containedUri);
183 if (isOpaque) { 183 if (isOpaque) {
184 result = parseUriWithException("${result.scheme}:${result.path.substring (1)}"); 184 result = parseUriWithException("${result.scheme}:${result.path.substring (1)}");
185 } 185 }
186 return result; 186 return result;
187 } catch (exception, stackTrace) { 187 } catch (exception, stackTrace) {
188 throw new AnalysisException("Could not resolve URI (${containedUri}) relat ive to source (${uri})", new CaughtException(exception, stackTrace)); 188 throw new AnalysisException("Could not resolve URI ($containedUri) relativ e to source ($uri)", new CaughtException(exception, stackTrace));
189 } 189 }
190 } 190 }
191 191
192 @override 192 @override
193 String toString() { 193 String toString() {
194 if (file == null) { 194 if (file == null) {
195 return "<unknown source>"; 195 return "<unknown source>";
196 } 196 }
197 return file.getAbsolutePath(); 197 return file.getAbsolutePath();
198 } 198 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 if (source is FileBasedSource) { 402 if (source is FileBasedSource) {
403 String sourcePath = source.file.getPath(); 403 String sourcePath = source.file.getPath();
404 for (JavaFile packagesDirectory in _packagesDirectories) { 404 for (JavaFile packagesDirectory in _packagesDirectories) {
405 List<JavaFile> pkgFolders = packagesDirectory.listFiles(); 405 List<JavaFile> pkgFolders = packagesDirectory.listFiles();
406 if (pkgFolders != null) { 406 if (pkgFolders != null) {
407 for (JavaFile pkgFolder in pkgFolders) { 407 for (JavaFile pkgFolder in pkgFolders) {
408 try { 408 try {
409 String pkgCanonicalPath = pkgFolder.getCanonicalPath(); 409 String pkgCanonicalPath = pkgFolder.getCanonicalPath();
410 if (sourcePath.startsWith(pkgCanonicalPath)) { 410 if (sourcePath.startsWith(pkgCanonicalPath)) {
411 String relPath = sourcePath.substring(pkgCanonicalPath.length); 411 String relPath = sourcePath.substring(pkgCanonicalPath.length);
412 return parseUriWithException("${PACKAGE_SCHEME}:${pkgFolder.getN ame()}${relPath}"); 412 return parseUriWithException("$PACKAGE_SCHEME:${pkgFolder.getNam e()}$relPath");
413 } 413 }
414 } catch (e) { 414 } catch (e) {
415 } 415 }
416 } 416 }
417 } 417 }
418 } 418 }
419 } 419 }
420 return null; 420 return null;
421 } 421 }
422 422
423 /** 423 /**
424 * Answer the canonical file for the specified package. 424 * Answer the canonical file for the specified package.
425 * 425 *
426 * @param packagesDirectory the "packages" directory (not `null`) 426 * @param packagesDirectory the "packages" directory (not `null`)
427 * @param pkgName the package name (not `null`, not empty) 427 * @param pkgName the package name (not `null`, not empty)
428 * @param relPath the path relative to the package directory (not `null`, no l eading slash, 428 * @param relPath the path relative to the package directory (not `null`, no l eading slash,
429 * but may be empty string) 429 * but may be empty string)
430 * @return the file (not `null`) 430 * @return the file (not `null`)
431 */ 431 */
432 JavaFile getCanonicalFile(JavaFile packagesDirectory, String pkgName, String r elPath) { 432 JavaFile getCanonicalFile(JavaFile packagesDirectory, String pkgName, String r elPath) {
433 JavaFile pkgDir = new JavaFile.relative(packagesDirectory, pkgName); 433 JavaFile pkgDir = new JavaFile.relative(packagesDirectory, pkgName);
434 try { 434 try {
435 pkgDir = pkgDir.getCanonicalFile(); 435 pkgDir = pkgDir.getCanonicalFile();
436 } on JavaIOException catch (e) { 436 } on JavaIOException catch (e) {
437 if (!e.toString().contains("Required key not available")) { 437 if (!e.toString().contains("Required key not available")) {
438 AnalysisEngine.instance.logger.logError2("Canonical failed: ${pkgDir}", e); 438 AnalysisEngine.instance.logger.logError2("Canonical failed: $pkgDir", e) ;
439 } else if (_CanLogRequiredKeyIoException) { 439 } else if (_CanLogRequiredKeyIoException) {
440 _CanLogRequiredKeyIoException = false; 440 _CanLogRequiredKeyIoException = false;
441 AnalysisEngine.instance.logger.logError2("Canonical failed: ${pkgDir}", e); 441 AnalysisEngine.instance.logger.logError2("Canonical failed: $pkgDir", e) ;
442 } 442 }
443 } 443 }
444 return new JavaFile.relative(pkgDir, relPath.replaceAll('/', new String.from CharCode(JavaFile.separatorChar))); 444 return new JavaFile.relative(pkgDir, relPath.replaceAll('/', new String.from CharCode(JavaFile.separatorChar)));
445 } 445 }
446 446
447 /** 447 /**
448 * @return `true` if "file" was found in "packagesDir", and it is part of the "lib" folder 448 * @return `true` if "file" was found in "packagesDir", and it is part of the "lib" folder
449 * of the application that contains in this "packagesDir". 449 * of the application that contains in this "packagesDir".
450 */ 450 */
451 bool _isSelfReference(JavaFile packagesDir, JavaFile file) { 451 bool _isSelfReference(JavaFile packagesDir, JavaFile file) {
452 JavaFile rootDir = packagesDir.getParentFile(); 452 JavaFile rootDir = packagesDir.getParentFile();
453 if (rootDir == null) { 453 if (rootDir == null) {
454 return false; 454 return false;
455 } 455 }
456 String rootPath = rootDir.getAbsolutePath(); 456 String rootPath = rootDir.getAbsolutePath();
457 String filePath = file.getAbsolutePath(); 457 String filePath = file.getAbsolutePath();
458 return filePath.startsWith("${rootPath}/lib"); 458 return filePath.startsWith("$rootPath/lib");
459 } 459 }
460 } 460 }
461 461
462 /** 462 /**
463 * Instances of the class `RelativeFileUriResolver` resolve `file` URI's. 463 * Instances of the class `RelativeFileUriResolver` resolve `file` URI's.
464 */ 464 */
465 class RelativeFileUriResolver extends UriResolver { 465 class RelativeFileUriResolver extends UriResolver {
466 /** 466 /**
467 * The name of the `file` scheme. 467 * The name of the `file` scheme.
468 */ 468 */
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 for (JavaFile dir in _relativeDirectories) { 501 for (JavaFile dir in _relativeDirectories) {
502 JavaFile file = new JavaFile.relative(dir, filePath); 502 JavaFile file = new JavaFile.relative(dir, filePath);
503 if (file.exists()) { 503 if (file.exists()) {
504 return new FileBasedSource.con2(uri, file); 504 return new FileBasedSource.con2(uri, file);
505 } 505 }
506 } 506 }
507 } 507 }
508 return null; 508 return null;
509 } 509 }
510 } 510 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/source.dart ('k') | pkg/analyzer/lib/src/generated/testing/ast_factory.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698