| OLD | NEW |
| 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 'dart:collection'; |
| 11 |
| 10 import 'engine.dart'; | 12 import 'engine.dart'; |
| 11 import 'java_core.dart'; | 13 import 'java_core.dart'; |
| 12 import 'java_engine.dart'; | 14 import 'java_engine.dart'; |
| 13 import 'java_io.dart'; | 15 import 'java_io.dart'; |
| 14 import 'source.dart'; | 16 import 'source.dart'; |
| 15 import 'utilities_general.dart'; | 17 import 'utilities_general.dart'; |
| 16 | 18 |
| 17 export 'source.dart'; | 19 export 'source.dart'; |
| 18 | 20 |
| 19 /** | 21 /** |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 /** | 88 /** |
| 87 * Instances of the class `FileBasedSource` implement a source that represents a
file. | 89 * Instances of the class `FileBasedSource` implement a source that represents a
file. |
| 88 */ | 90 */ |
| 89 class FileBasedSource extends Source { | 91 class FileBasedSource extends Source { |
| 90 /** | 92 /** |
| 91 * A function that changes the way that files are read off of disk. | 93 * A function that changes the way that files are read off of disk. |
| 92 */ | 94 */ |
| 93 static Function fileReadMode = (String s) => s; | 95 static Function fileReadMode = (String s) => s; |
| 94 | 96 |
| 95 /** | 97 /** |
| 98 * Map from encoded URI/filepath pair to a unique integer identifier. This |
| 99 * identifier is used for equality tests and hash codes. |
| 100 * |
| 101 * The URI and filepath are joined into a pair by separating them with an '@' |
| 102 * character. |
| 103 */ |
| 104 static final Map<String, int> _idTable = new HashMap<String, int>(); |
| 105 |
| 106 /** |
| 96 * The URI from which this source was originally derived. | 107 * The URI from which this source was originally derived. |
| 97 */ | 108 */ |
| 98 final Uri uri; | 109 final Uri uri; |
| 99 | 110 |
| 100 /** | 111 /** |
| 112 * The unique ID associated with this [FileBasedSource]. |
| 113 */ |
| 114 final int id; |
| 115 |
| 116 /** |
| 101 * The file represented by this source. | 117 * The file represented by this source. |
| 102 */ | 118 */ |
| 103 final JavaFile file; | 119 final JavaFile file; |
| 104 | 120 |
| 105 /** | 121 /** |
| 106 * The cached absolute path of this source. | 122 * The cached absolute path of this source. |
| 107 */ | 123 */ |
| 108 String _absolutePath; | 124 String _absolutePath; |
| 109 | 125 |
| 110 /** | 126 /** |
| 111 * The cached encoding for this source. | 127 * The cached encoding for this source. |
| 112 */ | 128 */ |
| 113 String _encoding; | 129 String _encoding; |
| 114 | 130 |
| 115 /** | 131 /** |
| 116 * Initialize a newly created source object. | 132 * Initialize a newly created source object. |
| 117 * | 133 * |
| 118 * @param file the file represented by this source | 134 * @param file the file represented by this source |
| 119 */ | 135 */ |
| 120 FileBasedSource.con1(JavaFile file) : this.con2(file.toURI(), file); | 136 FileBasedSource.con1(JavaFile file) : this.con2(file.toURI(), file); |
| 121 | 137 |
| 122 /** | 138 /** |
| 123 * Initialize a newly created source object. | 139 * Initialize a newly created source object. |
| 124 * | 140 * |
| 125 * @param file the file represented by this source | 141 * @param file the file represented by this source |
| 126 * @param uri the URI from which this source was originally derived | 142 * @param uri the URI from which this source was originally derived |
| 127 */ | 143 */ |
| 128 FileBasedSource.con2(this.uri, this.file); | 144 FileBasedSource.con2(Uri uri, JavaFile file) |
| 145 : uri = uri, file = file, |
| 146 id = _idTable.putIfAbsent( |
| 147 '$uri@${file.getPath()}', |
| 148 () => _idTable.length); |
| 129 | 149 |
| 130 @override | 150 @override |
| 131 TimestampedData<String> get contents { | 151 TimestampedData<String> get contents { |
| 132 return PerformanceStatistics.io.makeCurrentWhile(() { | 152 return PerformanceStatistics.io.makeCurrentWhile(() { |
| 133 return contentsFromFile; | 153 return contentsFromFile; |
| 134 }); | 154 }); |
| 135 } | 155 } |
| 136 | 156 |
| 137 /** | 157 /** |
| 138 * Get the contents and timestamp of the underlying file. | 158 * Get the contents and timestamp of the underlying file. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 161 | 181 |
| 162 @override | 182 @override |
| 163 String get fullName { | 183 String get fullName { |
| 164 if (_absolutePath == null) { | 184 if (_absolutePath == null) { |
| 165 _absolutePath = file.getAbsolutePath(); | 185 _absolutePath = file.getAbsolutePath(); |
| 166 } | 186 } |
| 167 return _absolutePath; | 187 return _absolutePath; |
| 168 } | 188 } |
| 169 | 189 |
| 170 @override | 190 @override |
| 171 int get hashCode => file.hashCode; | 191 int get hashCode => id; |
| 172 | 192 |
| 173 @override | 193 @override |
| 174 bool get isInSystemLibrary => uri.scheme == DartUriResolver.DART_SCHEME; | 194 bool get isInSystemLibrary => uri.scheme == DartUriResolver.DART_SCHEME; |
| 175 | 195 |
| 176 @override | 196 @override |
| 177 int get modificationStamp => file.lastModified(); | 197 int get modificationStamp => file.lastModified(); |
| 178 | 198 |
| 179 @override | 199 @override |
| 180 String get shortName => file.getName(); | 200 String get shortName => file.getName(); |
| 181 | 201 |
| 182 @override | 202 @override |
| 183 UriKind get uriKind { | 203 UriKind get uriKind { |
| 184 String scheme = uri.scheme; | 204 String scheme = uri.scheme; |
| 185 if (scheme == PackageUriResolver.PACKAGE_SCHEME) { | 205 if (scheme == PackageUriResolver.PACKAGE_SCHEME) { |
| 186 return UriKind.PACKAGE_URI; | 206 return UriKind.PACKAGE_URI; |
| 187 } else if (scheme == DartUriResolver.DART_SCHEME) { | 207 } else if (scheme == DartUriResolver.DART_SCHEME) { |
| 188 return UriKind.DART_URI; | 208 return UriKind.DART_URI; |
| 189 } else if (scheme == FileUriResolver.FILE_SCHEME) { | 209 } else if (scheme == FileUriResolver.FILE_SCHEME) { |
| 190 return UriKind.FILE_URI; | 210 return UriKind.FILE_URI; |
| 191 } | 211 } |
| 192 return UriKind.FILE_URI; | 212 return UriKind.FILE_URI; |
| 193 } | 213 } |
| 194 | 214 |
| 195 @override | 215 @override |
| 196 bool operator ==(Object object) => | 216 bool operator ==(Object object) => |
| 197 object is FileBasedSource && uri == object.uri; | 217 object is FileBasedSource && id == object.id; |
| 198 | 218 |
| 199 @override | 219 @override |
| 200 bool exists() => file.isFile(); | 220 bool exists() => file.isFile(); |
| 201 | 221 |
| 202 @override | 222 @override |
| 203 Uri resolveRelativeUri(Uri containedUri) { | 223 Uri resolveRelativeUri(Uri containedUri) { |
| 204 try { | 224 try { |
| 205 Uri baseUri = uri; | 225 Uri baseUri = uri; |
| 206 bool isOpaque = uri.isAbsolute && !uri.path.startsWith('/'); | 226 bool isOpaque = uri.isAbsolute && !uri.path.startsWith('/'); |
| 207 if (isOpaque) { | 227 if (isOpaque) { |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 } | 538 } |
| 519 | 539 |
| 520 /** | 540 /** |
| 521 * Return `true` if the given URI is a `file` URI. | 541 * Return `true` if the given URI is a `file` URI. |
| 522 * | 542 * |
| 523 * @param uri the URI being tested | 543 * @param uri the URI being tested |
| 524 * @return `true` if the given URI is a `file` URI | 544 * @return `true` if the given URI is a `file` URI |
| 525 */ | 545 */ |
| 526 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; | 546 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; |
| 527 } | 547 } |
| OLD | NEW |