Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 2036203005: Resynthesize CompilationUnitElement.types lazily. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 elementAnnotation.annotationAst = AstFactory.annotation2( 1502 elementAnnotation.annotationAst = AstFactory.annotation2(
1503 typeName, constructorName, constExpr.argumentList); 1503 typeName, constructorName, constExpr.argumentList);
1504 } else { 1504 } else {
1505 throw new StateError( 1505 throw new StateError(
1506 'Unexpected annotation type: ${constExpr.runtimeType}'); 1506 'Unexpected annotation type: ${constExpr.runtimeType}');
1507 } 1507 }
1508 return elementAnnotation; 1508 return elementAnnotation;
1509 } 1509 }
1510 1510
1511 /** 1511 /**
1512 * Build the annotations for the given [element].
1513 */
1514 void buildAnnotations(
1515 ElementImpl element, List<UnlinkedConst> serializedAnnotations) {
1516 if (serializedAnnotations.isNotEmpty) {
1517 element.metadata = serializedAnnotations
1518 .map((a) => buildAnnotation(element, a))
1519 .toList();
1520 }
1521 }
1522
1523 /**
1524 * Resynthesize a [ClassElement] and place it in [unitHolder].
1525 */
1526 void buildClass(UnlinkedClass serializedClass) {
1527 ClassElementImpl classElement =
1528 new ClassElementImpl.forSerialized(serializedClass, unit);
1529 classElement.hasBeenInferred = summaryResynthesizer.strongMode;
1530 unitHolder.addType(classElement);
1531 }
1532
1533 /**
1534 * Build the documentation for the given [element]. Does nothing if 1512 * Build the documentation for the given [element]. Does nothing if
1535 * [serializedDocumentationComment] is `null`. 1513 * [serializedDocumentationComment] is `null`.
1536 */ 1514 */
1537 void buildDocumentation(ElementImpl element, 1515 void buildDocumentation(ElementImpl element,
1538 UnlinkedDocumentationComment serializedDocumentationComment) { 1516 UnlinkedDocumentationComment serializedDocumentationComment) {
1539 if (serializedDocumentationComment != null) { 1517 if (serializedDocumentationComment != null) {
1540 element.documentationComment = serializedDocumentationComment.text; 1518 element.documentationComment = serializedDocumentationComment.text;
1541 element.setDocRange(serializedDocumentationComment.offset, 1519 element.setDocRange(serializedDocumentationComment.offset,
1542 serializedDocumentationComment.length); 1520 serializedDocumentationComment.length);
1543 } 1521 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 // Build the value of the 'values' field. 1572 // Build the value of the 'values' field.
1595 valuesField.evaluationResult = new EvaluationResultImpl( 1573 valuesField.evaluationResult = new EvaluationResultImpl(
1596 new DartObjectImpl(valuesField.type, new ListState(constantValues))); 1574 new DartObjectImpl(valuesField.type, new ListState(constantValues)));
1597 // done 1575 // done
1598 classElement.fields = memberHolder.fields; 1576 classElement.fields = memberHolder.fields;
1599 classElement.accessors = memberHolder.accessors; 1577 classElement.accessors = memberHolder.accessors;
1600 unitHolder.addEnum(classElement); 1578 unitHolder.addEnum(classElement);
1601 } 1579 }
1602 1580
1603 /** 1581 /**
1604 * Resynthesize a [FieldElement].
1605 */
1606 void buildField(ClassElementImpl enclosingClass,
1607 UnlinkedVariable serializedVariable, ElementHolder holder) {
1608 FieldElementImpl element = new FieldElementImpl.forSerializedFactory(
1609 serializedVariable, enclosingClass);
1610 holder.addField(element);
1611 buildImplicitAccessors(element, holder);
1612 }
1613
1614 /**
1615 * Build the implicit getter and setter associated with [element], and place 1582 * Build the implicit getter and setter associated with [element], and place
1616 * them in [holder]. 1583 * them in [holder].
1617 */ 1584 */
1618 void buildImplicitAccessors( 1585 void buildImplicitAccessors(
1619 PropertyInducingElementImpl element, ElementHolder holder) { 1586 PropertyInducingElementImpl element, ElementHolder holder) {
1620 PropertyAccessorElementImpl getter = buildImplicitGetter(element); 1587 PropertyAccessorElementImpl getter = buildImplicitGetter(element);
1621 holder?.addAccessor(getter); 1588 holder?.addAccessor(getter);
1622 if (!(element.isConst || element.isFinal)) { 1589 if (!(element.isConst || element.isFinal)) {
1623 PropertyAccessorElementImpl setter = buildImplicitSetter(element); 1590 PropertyAccessorElementImpl setter = buildImplicitSetter(element);
1624 holder?.addAccessor(setter); 1591 holder?.addAccessor(setter);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1891 referenceInfos[index] = result; 1858 referenceInfos[index] = result;
1892 } 1859 }
1893 return result; 1860 return result;
1894 } 1861 }
1895 1862
1896 /** 1863 /**
1897 * Populate a [CompilationUnitElement] by deserializing all the elements 1864 * Populate a [CompilationUnitElement] by deserializing all the elements
1898 * contained in it. 1865 * contained in it.
1899 */ 1866 */
1900 void populateUnit() { 1867 void populateUnit() {
1901 unlinkedUnit.classes.forEach(buildClass);
1902 unlinkedUnit.enums.forEach(buildEnum); 1868 unlinkedUnit.enums.forEach(buildEnum);
1903 unit.enums = unitHolder.enums; 1869 unit.enums = unitHolder.enums;
1904 unit.types = unitHolder.types;
1905 } 1870 }
1906 1871
1907 Expression _buildConstExpression(ElementImpl context, UnlinkedConst uc) { 1872 Expression _buildConstExpression(ElementImpl context, UnlinkedConst uc) {
1908 return new _ConstExprBuilder(this, context, uc).build(); 1873 return new _ConstExprBuilder(this, context, uc).build();
1909 } 1874 }
1910 1875
1911 /** 1876 /**
1912 * Return the defining type for a [ConstructorElement] by applying 1877 * Return the defining type for a [ConstructorElement] by applying
1913 * [typeArgumentRefs] to the given linked [info]. 1878 * [typeArgumentRefs] to the given linked [info].
1914 */ 1879 */
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1973 static String _getElementIdentifier(String name, ReferenceKind kind) { 1938 static String _getElementIdentifier(String name, ReferenceKind kind) {
1974 if (kind == ReferenceKind.topLevelPropertyAccessor || 1939 if (kind == ReferenceKind.topLevelPropertyAccessor ||
1975 kind == ReferenceKind.propertyAccessor) { 1940 kind == ReferenceKind.propertyAccessor) {
1976 if (!name.endsWith('=')) { 1941 if (!name.endsWith('=')) {
1977 return name + '?'; 1942 return name + '?';
1978 } 1943 }
1979 } 1944 }
1980 return name; 1945 return name;
1981 } 1946 }
1982 } 1947 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698