Skip to content

Commit 9c24301

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Print isSynthetic, do not print not useful flags of property related fragments.
Change-Id: Ic8f44bb3fd1ff58f261bdce2eaec2b9ca63c4b6f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395423 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 2e9058e commit 9c24301

27 files changed

+3048
-3078
lines changed

pkg/analyzer/lib/dart/element/element2.dart

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,13 @@ abstract class ExecutableFragment implements FunctionTypedFragment {
658658
/// Whether the body is marked as being synchronous.
659659
bool get isSynchronous;
660660

661+
/// Whether this fragment is synthetic.
662+
///
663+
/// A synthetic fragment is a fragment that is not represented in the source
664+
/// code explicitly, but is implied by the source code, such as the default
665+
/// constructor for a class that does not explicitly define any constructors.
666+
bool get isSynthetic;
667+
661668
@override
662669
LibraryFragment get libraryFragment;
663670

@@ -2123,16 +2130,10 @@ abstract class PropertyInducingFragment
21232130

21242131
/// Whether the element is an augmentation.
21252132
///
2126-
/// Property indicing fragments are augmentations if they are explicitly
2133+
/// Property inducing fragments are augmentations if they are explicitly
21272134
/// marked as such using the 'augment' modifier.
21282135
bool get isAugmentation;
21292136

2130-
/// Whether the fragment is a static fragment.
2131-
///
2132-
/// A static fragment is a fragment that is not associated with a particular
2133-
/// instance, but rather with an entire library or class.
2134-
bool get isStatic;
2135-
21362137
/// Whether this fragment is synthetic.
21372138
///
21382139
/// A synthetic fragment is a fragment that is not represented in the source
@@ -2547,15 +2548,6 @@ abstract class VariableFragment implements Fragment {
25472548
@override
25482549
VariableElement2 get element;
25492550

2550-
/// Whether the variable was declared with the 'const' modifier.
2551-
bool get isConst;
2552-
2553-
/// Whether the variable was declared with the 'final' modifier.
2554-
///
2555-
/// Variables that are declared with the 'const' modifier will return `false`
2556-
/// even though they are implicitly final.
2557-
bool get isFinal;
2558-
25592551
@override
25602552
VariableFragment? get nextFragment;
25612553

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4362,7 +4362,7 @@ class FormalParameterElementImpl extends PromotableElementImpl2
43624362

43634363
@override
43644364
// TODO(augmentations): Implement the merge of formal parameters.
4365-
bool get isFinal => firstFragment.isFinal;
4365+
bool get isFinal => wrappedElement.isFinal;
43664366

43674367
@override
43684368
bool get isInitializingFormal => wrappedElement.isInitializingFormal;

pkg/analyzer/test/src/summary/element_text.dart

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -485,16 +485,14 @@ class _Element2Writer extends _AbstractElementWriter {
485485
_sink.writeIndentedLine(() {
486486
_sink.writeIf(e.isSynthetic, 'synthetic ');
487487
_sink.writeIf(e.isStatic, 'static ');
488-
_sink.writeIf(e is FieldElementImpl && e.isAbstract, 'abstract ');
489-
_sink.writeIf(e is FieldElementImpl && e.isCovariant, 'covariant ');
490-
_sink.writeIf(e is FieldElementImpl && e.isExternal, 'external ');
488+
_sink.writeIf(e.isAbstract, 'abstract ');
489+
_sink.writeIf(e.isCovariant, 'covariant ');
490+
_sink.writeIf(e.isExternal, 'external ');
491491
_sink.writeIf(e.isLate, 'late ');
492492
_sink.writeIf(e.isFinal, 'final ');
493493
_sink.writeIf(e.isConst, 'const ');
494-
if (e is FieldElementImpl) {
495-
_sink.writeIf(e.isEnumConstant, 'enumConstant ');
496-
_sink.writeIf(e.isPromotable, 'promotable ');
497-
}
494+
_sink.writeIf(e.isEnumConstant, 'enumConstant ');
495+
_sink.writeIf(e.isPromotable, 'promotable ');
498496

499497
_writeElementName(e);
500498
});
@@ -550,19 +548,8 @@ class _Element2Writer extends _AbstractElementWriter {
550548
// }
551549

552550
_sink.writeIndentedLine(() {
553-
// _sink.writeIf(f.isAugmentation, 'augment ');
554-
// _sink.writeIf(f.isSynthetic, 'synthetic ');
555-
// _sink.writeIf(f.isStatic, 'static ');
556-
_sink.writeIf(f is FieldElementImpl && f.isAbstract, 'abstract ');
557-
_sink.writeIf(f is FieldElementImpl && f.isCovariant, 'covariant ');
558-
_sink.writeIf(f is FieldElementImpl && f.isExternal, 'external ');
559-
// _sink.writeIf(f.isLate, 'late ');
560-
// _sink.writeIf(f.isFinal, 'final ');
561-
// _sink.writeIf(f.isConst, 'const ');
562-
if (f is FieldElementImpl) {
563-
_sink.writeIf(f.isEnumConstant, 'enumConstant ');
564-
_sink.writeIf(f.isPromotable, 'promotable ');
565-
}
551+
_sink.writeIf(f.isAugmentation, 'augment ');
552+
_sink.writeIf(f.isSynthetic, 'synthetic ');
566553

567554
_writeFragmentName(f);
568555
});
@@ -899,13 +886,9 @@ class _Element2Writer extends _AbstractElementWriter {
899886

900887
_sink.writeIndentedLine(() {
901888
_sink.writeIf(f.isAugmentation, 'augment ');
902-
// _sink.writeIf(e.isSynthetic, 'synthetic ');
903-
// _sink.writeIf(e.isStatic, 'static ');
904-
// _sink.writeIf(e.isAbstract, 'abstract ');
905-
// _sink.writeIf(e.isExternal, 'external ');
889+
_sink.writeIf(f.isSynthetic, 'synthetic ');
906890

907891
_sink.write('get ');
908-
909892
_writeFragmentName(f);
910893
// _writeBodyModifiers(e);
911894
});
@@ -1690,10 +1673,7 @@ class _Element2Writer extends _AbstractElementWriter {
16901673

16911674
_sink.writeIndentedLine(() {
16921675
_sink.writeIf(f.isAugmentation, 'augment ');
1693-
// _sink.writeIf(f.isSynthetic, 'synthetic ');
1694-
// _sink.writeIf(f.isStatic, 'static ');
1695-
// _sink.writeIf(f.isAbstract, 'abstract ');
1696-
// _sink.writeIf(f.isExternal, 'external ');
1676+
_sink.writeIf(f.isSynthetic, 'synthetic ');
16971677

16981678
_sink.write('set ');
16991679
_writeFragmentName(f);
@@ -1883,9 +1863,7 @@ class _Element2Writer extends _AbstractElementWriter {
18831863
_sink.writeIndentedLine(() {
18841864
_sink.writeIf(f.isAugmentation, 'augment ');
18851865
_sink.writeIf(f.isSynthetic, 'synthetic ');
1886-
// _sink.writeIf(f.isLate, 'late ');
1887-
_sink.writeIf(f.isFinal, 'final ');
1888-
_sink.writeIf(f.isConst, 'const ');
1866+
18891867
_writeFragmentName(f);
18901868
});
18911869

0 commit comments

Comments
 (0)