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

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

Issue 318983002: Use parseDirectives were possible. Also mark analyzer ready to be released. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 139
140 /// Dart SDK which contains a mock implementation of the SDK libraries. May be 140 /// Dart SDK which contains a mock implementation of the SDK libraries. May be
141 /// used to speed up resultion when most of the core libraries is not needed. 141 /// used to speed up resultion when most of the core libraries is not needed.
142 class MockDartSdk implements DartSdk { 142 class MockDartSdk implements DartSdk {
143 final Map<Uri, _MockSdkSource> _sources = {}; 143 final Map<Uri, _MockSdkSource> _sources = {};
144 final bool reportMissing; 144 final bool reportMissing;
145 final Map<String, SdkLibrary> _libs = {}; 145 final Map<String, SdkLibrary> _libs = {};
146 final String sdkVersion = '0'; 146 final String sdkVersion = '0';
147 List<String> get uris => _sources.keys.map((uri) => '$uri').toList(); 147 List<String> get uris => _sources.keys.map((uri) => '$uri').toList();
148 final AnalysisContext context = new _SdkAnalysisContext(); 148 final AnalysisContext context = new SdkAnalysisContext();
149 149
150 MockDartSdk(Map<String, String> sources, {this.reportMissing}) { 150 MockDartSdk(Map<String, String> sources, {this.reportMissing}) {
151 sources.forEach((uriString, contents) { 151 sources.forEach((uriString, contents) {
152 var uri = Uri.parse(uriString); 152 var uri = Uri.parse(uriString);
153 _sources[uri] = new _MockSdkSource(uri, contents); 153 _sources[uri] = new _MockSdkSource(uri, contents);
154 _libs[uriString] = new SdkLibraryImpl(uri.path) 154 _libs[uriString] = new SdkLibraryImpl(uri.path)
155 ..setDart2JsLibrary() 155 ..setDart2JsLibrary()
156 ..setVmLibrary(); 156 ..setVmLibrary();
157 }); 157 });
158 } 158 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 String get shortName => uri.path; 202 String get shortName => uri.path;
203 203
204 UriKind get uriKind => UriKind.DART_URI; 204 UriKind get uriKind => UriKind.DART_URI;
205 205
206 bool get isInSystemLibrary => true; 206 bool get isInSystemLibrary => true;
207 207
208 Source resolveRelative(Uri relativeUri) => 208 Source resolveRelative(Uri relativeUri) =>
209 throw new UnsupportedError('not expecting relative urls in dart: mocks'); 209 throw new UnsupportedError('not expecting relative urls in dart: mocks');
210 } 210 }
211
212 // TODO(sigmund): delete once we bump the dependency on analyzer. We copied
213 // this code from SdkAnalysisContext in 'analyzer/src/generated/engine.dart' to
214 // prevent bumping the dependency on analyzer. We should remove this as soon as
215 // we start depending on analyzer >= 0.15.5.
216 class _SdkAnalysisContext extends AnalysisContextImpl {
217 @override
218 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) {
219 if (factory == null) return super.createCacheFromSourceFactory(factory);
220 var sdk = factory.dartSdk;
221 if (sdk == null) throw "Missing a DartUriResolver in source factory";
222 return new AnalysisCache(
223 [AnalysisEngine.instance.partitionManager.forSdk(sdk)]);
224 }
225 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698