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

Side by Side Diff: pkg/analyzer_plugin/test/support/mock_sdk.dart

Issue 2975253002: Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt. (Closed)
Patch Set: Created 3 years, 5 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
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:analyzer/file_system/file_system.dart' as resource; 5 import 'package:analyzer/file_system/file_system.dart' as resource;
6 import 'package:analyzer/file_system/memory_file_system.dart' as resource; 6 import 'package:analyzer/file_system/memory_file_system.dart' as resource;
7 import 'package:analyzer/src/context/context.dart'; 7 import 'package:analyzer/src/context/context.dart';
8 import 'package:analyzer/src/generated/engine.dart'; 8 import 'package:analyzer/src/generated/engine.dart';
9 import 'package:analyzer/src/generated/sdk.dart'; 9 import 'package:analyzer/src/generated/sdk.dart';
10 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
11 import 'package:analyzer/src/summary/idl.dart' show PackageBundle; 11 import 'package:analyzer/src/summary/idl.dart' show PackageBundle;
12 import 'package:analyzer/src/summary/summary_file_builder.dart'; 12 import 'package:analyzer/src/summary/summary_file_builder.dart';
13 13
14 /** 14 /**
15 * A utility class that will create a Mock SDK on the virtual disk managed by a 15 * A utility class that will create a Mock SDK on the virtual disk managed by a
16 * memory resource provider. 16 * memory resource provider.
17 */ 17 */
18 class MockSdk implements DartSdk { 18 class MockSdk implements DartSdk {
19 static const MockSdkLibrary LIB_CORE = const MockSdkLibrary( 19 static const MockSdkLibrary LIB_CORE =
20 'dart:core', 20 const MockSdkLibrary('dart:core', '/lib/core/core.dart', '''
21 '/lib/core/core.dart',
22 '''
23 library dart.core; 21 library dart.core;
24 22
25 import 'dart:async'; 23 import 'dart:async';
26 import 'dart:_internal'; 24 import 'dart:_internal';
27 25
28 class Object { 26 class Object {
29 const Object() {} 27 const Object() {}
30 bool operator ==(other) => identical(this, other); 28 bool operator ==(other) => identical(this, other);
31 String toString() => 'a string'; 29 String toString() => 'a string';
32 int get hashCode => 0; 30 int get hashCode => 0;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 class Uri { 165 class Uri {
168 static List<int> parseIPv6Address(String host, [int start = 0, int end]) { 166 static List<int> parseIPv6Address(String host, [int start = 0, int end]) {
169 int parseHex(int start, int end) { 167 int parseHex(int start, int end) {
170 return 0; 168 return 0;
171 } 169 }
172 return null; 170 return null;
173 } 171 }
174 } 172 }
175 '''); 173 ''');
176 174
177 static const MockSdkLibrary LIB_ASYNC = const MockSdkLibrary( 175 static const MockSdkLibrary LIB_ASYNC =
178 'dart:async', 176 const MockSdkLibrary('dart:async', '/lib/async/async.dart', '''
179 '/lib/async/async.dart',
180 '''
181 library dart.async; 177 library dart.async;
182 178
183 import 'dart:math'; 179 import 'dart:math';
184 180
185 class Future<T> { 181 class Future<T> {
186 factory Future(computation()) => null; 182 factory Future(computation()) => null;
187 factory Future.delayed(Duration duration, [T computation()]) => null; 183 factory Future.delayed(Duration duration, [T computation()]) => null;
188 factory Future.value([value]) => null; 184 factory Future.value([value]) => null;
189 static Future wait(List<Future> futures) => null; 185 static Future wait(List<Future> futures) => null;
190 } 186 }
191 187
192 class FutureOr<T> {} 188 class FutureOr<T> {}
193 189
194 class Stream<T> {} 190 class Stream<T> {}
195 abstract class StreamTransformer<S, T> {} 191 abstract class StreamTransformer<S, T> {}
196 '''); 192 ''');
197 193
198 static const MockSdkLibrary LIB_COLLECTION = const MockSdkLibrary( 194 static const MockSdkLibrary LIB_COLLECTION = const MockSdkLibrary(
199 'dart:collection', 195 'dart:collection', '/lib/collection/collection.dart', '''
200 '/lib/collection/collection.dart',
201 '''
202 library dart.collection; 196 library dart.collection;
203 197
204 abstract class HashMap<K, V> implements Map<K, V> {} 198 abstract class HashMap<K, V> implements Map<K, V> {}
205 abstract class LinkedHashMap<K, V> implements Map<K, V> {} 199 abstract class LinkedHashMap<K, V> implements Map<K, V> {}
206 '''); 200 ''');
207 201
208 static const MockSdkLibrary LIB_CONVERT = const MockSdkLibrary( 202 static const MockSdkLibrary LIB_CONVERT =
209 'dart:convert', 203 const MockSdkLibrary('dart:convert', '/lib/convert/convert.dart', '''
210 '/lib/convert/convert.dart',
211 '''
212 library dart.convert; 204 library dart.convert;
213 205
214 import 'dart:async'; 206 import 'dart:async';
215 207
216 abstract class Converter<S, T> implements StreamTransformer {} 208 abstract class Converter<S, T> implements StreamTransformer {}
217 class JsonDecoder extends Converter<String, Object> {} 209 class JsonDecoder extends Converter<String, Object> {}
218 '''); 210 ''');
219 211
220 static const MockSdkLibrary LIB_MATH = const MockSdkLibrary( 212 static const MockSdkLibrary LIB_MATH =
221 'dart:math', 213 const MockSdkLibrary('dart:math', '/lib/math/math.dart', '''
222 '/lib/math/math.dart',
223 '''
224 library dart.math; 214 library dart.math;
225 const double E = 2.718281828459045; 215 const double E = 2.718281828459045;
226 const double PI = 3.1415926535897932; 216 const double PI = 3.1415926535897932;
227 const double LN10 = 2.302585092994046; 217 const double LN10 = 2.302585092994046;
228 T min<T extends num>(T a, T b) => null; 218 T min<T extends num>(T a, T b) => null;
229 T max<T extends num>(T a, T b) => null; 219 T max<T extends num>(T a, T b) => null;
230 external double cos(num radians); 220 external double cos(num radians);
231 external num pow(num x, num exponent); 221 external num pow(num x, num exponent);
232 external double sin(num radians); 222 external double sin(num radians);
233 external double sqrt(num x); 223 external double sqrt(num x);
234 class Random { 224 class Random {
235 bool nextBool() => true; 225 bool nextBool() => true;
236 double nextDouble() => 2.0; 226 double nextDouble() => 2.0;
237 int nextInt() => 1; 227 int nextInt() => 1;
238 } 228 }
239 '''); 229 ''');
240 230
241 static const MockSdkLibrary LIB_HTML = const MockSdkLibrary( 231 static const MockSdkLibrary LIB_HTML = const MockSdkLibrary(
242 'dart:html', 232 'dart:html', '/lib/html/dartium/html_dartium.dart', '''
243 '/lib/html/dartium/html_dartium.dart',
244 '''
245 library dart.html; 233 library dart.html;
246 class HtmlElement {} 234 class HtmlElement {}
247 '''); 235 ''');
248 236
249 static const MockSdkLibrary LIB_INTERNAL = const MockSdkLibrary( 237 static const MockSdkLibrary LIB_INTERNAL =
250 'dart:_internal', 238 const MockSdkLibrary('dart:_internal', '/lib/internal/internal.dart', '''
251 '/lib/internal/internal.dart',
252 '''
253 library dart._internal; 239 library dart._internal;
254 external void printToConsole(String line); 240 external void printToConsole(String line);
255 '''); 241 ''');
256 242
257 static const List<SdkLibrary> LIBRARIES = const [ 243 static const List<SdkLibrary> LIBRARIES = const [
258 LIB_CORE, 244 LIB_CORE,
259 LIB_ASYNC, 245 LIB_ASYNC,
260 LIB_COLLECTION, 246 LIB_COLLECTION,
261 LIB_CONVERT, 247 LIB_CONVERT,
262 LIB_MATH, 248 LIB_MATH,
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 bool get isInternal => shortName.startsWith('dart:_'); 440 bool get isInternal => shortName.startsWith('dart:_');
455 441
456 @override 442 @override
457 bool get isShared => throw unimplemented; 443 bool get isShared => throw unimplemented;
458 444
459 @override 445 @override
460 bool get isVmLibrary => throw unimplemented; 446 bool get isVmLibrary => throw unimplemented;
461 447
462 UnimplementedError get unimplemented => new UnimplementedError(); 448 UnimplementedError get unimplemented => new UnimplementedError();
463 } 449 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698