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 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1520 } | 1520 } |
1521 } | 1521 } |
1522 | 1522 |
1523 /** | 1523 /** |
1524 * Resynthesize a [ClassElement] and place it in [unitHolder]. | 1524 * Resynthesize a [ClassElement] and place it in [unitHolder]. |
1525 */ | 1525 */ |
1526 void buildClass(UnlinkedClass serializedClass) { | 1526 void buildClass(UnlinkedClass serializedClass) { |
1527 ClassElementImpl classElement = | 1527 ClassElementImpl classElement = |
1528 new ClassElementImpl.forSerialized(serializedClass, unit); | 1528 new ClassElementImpl.forSerialized(serializedClass, unit); |
1529 classElement.hasBeenInferred = summaryResynthesizer.strongMode; | 1529 classElement.hasBeenInferred = summaryResynthesizer.strongMode; |
1530 InterfaceTypeImpl correspondingType = new InterfaceTypeImpl(classElement); | |
1531 // TODO(scheglov) move to ClassElementImpl | |
1532 correspondingType.typeArguments = classElement.typeParameterTypes; | |
1533 classElement.type = correspondingType; | |
1534 unitHolder.addType(classElement); | 1530 unitHolder.addType(classElement); |
1535 } | 1531 } |
1536 | 1532 |
1537 /** | 1533 /** |
1538 * Build the documentation for the given [element]. Does nothing if | 1534 * Build the documentation for the given [element]. Does nothing if |
1539 * [serializedDocumentationComment] is `null`. | 1535 * [serializedDocumentationComment] is `null`. |
1540 */ | 1536 */ |
1541 void buildDocumentation(ElementImpl element, | 1537 void buildDocumentation(ElementImpl element, |
1542 UnlinkedDocumentationComment serializedDocumentationComment) { | 1538 UnlinkedDocumentationComment serializedDocumentationComment) { |
1543 if (serializedDocumentationComment != null) { | 1539 if (serializedDocumentationComment != null) { |
1544 element.documentationComment = serializedDocumentationComment.text; | 1540 element.documentationComment = serializedDocumentationComment.text; |
1545 element.setDocRange(serializedDocumentationComment.offset, | 1541 element.setDocRange(serializedDocumentationComment.offset, |
1546 serializedDocumentationComment.length); | 1542 serializedDocumentationComment.length); |
1547 } | 1543 } |
1548 } | 1544 } |
1549 | 1545 |
1550 /** | 1546 /** |
1551 * Resynthesize the [ClassElement] corresponding to an enum, along with the | 1547 * Resynthesize the [ClassElement] corresponding to an enum, along with the |
1552 * associated fields and implicit accessors. | 1548 * associated fields and implicit accessors. |
1553 */ | 1549 */ |
1554 void buildEnum(UnlinkedEnum serializedEnum) { | 1550 void buildEnum(UnlinkedEnum serializedEnum) { |
1555 assert(!libraryResynthesizer.isCoreLibrary); | 1551 assert(!libraryResynthesizer.isCoreLibrary); |
1556 EnumElementImpl classElement = | 1552 EnumElementImpl classElement = |
1557 new EnumElementImpl.forSerialized(serializedEnum, unit); | 1553 new EnumElementImpl.forSerialized(serializedEnum, unit); |
1558 InterfaceType enumType = new InterfaceTypeImpl(classElement); | 1554 InterfaceType enumType = classElement.type; |
1559 classElement.type = enumType; | |
1560 ElementHolder memberHolder = new ElementHolder(); | 1555 ElementHolder memberHolder = new ElementHolder(); |
1561 // Build the 'index' field. | 1556 // Build the 'index' field. |
1562 FieldElementImpl indexField = new FieldElementImpl('index', -1); | 1557 FieldElementImpl indexField = new FieldElementImpl('index', -1); |
1563 indexField.final2 = true; | 1558 indexField.final2 = true; |
1564 indexField.synthetic = true; | 1559 indexField.synthetic = true; |
1565 indexField.type = typeProvider.intType; | 1560 indexField.type = typeProvider.intType; |
1566 memberHolder.addField(indexField); | 1561 memberHolder.addField(indexField); |
1567 buildImplicitAccessors(indexField, memberHolder); | 1562 buildImplicitAccessors(indexField, memberHolder); |
1568 // Build the 'values' field. | 1563 // Build the 'values' field. |
1569 FieldElementImpl valuesField = new ConstFieldElementImpl('values', -1); | 1564 FieldElementImpl valuesField = new ConstFieldElementImpl('values', -1); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1978 static String _getElementIdentifier(String name, ReferenceKind kind) { | 1973 static String _getElementIdentifier(String name, ReferenceKind kind) { |
1979 if (kind == ReferenceKind.topLevelPropertyAccessor || | 1974 if (kind == ReferenceKind.topLevelPropertyAccessor || |
1980 kind == ReferenceKind.propertyAccessor) { | 1975 kind == ReferenceKind.propertyAccessor) { |
1981 if (!name.endsWith('=')) { | 1976 if (!name.endsWith('=')) { |
1982 return name + '?'; | 1977 return name + '?'; |
1983 } | 1978 } |
1984 } | 1979 } |
1985 return name; | 1980 return name; |
1986 } | 1981 } |
1987 } | 1982 } |
OLD | NEW |