| 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 analyzer.test.src.context.mock_sdk; | 5 library analyzer.test.src.context.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/context/cache.dart'; | 9 import 'package:analyzer/src/context/cache.dart'; |
| 10 import 'package:analyzer/src/context/context.dart'; | 10 import 'package:analyzer/src/context/context.dart'; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 factory Completer.sync() => new _SyncCompleter<T>(); | 59 factory Completer.sync() => new _SyncCompleter<T>(); |
| 60 Future<T> get future; | 60 Future<T> get future; |
| 61 void complete([value]); | 61 void complete([value]); |
| 62 void completeError(Object error, [StackTrace stackTrace]); | 62 void completeError(Object error, [StackTrace stackTrace]); |
| 63 bool get isCompleted; | 63 bool get isCompleted; |
| 64 } | 64 } |
| 65 ''', | 65 ''', |
| 66 const <String, String>{ | 66 const <String, String>{ |
| 67 '$sdkRoot/lib/async/stream.dart': r''' | 67 '$sdkRoot/lib/async/stream.dart': r''' |
| 68 part of dart.async; | 68 part of dart.async; |
| 69 |
| 69 class Stream<T> { | 70 class Stream<T> { |
| 70 Future<T> get first; | 71 Future<T> get first; |
| 72 StreamSubscription<T> listen(void onData(T event), |
| 73 { Function onError, |
| 74 void onDone(), |
| 75 bool cancelOnError}); |
| 71 } | 76 } |
| 77 |
| 78 abstract class StreamSubscription<T> { |
| 79 Future cancel(); |
| 80 void onData(void handleData(T data)); |
| 81 void onError(Function handleError); |
| 82 void onDone(void handleDone()); |
| 83 void pause([Future resumeSignal]); |
| 84 void resume(); |
| 85 bool get isPaused; |
| 86 Future<E> asFuture<E>([E futureValue]); |
| 87 } |
| 88 |
| 72 abstract class StreamTransformer<S, T> {} | 89 abstract class StreamTransformer<S, T> {} |
| 73 ''' | 90 ''' |
| 74 }); | 91 }); |
| 75 | 92 |
| 76 const _MockSdkLibrary _LIB_COLLECTION = const _MockSdkLibrary( | 93 const _MockSdkLibrary _LIB_COLLECTION = const _MockSdkLibrary( |
| 77 'dart:collection', | 94 'dart:collection', |
| 78 '$sdkRoot/lib/collection/collection.dart', | 95 '$sdkRoot/lib/collection/collection.dart', |
| 79 ''' | 96 ''' |
| 80 library dart.collection; | 97 library dart.collection; |
| 81 | 98 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 99 '$sdkRoot/lib/core/core.dart', | 116 '$sdkRoot/lib/core/core.dart', |
| 100 ''' | 117 ''' |
| 101 library dart.core; | 118 library dart.core; |
| 102 | 119 |
| 103 import 'dart:async'; | 120 import 'dart:async'; |
| 104 | 121 |
| 105 class Object { | 122 class Object { |
| 106 bool operator ==(other) => identical(this, other); | 123 bool operator ==(other) => identical(this, other); |
| 107 String toString() => 'a string'; | 124 String toString() => 'a string'; |
| 108 int get hashCode => 0; | 125 int get hashCode => 0; |
| 126 Type get runtimeType => null; |
| 127 dynamic noSuchMethod(Invocation invocation) => null; |
| 109 } | 128 } |
| 110 | 129 |
| 111 class Function {} | 130 class Function {} |
| 112 class StackTrace {} | 131 class StackTrace {} |
| 113 class Symbol {} | 132 |
| 133 class Symbol { |
| 134 const factory Symbol(String name) { |
| 135 return null; |
| 136 } |
| 137 } |
| 138 |
| 114 class Type {} | 139 class Type {} |
| 115 | 140 |
| 116 abstract class Comparable<T> { | 141 abstract class Comparable<T> { |
| 117 int compareTo(T other); | 142 int compareTo(T other); |
| 118 } | 143 } |
| 119 | 144 |
| 120 abstract class Pattern {} | 145 abstract class Pattern {} |
| 121 abstract class String implements Comparable<String>, Pattern { | 146 abstract class String implements Comparable<String>, Pattern { |
| 122 external factory String.fromCharCodes(Iterable<int> charCodes, | 147 external factory String.fromCharCodes(Iterable<int> charCodes, |
| 123 [int start = 0, int end]); | 148 [int start = 0, int end]); |
| 124 String operator +(String other) => null; | 149 String operator +(String other) => null; |
| 125 bool get isEmpty => false; | 150 bool get isEmpty => false; |
| 126 bool get isNotEmpty => false; | 151 bool get isNotEmpty => false; |
| 127 int get length => 0; | 152 int get length => 0; |
| 128 String substring(int len) => null; | 153 String substring(int len) => null; |
| 154 String toLowerCase(); |
| 129 String toUpperCase(); | 155 String toUpperCase(); |
| 130 List<int> get codeUnits; | 156 List<int> get codeUnits; |
| 131 } | 157 } |
| 132 abstract class RegExp implements Pattern { | 158 abstract class RegExp implements Pattern { |
| 133 external factory RegExp(String source); | 159 external factory RegExp(String source); |
| 134 } | 160 } |
| 135 | 161 |
| 136 class bool extends Object {} | 162 class bool extends Object { |
| 163 external const factory bool.fromEnvironment(String name, |
| 164 {bool defaultValue: false}); |
| 165 } |
| 166 |
| 167 abstract class Invocation {} |
| 168 |
| 137 abstract class num implements Comparable<num> { | 169 abstract class num implements Comparable<num> { |
| 138 bool operator <(num other); | 170 bool operator <(num other); |
| 139 bool operator <=(num other); | 171 bool operator <=(num other); |
| 140 bool operator >(num other); | 172 bool operator >(num other); |
| 141 bool operator >=(num other); | 173 bool operator >=(num other); |
| 142 num operator +(num other); | 174 num operator +(num other); |
| 143 num operator -(num other); | 175 num operator -(num other); |
| 144 num operator *(num other); | 176 num operator *(num other); |
| 145 num operator /(num other); | 177 num operator /(num other); |
| 146 int operator ^(int other); | 178 int operator ^(int other); |
| 147 int operator &(int other); | |
| 148 int operator |(int other); | 179 int operator |(int other); |
| 149 int operator <<(int other); | 180 int operator <<(int other); |
| 150 int operator >>(int other); | 181 int operator >>(int other); |
| 151 int operator ~/(num other); | 182 int operator ~/(num other); |
| 152 num operator %(num other); | 183 num operator %(num other); |
| 153 int operator ~(); | 184 int operator ~(); |
| 185 num operator -(); |
| 154 int toInt(); | 186 int toInt(); |
| 155 double toDouble(); | 187 double toDouble(); |
| 156 num abs(); | 188 num abs(); |
| 157 int round(); | 189 int round(); |
| 158 } | 190 } |
| 159 abstract class int extends num { | 191 abstract class int extends num { |
| 192 external const factory int.fromEnvironment(String name, {int defaultValue}); |
| 193 |
| 194 bool get isNegative; |
| 160 bool get isEven => false; | 195 bool get isEven => false; |
| 196 |
| 197 int operator &(int other); |
| 198 int operator |(int other); |
| 199 int operator ^(int other); |
| 200 int operator ~(); |
| 201 int operator <<(int shiftAmount); |
| 202 int operator >>(int shiftAmount); |
| 203 |
| 161 int operator -(); | 204 int operator -(); |
| 205 |
| 162 external static int parse(String source, | 206 external static int parse(String source, |
| 163 { int radix, | 207 { int radix, |
| 164 int onError(String source) }); | 208 int onError(String source) }); |
| 165 } | 209 } |
| 166 | 210 |
| 167 abstract class double extends num { | 211 abstract class double extends num { |
| 168 static const double NAN = 0.0 / 0.0; | 212 static const double NAN = 0.0 / 0.0; |
| 169 static const double INFINITY = 1.0 / 0.0; | 213 static const double INFINITY = 1.0 / 0.0; |
| 170 static const double NEGATIVE_INFINITY = -INFINITY; | 214 static const double NEGATIVE_INFINITY = -INFINITY; |
| 171 static const double MIN_POSITIVE = 5e-324; | 215 static const double MIN_POSITIVE = 5e-324; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 187 int truncate(); | 231 int truncate(); |
| 188 double roundToDouble(); | 232 double roundToDouble(); |
| 189 double floorToDouble(); | 233 double floorToDouble(); |
| 190 double ceilToDouble(); | 234 double ceilToDouble(); |
| 191 double truncateToDouble(); | 235 double truncateToDouble(); |
| 192 external static double parse(String source, | 236 external static double parse(String source, |
| 193 [double onError(String source)]); | 237 [double onError(String source)]); |
| 194 } | 238 } |
| 195 | 239 |
| 196 class DateTime extends Object {} | 240 class DateTime extends Object {} |
| 197 class Null extends Object {} | 241 |
| 242 class Null extends Object { |
| 243 factory Null._uninstantiable() { |
| 244 throw new UnsupportedError('class Null cannot be instantiated'); |
| 245 } |
| 246 } |
| 198 | 247 |
| 199 class Deprecated extends Object { | 248 class Deprecated extends Object { |
| 200 final String expires; | 249 final String expires; |
| 201 const Deprecated(this.expires); | 250 const Deprecated(this.expires); |
| 202 } | 251 } |
| 203 const Object deprecated = const Deprecated("next release"); | 252 const Object deprecated = const Deprecated("next release"); |
| 204 | 253 |
| 205 class Iterator<E> { | 254 class Iterator<E> { |
| 206 bool moveNext(); | 255 bool moveNext(); |
| 207 E get current; | 256 E get current; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 226 List(); | 275 List(); |
| 227 void add(E value) {} | 276 void add(E value) {} |
| 228 void addAll(Iterable<E> iterable) {} | 277 void addAll(Iterable<E> iterable) {} |
| 229 E operator [](int index) => null; | 278 E operator [](int index) => null; |
| 230 void operator []=(int index, E value) {} | 279 void operator []=(int index, E value) {} |
| 231 Iterator<E> get iterator => null; | 280 Iterator<E> get iterator => null; |
| 232 void clear() {} | 281 void clear() {} |
| 233 | 282 |
| 234 bool get isEmpty => false; | 283 bool get isEmpty => false; |
| 235 E get first => null; | 284 E get first => null; |
| 285 E get last => null; |
| 236 | 286 |
| 237 Iterable/*<R>*/ map/*<R>*/(/*=R*/ f(E e)) => null; | 287 Iterable/*<R>*/ map/*<R>*/(/*=R*/ f(E e)) => null; |
| 238 | 288 |
| 239 /*=R*/ fold/*<R>*/(/*=R*/ initialValue, | 289 /*=R*/ fold/*<R>*/(/*=R*/ initialValue, |
| 240 /*=R*/ combine(/*=R*/ previousValue, E element)) => null; | 290 /*=R*/ combine(/*=R*/ previousValue, E element)) => null; |
| 241 | 291 |
| 242 } | 292 } |
| 243 | 293 |
| 244 class Map<K, V> extends Object { | 294 class Map<K, V> extends Object { |
| 245 Iterable<K> get keys => null; | |
| 246 V operator [](K key) => null; | 295 V operator [](K key) => null; |
| 247 void operator []=(K key, V value) {} | 296 void operator []=(K key, V value) {} |
| 297 Iterable<K> get keys => null; |
| 298 int get length; |
| 299 Iterable<V> get values; |
| 248 } | 300 } |
| 249 | 301 |
| 250 external bool identical(Object a, Object b); | 302 external bool identical(Object a, Object b); |
| 251 | 303 |
| 252 void print(Object object) {} | 304 void print(Object object) {} |
| 253 | 305 |
| 254 class _Proxy { const _Proxy(); } | 306 class _Proxy { const _Proxy(); } |
| 255 const Object proxy = const _Proxy(); | 307 const Object proxy = const _Proxy(); |
| 256 | 308 |
| 257 class _Override { const _Override(); } | 309 class _Override { const _Override(); } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 275 ''' | 327 ''' |
| 276 library dart.html; | 328 library dart.html; |
| 277 class HtmlElement {} | 329 class HtmlElement {} |
| 278 '''); | 330 '''); |
| 279 | 331 |
| 280 const _MockSdkLibrary _LIB_HTML_DARTIUM = const _MockSdkLibrary( | 332 const _MockSdkLibrary _LIB_HTML_DARTIUM = const _MockSdkLibrary( |
| 281 'dart:html', | 333 'dart:html', |
| 282 '$sdkRoot/lib/html/dartium/html_dartium.dart', | 334 '$sdkRoot/lib/html/dartium/html_dartium.dart', |
| 283 ''' | 335 ''' |
| 284 library dart.html; | 336 library dart.html; |
| 285 class HtmlElement {} | 337 |
| 338 abstract class HtmlElement {} |
| 339 |
| 340 abstract class CanvasElement extends HtmlElement { |
| 341 Object getContext(String contextId, [Map attributes]); |
| 342 CanvasRenderingContext2D get context2D; |
| 343 } |
| 344 |
| 345 abstract class class CanvasRenderingContext2D {} |
| 346 '''); |
| 347 |
| 348 const _MockSdkLibrary _LIB_INTERCEPTORS = const _MockSdkLibrary( |
| 349 'dart:_interceptors', |
| 350 '$sdkRoot/lib/_internal/js_runtime/lib/interceptors.dart', |
| 351 ''' |
| 352 library dart._interceptors; |
| 286 '''); | 353 '''); |
| 287 | 354 |
| 288 const _MockSdkLibrary _LIB_MATH = const _MockSdkLibrary( | 355 const _MockSdkLibrary _LIB_MATH = const _MockSdkLibrary( |
| 289 'dart:math', | 356 'dart:math', |
| 290 '$sdkRoot/lib/math/math.dart', | 357 '$sdkRoot/lib/math/math.dart', |
| 291 ''' | 358 ''' |
| 292 library dart.math; | 359 library dart.math; |
| 293 | 360 |
| 294 const double E = 2.718281828459045; | 361 const double E = 2.718281828459045; |
| 295 const double PI = 3.1415926535897932; | 362 const double PI = 3.1415926535897932; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 310 | 377 |
| 311 const List<SdkLibrary> _LIBRARIES = const [ | 378 const List<SdkLibrary> _LIBRARIES = const [ |
| 312 _LIB_CORE, | 379 _LIB_CORE, |
| 313 _LIB_ASYNC, | 380 _LIB_ASYNC, |
| 314 _LIB_COLLECTION, | 381 _LIB_COLLECTION, |
| 315 _LIB_CONVERT, | 382 _LIB_CONVERT, |
| 316 _LIB_FOREIGN_HELPER, | 383 _LIB_FOREIGN_HELPER, |
| 317 _LIB_MATH, | 384 _LIB_MATH, |
| 318 _LIB_HTML_DART2JS, | 385 _LIB_HTML_DART2JS, |
| 319 _LIB_HTML_DARTIUM, | 386 _LIB_HTML_DARTIUM, |
| 387 _LIB_INTERCEPTORS, |
| 320 ]; | 388 ]; |
| 321 | 389 |
| 322 class MockSdk implements DartSdk { | 390 class MockSdk implements DartSdk { |
| 323 static const Map<String, String> FULL_URI_MAP = const { | 391 static const Map<String, String> FULL_URI_MAP = const { |
| 324 "dart:core": "$sdkRoot/lib/core/core.dart", | 392 "dart:core": "$sdkRoot/lib/core/core.dart", |
| 325 "dart:html": "$sdkRoot/lib/html/dartium/html_dartium.dart", | 393 "dart:html": "$sdkRoot/lib/html/dartium/html_dartium.dart", |
| 326 "dart:async": "$sdkRoot/lib/async/async.dart", | 394 "dart:async": "$sdkRoot/lib/async/async.dart", |
| 327 "dart:async/stream.dart": "$sdkRoot/lib/async/stream.dart", | 395 "dart:async/stream.dart": "$sdkRoot/lib/async/stream.dart", |
| 328 "dart:collection": "$sdkRoot/lib/collection/collection.dart", | 396 "dart:collection": "$sdkRoot/lib/collection/collection.dart", |
| 329 "dart:convert": "$sdkRoot/lib/convert/convert.dart", | 397 "dart:convert": "$sdkRoot/lib/convert/convert.dart", |
| 330 "dart:_foreign_helper": "$sdkRoot/lib/_foreign_helper/_foreign_helper.dart", | 398 "dart:_foreign_helper": "$sdkRoot/lib/_foreign_helper/_foreign_helper.dart", |
| 399 "dart:_interceptors": |
| 400 "$sdkRoot/lib/_internal/js_runtime/lib/interceptors.dart", |
| 331 "dart:math": "$sdkRoot/lib/math/math.dart" | 401 "dart:math": "$sdkRoot/lib/math/math.dart" |
| 332 }; | 402 }; |
| 333 | 403 |
| 334 static const Map<String, String> NO_ASYNC_URI_MAP = const { | 404 static const Map<String, String> NO_ASYNC_URI_MAP = const { |
| 335 "dart:core": "$sdkRoot/lib/core/core.dart", | 405 "dart:core": "$sdkRoot/lib/core/core.dart", |
| 336 }; | 406 }; |
| 337 | 407 |
| 338 final resource.MemoryResourceProvider provider; | 408 final resource.MemoryResourceProvider provider; |
| 339 | 409 |
| 340 final Map<String, String> uriMap; | 410 final Map<String, String> uriMap; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 | 607 |
| 538 @override | 608 @override |
| 539 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { | 609 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { |
| 540 if (factory == null) { | 610 if (factory == null) { |
| 541 return super.createCacheFromSourceFactory(factory); | 611 return super.createCacheFromSourceFactory(factory); |
| 542 } | 612 } |
| 543 return new AnalysisCache( | 613 return new AnalysisCache( |
| 544 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); | 614 <CachePartition>[AnalysisEngine.instance.partitionManager.forSdk(sdk)]); |
| 545 } | 615 } |
| 546 } | 616 } |
| OLD | NEW |