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

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

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

Powered by Google App Engine
This is Rietveld 408576698