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

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

Issue 109853003: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 7 years 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 3
4 library engine.source.io; 4 library engine.source.io;
5 5
6 import 'source.dart'; 6 import 'source.dart';
7 import 'java_core.dart'; 7 import 'java_core.dart';
8 import 'java_io.dart'; 8 import 'java_io.dart';
9 import 'engine.dart' show AnalysisContext, AnalysisEngine; 9 import 'engine.dart' show AnalysisContext, AnalysisEngine;
10 export 'source.dart'; 10 export 'source.dart';
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 class FileBasedSource implements Source { 61 class FileBasedSource implements Source {
62 /** 62 /**
63 * The content cache used to access the contents of this source if they have b een overridden from 63 * The content cache used to access the contents of this source if they have b een overridden from
64 * what is on disk or cached. 64 * what is on disk or cached.
65 */ 65 */
66 ContentCache _contentCache; 66 ContentCache _contentCache;
67 67
68 /** 68 /**
69 * The file represented by this source. 69 * The file represented by this source.
70 */ 70 */
71 JavaFile file; 71 JavaFile _file;
72 72
73 /** 73 /**
74 * The cached encoding for this source. 74 * The cached encoding for this source.
75 */ 75 */
76 String _encoding; 76 String _encoding;
77 77
78 /** 78 /**
79 * The kind of URI from which this source was originally derived. 79 * The kind of URI from which this source was originally derived.
80 */ 80 */
81 UriKind _uriKind; 81 UriKind _uriKind;
82 82
83 /** 83 /**
84 * Initialize a newly created source object. The source object is assumed to n ot be in a system 84 * Initialize a newly created source object. The source object is assumed to n ot be in a system
85 * library. 85 * library.
86 * 86 *
87 * @param contentCache the content cache used to access the contents of this s ource 87 * @param contentCache the content cache used to access the contents of this s ource
88 * @param file the file represented by this source 88 * @param file the file represented by this source
89 */ 89 */
90 FileBasedSource.con1(ContentCache contentCache, JavaFile file) : this.con2(con tentCache, file, UriKind.FILE_URI); 90 FileBasedSource.con1(ContentCache contentCache, JavaFile file) : this.con2(con tentCache, file, UriKind.FILE_URI);
91 91
92 /** 92 /**
93 * Initialize a newly created source object. 93 * Initialize a newly created source object.
94 * 94 *
95 * @param contentCache the content cache used to access the contents of this s ource 95 * @param contentCache the content cache used to access the contents of this s ource
96 * @param file the file represented by this source 96 * @param file the file represented by this source
97 * @param flags `true` if this source is in one of the system libraries 97 * @param flags `true` if this source is in one of the system libraries
98 */ 98 */
99 FileBasedSource.con2(ContentCache contentCache, JavaFile file, UriKind uriKind ) { 99 FileBasedSource.con2(ContentCache contentCache, JavaFile file, UriKind uriKind ) {
100 this._contentCache = contentCache; 100 this._contentCache = contentCache;
101 this.file = file; 101 this._file = file;
102 this._uriKind = uriKind; 102 this._uriKind = uriKind;
103 } 103 }
104 104
105 bool operator ==(Object object) => object != null && this.runtimeType == objec t.runtimeType && file == (object as FileBasedSource).file; 105 bool operator ==(Object object) => object != null && this.runtimeType == objec t.runtimeType && _file == (object as FileBasedSource)._file;
106 106
107 bool exists() => _contentCache.getContents(this) != null || (file.exists() && !file.isDirectory()); 107 bool exists() => _contentCache.getContents(this) != null || (_file.exists() && !_file.isDirectory());
108 108
109 void getContents(Source_ContentReceiver receiver) { 109 void getContents(Source_ContentReceiver receiver) {
110 String contents = _contentCache.getContents(this); 110 String contents = _contentCache.getContents(this);
111 if (contents != null) { 111 if (contents != null) {
112 receiver.accept2(contents, _contentCache.getModificationStamp(this)); 112 receiver.accept2(contents, _contentCache.getModificationStamp(this));
113 return; 113 return;
114 } 114 }
115 getContentsFromFile(receiver); 115 getContentsFromFile(receiver);
116 } 116 }
117 117
118 String get encoding { 118 String get encoding {
119 if (_encoding == null) { 119 if (_encoding == null) {
120 _encoding = "${_uriKind.encoding}${file.toURI().toString()}"; 120 _encoding = "${_uriKind.encoding}${_file.toURI().toString()}";
121 } 121 }
122 return _encoding; 122 return _encoding;
123 } 123 }
124 124
125 String get fullName => file.getAbsolutePath(); 125 String get fullName => _file.getAbsolutePath();
126 126
127 int get modificationStamp { 127 int get modificationStamp {
128 int stamp = _contentCache.getModificationStamp(this); 128 int stamp = _contentCache.getModificationStamp(this);
129 if (stamp != null) { 129 if (stamp != null) {
130 return stamp; 130 return stamp;
131 } 131 }
132 return file.lastModified(); 132 return _file.lastModified();
133 } 133 }
134 134
135 String get shortName => file.getName(); 135 String get shortName => _file.getName();
136 136
137 UriKind get uriKind => _uriKind; 137 UriKind get uriKind => _uriKind;
138 138
139 int get hashCode => file.hashCode; 139 int get hashCode => _file.hashCode;
140 140
141 bool get isInSystemLibrary => identical(_uriKind, UriKind.DART_URI); 141 bool get isInSystemLibrary => identical(_uriKind, UriKind.DART_URI);
142 142
143 Source resolveRelative(Uri containedUri) { 143 Source resolveRelative(Uri containedUri) {
144 try { 144 try {
145 Uri resolvedUri = file.toURI().resolveUri(containedUri); 145 Uri resolvedUri = file.toURI().resolveUri(containedUri);
146 return new FileBasedSource.con2(_contentCache, new JavaFile.fromUri(resolv edUri), _uriKind); 146 return new FileBasedSource.con2(_contentCache, new JavaFile.fromUri(resolv edUri), _uriKind);
147 } on JavaException catch (exception) { 147 } on JavaException catch (exception) {
148 } 148 }
149 return null; 149 return null;
150 } 150 }
151 151
152 String toString() { 152 String toString() {
153 if (file == null) { 153 if (_file == null) {
154 return "<unknown source>"; 154 return "<unknown source>";
155 } 155 }
156 return file.getAbsolutePath(); 156 return _file.getAbsolutePath();
157 } 157 }
158 158
159 /** 159 /**
160 * Get the contents of underlying file and pass it to the given receiver. Exac tly one of the 160 * Get the contents of underlying file and pass it to the given receiver. Exac tly one of the
161 * methods defined on the receiver will be invoked unless an exception is thro wn. The method that 161 * methods defined on the receiver will be invoked unless an exception is thro wn. The method that
162 * will be invoked depends on which of the possible representations of the con tents is the most 162 * will be invoked depends on which of the possible representations of the con tents is the most
163 * efficient. Whichever method is invoked, it will be invoked before this meth od returns. 163 * efficient. Whichever method is invoked, it will be invoked before this meth od returns.
164 * 164 *
165 * @param receiver the content receiver to which the content of this source wi ll be passed 165 * @param receiver the content receiver to which the content of this source wi ll be passed
166 * @throws Exception if the contents of this source could not be accessed 166 * @throws Exception if the contents of this source could not be accessed
167 * @see #getContents(com.google.dart.engine.source.Source.ContentReceiver) 167 * @see #getContents(com.google.dart.engine.source.Source.ContentReceiver)
168 */ 168 */
169 void getContentsFromFile(Source_ContentReceiver receiver) { 169 void getContentsFromFile(Source_ContentReceiver receiver) {
170 { 170 {
171 } 171 }
172 receiver.accept2(file.readAsStringSync(), file.lastModified()); 172 receiver.accept2(file.readAsStringSync(), file.lastModified());
173 } 173 }
174
175 /**
176 * Return the file represented by this source. This is an internal method that is only intended to
177 * be used by [UriResolver].
178 *
179 * @return the file represented by this source
180 */
181 JavaFile get file => _file;
174 } 182 }
175 183
176 /** 184 /**
177 * Instances of the class `PackageUriResolver` resolve `package` URI's in the co ntext of 185 * Instances of the class `PackageUriResolver` resolve `package` URI's in the co ntext of
178 * an application. 186 * an application.
179 * 187 *
180 * For the purposes of sharing analysis, the path to each package under the "pac kages" directory 188 * For the purposes of sharing analysis, the path to each package under the "pac kages" directory
181 * should be canonicalized, but to preserve relative links within a package, the remainder of the 189 * should be canonicalized, but to preserve relative links within a package, the remainder of the
182 * path from the package directory to the leaf should not. 190 * path from the package directory to the leaf should not.
183 * 191 *
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 static String appendFileSeparator(String path) { 348 static String appendFileSeparator(String path) {
341 if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) == JavaFile.separatorChar) { 349 if (path == null || path.length <= 0 || path.codeUnitAt(path.length - 1) == JavaFile.separatorChar) {
342 return path; 350 return path;
343 } 351 }
344 return "${path}${JavaFile.separator}"; 352 return "${path}${JavaFile.separator}";
345 } 353 }
346 354
347 /** 355 /**
348 * The container's path (not `null`). 356 * The container's path (not `null`).
349 */ 357 */
350 String path; 358 String _path;
351 359
352 /** 360 /**
353 * Construct a container representing the specified directory and containing a ny sources whose 361 * Construct a container representing the specified directory and containing a ny sources whose
354 * [Source#getFullName] starts with the directory's path. This is a convenienc e method, 362 * [Source#getFullName] starts with the directory's path. This is a convenienc e method,
355 * fully equivalent to [DirectoryBasedSourceContainer#DirectoryBasedSourceCont ainer] 363 * fully equivalent to [DirectoryBasedSourceContainer#DirectoryBasedSourceCont ainer]
356 * . 364 * .
357 * 365 *
358 * @param directory the directory (not `null`) 366 * @param directory the directory (not `null`)
359 */ 367 */
360 DirectoryBasedSourceContainer.con1(JavaFile directory) : this.con2(directory.g etPath()); 368 DirectoryBasedSourceContainer.con1(JavaFile directory) : this.con2(directory.g etPath());
361 369
362 /** 370 /**
363 * Construct a container representing the specified path and containing any so urces whose 371 * Construct a container representing the specified path and containing any so urces whose
364 * [Source#getFullName] starts with the specified path. 372 * [Source#getFullName] starts with the specified path.
365 * 373 *
366 * @param path the path (not `null` and not empty) 374 * @param path the path (not `null` and not empty)
367 */ 375 */
368 DirectoryBasedSourceContainer.con2(String path) { 376 DirectoryBasedSourceContainer.con2(String path) {
369 this.path = appendFileSeparator(path); 377 this._path = appendFileSeparator(path);
370 } 378 }
371 379
372 bool contains(Source source) => source.fullName.startsWith(path); 380 bool contains(Source source) => source.fullName.startsWith(_path);
373 381
374 bool operator ==(Object obj) => (obj is DirectoryBasedSourceContainer) && (obj as DirectoryBasedSourceContainer).path == path; 382 bool operator ==(Object obj) => (obj is DirectoryBasedSourceContainer) && (obj as DirectoryBasedSourceContainer).path == path;
375 383
376 int get hashCode => path.hashCode; 384 /**
385 * Answer the receiver's path, used to determine if a source is contained in t he receiver.
386 *
387 * @return the path (not `null`, not empty)
388 */
389 String get path => _path;
377 390
378 String toString() => "SourceContainer[${path}]"; 391 int get hashCode => _path.hashCode;
392
393 String toString() => "SourceContainer[${_path}]";
379 } 394 }
380 395
381 /** 396 /**
382 * Instances of the class `FileUriResolver` resolve `file` URI's. 397 * Instances of the class `FileUriResolver` resolve `file` URI's.
383 * 398 *
384 * @coverage dart.engine.source 399 * @coverage dart.engine.source
385 */ 400 */
386 class FileUriResolver extends UriResolver { 401 class FileUriResolver extends UriResolver {
387 /** 402 /**
388 * The name of the `file` scheme. 403 * The name of the `file` scheme.
(...skipping 15 matching lines...) Expand all
404 return null; 419 return null;
405 } 420 }
406 421
407 Source resolveAbsolute(ContentCache contentCache, Uri uri) { 422 Source resolveAbsolute(ContentCache contentCache, Uri uri) {
408 if (!isFileUri(uri)) { 423 if (!isFileUri(uri)) {
409 return null; 424 return null;
410 } 425 }
411 return new FileBasedSource.con1(contentCache, new JavaFile.fromUri(uri)); 426 return new FileBasedSource.con1(contentCache, new JavaFile.fromUri(uri));
412 } 427 }
413 } 428 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/source.dart ('k') | pkg/analyzer/lib/src/generated/utilities_dart.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698