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

Side by Side Diff: pkg/analyzer2dart/test/mock_sdk.dart

Issue 561373002: Issue 19682. New analyzer snapshot that fixes an inline refactoring problem. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changes for mock_sdk Created 6 years, 3 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
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 testing.mock_sdk; 5 library testing.mock_sdk;
6 6
7 import 'package:analyzer/file_system/file_system.dart' as resource; 7 import 'package:analyzer/file_system/file_system.dart' as resource;
8 import 'package:analyzer/file_system/memory_file_system.dart' as resource; 8 import 'package:analyzer/file_system/memory_file_system.dart' as resource;
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/sdk.dart'; 10 import 'package:analyzer/src/generated/sdk.dart';
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 static const List<SdkLibrary> LIBRARIES = const [ 101 static const List<SdkLibrary> LIBRARIES = const [
102 LIB_CORE, 102 LIB_CORE,
103 LIB_ASYNC, 103 LIB_ASYNC,
104 LIB_MATH, 104 LIB_MATH,
105 LIB_HTML,]; 105 LIB_HTML,];
106 106
107 final resource.MemoryResourceProvider provider = 107 final resource.MemoryResourceProvider provider =
108 new resource.MemoryResourceProvider(); 108 new resource.MemoryResourceProvider();
109 109
110 /**
111 * The [AnalysisContext] which is used for all of the sources.
112 */
113 InternalAnalysisContext _analysisContext;
114
110 MockSdk() { 115 MockSdk() {
111 LIBRARIES.forEach((_MockSdkLibrary library) { 116 LIBRARIES.forEach((_MockSdkLibrary library) {
112 provider.newFile(library.path, library.content); 117 provider.newFile(library.path, library.content);
113 }); 118 });
114 } 119 }
115 120
116 @override 121 @override
117 AnalysisContext get context => throw unimplemented; 122 AnalysisContext get context {
123 if (_analysisContext == null) {
124 _analysisContext = new SdkAnalysisContext();
125 SourceFactory factory = new SourceFactory([new DartUriResolver(this)]);
126 _analysisContext.sourceFactory = factory;
127 ChangeSet changeSet = new ChangeSet();
128 for (String uri in uris) {
129 Source source = factory.forUri(uri);
130 changeSet.addedSource(source);
131 }
132 _analysisContext.applyChanges(changeSet);
133 }
134 return _analysisContext;
135 }
118 136
119 @override 137 @override
120 List<SdkLibrary> get sdkLibraries => LIBRARIES; 138 List<SdkLibrary> get sdkLibraries => LIBRARIES;
121 139
122 @override 140 @override
123 String get sdkVersion => throw unimplemented; 141 String get sdkVersion => throw unimplemented;
124 142
125 UnimplementedError get unimplemented => new UnimplementedError(); 143 UnimplementedError get unimplemented => new UnimplementedError();
126 144
127 @override 145 @override
128 List<String> get uris => throw unimplemented; 146 List<String> get uris {
147 List<String> uris = <String>[];
148 for (SdkLibrary library in LIBRARIES) {
149 uris.add('dart:' + library.shortName);
150 }
151 return uris;
152 }
129 153
130 @override 154 @override
131 Source fromFileUri(Uri uri) { 155 Source fromFileUri(Uri uri) {
132 String filePath = uri.path; 156 String filePath = uri.path;
133 String libPath = '/lib'; 157 String libPath = '/lib';
134 if (!filePath.startsWith("$libPath/")) { 158 if (!filePath.startsWith("$libPath/")) {
135 return null; 159 return null;
136 } 160 }
137 for (SdkLibrary library in LIBRARIES) { 161 for (SdkLibrary library in LIBRARIES) {
138 String libraryPath = library.path; 162 String libraryPath = library.path;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 bool get isInternal => throw unimplemented; 239 bool get isInternal => throw unimplemented;
216 240
217 @override 241 @override
218 bool get isShared => throw unimplemented; 242 bool get isShared => throw unimplemented;
219 243
220 @override 244 @override
221 bool get isVmLibrary => throw unimplemented; 245 bool get isVmLibrary => throw unimplemented;
222 246
223 UnimplementedError get unimplemented => new UnimplementedError(); 247 UnimplementedError get unimplemented => new UnimplementedError();
224 } 248 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/resolver_test.dart ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698