OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 ddc.src.testing; | 5 library ddc.src.testing; |
6 | 6 |
7 import 'package:analyzer/src/generated/ast.dart'; | 7 import 'package:analyzer/src/generated/ast.dart'; |
8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
9 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; | 9 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; |
10 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 final UriKind uriKind; | 280 final UriKind uriKind; |
281 | 281 |
282 _TestSource(uri, contents) | 282 _TestSource(uri, contents) |
283 : uri = uri, | 283 : uri = uri, |
284 contents = new TimestampedData<String>(0, contents), | 284 contents = new TimestampedData<String>(0, contents), |
285 _file = new SourceFile(contents, url: uri), | 285 _file = new SourceFile(contents, url: uri), |
286 uriKind = uri.scheme == 'file' ? UriKind.FILE_URI : UriKind.PACKAGE_URI; | 286 uriKind = uri.scheme == 'file' ? UriKind.FILE_URI : UriKind.PACKAGE_URI; |
287 | 287 |
288 bool exists() => true; | 288 bool exists() => true; |
289 | 289 |
| 290 Source get source => this; |
| 291 |
290 String _encoding; | 292 String _encoding; |
291 String get encoding => _encoding != null ? _encoding : (_encoding = '$uri'); | 293 String get encoding => _encoding != null ? _encoding : (_encoding = '$uri'); |
292 | 294 |
293 String get fullName => uri.path; | 295 String get fullName => uri.path; |
294 | 296 |
295 int get modificationStamp => 0; | 297 int get modificationStamp => 0; |
296 String get shortName => path.basename(uri.path); | 298 String get shortName => path.basename(uri.path); |
297 | 299 |
298 operator ==(other) => other is _TestSource && uri == other.uri; | 300 operator ==(other) => other is _TestSource && uri == other.uri; |
299 int get hashCode => uri.hashCode; | 301 int get hashCode => uri.hashCode; |
300 bool get isInSystemLibrary => false; | 302 bool get isInSystemLibrary => false; |
301 | 303 |
302 Uri resolveRelativeUri(Uri relativeUri) => uri.resolveUri(relativeUri); | 304 Uri resolveRelativeUri(Uri relativeUri) => uri.resolveUri(relativeUri); |
303 | 305 |
304 SourceSpan spanFor(AstNode node) { | 306 SourceSpan spanFor(AstNode node) { |
305 final begin = node is AnnotatedNode | 307 final begin = node is AnnotatedNode |
306 ? node.firstTokenAfterCommentAndMetadata.offset | 308 ? node.firstTokenAfterCommentAndMetadata.offset |
307 : node.offset; | 309 : node.offset; |
308 return _file.span(begin, node.end); | 310 return _file.span(begin, node.end); |
309 } | 311 } |
310 | 312 |
311 String toString() => '[$runtimeType: $uri]'; | 313 String toString() => '[$runtimeType: $uri]'; |
312 } | 314 } |
OLD | NEW |