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

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

Issue 192363003: Translate Java's @Override into Dart's @override. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/source.dart ('k') | pkg/analyzer/test/generated/ast_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 27 matching lines...) Expand all
38 /** 38 /**
39 * Determines if the given [Source] is local. 39 * Determines if the given [Source] is local.
40 * 40 *
41 * @param source the [Source] to analyze 41 * @param source the [Source] to analyze
42 * @return `true` if the given [Source] is local 42 * @return `true` if the given [Source] is local
43 */ 43 */
44 bool isLocal(Source source); 44 bool isLocal(Source source);
45 } 45 }
46 46
47 class LocalSourcePredicate_FALSE implements LocalSourcePredicate { 47 class LocalSourcePredicate_FALSE implements LocalSourcePredicate {
48 @override
48 bool isLocal(Source source) => false; 49 bool isLocal(Source source) => false;
49 } 50 }
50 51
51 class LocalSourcePredicate_TRUE implements LocalSourcePredicate { 52 class LocalSourcePredicate_TRUE implements LocalSourcePredicate {
53 @override
52 bool isLocal(Source source) => true; 54 bool isLocal(Source source) => true;
53 } 55 }
54 56
55 class LocalSourcePredicate_NOT_SDK implements LocalSourcePredicate { 57 class LocalSourcePredicate_NOT_SDK implements LocalSourcePredicate {
58 @override
56 bool isLocal(Source source) => source.uriKind != UriKind.DART_URI; 59 bool isLocal(Source source) => source.uriKind != UriKind.DART_URI;
57 } 60 }
58 61
59 /** 62 /**
60 * 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.
61 */ 64 */
62 class FileBasedSource implements Source { 65 class FileBasedSource implements Source {
63 /** 66 /**
64 * The file represented by this source. 67 * The file represented by this source.
65 */ 68 */
(...skipping 21 matching lines...) Expand all
87 * Initialize a newly created source object. 90 * Initialize a newly created source object.
88 * 91 *
89 * @param file the file represented by this source 92 * @param file the file represented by this source
90 * @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
91 */ 94 */
92 FileBasedSource.con2(JavaFile file, UriKind uriKind) { 95 FileBasedSource.con2(JavaFile file, UriKind uriKind) {
93 this._file = file; 96 this._file = file;
94 this._uriKind = uriKind; 97 this._uriKind = uriKind;
95 } 98 }
96 99
100 @override
97 bool operator ==(Object object) => object != null && this.runtimeType == objec t.runtimeType && _file == (object as FileBasedSource)._file; 101 bool operator ==(Object object) => object != null && this.runtimeType == objec t.runtimeType && _file == (object as FileBasedSource)._file;
98 102
103 @override
99 bool exists() => _file.isFile(); 104 bool exists() => _file.isFile();
100 105
106 @override
101 TimestampedData<String> get contents { 107 TimestampedData<String> get contents {
102 TimeCounter_TimeCounterHandle handle = PerformanceStatistics.io.start(); 108 TimeCounter_TimeCounterHandle handle = PerformanceStatistics.io.start();
103 try { 109 try {
104 return contentsFromFile; 110 return contentsFromFile;
105 } finally { 111 } finally {
106 handle.stop(); 112 handle.stop();
107 } 113 }
108 } 114 }
109 115
116 @override
110 String get encoding { 117 String get encoding {
111 if (_encoding == null) { 118 if (_encoding == null) {
112 _encoding = "${_uriKind.encoding}${_file.toURI().toString()}"; 119 _encoding = "${_uriKind.encoding}${_file.toURI().toString()}";
113 } 120 }
114 return _encoding; 121 return _encoding;
115 } 122 }
116 123
124 @override
117 String get fullName => _file.getAbsolutePath(); 125 String get fullName => _file.getAbsolutePath();
118 126
127 @override
119 int get modificationStamp => _file.lastModified(); 128 int get modificationStamp => _file.lastModified();
120 129
130 @override
121 String get shortName => _file.getName(); 131 String get shortName => _file.getName();
122 132
133 @override
123 UriKind get uriKind => _uriKind; 134 UriKind get uriKind => _uriKind;
124 135
136 @override
125 int get hashCode => _file.hashCode; 137 int get hashCode => _file.hashCode;
126 138
139 @override
127 bool get isInSystemLibrary => identical(_uriKind, UriKind.DART_URI); 140 bool get isInSystemLibrary => identical(_uriKind, UriKind.DART_URI);
128 141
142 @override
129 Source resolveRelative(Uri containedUri) { 143 Source resolveRelative(Uri containedUri) {
130 try { 144 try {
131 Uri resolvedUri = file.toURI().resolveUri(containedUri); 145 Uri resolvedUri = file.toURI().resolveUri(containedUri);
132 return new FileBasedSource.con2(new JavaFile.fromUri(resolvedUri), _uriKin d); 146 return new FileBasedSource.con2(new JavaFile.fromUri(resolvedUri), _uriKin d);
133 } on JavaException catch (exception) { 147 } on JavaException catch (exception) {
134 } 148 }
135 return null; 149 return null;
136 } 150 }
137 151
152 @override
138 String toString() { 153 String toString() {
139 if (_file == null) { 154 if (_file == null) {
140 return "<unknown source>"; 155 return "<unknown source>";
141 } 156 }
142 return _file.getAbsolutePath(); 157 return _file.getAbsolutePath();
143 } 158 }
144 159
145 /** 160 /**
146 * Get the contents and timestamp of the underlying file. 161 * Get the contents and timestamp of the underlying file.
147 * 162 *
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 * @param packagesDirectories the package directories that `package` URI's are assumed to be 220 * @param packagesDirectories the package directories that `package` URI's are assumed to be
206 * relative to 221 * relative to
207 */ 222 */
208 PackageUriResolver(List<JavaFile> packagesDirectories) { 223 PackageUriResolver(List<JavaFile> packagesDirectories) {
209 if (packagesDirectories.length < 1) { 224 if (packagesDirectories.length < 1) {
210 throw new IllegalArgumentException("At least one package directory must be provided"); 225 throw new IllegalArgumentException("At least one package directory must be provided");
211 } 226 }
212 this._packagesDirectories = packagesDirectories; 227 this._packagesDirectories = packagesDirectories;
213 } 228 }
214 229
230 @override
215 Source fromEncoding(UriKind kind, Uri uri) { 231 Source fromEncoding(UriKind kind, Uri uri) {
216 if (identical(kind, UriKind.PACKAGE_SELF_URI) || identical(kind, UriKind.PAC KAGE_URI)) { 232 if (identical(kind, UriKind.PACKAGE_SELF_URI) || identical(kind, UriKind.PAC KAGE_URI)) {
217 return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind); 233 return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind);
218 } 234 }
219 return null; 235 return null;
220 } 236 }
221 237
238 @override
222 Source resolveAbsolute(Uri uri) { 239 Source resolveAbsolute(Uri uri) {
223 if (!isPackageUri(uri)) { 240 if (!isPackageUri(uri)) {
224 return null; 241 return null;
225 } 242 }
226 String path = uri.path; 243 String path = uri.path;
227 if (path == null) { 244 if (path == null) {
228 path = uri.path; 245 path = uri.path;
229 if (path == null) { 246 if (path == null) {
230 return null; 247 return null;
231 } 248 }
(...skipping 17 matching lines...) Expand all
249 JavaFile resolvedFile = new JavaFile.relative(packagesDirectory, path); 266 JavaFile resolvedFile = new JavaFile.relative(packagesDirectory, path);
250 if (resolvedFile.exists()) { 267 if (resolvedFile.exists()) {
251 JavaFile canonicalFile = getCanonicalFile(packagesDirectory, pkgName, re lPath); 268 JavaFile canonicalFile = getCanonicalFile(packagesDirectory, pkgName, re lPath);
252 UriKind uriKind = _isSelfReference(packagesDirectory, canonicalFile) ? U riKind.PACKAGE_SELF_URI : UriKind.PACKAGE_URI; 269 UriKind uriKind = _isSelfReference(packagesDirectory, canonicalFile) ? U riKind.PACKAGE_SELF_URI : UriKind.PACKAGE_URI;
253 return new FileBasedSource.con2(canonicalFile, uriKind); 270 return new FileBasedSource.con2(canonicalFile, uriKind);
254 } 271 }
255 } 272 }
256 return new FileBasedSource.con2(getCanonicalFile(_packagesDirectories[0], pk gName, relPath), UriKind.PACKAGE_URI); 273 return new FileBasedSource.con2(getCanonicalFile(_packagesDirectories[0], pk gName, relPath), UriKind.PACKAGE_URI);
257 } 274 }
258 275
276 @override
259 Uri restoreAbsolute(Source source) { 277 Uri restoreAbsolute(Source source) {
260 if (source is FileBasedSource) { 278 if (source is FileBasedSource) {
261 String sourcePath = source.file.getPath(); 279 String sourcePath = source.file.getPath();
262 for (JavaFile packagesDirectory in _packagesDirectories) { 280 for (JavaFile packagesDirectory in _packagesDirectories) {
263 List<JavaFile> pkgFolders = packagesDirectory.listFiles(); 281 List<JavaFile> pkgFolders = packagesDirectory.listFiles();
264 if (pkgFolders != null) { 282 if (pkgFolders != null) {
265 for (JavaFile pkgFolder in pkgFolders) { 283 for (JavaFile pkgFolder in pkgFolders) {
266 try { 284 try {
267 String pkgCanonicalPath = pkgFolder.getCanonicalPath(); 285 String pkgCanonicalPath = pkgFolder.getCanonicalPath();
268 if (sourcePath.startsWith(pkgCanonicalPath)) { 286 if (sourcePath.startsWith(pkgCanonicalPath)) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 /** 372 /**
355 * Construct a container representing the specified path and containing any so urces whose 373 * Construct a container representing the specified path and containing any so urces whose
356 * [Source#getFullName] starts with the specified path. 374 * [Source#getFullName] starts with the specified path.
357 * 375 *
358 * @param path the path (not `null` and not empty) 376 * @param path the path (not `null` and not empty)
359 */ 377 */
360 DirectoryBasedSourceContainer.con2(String path) { 378 DirectoryBasedSourceContainer.con2(String path) {
361 this._path = _appendFileSeparator(path); 379 this._path = _appendFileSeparator(path);
362 } 380 }
363 381
382 @override
364 bool contains(Source source) => source.fullName.startsWith(_path); 383 bool contains(Source source) => source.fullName.startsWith(_path);
365 384
385 @override
366 bool operator ==(Object obj) => (obj is DirectoryBasedSourceContainer) && obj. path == path; 386 bool operator ==(Object obj) => (obj is DirectoryBasedSourceContainer) && obj. path == path;
367 387
368 /** 388 /**
369 * Answer the receiver's path, used to determine if a source is contained in t he receiver. 389 * Answer the receiver's path, used to determine if a source is contained in t he receiver.
370 * 390 *
371 * @return the path (not `null`, not empty) 391 * @return the path (not `null`, not empty)
372 */ 392 */
373 String get path => _path; 393 String get path => _path;
374 394
395 @override
375 int get hashCode => _path.hashCode; 396 int get hashCode => _path.hashCode;
376 397
398 @override
377 String toString() => "SourceContainer[${_path}]"; 399 String toString() => "SourceContainer[${_path}]";
378 } 400 }
379 401
380 /** 402 /**
381 * Instances of the class `FileUriResolver` resolve `file` URI's. 403 * Instances of the class `FileUriResolver` resolve `file` URI's.
382 */ 404 */
383 class FileUriResolver extends UriResolver { 405 class FileUriResolver extends UriResolver {
384 /** 406 /**
385 * The name of the `file` scheme. 407 * The name of the `file` scheme.
386 */ 408 */
387 static String FILE_SCHEME = "file"; 409 static String FILE_SCHEME = "file";
388 410
389 /** 411 /**
390 * Return `true` if the given URI is a `file` URI. 412 * Return `true` if the given URI is a `file` URI.
391 * 413 *
392 * @param uri the URI being tested 414 * @param uri the URI being tested
393 * @return `true` if the given URI is a `file` URI 415 * @return `true` if the given URI is a `file` URI
394 */ 416 */
395 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; 417 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
396 418
419 @override
397 Source fromEncoding(UriKind kind, Uri uri) { 420 Source fromEncoding(UriKind kind, Uri uri) {
398 if (identical(kind, UriKind.FILE_URI)) { 421 if (identical(kind, UriKind.FILE_URI)) {
399 return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind); 422 return new FileBasedSource.con2(new JavaFile.fromUri(uri), kind);
400 } 423 }
401 return null; 424 return null;
402 } 425 }
403 426
427 @override
404 Source resolveAbsolute(Uri uri) { 428 Source resolveAbsolute(Uri uri) {
405 if (!isFileUri(uri)) { 429 if (!isFileUri(uri)) {
406 return null; 430 return null;
407 } 431 }
408 return new FileBasedSource.con1(new JavaFile.fromUri(uri)); 432 return new FileBasedSource.con1(new JavaFile.fromUri(uri));
409 } 433 }
410 } 434 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/source.dart ('k') | pkg/analyzer/test/generated/ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698