OLD | NEW |
---|---|
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/dart/ast/ast.dart'; | 5 import 'package:analyzer/dart/ast/ast.dart'; |
6 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | 6 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
7 import 'package:analyzer/dart/ast/token.dart'; | 7 import 'package:analyzer/dart/ast/token.dart'; |
8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
9 import 'package:analyzer/dart/element/type.dart'; | 9 import 'package:analyzer/dart/element/type.dart'; |
10 import 'package:analyzer/src/dart/element/element.dart'; | 10 import 'package:analyzer/src/dart/element/element.dart'; |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
738 var namedParameters = type.namedParameters | 738 var namedParameters = type.namedParameters |
739 .map((k) => new kernel.VariableDeclaration(k.name, type: k.type)) | 739 .map((k) => new kernel.VariableDeclaration(k.name, type: k.type)) |
740 .toList(growable: false); | 740 .toList(growable: false); |
741 | 741 |
742 return [positionalParameters, namedParameters]; | 742 return [positionalParameters, namedParameters]; |
743 } | 743 } |
744 | 744 |
745 @override | 745 @override |
746 InterfaceType getInterfaceType( | 746 InterfaceType getInterfaceType( |
747 ElementImpl context, kernel.Supertype kernelType) { | 747 ElementImpl context, kernel.Supertype kernelType) { |
748 if (kernelType.classNode.isEnum) { | |
749 return null; | |
Brian Wilkerson
2017/08/31 19:54:15
Does this mean that we won't be able to resynthesi
scheglov
2017/08/31 19:55:23
We can resynthesize enums.
We just should not allo
| |
750 } | |
748 return _getInterfaceType( | 751 return _getInterfaceType( |
749 context, kernelType.className.canonicalName, kernelType.typeArguments); | 752 context, kernelType.className.canonicalName, kernelType.typeArguments); |
750 } | 753 } |
751 | 754 |
752 @override | 755 @override |
756 List<InterfaceType> getInterfaceTypes( | |
757 ElementImpl context, List<kernel.Supertype> types) { | |
758 var interfaceTypes = <InterfaceType>[]; | |
759 for (kernel.Supertype kernelType in types) { | |
760 InterfaceType interfaceType = getInterfaceType(context, kernelType); | |
761 if (interfaceType != null) { | |
762 interfaceTypes.add(interfaceType); | |
763 } | |
764 } | |
765 return interfaceTypes; | |
766 } | |
767 | |
768 @override | |
753 ConstructorElementImpl getRedirectedConstructor( | 769 ConstructorElementImpl getRedirectedConstructor( |
754 kernel.Constructor kernelConstructor, kernel.Procedure kernelFactory) { | 770 kernel.Constructor kernelConstructor, kernel.Procedure kernelFactory) { |
755 if (kernelConstructor != null) { | 771 if (kernelConstructor != null) { |
756 for (var initializer in kernelConstructor.initializers) { | 772 for (var initializer in kernelConstructor.initializers) { |
757 if (initializer is kernel.RedirectingInitializer) { | 773 if (initializer is kernel.RedirectingInitializer) { |
758 return libraryContext.resynthesizer | 774 return libraryContext.resynthesizer |
759 ._getElement(initializer.targetReference.canonicalName) | 775 ._getElement(initializer.targetReference.canonicalName) |
760 as ConstructorElementImpl; | 776 as ConstructorElementImpl; |
761 } | 777 } |
762 } | 778 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
869 for (var typeParameter in ctx.typeParameters) { | 885 for (var typeParameter in ctx.typeParameters) { |
870 if (typeParameter.name == name) { | 886 if (typeParameter.name == name) { |
871 return typeParameter; | 887 return typeParameter; |
872 } | 888 } |
873 } | 889 } |
874 } | 890 } |
875 } | 891 } |
876 throw new StateError('Not found $kernelTypeParameter in $context'); | 892 throw new StateError('Not found $kernelTypeParameter in $context'); |
877 } | 893 } |
878 } | 894 } |
OLD | NEW |