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 library dev_compiler.src.closure.closure_codegen; | 5 library dev_compiler.src.closure.closure_codegen; |
6 | 6 |
7 import 'package:analyzer/analyzer.dart' show ParameterKind; | 7 import 'package:analyzer/analyzer.dart' show ParameterKind; |
8 import 'package:analyzer/src/generated/element.dart'; | 8 import 'package:analyzer/src/generated/element.dart'; |
9 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; | 9 import 'package:analyzer/src/generated/resolver.dart' show TypeProvider; |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 ClosureAnnotation closureAnnotationForTypeDef(FunctionTypeAliasElement e) => | 29 ClosureAnnotation closureAnnotationForTypeDef(FunctionTypeAliasElement e) => |
30 new ClosureAnnotation( | 30 new ClosureAnnotation( |
31 type: _closureTypeForDartType(e.type, forceTypeDefExpansion: true), | 31 type: _closureTypeForDartType(e.type, forceTypeDefExpansion: true), |
32 isTypedef: true); | 32 isTypedef: true); |
33 | 33 |
34 ClosureAnnotation closureAnnotationForDefaultConstructor(ClassElement e) => | 34 ClosureAnnotation closureAnnotationForDefaultConstructor(ClassElement e) => |
35 new ClosureAnnotation( | 35 new ClosureAnnotation( |
36 superType: _closureTypeForDartType(e.supertype), | 36 superType: _closureTypeForDartType(e.supertype), |
37 interfaces: e.interfaces.map(_closureTypeForDartType).toList()); | 37 interfaces: e.interfaces.map(_closureTypeForDartType).toList()); |
38 | 38 |
| 39 // TODO(ochafik): Handle destructured params when Closure supports it. |
39 ClosureAnnotation closureAnnotationFor( | 40 ClosureAnnotation closureAnnotationFor( |
40 ExecutableElement e, String namedArgsMapName) { | 41 ExecutableElement e, String namedArgsMapName) { |
41 var paramTypes = <String, ClosureType>{}; | 42 var paramTypes = <String, ClosureType>{}; |
42 var namedArgs = <String, ClosureType>{}; | 43 var namedArgs = <String, ClosureType>{}; |
43 for (var param in e.parameters) { | 44 for (var param in e.parameters) { |
44 var t = _closureTypeForDartType(param.type); | 45 var t = _closureTypeForDartType(param.type); |
45 switch (param.parameterKind) { | 46 switch (param.parameterKind) { |
46 case ParameterKind.NAMED: | 47 case ParameterKind.NAMED: |
47 namedArgs[param.name] = t.orUndefined(); | 48 namedArgs[param.name] = t.orUndefined(); |
48 break; | 49 break; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 if (type is InterfaceType) { | 135 if (type is InterfaceType) { |
135 return _closureTypeForClass(type.element, type); | 136 return _closureTypeForClass(type.element, type); |
136 } | 137 } |
137 return new ClosureType.unknown(); | 138 return new ClosureType.unknown(); |
138 } | 139 } |
139 | 140 |
140 /// TODO(ochafik): Use a package-and-file-uri-dependent naming, since librarie
s can collide. | 141 /// TODO(ochafik): Use a package-and-file-uri-dependent naming, since librarie
s can collide. |
141 String _getFullName(ClassElement type) => | 142 String _getFullName(ClassElement type) => |
142 type.library.name == '' ? type.name : '${type.library.name}.${type.name}'; | 143 type.library.name == '' ? type.name : '${type.library.name}.${type.name}'; |
143 } | 144 } |
OLD | NEW |