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.src.dart.element.element; | 5 library analyzer.src.dart.element.element; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:math' show min; | 8 import 'dart:math' show min; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 } | 843 } |
844 return true; | 844 return true; |
845 } | 845 } |
846 | 846 |
847 @override | 847 @override |
848 List<kernel.TypeParameter> get kernelTypeParams => _kernel?.typeParameters; | 848 List<kernel.TypeParameter> get kernelTypeParams => _kernel?.typeParameters; |
849 | 849 |
850 @override | 850 @override |
851 List<ElementAnnotation> get metadata { | 851 List<ElementAnnotation> get metadata { |
852 if (_kernel != null) { | 852 if (_kernel != null) { |
853 _metadata ??= enclosingUnit._kernelContext | 853 _metadata ??= |
854 .buildAnnotations(enclosingUnit, _kernel.annotations); | 854 enclosingUnit._kernelContext.buildAnnotations(_kernel.annotations); |
855 } | 855 } |
856 if (_unlinkedClass != null) { | 856 if (_unlinkedClass != null) { |
857 return _metadata ??= | 857 return _metadata ??= |
858 _buildAnnotations(enclosingUnit, _unlinkedClass.annotations); | 858 _buildAnnotations(enclosingUnit, _unlinkedClass.annotations); |
859 } | 859 } |
860 return super.metadata; | 860 return super.metadata; |
861 } | 861 } |
862 | 862 |
863 @override | 863 @override |
864 List<MethodElement> get methods { | 864 List<MethodElement> get methods { |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1447 * The unlinked representation of the unit in the summary. | 1447 * The unlinked representation of the unit in the summary. |
1448 */ | 1448 */ |
1449 final UnlinkedUnit _unlinkedUnit; | 1449 final UnlinkedUnit _unlinkedUnit; |
1450 | 1450 |
1451 /** | 1451 /** |
1452 * The unlinked representation of the part in the summary. | 1452 * The unlinked representation of the part in the summary. |
1453 */ | 1453 */ |
1454 final UnlinkedPart _unlinkedPart; | 1454 final UnlinkedPart _unlinkedPart; |
1455 | 1455 |
1456 /** | 1456 /** |
1457 * The kernel context in which the library is resynthesized. | 1457 * The kernel context in which the unit is resynthesized. |
1458 */ | 1458 */ |
1459 final KernelLibraryResynthesizerContext _kernelContext; | 1459 final KernelUnitResynthesizerContext _kernelContext; |
1460 | 1460 |
1461 /** | 1461 /** |
1462 * The source that corresponds to this compilation unit. | 1462 * The source that corresponds to this compilation unit. |
1463 */ | 1463 */ |
1464 @override | 1464 @override |
1465 Source source; | 1465 Source source; |
1466 | 1466 |
1467 @override | 1467 @override |
1468 LineInfo lineInfo; | 1468 LineInfo lineInfo; |
1469 | 1469 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 super.forSerialized(null) { | 1572 super.forSerialized(null) { |
1573 _enclosingElement = enclosingLibrary; | 1573 _enclosingElement = enclosingLibrary; |
1574 _name = name; | 1574 _name = name; |
1575 _nameOffset = -1; | 1575 _nameOffset = -1; |
1576 } | 1576 } |
1577 | 1577 |
1578 @override | 1578 @override |
1579 List<PropertyAccessorElement> get accessors { | 1579 List<PropertyAccessorElement> get accessors { |
1580 if (_accessors == null) { | 1580 if (_accessors == null) { |
1581 if (_kernelContext != null) { | 1581 if (_kernelContext != null) { |
1582 _explicitTopLevelAccessors ??= | 1582 _explicitTopLevelAccessors ??= _kernelContext.buildTopLevelAccessors(); |
1583 _kernelContext.buildTopLevelAccessors(this); | 1583 _explicitTopLevelVariables ??= _kernelContext.buildTopLevelVariables(); |
1584 _explicitTopLevelVariables ??= | |
1585 _kernelContext.buildTopLevelVariables(this); | |
1586 } | 1584 } |
1587 if (_unlinkedUnit != null) { | 1585 if (_unlinkedUnit != null) { |
1588 _explicitTopLevelAccessors ??= | 1586 _explicitTopLevelAccessors ??= |
1589 resynthesizerContext.buildTopLevelAccessors(); | 1587 resynthesizerContext.buildTopLevelAccessors(); |
1590 _explicitTopLevelVariables ??= | 1588 _explicitTopLevelVariables ??= |
1591 resynthesizerContext.buildTopLevelVariables(); | 1589 resynthesizerContext.buildTopLevelVariables(); |
1592 } | 1590 } |
1593 if (_explicitTopLevelAccessors != null) { | 1591 if (_explicitTopLevelAccessors != null) { |
1594 _accessors = <PropertyAccessorElementImpl>[] | 1592 _accessors = <PropertyAccessorElementImpl>[] |
1595 ..addAll(_explicitTopLevelAccessors.accessors) | 1593 ..addAll(_explicitTopLevelAccessors.accessors) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1631 super.enclosingElement as LibraryElement; | 1629 super.enclosingElement as LibraryElement; |
1632 | 1630 |
1633 @override | 1631 @override |
1634 CompilationUnitElementImpl get enclosingUnit { | 1632 CompilationUnitElementImpl get enclosingUnit { |
1635 return this; | 1633 return this; |
1636 } | 1634 } |
1637 | 1635 |
1638 @override | 1636 @override |
1639 List<ClassElement> get enums { | 1637 List<ClassElement> get enums { |
1640 if (_kernelContext != null) { | 1638 if (_kernelContext != null) { |
1641 _enums ??= _kernelContext.library.classes | 1639 _enums ??= _kernelContext.kernelUnit.classes |
1642 .where((k) => k.isEnum) | 1640 .where((k) => k.isEnum) |
1643 .map((k) => new EnumElementImpl.forKernel(this, k)) | 1641 .map((k) => new EnumElementImpl.forKernel(this, k)) |
1644 .toList(growable: false); | 1642 .toList(growable: false); |
1645 } | 1643 } |
1646 if (_unlinkedUnit != null) { | 1644 if (_unlinkedUnit != null) { |
1647 _enums ??= _unlinkedUnit.enums | 1645 _enums ??= _unlinkedUnit.enums |
1648 .map((e) => new EnumElementImpl.forSerialized(e, this)) | 1646 .map((e) => new EnumElementImpl.forSerialized(e, this)) |
1649 .toList(growable: false); | 1647 .toList(growable: false); |
1650 } | 1648 } |
1651 return _enums ?? const <ClassElement>[]; | 1649 return _enums ?? const <ClassElement>[]; |
1652 } | 1650 } |
1653 | 1651 |
1654 /** | 1652 /** |
1655 * Set the enums contained in this compilation unit to the given [enums]. | 1653 * Set the enums contained in this compilation unit to the given [enums]. |
1656 */ | 1654 */ |
1657 void set enums(List<ClassElement> enums) { | 1655 void set enums(List<ClassElement> enums) { |
1658 _assertNotResynthesized(_unlinkedUnit); | 1656 _assertNotResynthesized(_unlinkedUnit); |
1659 for (ClassElement enumDeclaration in enums) { | 1657 for (ClassElement enumDeclaration in enums) { |
1660 (enumDeclaration as EnumElementImpl).enclosingElement = this; | 1658 (enumDeclaration as EnumElementImpl).enclosingElement = this; |
1661 } | 1659 } |
1662 this._enums = enums; | 1660 this._enums = enums; |
1663 } | 1661 } |
1664 | 1662 |
1665 @override | 1663 @override |
1666 List<FunctionElement> get functions { | 1664 List<FunctionElement> get functions { |
1667 if (_kernelContext != null) { | 1665 if (_kernelContext != null) { |
1668 _functions ??= _kernelContext.library.procedures | 1666 _functions ??= _kernelContext.kernelUnit.procedures |
1669 .where((k) => k.kind == kernel.ProcedureKind.Method) | 1667 .where((k) => k.kind == kernel.ProcedureKind.Method) |
1670 .map((k) => new FunctionElementImpl.forKernel(this, k)) | 1668 .map((k) => new FunctionElementImpl.forKernel(this, k)) |
1671 .toList(growable: false); | 1669 .toList(growable: false); |
1672 } | 1670 } |
1673 if (_unlinkedUnit != null) { | 1671 if (_unlinkedUnit != null) { |
1674 _functions ??= _unlinkedUnit.executables | 1672 _functions ??= _unlinkedUnit.executables |
1675 .where((e) => e.kind == UnlinkedExecutableKind.functionOrMethod) | 1673 .where((e) => e.kind == UnlinkedExecutableKind.functionOrMethod) |
1676 .map((e) => new FunctionElementImpl.forSerialized(e, this)) | 1674 .map((e) => new FunctionElementImpl.forSerialized(e, this)) |
1677 .toList(growable: false); | 1675 .toList(growable: false); |
1678 } | 1676 } |
1679 return _functions ?? const <FunctionElement>[]; | 1677 return _functions ?? const <FunctionElement>[]; |
1680 } | 1678 } |
1681 | 1679 |
1682 /** | 1680 /** |
1683 * Set the top-level functions contained in this compilation unit to the given | 1681 * Set the top-level functions contained in this compilation unit to the given |
1684 * [functions]. | 1682 * [functions]. |
1685 */ | 1683 */ |
1686 void set functions(List<FunctionElement> functions) { | 1684 void set functions(List<FunctionElement> functions) { |
1687 for (FunctionElement function in functions) { | 1685 for (FunctionElement function in functions) { |
1688 (function as FunctionElementImpl).enclosingElement = this; | 1686 (function as FunctionElementImpl).enclosingElement = this; |
1689 } | 1687 } |
1690 this._functions = functions; | 1688 this._functions = functions; |
1691 } | 1689 } |
1692 | 1690 |
1693 @override | 1691 @override |
1694 List<FunctionTypeAliasElement> get functionTypeAliases { | 1692 List<FunctionTypeAliasElement> get functionTypeAliases { |
1695 if (_kernelContext != null) { | 1693 if (_kernelContext != null) { |
1696 _typeAliases ??= _kernelContext.library.typedefs | 1694 _typeAliases ??= _kernelContext.kernelUnit.typedefs |
1697 .map((k) => new FunctionTypeAliasElementImpl.forKernel(this, k)) | 1695 .map((k) => new FunctionTypeAliasElementImpl.forKernel(this, k)) |
1698 .toList(growable: false); | 1696 .toList(growable: false); |
1699 } | 1697 } |
1700 if (_unlinkedUnit != null) { | 1698 if (_unlinkedUnit != null) { |
1701 _typeAliases ??= _unlinkedUnit.typedefs.map((t) { | 1699 _typeAliases ??= _unlinkedUnit.typedefs.map((t) { |
1702 if (t.style == TypedefStyle.functionType) { | 1700 if (t.style == TypedefStyle.functionType) { |
1703 return new FunctionTypeAliasElementImpl.forSerialized(t, this); | 1701 return new FunctionTypeAliasElementImpl.forSerialized(t, this); |
1704 } else if (t.style == TypedefStyle.genericFunctionType) { | 1702 } else if (t.style == TypedefStyle.genericFunctionType) { |
1705 return new GenericTypeAliasElementImpl.forSerialized(t, this); | 1703 return new GenericTypeAliasElementImpl.forSerialized(t, this); |
1706 } | 1704 } |
(...skipping 29 matching lines...) Expand all Loading... |
1736 library.definingCompilationUnit as CompilationUnitElementImpl, | 1734 library.definingCompilationUnit as CompilationUnitElementImpl, |
1737 _unlinkedPart.annotations); | 1735 _unlinkedPart.annotations); |
1738 } | 1736 } |
1739 return super.metadata; | 1737 return super.metadata; |
1740 } | 1738 } |
1741 | 1739 |
1742 @override | 1740 @override |
1743 List<TopLevelVariableElement> get topLevelVariables { | 1741 List<TopLevelVariableElement> get topLevelVariables { |
1744 if (_variables == null) { | 1742 if (_variables == null) { |
1745 if (_kernelContext != null) { | 1743 if (_kernelContext != null) { |
1746 _explicitTopLevelAccessors ??= | 1744 _explicitTopLevelAccessors ??= _kernelContext.buildTopLevelAccessors(); |
1747 _kernelContext.buildTopLevelAccessors(this); | 1745 _explicitTopLevelVariables ??= _kernelContext.buildTopLevelVariables(); |
1748 _explicitTopLevelVariables ??= | |
1749 _kernelContext.buildTopLevelVariables(this); | |
1750 } | 1746 } |
1751 if (_unlinkedUnit != null) { | 1747 if (_unlinkedUnit != null) { |
1752 _explicitTopLevelAccessors ??= | 1748 _explicitTopLevelAccessors ??= |
1753 resynthesizerContext.buildTopLevelAccessors(); | 1749 resynthesizerContext.buildTopLevelAccessors(); |
1754 _explicitTopLevelVariables ??= | 1750 _explicitTopLevelVariables ??= |
1755 resynthesizerContext.buildTopLevelVariables(); | 1751 resynthesizerContext.buildTopLevelVariables(); |
1756 } | 1752 } |
1757 if (_explicitTopLevelVariables != null) { | 1753 if (_explicitTopLevelVariables != null) { |
1758 var variables = <TopLevelVariableElement>[] | 1754 var variables = <TopLevelVariableElement>[] |
1759 ..addAll(_explicitTopLevelVariables.variables) | 1755 ..addAll(_explicitTopLevelVariables.variables) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1799 } | 1795 } |
1800 this._typeAliases = typeAliases; | 1796 this._typeAliases = typeAliases; |
1801 } | 1797 } |
1802 | 1798 |
1803 @override | 1799 @override |
1804 TypeParameterizedElementMixin get typeParameterContext => null; | 1800 TypeParameterizedElementMixin get typeParameterContext => null; |
1805 | 1801 |
1806 @override | 1802 @override |
1807 List<ClassElement> get types { | 1803 List<ClassElement> get types { |
1808 if (_kernelContext != null) { | 1804 if (_kernelContext != null) { |
1809 _types ??= _kernelContext.library.classes | 1805 _types ??= _kernelContext.kernelUnit.classes |
1810 .where((k) => !k.isEnum && !k.isSyntheticMixinImplementation) | 1806 .where((k) => !k.isEnum && !k.isSyntheticMixinImplementation) |
1811 .map((k) => new ClassElementImpl.forKernel(this, k)) | 1807 .map((k) => new ClassElementImpl.forKernel(this, k)) |
1812 .toList(growable: false); | 1808 .toList(growable: false); |
1813 } | 1809 } |
1814 if (_unlinkedUnit != null) { | 1810 if (_unlinkedUnit != null) { |
1815 _types ??= _unlinkedUnit.classes | 1811 _types ??= _unlinkedUnit.classes |
1816 .map((c) => new ClassElementImpl.forSerialized(c, this)) | 1812 .map((c) => new ClassElementImpl.forSerialized(c, this)) |
1817 .toList(growable: false); | 1813 .toList(growable: false); |
1818 } | 1814 } |
1819 return _types ?? const <ClassElement>[]; | 1815 return _types ?? const <ClassElement>[]; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 } | 1928 } |
1933 } | 1929 } |
1934 return null; | 1930 return null; |
1935 } | 1931 } |
1936 | 1932 |
1937 /** | 1933 /** |
1938 * Replace the given [from] top-level variable with [to] in this compilation u
nit. | 1934 * Replace the given [from] top-level variable with [to] in this compilation u
nit. |
1939 */ | 1935 */ |
1940 void replaceTopLevelVariable( | 1936 void replaceTopLevelVariable( |
1941 TopLevelVariableElement from, TopLevelVariableElement to) { | 1937 TopLevelVariableElement from, TopLevelVariableElement to) { |
1942 if (_unlinkedUnit != null) { | 1938 if (_kernelContext != null || _unlinkedUnit != null) { |
1943 // Getters and setter in different units should be patched to use the | 1939 // Getters and setter in different units should be patched to use the |
1944 // same variables before these variables were asked and returned. | 1940 // same variables before these variables were asked and returned. |
1945 assert(_variables == null); | 1941 assert(_variables == null); |
1946 _topLevelVariableReplaceMap ??= | 1942 _topLevelVariableReplaceMap ??= |
1947 <TopLevelVariableElement, TopLevelVariableElement>{}; | 1943 <TopLevelVariableElement, TopLevelVariableElement>{}; |
1948 _topLevelVariableReplaceMap[from] = to; | 1944 _topLevelVariableReplaceMap[from] = to; |
1949 } else { | 1945 } else { |
1950 int index = _variables.indexOf(from); | 1946 int index = _variables.indexOf(from); |
1951 _variables[index] = to; | 1947 _variables[index] = to; |
1952 } | 1948 } |
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4148 bool get isSynchronous => !isAsynchronous; | 4144 bool get isSynchronous => !isAsynchronous; |
4149 | 4145 |
4150 @override | 4146 @override |
4151 List<kernel.TypeParameter> get kernelTypeParams { | 4147 List<kernel.TypeParameter> get kernelTypeParams { |
4152 return _kernel?.function?.typeParameters; | 4148 return _kernel?.function?.typeParameters; |
4153 } | 4149 } |
4154 | 4150 |
4155 @override | 4151 @override |
4156 List<ElementAnnotation> get metadata { | 4152 List<ElementAnnotation> get metadata { |
4157 if (_kernel != null) { | 4153 if (_kernel != null) { |
4158 _metadata ??= enclosingUnit._kernelContext | 4154 _metadata ??= |
4159 .buildAnnotations(enclosingUnit, _kernel.annotations); | 4155 enclosingUnit._kernelContext.buildAnnotations(_kernel.annotations); |
4160 } | 4156 } |
4161 if (serializedExecutable != null) { | 4157 if (serializedExecutable != null) { |
4162 return _metadata ??= | 4158 return _metadata ??= |
4163 _buildAnnotations(enclosingUnit, serializedExecutable.annotations); | 4159 _buildAnnotations(enclosingUnit, serializedExecutable.annotations); |
4164 } | 4160 } |
4165 return super.metadata; | 4161 return super.metadata; |
4166 } | 4162 } |
4167 | 4163 |
4168 @override | 4164 @override |
4169 String get name { | 4165 String get name { |
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5087 | 5083 |
5088 @override | 5084 @override |
5089 List<kernel.TypeParameter> get kernelTypeParams => _kernel?.typeParameters; | 5085 List<kernel.TypeParameter> get kernelTypeParams => _kernel?.typeParameters; |
5090 | 5086 |
5091 @override | 5087 @override |
5092 ElementKind get kind => ElementKind.FUNCTION_TYPE_ALIAS; | 5088 ElementKind get kind => ElementKind.FUNCTION_TYPE_ALIAS; |
5093 | 5089 |
5094 @override | 5090 @override |
5095 List<ElementAnnotation> get metadata { | 5091 List<ElementAnnotation> get metadata { |
5096 if (_kernel != null) { | 5092 if (_kernel != null) { |
5097 _metadata ??= enclosingUnit._kernelContext | 5093 _metadata ??= |
5098 .buildAnnotations(enclosingUnit, _kernel.annotations); | 5094 enclosingUnit._kernelContext.buildAnnotations(_kernel.annotations); |
5099 } | 5095 } |
5100 if (_unlinkedTypedef != null) { | 5096 if (_unlinkedTypedef != null) { |
5101 return _metadata ??= | 5097 return _metadata ??= |
5102 _buildAnnotations(enclosingUnit, _unlinkedTypedef.annotations); | 5098 _buildAnnotations(enclosingUnit, _unlinkedTypedef.annotations); |
5103 } | 5099 } |
5104 return super.metadata; | 5100 return super.metadata; |
5105 } | 5101 } |
5106 | 5102 |
5107 @override | 5103 @override |
5108 String get name { | 5104 String get name { |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6083 } | 6079 } |
6084 } | 6080 } |
6085 | 6081 |
6086 /** | 6082 /** |
6087 * The kernel context in which a library is resynthesized. | 6083 * The kernel context in which a library is resynthesized. |
6088 */ | 6084 */ |
6089 abstract class KernelLibraryResynthesizerContext { | 6085 abstract class KernelLibraryResynthesizerContext { |
6090 kernel.Library get library; | 6086 kernel.Library get library; |
6091 | 6087 |
6092 /** | 6088 /** |
| 6089 * Return the [LibraryElement] for the given absolute [uriStr]. |
| 6090 */ |
| 6091 LibraryElement getLibrary(String uriStr); |
| 6092 } |
| 6093 |
| 6094 /** |
| 6095 * Top-level declarations of a Kernel library filtered by the unit. |
| 6096 */ |
| 6097 abstract class KernelUnit { |
| 6098 List<kernel.Class> get classes; |
| 6099 |
| 6100 List<kernel.Field> get fields; |
| 6101 |
| 6102 List<kernel.Procedure> get procedures; |
| 6103 |
| 6104 List<kernel.Typedef> get typedefs; |
| 6105 } |
| 6106 |
| 6107 /** |
| 6108 * The kernel context in which a unit is resynthesized. |
| 6109 */ |
| 6110 abstract class KernelUnitResynthesizerContext { |
| 6111 /** |
| 6112 * Subset of top-level declarations in the unit. |
| 6113 */ |
| 6114 KernelUnit get kernelUnit; |
| 6115 |
| 6116 /** |
6093 * Build [ElementAnnotation]s for the given Kernel [annotations]. | 6117 * Build [ElementAnnotation]s for the given Kernel [annotations]. |
6094 */ | 6118 */ |
6095 List<ElementAnnotation> buildAnnotations( | 6119 List<ElementAnnotation> buildAnnotations(List<kernel.Expression> annotations); |
6096 CompilationUnitElementImpl unit, List<kernel.Expression> annotations); | |
6097 | 6120 |
6098 /** | 6121 /** |
6099 * Build explicit top-level property accessors. | 6122 * Build explicit top-level property accessors. |
6100 */ | 6123 */ |
6101 UnitExplicitTopLevelAccessors buildTopLevelAccessors( | 6124 UnitExplicitTopLevelAccessors buildTopLevelAccessors(); |
6102 CompilationUnitElementImpl unit); | |
6103 | 6125 |
6104 /** | 6126 /** |
6105 * Build explicit top-level variables. | 6127 * Build explicit top-level variables. |
6106 */ | 6128 */ |
6107 UnitExplicitTopLevelVariables buildTopLevelVariables( | 6129 UnitExplicitTopLevelVariables buildTopLevelVariables(); |
6108 CompilationUnitElementImpl unit); | |
6109 | 6130 |
6110 /** | 6131 /** |
6111 * Return the resynthesized [ConstructorInitializer] for the given Kernel | 6132 * Return the resynthesized [ConstructorInitializer] for the given Kernel |
6112 * [initializer], or `null` if synthetic. | 6133 * [initializer], or `null` if synthetic. |
6113 */ | 6134 */ |
6114 ConstructorInitializer getConstructorInitializer( | 6135 ConstructorInitializer getConstructorInitializer( |
6115 ConstructorElementImpl constructor, kernel.Initializer initializer); | 6136 ConstructorElementImpl constructor, kernel.Initializer initializer); |
6116 | 6137 |
6117 /** | 6138 /** |
6118 * Return the [Expression] for the given kernel. | 6139 * Return the [Expression] for the given kernel. |
6119 */ | 6140 */ |
6120 Expression getExpression(ElementImpl context, kernel.Expression expression); | 6141 Expression getExpression(ElementImpl context, kernel.Expression expression); |
6121 | 6142 |
6122 /** | 6143 /** |
6123 * Return the list with exactly two elements - positional and named parameter | 6144 * Return the list with exactly two elements - positional and named parameter |
6124 * lists. | 6145 * lists. |
6125 */ | 6146 */ |
6126 List<List<kernel.VariableDeclaration>> getFunctionTypeParameters( | 6147 List<List<kernel.VariableDeclaration>> getFunctionTypeParameters( |
6127 kernel.FunctionType functionType); | 6148 kernel.FunctionType functionType); |
6128 | 6149 |
6129 /** | 6150 /** |
6130 * Return the [InterfaceType] for the given Kernel [type], or `null` if the | 6151 * Return the [InterfaceType] for the given Kernel [type], or `null` if the |
6131 * [type] does not correspond to an [InterfaceType]. | 6152 * [type] does not correspond to an [InterfaceType]. |
6132 */ | 6153 */ |
6133 InterfaceType getInterfaceType(ElementImpl context, kernel.Supertype type); | 6154 InterfaceType getInterfaceType(ElementImpl context, kernel.Supertype type); |
6134 | 6155 |
6135 /** | 6156 /** |
6136 * Return the [LibraryElement] for the given absolute [uriStr]. | |
6137 */ | |
6138 LibraryElement getLibrary(String uriStr); | |
6139 | |
6140 /** | |
6141 * Return the [ConstructorElementImpl] to which the given [kernelConstructor] | 6157 * Return the [ConstructorElementImpl] to which the given [kernelConstructor] |
6142 * or [kernelFactory] redirects. | 6158 * or [kernelFactory] redirects. |
6143 */ | 6159 */ |
6144 ConstructorElementImpl getRedirectedConstructor( | 6160 ConstructorElementImpl getRedirectedConstructor( |
6145 kernel.Constructor kernelConstructor, kernel.Procedure kernelFactory); | 6161 kernel.Constructor kernelConstructor, kernel.Procedure kernelFactory); |
6146 | 6162 |
6147 /** | 6163 /** |
6148 * Return the [DartType] for the given Kernel [type], or `null` if the [type] | 6164 * Return the [DartType] for the given Kernel [type], or `null` if the [type] |
6149 * does not correspond to a [DartType]. | 6165 * does not correspond to a [DartType]. |
6150 */ | 6166 */ |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6318 : resynthesizerContext = null, | 6334 : resynthesizerContext = null, |
6319 _unlinkedDefiningUnit = null, | 6335 _unlinkedDefiningUnit = null, |
6320 nameLength = _kernelContext.library.name?.length ?? 0, | 6336 nameLength = _kernelContext.library.name?.length ?? 0, |
6321 super.forSerialized(null) { | 6337 super.forSerialized(null) { |
6322 _name = _kernelContext.library.name ?? ''; | 6338 _name = _kernelContext.library.name ?? ''; |
6323 _nameOffset = _kernelContext.library.fileOffset; | 6339 _nameOffset = _kernelContext.library.fileOffset; |
6324 setResolutionCapability( | 6340 setResolutionCapability( |
6325 LibraryResolutionCapability.resolvedTypeNames, true); | 6341 LibraryResolutionCapability.resolvedTypeNames, true); |
6326 setResolutionCapability( | 6342 setResolutionCapability( |
6327 LibraryResolutionCapability.constantExpressions, true); | 6343 LibraryResolutionCapability.constantExpressions, true); |
6328 | |
6329 definingCompilationUnit = new CompilationUnitElementImpl.forKernel( | |
6330 this, _kernelContext, '<no-name>'); | |
6331 | |
6332 // TODO(scheglov) how to support parts? | |
6333 } | 6344 } |
6334 | 6345 |
6335 /** | 6346 /** |
6336 * Initialize a newly created library element in the given [context] to have | 6347 * Initialize a newly created library element in the given [context] to have |
6337 * the given [name]. | 6348 * the given [name]. |
6338 */ | 6349 */ |
6339 LibraryElementImpl.forNode(this.context, LibraryIdentifier name) | 6350 LibraryElementImpl.forNode(this.context, LibraryIdentifier name) |
6340 : nameLength = name != null ? name.length : 0, | 6351 : nameLength = name != null ? name.length : 0, |
6341 resynthesizerContext = null, | 6352 resynthesizerContext = null, |
6342 _kernelContext = null, | 6353 _kernelContext = null, |
(...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7823 | 7834 |
7824 @override | 7835 @override |
7825 void set isFinal(bool isFinal) { | 7836 void set isFinal(bool isFinal) { |
7826 _assertNotResynthesized(_unlinkedVariable); | 7837 _assertNotResynthesized(_unlinkedVariable); |
7827 super.isFinal = isFinal; | 7838 super.isFinal = isFinal; |
7828 } | 7839 } |
7829 | 7840 |
7830 @override | 7841 @override |
7831 List<ElementAnnotation> get metadata { | 7842 List<ElementAnnotation> get metadata { |
7832 if (_kernel != null) { | 7843 if (_kernel != null) { |
7833 _metadata ??= enclosingUnit._kernelContext | 7844 _metadata ??= |
7834 .buildAnnotations(enclosingUnit, _kernel.annotations); | 7845 enclosingUnit._kernelContext.buildAnnotations(_kernel.annotations); |
7835 } | 7846 } |
7836 if (_unlinkedVariable != null) { | 7847 if (_unlinkedVariable != null) { |
7837 return _metadata ??= | 7848 return _metadata ??= |
7838 _buildAnnotations(enclosingUnit, _unlinkedVariable.annotations); | 7849 _buildAnnotations(enclosingUnit, _unlinkedVariable.annotations); |
7839 } | 7850 } |
7840 return super.metadata; | 7851 return super.metadata; |
7841 } | 7852 } |
7842 | 7853 |
7843 @override | 7854 @override |
7844 String get name { | 7855 String get name { |
(...skipping 2079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9924 | 9935 |
9925 @override | 9936 @override |
9926 DartObject computeConstantValue() => null; | 9937 DartObject computeConstantValue() => null; |
9927 | 9938 |
9928 @override | 9939 @override |
9929 void visitChildren(ElementVisitor visitor) { | 9940 void visitChildren(ElementVisitor visitor) { |
9930 super.visitChildren(visitor); | 9941 super.visitChildren(visitor); |
9931 _initializer?.accept(visitor); | 9942 _initializer?.accept(visitor); |
9932 } | 9943 } |
9933 } | 9944 } |
OLD | NEW |