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 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 Source resolveRelative(Uri relativeUri) { | 111 Uri resolveRelative(Uri relativeUri) { |
| 112 // Assume that the type can be accessed via this URI, since these | 112 // Assume that the type can be accessed via this URI, since these |
| 113 // should only be parts for dart core files. | 113 // should only be parts for dart core files. |
| 114 return wrap(_proxy.resolveRelative(relativeUri), uri); | 114 return _proxy.uri.resolveUri(relativeUri); |
|
blois
2014/08/05 21:33:26
The DartSourceProxy wraps 'dart:' sources, and I'm
Brian Wilkerson
2014/08/05 21:44:21
That's a bug. It should be resolved to dart:core/a
| |
| 115 } | 115 } |
| 116 | 116 |
| 117 bool exists() => _proxy.exists(); | 117 bool exists() => _proxy.exists(); |
| 118 | 118 |
| 119 bool operator ==(Object other) => | 119 bool operator ==(Object other) => |
| 120 (other is DartSourceProxy && _proxy == other._proxy); | 120 (other is DartSourceProxy && _proxy == other._proxy); |
| 121 | 121 |
| 122 int get hashCode => _proxy.hashCode; | 122 int get hashCode => _proxy.hashCode; |
| 123 | 123 |
| 124 TimestampedData<String> get contents => _proxy.contents; | 124 TimestampedData<String> get contents => _proxy.contents; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 | 174 |
| 175 Source _getSource(Uri uri) { | 175 Source _getSource(Uri uri) { |
| 176 var src = _sources[uri]; | 176 var src = _sources[uri]; |
| 177 if (src == null) { | 177 if (src == null) { |
| 178 if (reportMissing) print('warning: missing mock for $uri.'); | 178 if (reportMissing) print('warning: missing mock for $uri.'); |
| 179 _sources[uri] = src = | 179 _sources[uri] = src = |
| 180 new _MockSdkSource(uri, 'library dart.${uri.path};'); | 180 new _MockSdkSource(uri, 'library dart.${uri.path};'); |
| 181 } | 181 } |
| 182 return src; | 182 return src; |
| 183 } | 183 } |
| 184 | |
| 185 @override | |
| 186 Source fromFileUri(Uri uri) { | |
| 187 throw new UnsupportedError('MockDartSdk.fromFileUri'); | |
| 188 } | |
| 184 } | 189 } |
| 185 | 190 |
| 186 class _MockSdkSource implements UriAnnotatedSource { | 191 class _MockSdkSource implements UriAnnotatedSource { |
| 187 /// Absolute URI which this source can be imported from. | 192 /// Absolute URI which this source can be imported from. |
| 188 final Uri uri; | 193 final Uri uri; |
| 189 final String _contents; | 194 final String _contents; |
| 190 | 195 |
| 191 _MockSdkSource(this.uri, this._contents); | 196 _MockSdkSource(this.uri, this._contents); |
| 192 | 197 |
| 193 bool exists() => true; | 198 bool exists() => true; |
| 194 | 199 |
| 195 int get hashCode => uri.hashCode; | 200 int get hashCode => uri.hashCode; |
| 196 | 201 |
| 197 final int modificationStamp = 1; | 202 final int modificationStamp = 1; |
| 198 | 203 |
| 199 TimestampedData<String> get contents => | 204 TimestampedData<String> get contents => |
| 200 new TimestampedData(modificationStamp, _contents); | 205 new TimestampedData(modificationStamp, _contents); |
| 201 | 206 |
| 202 String get encoding => "${uriKind.encoding}$uri"; | 207 String get encoding => "${uriKind.encoding}$uri"; |
| 203 | 208 |
| 204 String get fullName => shortName; | 209 String get fullName => shortName; |
| 205 | 210 |
| 206 String get shortName => uri.path; | 211 String get shortName => uri.path; |
| 207 | 212 |
| 208 UriKind get uriKind => UriKind.DART_URI; | 213 UriKind get uriKind => UriKind.DART_URI; |
| 209 | 214 |
| 210 bool get isInSystemLibrary => true; | 215 bool get isInSystemLibrary => true; |
| 211 | 216 |
| 212 Source resolveRelative(Uri relativeUri) => | 217 Uri resolveRelative(Uri relativeUri) => |
| 213 throw new UnsupportedError('not expecting relative urls in dart: mocks'); | 218 throw new UnsupportedError('not expecting relative urls in dart: mocks'); |
| 214 } | 219 } |
| OLD | NEW |