Chromium Code Reviews| 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 library analyzer.src.generated.source_io; | 5 library analyzer.src.generated.source_io; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/exception/exception.dart'; | 9 import 'package:analyzer/exception/exception.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| 11 import 'package:analyzer/src/generated/java_io.dart'; | 11 import 'package:analyzer/src/generated/java_io.dart'; |
| 12 import 'package:analyzer/src/generated/source.dart'; | 12 import 'package:analyzer/src/generated/source.dart'; |
| 13 import 'package:path/path.dart' as path; | 13 import 'package:path/path.dart' as path; |
| 14 import 'package:source_span/source_span.dart' as source_span; | |
| 14 | 15 |
| 15 export 'package:analyzer/src/generated/source.dart'; | 16 export 'package:analyzer/src/generated/source.dart'; |
| 16 | 17 |
| 17 /** | 18 /** |
| 18 * Instances of the class [DirectoryBasedSourceContainer] represent a source con tainer that | 19 * Instances of the class [DirectoryBasedSourceContainer] represent a source con tainer that |
| 19 * contains all sources within a given directory. | 20 * contains all sources within a given directory. |
| 20 */ | 21 */ |
| 21 @deprecated | 22 @deprecated |
| 22 class DirectoryBasedSourceContainer implements SourceContainer { | 23 class DirectoryBasedSourceContainer implements SourceContainer { |
| 23 /** | 24 /** |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 | 140 |
| 140 /** | 141 /** |
| 141 * Map from encoded URI/filepath pair to a unique integer identifier. This | 142 * Map from encoded URI/filepath pair to a unique integer identifier. This |
| 142 * identifier is used for equality tests and hash codes. | 143 * identifier is used for equality tests and hash codes. |
| 143 * | 144 * |
| 144 * The URI and filepath are joined into a pair by separating them with an '@' | 145 * The URI and filepath are joined into a pair by separating them with an '@' |
| 145 * character. | 146 * character. |
| 146 */ | 147 */ |
| 147 static final Map<String, int> _idTable = new HashMap<String, int>(); | 148 static final Map<String, int> _idTable = new HashMap<String, int>(); |
| 148 | 149 |
| 150 source_span.SourceFile _sourceFile; | |
| 151 | |
| 149 /** | 152 /** |
| 150 * The URI from which this source was originally derived. | 153 * The URI from which this source was originally derived. |
| 151 */ | 154 */ |
| 152 @override | 155 @override |
| 153 final Uri uri; | 156 final Uri uri; |
| 154 | 157 |
| 155 /** | 158 /** |
| 156 * The unique ID associated with this [FileBasedSource]. | 159 * The unique ID associated with this [FileBasedSource]. |
| 157 */ | 160 */ |
| 158 final int id; | 161 final int id; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 @override | 231 @override |
| 229 bool get isInSystemLibrary => uri.scheme == DartUriResolver.DART_SCHEME; | 232 bool get isInSystemLibrary => uri.scheme == DartUriResolver.DART_SCHEME; |
| 230 | 233 |
| 231 @override | 234 @override |
| 232 int get modificationStamp => file.lastModified(); | 235 int get modificationStamp => file.lastModified(); |
| 233 | 236 |
| 234 @override | 237 @override |
| 235 String get shortName => file.getName(); | 238 String get shortName => file.getName(); |
| 236 | 239 |
| 237 @override | 240 @override |
| 241 source_span.SourceFile get sourceFile => _sourceFile ??= | |
| 242 new source_span.SourceFile(file.readAsStringSync(), url: uri); | |
|
Brian Wilkerson
2016/11/14 23:34:41
I haven't thought this through completely, but thi
| |
| 243 | |
| 244 @override | |
| 238 UriKind get uriKind { | 245 UriKind get uriKind { |
| 239 String scheme = uri.scheme; | 246 String scheme = uri.scheme; |
| 240 return UriKind.fromScheme(scheme); | 247 return UriKind.fromScheme(scheme); |
| 241 } | 248 } |
| 242 | 249 |
| 243 @override | 250 @override |
| 244 bool operator ==(Object object) { | 251 bool operator ==(Object object) { |
| 245 if (object is FileBasedSource) { | 252 if (object is FileBasedSource) { |
| 246 return id == object.id; | 253 return id == object.id; |
| 247 } else if (object is Source) { | 254 } else if (object is Source) { |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 568 } | 575 } |
| 569 | 576 |
| 570 /** | 577 /** |
| 571 * Return `true` if the given URI is a `file` URI. | 578 * Return `true` if the given URI is a `file` URI. |
| 572 * | 579 * |
| 573 * @param uri the URI being tested | 580 * @param uri the URI being tested |
| 574 * @return `true` if the given URI is a `file` URI | 581 * @return `true` if the given URI is a `file` URI |
| 575 */ | 582 */ |
| 576 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; | 583 static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME; |
| 577 } | 584 } |
| OLD | NEW |