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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 parentName = parentName.parent; | 99 parentName = parentName.parent; |
100 } else if (parentName.name == '@fields') { | 100 } else if (parentName.name == '@fields') { |
101 isField = true; | 101 isField = true; |
102 parentName = parentName.parent; | 102 parentName = parentName.parent; |
103 } else if (parentName.name == '@constructors') { | 103 } else if (parentName.name == '@constructors') { |
104 isConstructor = true; | 104 isConstructor = true; |
105 parentName = parentName.parent; | 105 parentName = parentName.parent; |
106 } else if (parentName.name == '@methods') { | 106 } else if (parentName.name == '@methods') { |
107 isMethod = true; | 107 isMethod = true; |
108 parentName = parentName.parent; | 108 parentName = parentName.parent; |
| 109 } else if (parentName.name == '@typedefs') { |
| 110 parentName = parentName.parent; |
109 } | 111 } |
110 | 112 |
111 ElementImpl parentElement = _getElement(parentName); | 113 ElementImpl parentElement = _getElement(parentName); |
112 if (parentElement == null) return null; | 114 if (parentElement == null) return null; |
113 | 115 |
114 // Search in units of the library. | 116 // Search in units of the library. |
115 if (parentElement is LibraryElementImpl) { | 117 if (parentElement is LibraryElementImpl) { |
116 for (CompilationUnitElement unit in parentElement.units) { | 118 for (CompilationUnitElement unit in parentElement.units) { |
117 CompilationUnitElementImpl unitImpl = unit; | 119 CompilationUnitElementImpl unitImpl = unit; |
118 ElementImpl child = unitImpl.getChild(name.name); | 120 ElementImpl child = unitImpl.getChild(name.name); |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 return _getInterfaceType(context, kernelType.className.canonicalName, | 729 return _getInterfaceType(context, kernelType.className.canonicalName, |
728 kernelType.typeArguments); | 730 kernelType.typeArguments); |
729 } | 731 } |
730 | 732 |
731 if (kernelType is kernel.TypeParameterType) { | 733 if (kernelType is kernel.TypeParameterType) { |
732 kernel.TypeParameter kTypeParameter = kernelType.parameter; | 734 kernel.TypeParameter kTypeParameter = kernelType.parameter; |
733 return _getTypeParameter(context, kTypeParameter).type; | 735 return _getTypeParameter(context, kTypeParameter).type; |
734 } | 736 } |
735 | 737 |
736 if (kernelType is kernel.FunctionType) { | 738 if (kernelType is kernel.FunctionType) { |
| 739 if (kernelType.typedef != null) { |
| 740 FunctionTypeAliasElementImpl element = libraryContext.resynthesizer |
| 741 ._getElement(kernelType.typedef.canonicalName); |
| 742 return element.type; |
| 743 } |
| 744 |
737 var functionElement = new FunctionElementImpl.synthetic([], null); | 745 var functionElement = new FunctionElementImpl.synthetic([], null); |
738 functionElement.enclosingElement = context; | 746 functionElement.enclosingElement = context; |
739 | 747 |
740 functionElement.typeParameters = kernelType.typeParameters.map((k) { | 748 functionElement.typeParameters = kernelType.typeParameters.map((k) { |
741 return new TypeParameterElementImpl.forKernel(functionElement, k); | 749 return new TypeParameterElementImpl.forKernel(functionElement, k); |
742 }).toList(growable: false); | 750 }).toList(growable: false); |
743 | 751 |
744 var parameters = getFunctionTypeParameters(kernelType); | 752 var parameters = getFunctionTypeParameters(kernelType); |
745 functionElement.parameters = ParameterElementImpl.forKernelParameters( | 753 functionElement.parameters = ParameterElementImpl.forKernelParameters( |
746 functionElement, | 754 functionElement, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 for (var typeParameter in ctx.typeParameters) { | 815 for (var typeParameter in ctx.typeParameters) { |
808 if (typeParameter.name == name) { | 816 if (typeParameter.name == name) { |
809 return typeParameter; | 817 return typeParameter; |
810 } | 818 } |
811 } | 819 } |
812 } | 820 } |
813 } | 821 } |
814 throw new StateError('Not found $kernelTypeParameter in $context'); | 822 throw new StateError('Not found $kernelTypeParameter in $context'); |
815 } | 823 } |
816 } | 824 } |
OLD | NEW |