| 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 'source.dart'; | 10 import 'source.dart'; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 this._contentCache = contentCache; | 104 this._contentCache = contentCache; |
| 105 this._file = file; | 105 this._file = file; |
| 106 this._uriKind = uriKind; | 106 this._uriKind = uriKind; |
| 107 } | 107 } |
| 108 | 108 |
| 109 bool operator ==(Object object) => object != null && this.runtimeType == objec
t.runtimeType && _file == (object as FileBasedSource)._file; | 109 bool operator ==(Object object) => object != null && this.runtimeType == objec
t.runtimeType && _file == (object as FileBasedSource)._file; |
| 110 | 110 |
| 111 bool exists() => _contentCache.getContents(this) != null || (_file.exists() &&
!_file.isDirectory()); | 111 bool exists() => _contentCache.getContents(this) != null || (_file.exists() &&
!_file.isDirectory()); |
| 112 | 112 |
| 113 void getContents(Source_ContentReceiver receiver) { | 113 void getContents(Source_ContentReceiver receiver) { |
| 114 // |
| 115 // First check to see whether our content cache has an override for our cont
ents. |
| 116 // |
| 114 String contents = _contentCache.getContents(this); | 117 String contents = _contentCache.getContents(this); |
| 115 if (contents != null) { | 118 if (contents != null) { |
| 116 receiver.accept2(contents, _contentCache.getModificationStamp(this)); | 119 receiver.accept2(contents, _contentCache.getModificationStamp(this)); |
| 117 return; | 120 return; |
| 118 } | 121 } |
| 122 // |
| 123 // If not, read the contents from the file using native I/O. |
| 124 // |
| 119 getContentsFromFile(receiver); | 125 getContentsFromFile(receiver); |
| 120 } | 126 } |
| 121 | 127 |
| 122 String get encoding { | 128 String get encoding { |
| 123 if (_encoding == null) { | 129 if (_encoding == null) { |
| 124 _encoding = "${_uriKind.encoding}${_file.toURI().toString()}"; | 130 _encoding = "${_uriKind.encoding}${_file.toURI().toString()}"; |
| 125 } | 131 } |
| 126 return _encoding; | 132 return _encoding; |
| 127 } | 133 } |
| 128 | 134 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 if (path == null) { | 254 if (path == null) { |
| 249 path = uri.path; | 255 path = uri.path; |
| 250 if (path == null) { | 256 if (path == null) { |
| 251 return null; | 257 return null; |
| 252 } | 258 } |
| 253 } | 259 } |
| 254 String pkgName; | 260 String pkgName; |
| 255 String relPath; | 261 String relPath; |
| 256 int index = path.indexOf('/'); | 262 int index = path.indexOf('/'); |
| 257 if (index == -1) { | 263 if (index == -1) { |
| 264 // No slash |
| 258 pkgName = path; | 265 pkgName = path; |
| 259 relPath = ""; | 266 relPath = ""; |
| 260 } else if (index == 0) { | 267 } else if (index == 0) { |
| 268 // Leading slash is invalid |
| 261 return null; | 269 return null; |
| 262 } else { | 270 } else { |
| 271 // <pkgName>/<relPath> |
| 263 pkgName = path.substring(0, index); | 272 pkgName = path.substring(0, index); |
| 264 relPath = path.substring(index + 1); | 273 relPath = path.substring(index + 1); |
| 265 } | 274 } |
| 266 for (JavaFile packagesDirectory in _packagesDirectories) { | 275 for (JavaFile packagesDirectory in _packagesDirectories) { |
| 267 JavaFile resolvedFile = new JavaFile.relative(packagesDirectory, path); | 276 JavaFile resolvedFile = new JavaFile.relative(packagesDirectory, path); |
| 268 if (resolvedFile.exists()) { | 277 if (resolvedFile.exists()) { |
| 269 JavaFile canonicalFile = getCanonicalFile(packagesDirectory, pkgName, re
lPath); | 278 JavaFile canonicalFile = getCanonicalFile(packagesDirectory, pkgName, re
lPath); |
| 270 UriKind uriKind = isSelfReference(packagesDirectory, canonicalFile) ? Ur
iKind.PACKAGE_SELF_URI : UriKind.PACKAGE_URI; | 279 UriKind uriKind = isSelfReference(packagesDirectory, canonicalFile) ? Ur
iKind.PACKAGE_SELF_URI : UriKind.PACKAGE_URI; |
| 271 return new FileBasedSource.con2(contentCache, canonicalFile, uriKind); | 280 return new FileBasedSource.con2(contentCache, canonicalFile, uriKind); |
| 272 } | 281 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 return null; | 432 return null; |
| 424 } | 433 } |
| 425 | 434 |
| 426 Source resolveAbsolute(ContentCache contentCache, Uri uri) { | 435 Source resolveAbsolute(ContentCache contentCache, Uri uri) { |
| 427 if (!isFileUri(uri)) { | 436 if (!isFileUri(uri)) { |
| 428 return null; | 437 return null; |
| 429 } | 438 } |
| 430 return new FileBasedSource.con1(contentCache, new JavaFile.fromUri(uri)); | 439 return new FileBasedSource.con1(contentCache, new JavaFile.fromUri(uri)); |
| 431 } | 440 } |
| 432 } | 441 } |
| OLD | NEW |