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

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

Issue 16256021: Remove trailing spaces in analyzer_experimental (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
4 library engine.source.io; 3 library engine.source.io;
5
6 import 'source.dart'; 4 import 'source.dart';
7 import 'dart:io'; 5 import 'dart:io';
8 import 'java_core.dart'; 6 import 'java_core.dart';
9 import 'java_io.dart'; 7 import 'java_io.dart';
10 import 'sdk.dart' show DartSdk; 8 import 'sdk.dart' show DartSdk;
11 import 'engine.dart' show AnalysisContext, AnalysisEngine; 9 import 'engine.dart' show AnalysisContext, AnalysisEngine;
12 export 'source.dart'; 10 export 'source.dart';
13
14
15 /** 11 /**
16 * Instances of the class {@code FileBasedSource} implement a source that repres ents a file. 12 * Instances of the class {@code FileBasedSource} implement a source that repres ents a file.
17 * @coverage dart.engine.source 13 * @coverage dart.engine.source
18 */ 14 */
19 class FileBasedSource implements Source { 15 class FileBasedSource implements Source {
20 16
21 /** 17 /**
22 * 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
23 * what is on disk or cached. 19 * what is on disk or cached.
24 */ 20 */
25 ContentCache _contentCache; 21 ContentCache _contentCache;
26 22
27 /** 23 /**
28 * The file represented by this source. 24 * The file represented by this source.
29 */ 25 */
30 JavaFile _file; 26 JavaFile _file;
31 27
32 /** 28 /**
33 * The cached encoding for this source. 29 * The cached encoding for this source.
34 */ 30 */
35 String _encoding; 31 String _encoding;
36 32
37 /** 33 /**
38 * The kind of URI from which this source was originally derived. 34 * The kind of URI from which this source was originally derived.
39 */ 35 */
40 UriKind _uriKind; 36 UriKind _uriKind;
41 37
42 /** 38 /**
43 * Initialize a newly created source object. The source object is assumed to n ot be in a system 39 * Initialize a newly created source object. The source object is assumed to n ot be in a system
44 * library. 40 * library.
45 * @param contentCache the content cache used to access the contents of this s ource 41 * @param contentCache the content cache used to access the contents of this s ource
46 * @param file the file represented by this source 42 * @param file the file represented by this source
47 */ 43 */
48 FileBasedSource.con1(ContentCache contentCache, JavaFile file) { 44 FileBasedSource.con1(ContentCache contentCache, JavaFile file) {
49 _jtd_constructor_336_impl(contentCache, file); 45 _jtd_constructor_338_impl(contentCache, file);
50 } 46 }
51 _jtd_constructor_336_impl(ContentCache contentCache, JavaFile file) { 47 _jtd_constructor_338_impl(ContentCache contentCache, JavaFile file) {
52 _jtd_constructor_337_impl(contentCache, file, UriKind.FILE_URI); 48 _jtd_constructor_339_impl(contentCache, file, UriKind.FILE_URI);
53 } 49 }
54 50
55 /** 51 /**
56 * Initialize a newly created source object. 52 * Initialize a newly created source object.
57 * @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
58 * @param file the file represented by this source 54 * @param file the file represented by this source
59 * @param flags {@code true} if this source is in one of the system libraries 55 * @param flags {@code true} if this source is in one of the system libraries
60 */ 56 */
61 FileBasedSource.con2(ContentCache contentCache2, JavaFile file2, UriKind uriKi nd2) { 57 FileBasedSource.con2(ContentCache contentCache2, JavaFile file2, UriKind uriKi nd2) {
62 _jtd_constructor_337_impl(contentCache2, file2, uriKind2); 58 _jtd_constructor_339_impl(contentCache2, file2, uriKind2);
63 } 59 }
64 _jtd_constructor_337_impl(ContentCache contentCache2, JavaFile file2, UriKind uriKind2) { 60 _jtd_constructor_339_impl(ContentCache contentCache2, JavaFile file2, UriKind uriKind2) {
65 this._contentCache = contentCache2; 61 this._contentCache = contentCache2;
66 this._file = file2; 62 this._file = file2;
67 this._uriKind = uriKind2; 63 this._uriKind = uriKind2;
68 this._encoding = "${uriKind2.encoding}${file2.toURI().toString()}"; 64 this._encoding = "${uriKind2.encoding}${file2.toURI().toString()}";
69 } 65 }
70 bool operator ==(Object object) => object != null && this.runtimeType == objec t.runtimeType && _file == ((object as FileBasedSource))._file; 66 bool operator ==(Object object) => object != null && this.runtimeType == objec t.runtimeType && _file == ((object as FileBasedSource))._file;
71 bool exists() => _contentCache.getContents(this) != null || (_file.exists() && !_file.isDirectory()); 67 bool exists() => _contentCache.getContents(this) != null || (_file.exists() && !_file.isDirectory());
72 void getContents(Source_ContentReceiver receiver) { 68 void getContents(Source_ContentReceiver receiver) {
73 { 69 {
74 String contents = _contentCache.getContents(this); 70 String contents = _contentCache.getContents(this);
(...skipping 24 matching lines...) Expand all
99 } catch (exception) { 95 } catch (exception) {
100 } 96 }
101 return null; 97 return null;
102 } 98 }
103 String toString() { 99 String toString() {
104 if (_file == null) { 100 if (_file == null) {
105 return "<unknown source>"; 101 return "<unknown source>";
106 } 102 }
107 return _file.getAbsolutePath(); 103 return _file.getAbsolutePath();
108 } 104 }
109 105
110 /** 106 /**
111 * 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
112 * be used by {@link UriResolver}. 108 * be used by {@link UriResolver}.
113 * @return the file represented by this source 109 * @return the file represented by this source
114 */ 110 */
115 JavaFile get file => _file; 111 JavaFile get file => _file;
116 } 112 }
117
118 /** 113 /**
119 * Instances of the class {@code PackageUriResolver} resolve {@code package} URI 's in the context of 114 * Instances of the class {@code PackageUriResolver} resolve {@code package} URI 's in the context of
120 * an application. 115 * an application.
121 * <p> 116 * <p>
122 * 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
123 * 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
124 * path from the package directory to the leaf should not. 119 * path from the package directory to the leaf should not.
125 * @coverage dart.engine.source 120 * @coverage dart.engine.source
126 */ 121 */
127 class PackageUriResolver extends UriResolver { 122 class PackageUriResolver extends UriResolver {
128 123
129 /** 124 /**
130 * The package directories that {@code package} URI's are assumed to be relati ve to. 125 * The package directories that {@code package} URI's are assumed to be relati ve to.
131 */ 126 */
132 List<JavaFile> _packagesDirectories; 127 List<JavaFile> _packagesDirectories;
133 128
134 /** 129 /**
135 * The name of the {@code package} scheme. 130 * The name of the {@code package} scheme.
136 */ 131 */
137 static String _PACKAGE_SCHEME = "package"; 132 static String PACKAGE_SCHEME = "package";
138 133
139 /** 134 /**
140 * 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.
141 */ 136 */
142 static bool _CanLogRequiredKeyIoException = true; 137 static bool _CanLogRequiredKeyIoException = true;
143 138
144 /** 139 /**
145 * Return {@code true} if the given URI is a {@code package} URI. 140 * Return {@code true} if the given URI is a {@code package} URI.
146 * @param uri the URI being tested 141 * @param uri the URI being tested
147 * @return {@code true} if the given URI is a {@code package} URI 142 * @return {@code true} if the given URI is a {@code package} URI
148 */ 143 */
149 static bool isPackageUri(Uri uri) => _PACKAGE_SCHEME == uri.scheme; 144 static bool isPackageUri(Uri uri) => PACKAGE_SCHEME == uri.scheme;
150 145
151 /** 146 /**
152 * Initialize a newly created resolver to resolve {@code package} URI's relati ve to the given 147 * Initialize a newly created resolver to resolve {@code package} URI's relati ve to the given
153 * package directories. 148 * package directories.
154 * @param packagesDirectories the package directories that {@code package} URI 's are assumed to be 149 * @param packagesDirectories the package directories that {@code package} URI 's are assumed to be
155 * relative to 150 * relative to
156 */ 151 */
157 PackageUriResolver(List<JavaFile> packagesDirectories) { 152 PackageUriResolver(List<JavaFile> packagesDirectories) {
158 if (packagesDirectories.length < 1) { 153 if (packagesDirectories.length < 1) {
159 throw new IllegalArgumentException("At least one package directory must be provided"); 154 throw new IllegalArgumentException("At least one package directory must be provided");
160 } 155 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 if (source is FileBasedSource) { 196 if (source is FileBasedSource) {
202 String sourcePath = ((source as FileBasedSource)).file.getPath(); 197 String sourcePath = ((source as FileBasedSource)).file.getPath();
203 for (JavaFile packagesDirectory in _packagesDirectories) { 198 for (JavaFile packagesDirectory in _packagesDirectories) {
204 List<JavaFile> pkgFolders = packagesDirectory.listFiles(); 199 List<JavaFile> pkgFolders = packagesDirectory.listFiles();
205 if (pkgFolders != null) { 200 if (pkgFolders != null) {
206 for (JavaFile pkgFolder in pkgFolders) { 201 for (JavaFile pkgFolder in pkgFolders) {
207 try { 202 try {
208 String pkgCanonicalPath = pkgFolder.getCanonicalPath(); 203 String pkgCanonicalPath = pkgFolder.getCanonicalPath();
209 if (sourcePath.startsWith(pkgCanonicalPath)) { 204 if (sourcePath.startsWith(pkgCanonicalPath)) {
210 String relPath = sourcePath.substring(pkgCanonicalPath.length); 205 String relPath = sourcePath.substring(pkgCanonicalPath.length);
211 return parseUriWithException("${_PACKAGE_SCHEME}:${pkgFolder.get Name()}${relPath}"); 206 return parseUriWithException("${PACKAGE_SCHEME}:${pkgFolder.getN ame()}${relPath}");
212 } 207 }
213 } catch (e) { 208 } catch (e) {
214 } 209 }
215 } 210 }
216 } 211 }
217 } 212 }
218 } 213 }
219 return null; 214 return null;
220 } 215 }
221 216
222 /** 217 /**
223 * Answer the canonical file for the specified package. 218 * Answer the canonical file for the specified package.
224 * @param packagesDirectory the "packages" directory (not {@code null}) 219 * @param packagesDirectory the "packages" directory (not {@code null})
225 * @param pkgName the package name (not {@code null}, not empty) 220 * @param pkgName the package name (not {@code null}, not empty)
226 * @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 {@code null} , no leading slash,
227 * but may be empty string) 222 * but may be empty string)
228 * @return the file (not {@code null}) 223 * @return the file (not {@code null})
229 */ 224 */
230 JavaFile getCanonicalFile(JavaFile packagesDirectory, String pkgName, String r elPath) { 225 JavaFile getCanonicalFile(JavaFile packagesDirectory, String pkgName, String r elPath) {
231 JavaFile pkgDir = new JavaFile.relative(packagesDirectory, pkgName); 226 JavaFile pkgDir = new JavaFile.relative(packagesDirectory, pkgName);
232 try { 227 try {
233 pkgDir = pkgDir.getCanonicalFile(); 228 pkgDir = pkgDir.getCanonicalFile();
234 } on IOException catch (e) { 229 } on IOException catch (e) {
235 if (!e.toString().contains("Required key not available")) { 230 if (!e.toString().contains("Required key not available")) {
236 AnalysisEngine.instance.logger.logError2("Canonical failed: ${pkgDir}", e); 231 AnalysisEngine.instance.logger.logError2("Canonical failed: ${pkgDir}", e);
237 } else if (_CanLogRequiredKeyIoException) { 232 } else if (_CanLogRequiredKeyIoException) {
238 _CanLogRequiredKeyIoException = false; 233 _CanLogRequiredKeyIoException = false;
239 AnalysisEngine.instance.logger.logError2("Canonical failed: ${pkgDir}", e); 234 AnalysisEngine.instance.logger.logError2("Canonical failed: ${pkgDir}", e);
240 } 235 }
241 } 236 }
242 return new JavaFile.relative(pkgDir, relPath.replaceAll('/', JavaFile.separa torChar)); 237 return new JavaFile.relative(pkgDir, relPath.replaceAll('/', JavaFile.separa torChar));
243 } 238 }
244 } 239 }
245
246 /** 240 /**
247 * Instances of the class {@link DirectoryBasedSourceContainer} represent a sour ce container that 241 * Instances of the class {@link DirectoryBasedSourceContainer} represent a sour ce container that
248 * contains all sources within a given directory. 242 * contains all sources within a given directory.
249 * @coverage dart.engine.source 243 * @coverage dart.engine.source
250 */ 244 */
251 class DirectoryBasedSourceContainer implements SourceContainer { 245 class DirectoryBasedSourceContainer implements SourceContainer {
252 246
253 /** 247 /**
254 * 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
255 * separator. 249 * separator.
256 * @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
257 * @return a path that ends with the system file separator 251 * @return a path that ends with the system file separator
258 */ 252 */
259 static String appendFileSeparator(String path) { 253 static String appendFileSeparator(String path) {
260 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) {
261 return path; 255 return path;
262 } 256 }
263 return "${path}${JavaFile.separator}"; 257 return "${path}${JavaFile.separator}";
264 } 258 }
265 259
266 /** 260 /**
267 * The container's path (not {@code null}). 261 * The container's path (not {@code null}).
268 */ 262 */
269 String _path; 263 String _path;
270 264
271 /** 265 /**
272 * 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{@link Source#getFullName()} starts with the directory's path. T his is a convenience method,
273 * fully equivalent to {@link DirectoryBasedSourceContainer#DirectoryBasedSour ceContainer(String)}. 267 * fully equivalent to {@link DirectoryBasedSourceContainer#DirectoryBasedSour ceContainer(String)}.
274 * @param directory the directory (not {@code null}) 268 * @param directory the directory (not {@code null})
275 */ 269 */
276 DirectoryBasedSourceContainer.con1(JavaFile directory) { 270 DirectoryBasedSourceContainer.con1(JavaFile directory) {
277 _jtd_constructor_334_impl(directory); 271 _jtd_constructor_336_impl(directory);
278 } 272 }
279 _jtd_constructor_334_impl(JavaFile directory) { 273 _jtd_constructor_336_impl(JavaFile directory) {
280 _jtd_constructor_335_impl(directory.getPath()); 274 _jtd_constructor_337_impl(directory.getPath());
281 } 275 }
282 276
283 /** 277 /**
284 * 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{@link Source#getFullName()} starts with the specified path.
285 * @param path the path (not {@code null} and not empty) 279 * @param path the path (not {@code null} and not empty)
286 */ 280 */
287 DirectoryBasedSourceContainer.con2(String path2) { 281 DirectoryBasedSourceContainer.con2(String path2) {
288 _jtd_constructor_335_impl(path2); 282 _jtd_constructor_337_impl(path2);
289 } 283 }
290 _jtd_constructor_335_impl(String path2) { 284 _jtd_constructor_337_impl(String path2) {
291 this._path = appendFileSeparator(path2); 285 this._path = appendFileSeparator(path2);
292 } 286 }
293 bool contains(Source source) => source.fullName.startsWith(_path); 287 bool contains(Source source) => source.fullName.startsWith(_path);
294 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;
295 289
296 /** 290 /**
297 * 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.
298 * @return the path (not {@code null}, not empty) 292 * @return the path (not {@code null}, not empty)
299 */ 293 */
300 String get path => _path; 294 String get path => _path;
301 int get hashCode => _path.hashCode; 295 int get hashCode => _path.hashCode;
302 String toString() => "SourceContainer[${_path}]"; 296 String toString() => "SourceContainer[${_path}]";
303 } 297 }
304
305 /** 298 /**
306 * Instances of the class {@code FileUriResolver} resolve {@code file} URI's. 299 * Instances of the class {@code FileUriResolver} resolve {@code file} URI's.
307 * @coverage dart.engine.source 300 * @coverage dart.engine.source
308 */ 301 */
309 class FileUriResolver extends UriResolver { 302 class FileUriResolver extends UriResolver {
310 303
311 /** 304 /**
312 * The name of the {@code file} scheme. 305 * The name of the {@code file} scheme.
313 */ 306 */
314 static String _FILE_SCHEME = "file"; 307 static String FILE_SCHEME = "file";
315 308
316 /** 309 /**
317 * Return {@code true} if the given URI is a {@code file} URI. 310 * Return {@code true} if the given URI is a {@code file} URI.
318 * @param uri the URI being tested 311 * @param uri the URI being tested
319 * @return {@code true} if the given URI is a {@code file} URI 312 * @return {@code true} if the given URI is a {@code file} URI
320 */ 313 */
321 static bool isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME; 314 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
322 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) { 315 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) {
323 if (identical(kind, UriKind.FILE_URI)) { 316 if (identical(kind, UriKind.FILE_URI)) {
324 return new FileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), k ind); 317 return new FileBasedSource.con2(contentCache, new JavaFile.fromUri(uri), k ind);
325 } 318 }
326 return null; 319 return null;
327 } 320 }
328 Source resolveAbsolute(ContentCache contentCache, Uri uri) { 321 Source resolveAbsolute(ContentCache contentCache, Uri uri) {
329 if (!isFileUri(uri)) { 322 if (!isFileUri(uri)) {
330 return null; 323 return null;
331 } 324 }
332 return new FileBasedSource.con1(contentCache, new JavaFile.fromUri(uri)); 325 return new FileBasedSource.con1(contentCache, new JavaFile.fromUri(uri));
333 } 326 }
334 } 327 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698