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

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

Issue 221483002: Fix for translation of \!= to \!identical(), but use == and \!= for Enum. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 // 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 bool isLocal(Source source) => source.uriKind != UriKind.DART_URI; 59 bool isLocal(Source source) => source.uriKind != UriKind.DART_URI;
60 } 60 }
61 61
62 /** 62 /**
63 * Instances of the class `FileBasedSource` implement a source that represents a file. 63 * Instances of the class `FileBasedSource` implement a source that represents a file.
64 */ 64 */
65 class FileBasedSource implements Source { 65 class FileBasedSource implements Source {
66 /** 66 /**
67 * The file represented by this source. 67 * The file represented by this source.
68 */ 68 */
69 JavaFile _file; 69 final JavaFile file;
70 70
71 /** 71 /**
72 * The cached encoding for this source. 72 * The cached encoding for this source.
73 */ 73 */
74 String _encoding; 74 String _encoding;
75 75
76 /** 76 /**
77 * The kind of URI from which this source was originally derived. 77 * The kind of URI from which this source was originally derived.
78 */ 78 */
79 UriKind _uriKind; 79 final UriKind uriKind;
80 80
81 /** 81 /**
82 * Initialize a newly created source object. The source object is assumed to n ot be in a system 82 * Initialize a newly created source object. The source object is assumed to n ot be in a system
83 * library. 83 * library.
84 * 84 *
85 * @param file the file represented by this source 85 * @param file the file represented by this source
86 */ 86 */
87 FileBasedSource.con1(JavaFile file) : this.con2(file, UriKind.FILE_URI); 87 FileBasedSource.con1(JavaFile file) : this.con2(file, UriKind.FILE_URI);
88 88
89 /** 89 /**
90 * Initialize a newly created source object. 90 * Initialize a newly created source object.
91 * 91 *
92 * @param file the file represented by this source 92 * @param file the file represented by this source
93 * @param flags `true` if this source is in one of the system libraries 93 * @param flags `true` if this source is in one of the system libraries
94 */ 94 */
95 FileBasedSource.con2(JavaFile file, UriKind uriKind) { 95 FileBasedSource.con2(this.file, this.uriKind);
96 this._file = file;
97 this._uriKind = uriKind;
98 }
99 96
100 @override 97 @override
101 bool operator ==(Object object) => object != null && this.runtimeType == objec t.runtimeType && _file == (object as FileBasedSource)._file; 98 bool operator ==(Object object) => object != null && this.runtimeType == objec t.runtimeType && file == (object as FileBasedSource).file;
102 99
103 @override 100 @override
104 bool exists() => _file.isFile(); 101 bool exists() => file.isFile();
105 102
106 @override 103 @override
107 TimestampedData<String> get contents { 104 TimestampedData<String> get contents {
108 TimeCounter_TimeCounterHandle handle = PerformanceStatistics.io.start(); 105 TimeCounter_TimeCounterHandle handle = PerformanceStatistics.io.start();
109 try { 106 try {
110 return contentsFromFile; 107 return contentsFromFile;
111 } finally { 108 } finally {
112 handle.stop(); 109 handle.stop();
113 } 110 }
114 } 111 }
115 112
116 @override 113 @override
117 String get encoding { 114 String get encoding {
118 if (_encoding == null) { 115 if (_encoding == null) {
119 _encoding = "${_uriKind.encoding}${_file.toURI().toString()}"; 116 _encoding = "${uriKind.encoding}${file.toURI().toString()}";
120 } 117 }
121 return _encoding; 118 return _encoding;
122 } 119 }
123 120
124 @override 121 @override
125 String get fullName => _file.getAbsolutePath(); 122 String get fullName => file.getAbsolutePath();
126 123
127 @override 124 @override
128 int get modificationStamp => _file.lastModified(); 125 int get modificationStamp => file.lastModified();
129 126
130 @override 127 @override
131 String get shortName => _file.getName(); 128 String get shortName => file.getName();
132 129
133 @override 130 @override
134 UriKind get uriKind => _uriKind; 131 int get hashCode => file.hashCode;
135 132
136 @override 133 @override
137 int get hashCode => _file.hashCode; 134 bool get isInSystemLibrary => uriKind == UriKind.DART_URI;
138
139 @override
140 bool get isInSystemLibrary => identical(_uriKind, UriKind.DART_URI);
141 135
142 @override 136 @override
143 Source resolveRelative(Uri containedUri) { 137 Source resolveRelative(Uri containedUri) {
144 try { 138 try {
145 Uri resolvedUri = file.toURI().resolveUri(containedUri); 139 Uri resolvedUri = file.toURI().resolveUri(containedUri);
146 return new FileBasedSource.con2(new JavaFile.fromUri(resolvedUri), _uriKin d); 140 return new FileBasedSource.con2(new JavaFile.fromUri(resolvedUri), uriKind );
147 } on JavaException catch (exception) { 141 } on JavaException catch (exception) {
148 } 142 }
149 return null; 143 return null;
150 } 144 }
151 145
152 @override 146 @override
153 String toString() { 147 String toString() {
154 if (_file == null) { 148 if (file == null) {
155 return "<unknown source>"; 149 return "<unknown source>";
156 } 150 }
157 return _file.getAbsolutePath(); 151 return file.getAbsolutePath();
158 } 152 }
159 153
160 /** 154 /**
161 * Get the contents and timestamp of the underlying file. 155 * Get the contents and timestamp of the underlying file.
162 * 156 *
163 * Clients should consider using the the method [AnalysisContext#getContents] 157 * Clients should consider using the the method [AnalysisContext#getContents]
164 * because contexts can have local overrides of the content of a source that t he source is not 158 * because contexts can have local overrides of the content of a source that t he source is not
165 * aware of. 159 * aware of.
166 * 160 *
167 * @return the contents of the source paired with the modification stamp of th e source 161 * @return the contents of the source paired with the modification stamp of th e source
168 * @throws Exception if the contents of this source could not be accessed 162 * @throws Exception if the contents of this source could not be accessed
169 * @see #getContents() 163 * @see #getContents()
170 */ 164 */
171 TimestampedData<String> get contentsFromFile { 165 TimestampedData<String> get contentsFromFile {
172 return new TimestampedData<String>(_file.lastModified(), _file.readAsStringS ync()); 166 return new TimestampedData<String>(file.lastModified(), file.readAsStringSyn c());
173 } 167 }
174
175 /**
176 * Return the file represented by this source. This is an internal method that is only intended to
177 * be used by subclasses of [UriResolver] that are designed to work with file- based sources.
178 *
179 * @return the file represented by this source
180 */
181 JavaFile get file => _file;
182 } 168 }
183 169
184 /** 170 /**
185 * Instances of the class `PackageUriResolver` resolve `package` URI's in the co ntext of 171 * Instances of the class `PackageUriResolver` resolve `package` URI's in the co ntext of
186 * an application. 172 * an application.
187 * 173 *
188 * For the purposes of sharing analysis, the path to each package under the "pac kages" directory 174 * For the purposes of sharing analysis, the path to each package under the "pac kages" directory
189 * should be canonicalized, but to preserve relative links within a package, the remainder of the 175 * should be canonicalized, but to preserve relative links within a package, the remainder of the
190 * path from the package directory to the leaf should not. 176 * path from the package directory to the leaf should not.
191 */ 177 */
192 class PackageUriResolver extends UriResolver { 178 class PackageUriResolver extends UriResolver {
193 /** 179 /**
194 * The package directories that `package` URI's are assumed to be relative to. 180 * The package directories that `package` URI's are assumed to be relative to.
195 */ 181 */
196 List<JavaFile> _packagesDirectories; 182 final List<JavaFile> _packagesDirectories;
197 183
198 /** 184 /**
199 * The name of the `package` scheme. 185 * The name of the `package` scheme.
200 */ 186 */
201 static String PACKAGE_SCHEME = "package"; 187 static String PACKAGE_SCHEME = "package";
202 188
203 /** 189 /**
204 * Log exceptions thrown with the message "Required key not available" only on ce. 190 * Log exceptions thrown with the message "Required key not available" only on ce.
205 */ 191 */
206 static bool _CanLogRequiredKeyIoException = true; 192 static bool _CanLogRequiredKeyIoException = true;
207 193
208 /** 194 /**
209 * Return `true` if the given URI is a `package` URI. 195 * Return `true` if the given URI is a `package` URI.
210 * 196 *
211 * @param uri the URI being tested 197 * @param uri the URI being tested
212 * @return `true` if the given URI is a `package` URI 198 * @return `true` if the given URI is a `package` URI
213 */ 199 */
214 static bool isPackageUri(Uri uri) => PACKAGE_SCHEME == uri.scheme; 200 static bool isPackageUri(Uri uri) => PACKAGE_SCHEME == uri.scheme;
215 201
216 /** 202 /**
217 * Initialize a newly created resolver to resolve `package` URI's relative to the given 203 * Initialize a newly created resolver to resolve `package` URI's relative to the given
218 * package directories. 204 * package directories.
219 * 205 *
220 * @param packagesDirectories the package directories that `package` URI's are assumed to be 206 * @param packagesDirectories the package directories that `package` URI's are assumed to be
221 * relative to 207 * relative to
222 */ 208 */
223 PackageUriResolver(List<JavaFile> packagesDirectories) { 209 PackageUriResolver(this._packagesDirectories) {
224 if (packagesDirectories.length < 1) { 210 if (_packagesDirectories.length < 1) {
225 throw new IllegalArgumentException("At least one package directory must be provided"); 211 throw new IllegalArgumentException("At least one package directory must be provided");
226 } 212 }
227 this._packagesDirectories = packagesDirectories;
228 } 213 }
229 214
230 @override 215 @override
231 Source fromEncoding(UriKind kind, Uri uri) { 216 Source fromEncoding(UriKind kind, Uri uri) {
232 if (identical(kind, UriKind.PACKAGE_SELF_URI) || identical(kind, UriKind.PAC KAGE_URI)) { 217 if (kind == UriKind.PACKAGE_SELF_URI || kind == UriKind.PACKAGE_URI) {
233 return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind); 218 return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind);
234 } 219 }
235 return null; 220 return null;
236 } 221 }
237 222
238 @override 223 @override
239 Source resolveAbsolute(Uri uri) { 224 Source resolveAbsolute(Uri uri) {
240 if (!isPackageUri(uri)) { 225 if (!isPackageUri(uri)) {
241 return null; 226 return null;
242 } 227 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 /** 396 /**
412 * Return `true` if the given URI is a `file` URI. 397 * Return `true` if the given URI is a `file` URI.
413 * 398 *
414 * @param uri the URI being tested 399 * @param uri the URI being tested
415 * @return `true` if the given URI is a `file` URI 400 * @return `true` if the given URI is a `file` URI
416 */ 401 */
417 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; 402 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
418 403
419 @override 404 @override
420 Source fromEncoding(UriKind kind, Uri uri) { 405 Source fromEncoding(UriKind kind, Uri uri) {
421 if (identical(kind, UriKind.FILE_URI)) { 406 if (kind == UriKind.FILE_URI) {
422 return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind); 407 return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind);
423 } 408 }
424 return null; 409 return null;
425 } 410 }
426 411
427 @override 412 @override
428 Source resolveAbsolute(Uri uri) { 413 Source resolveAbsolute(Uri uri) {
429 if (!isFileUri(uri)) { 414 if (!isFileUri(uri)) {
430 return null; 415 return null;
431 } 416 }
432 return new FileBasedSource.con1(new JavaFile.fromUri(uri)); 417 return new FileBasedSource.con1(new JavaFile.fromUri(uri));
433 } 418 }
434 } 419 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/source.dart ('k') | pkg/analyzer/lib/src/generated/utilities_collection.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698