Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: pkg/code_transformers/lib/src/dart_sdk.dart

Issue 447603002: patch from issue 428303004 Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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) => _proxy.resolveRelative(relativeUri);
112 // Assume that the type can be accessed via this URI, since these
113 // should only be parts for dart core files.
114 return wrap(_proxy.resolveRelative(relativeUri), uri);
115 }
116 112
117 bool exists() => _proxy.exists(); 113 bool exists() => _proxy.exists();
118 114
119 bool operator ==(Object other) => 115 bool operator ==(Object other) =>
120 (other is DartSourceProxy && _proxy == other._proxy); 116 (other is DartSourceProxy && _proxy == other._proxy);
121 117
122 int get hashCode => _proxy.hashCode; 118 int get hashCode => _proxy.hashCode;
123 119
124 TimestampedData<String> get contents => _proxy.contents; 120 TimestampedData<String> get contents => _proxy.contents;
125 121
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 170
175 Source _getSource(Uri uri) { 171 Source _getSource(Uri uri) {
176 var src = _sources[uri]; 172 var src = _sources[uri];
177 if (src == null) { 173 if (src == null) {
178 if (reportMissing) print('warning: missing mock for $uri.'); 174 if (reportMissing) print('warning: missing mock for $uri.');
179 _sources[uri] = src = 175 _sources[uri] = src =
180 new _MockSdkSource(uri, 'library dart.${uri.path};'); 176 new _MockSdkSource(uri, 'library dart.${uri.path};');
181 } 177 }
182 return src; 178 return src;
183 } 179 }
180
181 @override
182 Source fromFileUri(Uri uri) {
183 throw new UnsupportedError('MockDartSdk.fromFileUri');
184 }
184 } 185 }
185 186
186 class _MockSdkSource implements UriAnnotatedSource { 187 class _MockSdkSource implements UriAnnotatedSource {
187 /// Absolute URI which this source can be imported from. 188 /// Absolute URI which this source can be imported from.
188 final Uri uri; 189 final Uri uri;
189 final String _contents; 190 final String _contents;
190 191
191 _MockSdkSource(this.uri, this._contents); 192 _MockSdkSource(this.uri, this._contents);
192 193
193 bool exists() => true; 194 bool exists() => true;
194 195
195 int get hashCode => uri.hashCode; 196 int get hashCode => uri.hashCode;
196 197
197 final int modificationStamp = 1; 198 final int modificationStamp = 1;
198 199
199 TimestampedData<String> get contents => 200 TimestampedData<String> get contents =>
200 new TimestampedData(modificationStamp, _contents); 201 new TimestampedData(modificationStamp, _contents);
201 202
202 String get encoding => "${uriKind.encoding}$uri"; 203 String get encoding => "${uriKind.encoding}$uri";
203 204
204 String get fullName => shortName; 205 String get fullName => shortName;
205 206
206 String get shortName => uri.path; 207 String get shortName => uri.path;
207 208
208 UriKind get uriKind => UriKind.DART_URI; 209 UriKind get uriKind => UriKind.DART_URI;
209 210
210 bool get isInSystemLibrary => true; 211 bool get isInSystemLibrary => true;
211 212
212 Source resolveRelative(Uri relativeUri) => 213 Uri resolveRelative(Uri relativeUri) =>
213 throw new UnsupportedError('not expecting relative urls in dart: mocks'); 214 throw new UnsupportedError('not expecting relative urls in dart: mocks');
214 } 215 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/source/package_map_resolver_test.dart ('k') | pkg/code_transformers/lib/src/resolver_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698