| 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 code_transformers.src.dart_sdk; | 5 library code_transformers.src.dart_sdk; |
| 6 | 6 |
| 7 import 'dart:convert' as convert; | 7 import 'dart:convert' as convert; |
| 8 import 'dart:io' show File, Platform, Process; | 8 import 'dart:io' show File, Platform, Process; |
| 9 import 'package:path/path.dart' as path; | 9 import 'package:path/path.dart' as path; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 final Source _proxy; | 101 final Source _proxy; |
| 102 | 102 |
| 103 DartSourceProxy(this._proxy, this.uri); | 103 DartSourceProxy(this._proxy, this.uri); |
| 104 | 104 |
| 105 /// Ensures that [source] is a DartSourceProxy. | 105 /// Ensures that [source] is a DartSourceProxy. |
| 106 static DartSourceProxy wrap(Source source, Uri uri) { | 106 static DartSourceProxy wrap(Source source, Uri uri) { |
| 107 if (source == null || source is DartSourceProxy) return source; | 107 if (source == null || source is DartSourceProxy) return source; |
| 108 return new DartSourceProxy(source, uri); | 108 return new DartSourceProxy(source, uri); |
| 109 } | 109 } |
| 110 | 110 |
| 111 // Note: to support both analyzer versions <0.22.0 and analyzer >=0.22.0, we |
| 112 // implement both `resolveRelative` and `resolveRelativeUri`. Only one of them |
| 113 // is available at a time in the analyzer package, so we use the `as dynamic` |
| 114 // in these methods to hide warnings for the code that is missing. These APIs |
| 115 // are invoked from the analyzer itself, so we don't expect them to cause |
| 116 // failures. |
| 111 Source resolveRelative(Uri relativeUri) { | 117 Source resolveRelative(Uri relativeUri) { |
| 112 // Assume that the type can be accessed via this URI, since these | 118 // Assume that the type can be accessed via this URI, since these |
| 113 // should only be parts for dart core files. | 119 // should only be parts for dart core files. |
| 114 return wrap(_proxy.resolveRelative(relativeUri), uri); | 120 return wrap((_proxy as dynamic).resolveRelative(relativeUri), uri); |
| 115 } | 121 } |
| 116 | 122 |
| 117 Uri resolveRelativeUri(Uri relativeUri) { | 123 Uri resolveRelativeUri(Uri relativeUri) { |
| 118 return _proxy.resolveRelativeUri(relativeUri); | 124 return (_proxy as dynamic).resolveRelativeUri(relativeUri); |
| 119 } | 125 } |
| 120 | 126 |
| 121 bool exists() => _proxy.exists(); | 127 bool exists() => _proxy.exists(); |
| 122 | 128 |
| 123 bool operator ==(Object other) => | 129 bool operator ==(Object other) => |
| 124 (other is DartSourceProxy && _proxy == other._proxy); | 130 (other is DartSourceProxy && _proxy == other._proxy); |
| 125 | 131 |
| 126 int get hashCode => _proxy.hashCode; | 132 int get hashCode => _proxy.hashCode; |
| 127 | 133 |
| 128 TimestampedData<String> get contents => _proxy.contents; | 134 TimestampedData<String> get contents => _proxy.contents; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 UriKind get uriKind => UriKind.DART_URI; | 223 UriKind get uriKind => UriKind.DART_URI; |
| 218 | 224 |
| 219 bool get isInSystemLibrary => true; | 225 bool get isInSystemLibrary => true; |
| 220 | 226 |
| 221 Source resolveRelative(Uri relativeUri) => | 227 Source resolveRelative(Uri relativeUri) => |
| 222 throw new UnsupportedError('not expecting relative urls in dart: mocks'); | 228 throw new UnsupportedError('not expecting relative urls in dart: mocks'); |
| 223 | 229 |
| 224 Uri resolveRelativeUri(Uri relativeUri) => | 230 Uri resolveRelativeUri(Uri relativeUri) => |
| 225 throw new UnsupportedError('not expecting relative urls in dart: mocks'); | 231 throw new UnsupportedError('not expecting relative urls in dart: mocks'); |
| 226 } | 232 } |
| OLD | NEW |