| 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 summary_resynthesizer; | 5 library summary_resynthesizer; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1208 return new ClassElementHandle(summaryResynthesizer, location); | 1208 return new ClassElementHandle(summaryResynthesizer, location); |
| 1209 case ReferenceKind.typedef: | 1209 case ReferenceKind.typedef: |
| 1210 return new FunctionTypeAliasElementHandle( | 1210 return new FunctionTypeAliasElementHandle( |
| 1211 summaryResynthesizer, location); | 1211 summaryResynthesizer, location); |
| 1212 case ReferenceKind.topLevelFunction: | 1212 case ReferenceKind.topLevelFunction: |
| 1213 return new FunctionElementHandle(summaryResynthesizer, location); | 1213 return new FunctionElementHandle(summaryResynthesizer, location); |
| 1214 case ReferenceKind.topLevelPropertyAccessor: | 1214 case ReferenceKind.topLevelPropertyAccessor: |
| 1215 return new PropertyAccessorElementHandle( | 1215 return new PropertyAccessorElementHandle( |
| 1216 summaryResynthesizer, location); | 1216 summaryResynthesizer, location); |
| 1217 case ReferenceKind.constructor: | 1217 case ReferenceKind.constructor: |
| 1218 case ReferenceKind.function: |
| 1218 case ReferenceKind.propertyAccessor: | 1219 case ReferenceKind.propertyAccessor: |
| 1219 case ReferenceKind.method: | 1220 case ReferenceKind.method: |
| 1220 case ReferenceKind.length: | 1221 case ReferenceKind.length: |
| 1221 case ReferenceKind.prefix: | 1222 case ReferenceKind.prefix: |
| 1222 case ReferenceKind.unresolved: | 1223 case ReferenceKind.unresolved: |
| 1223 // Should never happen. Exported names never refer to import prefixes, | 1224 // Should never happen. Exported names never refer to import prefixes, |
| 1224 // and they always refer to defined top-level entities. | 1225 // and they always refer to defined top-level entities. |
| 1225 throw new StateError('Unexpected export name kind: ${exportName.kind}'); | 1226 throw new StateError('Unexpected export name kind: ${exportName.kind}'); |
| 1226 } | 1227 } |
| 1227 } | 1228 } |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 // The type is inherited from the matching field. | 1556 // The type is inherited from the matching field. |
| 1556 parameterElement.type = fields[serializedParameter.name]?.type ?? | 1557 parameterElement.type = fields[serializedParameter.name]?.type ?? |
| 1557 summaryResynthesizer.typeProvider.dynamicType; | 1558 summaryResynthesizer.typeProvider.dynamicType; |
| 1558 } else { | 1559 } else { |
| 1559 parameterElement.type = | 1560 parameterElement.type = |
| 1560 buildLinkedType(serializedParameter.inferredTypeSlot) ?? | 1561 buildLinkedType(serializedParameter.inferredTypeSlot) ?? |
| 1561 buildType(serializedParameter.type); | 1562 buildType(serializedParameter.type); |
| 1562 } | 1563 } |
| 1563 parameterElement.hasImplicitType = serializedParameter.type == null; | 1564 parameterElement.hasImplicitType = serializedParameter.type == null; |
| 1564 } | 1565 } |
| 1566 if (serializedParameter.initializer != null) { |
| 1567 parameterElement.initializer = |
| 1568 buildLocalFunction(serializedParameter.initializer); |
| 1569 } |
| 1565 switch (serializedParameter.kind) { | 1570 switch (serializedParameter.kind) { |
| 1566 case UnlinkedParamKind.named: | 1571 case UnlinkedParamKind.named: |
| 1567 parameterElement.parameterKind = ParameterKind.NAMED; | 1572 parameterElement.parameterKind = ParameterKind.NAMED; |
| 1568 break; | 1573 break; |
| 1569 case UnlinkedParamKind.positional: | 1574 case UnlinkedParamKind.positional: |
| 1570 parameterElement.parameterKind = ParameterKind.POSITIONAL; | 1575 parameterElement.parameterKind = ParameterKind.POSITIONAL; |
| 1571 break; | 1576 break; |
| 1572 case UnlinkedParamKind.required: | 1577 case UnlinkedParamKind.required: |
| 1573 parameterElement.parameterKind = ParameterKind.REQUIRED; | 1578 parameterElement.parameterKind = ParameterKind.REQUIRED; |
| 1574 break; | 1579 break; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1738 /** | 1743 /** |
| 1739 * Handle the parts that are common to variables. | 1744 * Handle the parts that are common to variables. |
| 1740 */ | 1745 */ |
| 1741 void buildVariableCommonParts( | 1746 void buildVariableCommonParts( |
| 1742 VariableElementImpl element, UnlinkedVariable serializedVariable) { | 1747 VariableElementImpl element, UnlinkedVariable serializedVariable) { |
| 1743 element.type = buildLinkedType(serializedVariable.inferredTypeSlot) ?? | 1748 element.type = buildLinkedType(serializedVariable.inferredTypeSlot) ?? |
| 1744 buildType(serializedVariable.type); | 1749 buildType(serializedVariable.type); |
| 1745 element.const3 = serializedVariable.isConst; | 1750 element.const3 = serializedVariable.isConst; |
| 1746 element.final2 = serializedVariable.isFinal; | 1751 element.final2 = serializedVariable.isFinal; |
| 1747 element.hasImplicitType = serializedVariable.type == null; | 1752 element.hasImplicitType = serializedVariable.type == null; |
| 1753 if (serializedVariable.initializer != null) { |
| 1754 element.initializer = buildLocalFunction(serializedVariable.initializer); |
| 1755 } |
| 1748 buildDocumentation(element, serializedVariable.documentationComment); | 1756 buildDocumentation(element, serializedVariable.documentationComment); |
| 1749 buildAnnotations(element, serializedVariable.annotations); | 1757 buildAnnotations(element, serializedVariable.annotations); |
| 1750 } | 1758 } |
| 1751 | 1759 |
| 1752 /** | 1760 /** |
| 1753 * Finish creating a [TypeParameterElement] by deserializing its bound. | 1761 * Finish creating a [TypeParameterElement] by deserializing its bound. |
| 1754 */ | 1762 */ |
| 1755 void finishTypeParameter(UnlinkedTypeParam serializedTypeParameter, | 1763 void finishTypeParameter(UnlinkedTypeParam serializedTypeParameter, |
| 1756 TypeParameterElementImpl typeParameterElement) { | 1764 TypeParameterElementImpl typeParameterElement) { |
| 1757 if (serializedTypeParameter.bound != null) { | 1765 if (serializedTypeParameter.bound != null) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1919 element = new FunctionElementHandle(summaryResynthesizer, location); | 1927 element = new FunctionElementHandle(summaryResynthesizer, location); |
| 1920 break; | 1928 break; |
| 1921 case ReferenceKind.topLevelPropertyAccessor: | 1929 case ReferenceKind.topLevelPropertyAccessor: |
| 1922 element = new PropertyAccessorElementHandle( | 1930 element = new PropertyAccessorElementHandle( |
| 1923 summaryResynthesizer, location); | 1931 summaryResynthesizer, location); |
| 1924 break; | 1932 break; |
| 1925 case ReferenceKind.typedef: | 1933 case ReferenceKind.typedef: |
| 1926 element = new FunctionTypeAliasElementHandle( | 1934 element = new FunctionTypeAliasElementHandle( |
| 1927 summaryResynthesizer, location); | 1935 summaryResynthesizer, location); |
| 1928 break; | 1936 break; |
| 1937 case ReferenceKind.function: |
| 1929 case ReferenceKind.prefix: | 1938 case ReferenceKind.prefix: |
| 1930 case ReferenceKind.unresolved: | 1939 case ReferenceKind.unresolved: |
| 1931 break; | 1940 break; |
| 1932 } | 1941 } |
| 1933 } | 1942 } |
| 1934 referenceInfos[i] = new _ReferenceInfo( | 1943 referenceInfos[i] = new _ReferenceInfo( |
| 1935 enclosingInfo, name, element, type, numTypeParameters); | 1944 enclosingInfo, name, element, type, numTypeParameters); |
| 1936 } | 1945 } |
| 1937 } | 1946 } |
| 1938 | 1947 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2207 } | 2216 } |
| 2208 : () => this.element; | 2217 : () => this.element; |
| 2209 // TODO(paulberry): Is it a bug that we have to pass `false` for | 2218 // TODO(paulberry): Is it a bug that we have to pass `false` for |
| 2210 // isInstantiated? | 2219 // isInstantiated? |
| 2211 return new DeferredFunctionTypeImpl(computer, null, typeArguments, false); | 2220 return new DeferredFunctionTypeImpl(computer, null, typeArguments, false); |
| 2212 } else { | 2221 } else { |
| 2213 return null; | 2222 return null; |
| 2214 } | 2223 } |
| 2215 } | 2224 } |
| 2216 } | 2225 } |
| OLD | NEW |