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

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

Issue 17249003: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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.source.io; 3 library engine.source.io;
4 import 'source.dart'; 4 import 'source.dart';
5 import 'dart:io'; 5 import 'dart:io';
6 import 'java_core.dart'; 6 import 'java_core.dart';
7 import 'java_io.dart'; 7 import 'java_io.dart';
8 import 'sdk.dart' show DartSdk; 8 import 'sdk.dart' show DartSdk;
9 import 'engine.dart' show AnalysisContext, AnalysisEngine; 9 import 'engine.dart' show AnalysisContext, AnalysisEngine;
10 export 'source.dart'; 10 export 'source.dart';
11 /** 11 /**
12 * Instances of the class {@code FileBasedSource} implement a source that repres ents a file. 12 * Instances of the class `FileBasedSource` implement a source that represents a file.
13 * @coverage dart.engine.source 13 * @coverage dart.engine.source
14 */ 14 */
15 class FileBasedSource implements Source { 15 class FileBasedSource implements Source {
16 16
17 /** 17 /**
18 * The content cache used to access the contents of this source if they have b een overridden from 18 * The content cache used to access the contents of this source if they have b een overridden from
19 * what is on disk or cached. 19 * what is on disk or cached.
20 */ 20 */
21 ContentCache _contentCache; 21 ContentCache _contentCache;
22 22
(...skipping 22 matching lines...) Expand all
45 _jtd_constructor_338_impl(contentCache, file); 45 _jtd_constructor_338_impl(contentCache, file);
46 } 46 }
47 _jtd_constructor_338_impl(ContentCache contentCache, JavaFile file) { 47 _jtd_constructor_338_impl(ContentCache contentCache, JavaFile file) {
48 _jtd_constructor_339_impl(contentCache, file, UriKind.FILE_URI); 48 _jtd_constructor_339_impl(contentCache, file, UriKind.FILE_URI);
49 } 49 }
50 50
51 /** 51 /**
52 * Initialize a newly created source object. 52 * Initialize a newly created source object.
53 * @param contentCache the content cache used to access the contents of this s ource 53 * @param contentCache the content cache used to access the contents of this s ource
54 * @param file the file represented by this source 54 * @param file the file represented by this source
55 * @param flags {@code true} if this source is in one of the system libraries 55 * @param flags `true` if this source is in one of the system libraries
56 */ 56 */
57 FileBasedSource.con2(ContentCache contentCache2, JavaFile file2, UriKind uriKi nd2) { 57 FileBasedSource.con2(ContentCache contentCache2, JavaFile file2, UriKind uriKi nd2) {
58 _jtd_constructor_339_impl(contentCache2, file2, uriKind2); 58 _jtd_constructor_339_impl(contentCache2, file2, uriKind2);
59 } 59 }
60 _jtd_constructor_339_impl(ContentCache contentCache2, JavaFile file2, UriKind uriKind2) { 60 _jtd_constructor_339_impl(ContentCache contentCache2, JavaFile file2, UriKind uriKind2) {
61 this._contentCache = contentCache2; 61 this._contentCache = contentCache2;
62 this._file = file2; 62 this._file = file2;
63 this._uriKind = uriKind2; 63 this._uriKind = uriKind2;
64 this._encoding = "${uriKind2.encoding}${file2.toURI().toString()}"; 64 this._encoding = "${uriKind2.encoding}${file2.toURI().toString()}";
65 } 65 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 String toString() { 99 String toString() {
100 if (_file == null) { 100 if (_file == null) {
101 return "<unknown source>"; 101 return "<unknown source>";
102 } 102 }
103 return _file.getAbsolutePath(); 103 return _file.getAbsolutePath();
104 } 104 }
105 105
106 /** 106 /**
107 * Return the file represented by this source. This is an internal method that is only intended to 107 * Return the file represented by this source. This is an internal method that is only intended to
108 * be used by {@link UriResolver}. 108 * be used by [UriResolver].
109 * @return the file represented by this source 109 * @return the file represented by this source
110 */ 110 */
111 JavaFile get file => _file; 111 JavaFile get file => _file;
112 } 112 }
113 /** 113 /**
114 * Instances of the class {@code PackageUriResolver} resolve {@code package} URI 's in the context of 114 * Instances of the class `PackageUriResolver` resolve `package` URI's in the co ntext of
115 * an application. 115 * an application.
116 * <p> 116 *
117 * For the purposes of sharing analysis, the path to each package under the "pac kages" directory 117 * For the purposes of sharing analysis, the path to each package under the "pac kages" directory
118 * should be canonicalized, but to preserve relative links within a package, the remainder of the 118 * should be canonicalized, but to preserve relative links within a package, the remainder of the
119 * path from the package directory to the leaf should not. 119 * path from the package directory to the leaf should not.
120 * @coverage dart.engine.source 120 * @coverage dart.engine.source
121 */ 121 */
122 class PackageUriResolver extends UriResolver { 122 class PackageUriResolver extends UriResolver {
123 123
124 /** 124 /**
125 * The package directories that {@code package} URI's are assumed to be relati ve to. 125 * The package directories that `package` URI's are assumed to be relative to.
126 */ 126 */
127 List<JavaFile> _packagesDirectories; 127 List<JavaFile> _packagesDirectories;
128 128
129 /** 129 /**
130 * The name of the {@code package} scheme. 130 * The name of the `package` scheme.
131 */ 131 */
132 static String PACKAGE_SCHEME = "package"; 132 static String PACKAGE_SCHEME = "package";
133 133
134 /** 134 /**
135 * Log exceptions thrown with the message "Required key not available" only on ce. 135 * Log exceptions thrown with the message "Required key not available" only on ce.
136 */ 136 */
137 static bool _CanLogRequiredKeyIoException = true; 137 static bool _CanLogRequiredKeyIoException = true;
138 138
139 /** 139 /**
140 * Return {@code true} if the given URI is a {@code package} URI. 140 * Return `true` if the given URI is a `package` URI.
141 * @param uri the URI being tested 141 * @param uri the URI being tested
142 * @return {@code true} if the given URI is a {@code package} URI 142 * @return `true` if the given URI is a `package` URI
143 */ 143 */
144 static bool isPackageUri(Uri uri) => PACKAGE_SCHEME == uri.scheme; 144 static bool isPackageUri(Uri uri) => PACKAGE_SCHEME == uri.scheme;
145 145
146 /** 146 /**
147 * Initialize a newly created resolver to resolve {@code package} URI's relati ve to the given 147 * Initialize a newly created resolver to resolve `package` URI's relative to the given
148 * package directories. 148 * package directories.
149 * @param packagesDirectories the package directories that {@code package} URI 's are assumed to be 149 * @param packagesDirectories the package directories that `package` URI's are assumed to be
150 * relative to 150 * relative to
151 */ 151 */
152 PackageUriResolver(List<JavaFile> packagesDirectories) { 152 PackageUriResolver(List<JavaFile> packagesDirectories) {
153 if (packagesDirectories.length < 1) { 153 if (packagesDirectories.length < 1) {
154 throw new IllegalArgumentException("At least one package directory must be provided"); 154 throw new IllegalArgumentException("At least one package directory must be provided");
155 } 155 }
156 this._packagesDirectories = packagesDirectories; 156 this._packagesDirectories = packagesDirectories;
157 } 157 }
158 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) { 158 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) {
159 if (identical(kind, UriKind.PACKAGE_URI)) { 159 if (identical(kind, UriKind.PACKAGE_URI)) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 209 }
210 } 210 }
211 } 211 }
212 } 212 }
213 } 213 }
214 return null; 214 return null;
215 } 215 }
216 216
217 /** 217 /**
218 * Answer the canonical file for the specified package. 218 * Answer the canonical file for the specified package.
219 * @param packagesDirectory the "packages" directory (not {@code null}) 219 * @param packagesDirectory the "packages" directory (not `null`)
220 * @param pkgName the package name (not {@code null}, not empty) 220 * @param pkgName the package name (not `null`, not empty)
221 * @param relPath the path relative to the package directory (not {@code null} , no leading slash, 221 * @param relPath the path relative to the package directory (not `null`, no l eading slash,
222 * but may be empty string) 222 * but may be empty string)
223 * @return the file (not {@code null}) 223 * @return the file (not `null`)
224 */ 224 */
225 JavaFile getCanonicalFile(JavaFile packagesDirectory, String pkgName, String r elPath) { 225 JavaFile getCanonicalFile(JavaFile packagesDirectory, String pkgName, String r elPath) {
226 JavaFile pkgDir = new JavaFile.relative(packagesDirectory, pkgName); 226 JavaFile pkgDir = new JavaFile.relative(packagesDirectory, pkgName);
227 try { 227 try {
228 pkgDir = pkgDir.getCanonicalFile(); 228 pkgDir = pkgDir.getCanonicalFile();
229 } on IOException catch (e) { 229 } on IOException catch (e) {
230 if (!e.toString().contains("Required key not available")) { 230 if (!e.toString().contains("Required key not available")) {
231 AnalysisEngine.instance.logger.logError2("Canonical failed: ${pkgDir}", e); 231 AnalysisEngine.instance.logger.logError2("Canonical failed: ${pkgDir}", e);
232 } else if (_CanLogRequiredKeyIoException) { 232 } else if (_CanLogRequiredKeyIoException) {
233 _CanLogRequiredKeyIoException = false; 233 _CanLogRequiredKeyIoException = false;
234 AnalysisEngine.instance.logger.logError2("Canonical failed: ${pkgDir}", e); 234 AnalysisEngine.instance.logger.logError2("Canonical failed: ${pkgDir}", e);
235 } 235 }
236 } 236 }
237 return new JavaFile.relative(pkgDir, relPath.replaceAll('/', new String.from CharCode(JavaFile.separatorChar))); 237 return new JavaFile.relative(pkgDir, relPath.replaceAll('/', new String.from CharCode(JavaFile.separatorChar)));
238 } 238 }
239 } 239 }
240 /** 240 /**
241 * Instances of the class {@link DirectoryBasedSourceContainer} represent a sour ce container that 241 * Instances of the class [DirectoryBasedSourceContainer] represent a source con tainer that
242 * contains all sources within a given directory. 242 * contains all sources within a given directory.
243 * @coverage dart.engine.source 243 * @coverage dart.engine.source
244 */ 244 */
245 class DirectoryBasedSourceContainer implements SourceContainer { 245 class DirectoryBasedSourceContainer implements SourceContainer {
246 246
247 /** 247 /**
248 * Append the system file separator to the given path unless the path already ends with a 248 * Append the system file separator to the given path unless the path already ends with a
249 * separator. 249 * separator.
250 * @param path the path to which the file separator is to be added 250 * @param path the path to which the file separator is to be added
251 * @return a path that ends with the system file separator 251 * @return a path that ends with the system file separator
252 */ 252 */
253 static String appendFileSeparator(String path) { 253 static String appendFileSeparator(String path) {
254 if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) == JavaFile.separatorChar) { 254 if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) == JavaFile.separatorChar) {
255 return path; 255 return path;
256 } 256 }
257 return "${path}${JavaFile.separator}"; 257 return "${path}${JavaFile.separator}";
258 } 258 }
259 259
260 /** 260 /**
261 * The container's path (not {@code null}). 261 * The container's path (not `null`).
262 */ 262 */
263 String _path; 263 String _path;
264 264
265 /** 265 /**
266 * Construct a container representing the specified directory and containing a ny sources whose{@link Source#getFullName()} starts with the directory's path. T his is a convenience method, 266 * Construct a container representing the specified directory and containing a ny sources whose[Source#getFullName] starts with the directory's path. This is a convenience method,
267 * fully equivalent to {@link DirectoryBasedSourceContainer#DirectoryBasedSour ceContainer(String)}. 267 * fully equivalent to [DirectoryBasedSourceContainer#DirectoryBasedSourceCont ainer].
268 * @param directory the directory (not {@code null}) 268 * @param directory the directory (not `null`)
269 */ 269 */
270 DirectoryBasedSourceContainer.con1(JavaFile directory) { 270 DirectoryBasedSourceContainer.con1(JavaFile directory) {
271 _jtd_constructor_336_impl(directory); 271 _jtd_constructor_336_impl(directory);
272 } 272 }
273 _jtd_constructor_336_impl(JavaFile directory) { 273 _jtd_constructor_336_impl(JavaFile directory) {
274 _jtd_constructor_337_impl(directory.getPath()); 274 _jtd_constructor_337_impl(directory.getPath());
275 } 275 }
276 276
277 /** 277 /**
278 * Construct a container representing the specified path and containing any so urces whose{@link Source#getFullName()} starts with the specified path. 278 * Construct a container representing the specified path and containing any so urces whose[Source#getFullName] starts with the specified path.
279 * @param path the path (not {@code null} and not empty) 279 * @param path the path (not `null` and not empty)
280 */ 280 */
281 DirectoryBasedSourceContainer.con2(String path2) { 281 DirectoryBasedSourceContainer.con2(String path2) {
282 _jtd_constructor_337_impl(path2); 282 _jtd_constructor_337_impl(path2);
283 } 283 }
284 _jtd_constructor_337_impl(String path2) { 284 _jtd_constructor_337_impl(String path2) {
285 this._path = appendFileSeparator(path2); 285 this._path = appendFileSeparator(path2);
286 } 286 }
287 bool contains(Source source) => source.fullName.startsWith(_path); 287 bool contains(Source source) => source.fullName.startsWith(_path);
288 bool operator ==(Object obj) => (obj is DirectoryBasedSourceContainer) && ((ob j as DirectoryBasedSourceContainer)).path == path; 288 bool operator ==(Object obj) => (obj is DirectoryBasedSourceContainer) && ((ob j as DirectoryBasedSourceContainer)).path == path;
289 289
290 /** 290 /**
291 * Answer the receiver's path, used to determine if a source is contained in t he receiver. 291 * Answer the receiver's path, used to determine if a source is contained in t he receiver.
292 * @return the path (not {@code null}, not empty) 292 * @return the path (not `null`, not empty)
293 */ 293 */
294 String get path => _path; 294 String get path => _path;
295 int get hashCode => _path.hashCode; 295 int get hashCode => _path.hashCode;
296 String toString() => "SourceContainer[${_path}]"; 296 String toString() => "SourceContainer[${_path}]";
297 } 297 }
298 /** 298 /**
299 * Instances of the class {@code FileUriResolver} resolve {@code file} URI's. 299 * Instances of the class `FileUriResolver` resolve `file` URI's.
300 * @coverage dart.engine.source 300 * @coverage dart.engine.source
301 */ 301 */
302 class FileUriResolver extends UriResolver { 302 class FileUriResolver extends UriResolver {
303 303
304 /** 304 /**
305 * The name of the {@code file} scheme. 305 * The name of the `file` scheme.
306 */ 306 */
307 static String FILE_SCHEME = "file"; 307 static String FILE_SCHEME = "file";
308 308
309 /** 309 /**
310 * Return {@code true} if the given URI is a {@code file} URI. 310 * Return `true` if the given URI is a `file` URI.
311 * @param uri the URI being tested 311 * @param uri the URI being tested
312 * @return {@code true} if the given URI is a {@code file} URI 312 * @return `true` if the given URI is a `file` URI
313 */ 313 */
314 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; 314 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
315 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) { 315 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) {
316 if (identical(kind, UriKind.FILE_URI)) { 316 if (identical(kind, UriKind.FILE_URI)) {
317 return new FileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), k ind); 317 return new FileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), k ind);
318 } 318 }
319 return null; 319 return null;
320 } 320 }
321 Source resolveAbsolute(ContentCache contentCache, Uri uri) { 321 Source resolveAbsolute(ContentCache contentCache, Uri uri) {
322 if (!isFileUri(uri)) { 322 if (!isFileUri(uri)) {
323 return null; 323 return null;
324 } 324 }
325 return new FileBasedSource.con1(contentCache, new JavaFile.fromUri(uri)); 325 return new FileBasedSource.con1(contentCache, new JavaFile.fromUri(uri));
326 } 326 }
327 } 327 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698