| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library analyzer.src.source.source_resource; | 5 library analyzer.src.source.source_resource; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/file_system/file_system.dart'; | 9 import 'package:analyzer/file_system/file_system.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 * | 77 * |
| 78 * Clients should consider using the method [AnalysisContext.getContents] | 78 * Clients should consider using the method [AnalysisContext.getContents] |
| 79 * because contexts can have local overrides of the content of a source that | 79 * because contexts can have local overrides of the content of a source that |
| 80 * the source is not aware of. | 80 * the source is not aware of. |
| 81 * | 81 * |
| 82 * Throws an exception if the contents of this source could not be accessed. | 82 * Throws an exception if the contents of this source could not be accessed. |
| 83 * See [contents]. | 83 * See [contents]. |
| 84 */ | 84 */ |
| 85 TimestampedData<String> get contentsFromFile { | 85 TimestampedData<String> get contentsFromFile { |
| 86 return new TimestampedData<String>( | 86 return new TimestampedData<String>( |
| 87 file.modificationStamp, fileReadMode(file.readAsStringSync())); | 87 modificationStamp, fileReadMode(file.readAsStringSync())); |
| 88 } | 88 } |
| 89 | 89 |
| 90 @override | 90 @override |
| 91 String get encoding => _encoding ??= uri.toString(); | 91 String get encoding => _encoding ??= uri.toString(); |
| 92 | 92 |
| 93 @override | 93 @override |
| 94 String get fullName => _absolutePath ??= file.path; | 94 String get fullName => _absolutePath ??= file.path; |
| 95 | 95 |
| 96 @override | 96 @override |
| 97 int get hashCode => id; | 97 int get hashCode => uri.hashCode; |
| 98 | 98 |
| 99 @override | 99 @override |
| 100 bool get isInSystemLibrary => uri.scheme == DartUriResolver.DART_SCHEME; | 100 bool get isInSystemLibrary => uri.scheme == DartUriResolver.DART_SCHEME; |
| 101 | 101 |
| 102 @override | 102 @override |
| 103 int get modificationStamp => file.modificationStamp; | 103 int get modificationStamp { |
| 104 try { |
| 105 return file.modificationStamp; |
| 106 } on FileSystemException { |
| 107 return -1; |
| 108 } |
| 109 } |
| 104 | 110 |
| 105 @override | 111 @override |
| 106 String get shortName => file.shortName; | 112 String get shortName => file.shortName; |
| 107 | 113 |
| 108 @override | 114 @override |
| 109 UriKind get uriKind => UriKind.fromScheme(uri.scheme); | 115 UriKind get uriKind => UriKind.fromScheme(uri.scheme); |
| 110 | 116 |
| 111 @override | 117 @override |
| 112 bool operator ==(Object object) { | 118 bool operator ==(Object object) { |
| 113 if (object is FileSource) { | 119 if (object is FileSource) { |
| 114 return id == object.id; | 120 return id == object.id; |
| 115 } else if (object is Source) { | 121 } else if (object is Source) { |
| 116 return uri == object.uri; | 122 return uri == object.uri; |
| 117 } | 123 } |
| 118 return false; | 124 return false; |
| 119 } | 125 } |
| 120 | 126 |
| 121 @override | 127 @override |
| 122 bool exists() => file.exists; | 128 bool exists() => file.exists; |
| 123 | 129 |
| 124 @override | 130 @override |
| 125 String toString() { | 131 String toString() { |
| 126 if (file == null) { | 132 if (file == null) { |
| 127 return "<unknown source>"; | 133 return "<unknown source>"; |
| 128 } | 134 } |
| 129 return file.path; | 135 return file.path; |
| 130 } | 136 } |
| 131 } | 137 } |
| OLD | NEW |