OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Holds a couple utility functions used at various places in the system. | 5 /// Holds a couple utility functions used at various places in the system. |
6 library dev_compiler.src.utils; | 6 library dev_compiler.src.utils; |
7 | 7 |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:path/path.dart' as path; | 10 import 'package:path/path.dart' as path; |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 bool inInvocationContext(SimpleIdentifier node) { | 375 bool inInvocationContext(SimpleIdentifier node) { |
376 var parent = node.parent; | 376 var parent = node.parent; |
377 return parent is MethodInvocation && parent.methodName == node; | 377 return parent is MethodInvocation && parent.methodName == node; |
378 } | 378 } |
379 | 379 |
380 // TODO(vsm): Move this onto the appropriate class. Ideally, we'd attach | 380 // TODO(vsm): Move this onto the appropriate class. Ideally, we'd attach |
381 // it to TypeProvider. | 381 // it to TypeProvider. |
382 | 382 |
383 final _objectMap = new Expando('providerToObjectMap'); | 383 final _objectMap = new Expando('providerToObjectMap'); |
384 Map<String, DartType> getObjectMemberMap(TypeProvider typeProvider) { | 384 Map<String, DartType> getObjectMemberMap(TypeProvider typeProvider) { |
385 Map<String, DartType> map = _objectMap[typeProvider]; | 385 var map = _objectMap[typeProvider] as Map<String, DartType>; |
Jennifer Messerly
2015/07/22 22:37:29
for some reason, this was a warning the old way. B
| |
386 if (map == null) { | 386 if (map == null) { |
387 map = <String, DartType>{}; | 387 map = <String, DartType>{}; |
388 _objectMap[typeProvider] = map; | 388 _objectMap[typeProvider] = map; |
389 var objectType = typeProvider.objectType; | 389 var objectType = typeProvider.objectType; |
390 var element = objectType.element; | 390 var element = objectType.element; |
391 // Only record methods (including getters) with no parameters. As parameter s are contravariant wrt | 391 // Only record methods (including getters) with no parameters. As parameter s are contravariant wrt |
392 // type, using Object's version may be too strict. | 392 // type, using Object's version may be too strict. |
393 // Add instance methods. | 393 // Add instance methods. |
394 element.methods.where((method) => !method.isStatic).forEach((method) { | 394 element.methods.where((method) => !method.isStatic).forEach((method) { |
395 map[method.name] = method.type; | 395 map[method.name] = method.type; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 } else { | 445 } else { |
446 // TODO(jmesserly): this is for backwards compat, but not sure it's very | 446 // TODO(jmesserly): this is for backwards compat, but not sure it's very |
447 // useful to log this. | 447 // useful to log this. |
448 return 'AnalyzerMessage'; | 448 return 'AnalyzerMessage'; |
449 } | 449 } |
450 } | 450 } |
451 | 451 |
452 bool isInlineJS(Element e) => e is FunctionElement && | 452 bool isInlineJS(Element e) => e is FunctionElement && |
453 e.library.source.uri.toString() == 'dart:_foreign_helper' && | 453 e.library.source.uri.toString() == 'dart:_foreign_helper' && |
454 e.name == 'JS'; | 454 e.name == 'JS'; |
OLD | NEW |