@@ -244,6 +244,13 @@ class InheritableAccessor extends Accessor with Inheritable {
244
244
}
245
245
return _enclosingElement;
246
246
}
247
+
248
+ @override
249
+ Set <String > get features {
250
+ Set <String > all_features = super .features;
251
+ if (isInherited) all_features.add ('inherited' );
252
+ return all_features;
253
+ }
247
254
}
248
255
249
256
/// Getters and setters.
@@ -279,10 +286,49 @@ class Accessor extends ModelElement
279
286
_enclosingCombo = combo;
280
287
}
281
288
289
+ bool get isSynthetic => element.isSynthetic;
290
+
291
+ @override
292
+ String get sourceCode {
293
+ if (_sourceCodeCache == null ) {
294
+ if (isSynthetic) {
295
+ _sourceCodeCache =
296
+ sourceCodeFor ((element as PropertyAccessorElement ).variable);
297
+ } else {
298
+ _sourceCodeCache = super .sourceCode;
299
+ }
300
+ }
301
+ return _sourceCodeCache;
302
+ }
303
+
304
+ @override
305
+ List <ModelElement > get computeDocumentationFrom {
306
+ if (isSynthetic) return [this ];
307
+ return super .computeDocumentationFrom;
308
+ }
309
+
282
310
@override
283
311
String get computeDocumentationComment {
284
- if (element.isSynthetic) {
285
- return (element as PropertyAccessorElement ).variable.documentationComment;
312
+ if (isSynthetic) {
313
+ String docComment = new ModelElement .fromElement (
314
+ (element as PropertyAccessorElement ).variable, package)
315
+ .element
316
+ .documentationComment;
317
+ // If we're a setter, only display something if we have something different than the getter.
318
+ // TODO(jcollins-g): modify analyzer to do this itself?
319
+ if (isGetter ||
320
+ // TODO(jcollins-g): @nodoc reading from comments is at the wrong abstraction level here.
321
+ (docComment != null &&
322
+ (docComment.contains ('<nodoc>' ) ||
323
+ docComment.contains ('@nodoc' ))) ||
324
+ (isSetter &&
325
+ enclosingCombo.hasGetter &&
326
+ enclosingCombo.getter.computeDocumentationComment !=
327
+ docComment)) {
328
+ return stripComments (docComment);
329
+ } else {
330
+ return '' ;
331
+ }
286
332
}
287
333
return stripComments (super .computeDocumentationComment);
288
334
}
@@ -326,6 +372,7 @@ class Accessor extends ModelElement
326
372
}
327
373
328
374
bool get isGetter => _accessor.isGetter;
375
+ bool get isSetter => _accessor.isSetter;
329
376
330
377
bool _overriddenElementIsSet = false ;
331
378
ModelElement _overriddenElement;
@@ -1359,6 +1406,8 @@ class Field extends ModelElement
1359
1406
..addAll ([hasPublicSetter, hasPublicGetterNoSetter]);
1360
1407
assert (assertCheck.containsAll ([true , false ]));
1361
1408
}
1409
+ documentationFrom;
1410
+ if (name == 'implicitGetterExplicitSetter' ) 1 + 1 ;
1362
1411
return super .documentation;
1363
1412
}
1364
1413
@@ -1421,13 +1470,11 @@ class Field extends ModelElement
1421
1470
1422
1471
@override
1423
1472
Set <String > get features {
1424
- Set <String > all_features = super .features;
1425
- all_features.addAll (annotations);
1426
-
1427
- /// final/const implies read-only, so don't display both strings.
1428
- if (readOnly && ! isFinal && ! isConst) all_features.add ('read-only' );
1429
- if (writeOnly) all_features.add ('write-only' );
1430
- if (readWrite) all_features.add ('read / write' );
1473
+ if (name == 'implicitGetterExplicitSetter' &&
1474
+ enclosingElement.name == 'ClassWithUnusualProperties' ) {
1475
+ 1 + 1 ;
1476
+ }
1477
+ Set <String > all_features = super .features..addAll (comboFeatures);
1431
1478
if (hasPublicGetter && hasPublicSetter) {
1432
1479
if (getter.isInherited && setter.isInherited) {
1433
1480
all_features.add ('inherited' );
@@ -1489,6 +1536,16 @@ class Field extends ModelElement
1489
1536
abstract class GetterSetterCombo implements ModelElement {
1490
1537
Accessor get getter;
1491
1538
1539
+ Set <String > get comboFeatures {
1540
+ Set <String > all_features = new Set ();
1541
+ if (hasExplicitGetter) all_features.addAll (getter.features);
1542
+ if (hasExplicitSetter) all_features.addAll (setter.features);
1543
+ if (readOnly && ! isFinal && ! isConst) all_features.add ('read-only' );
1544
+ if (writeOnly) all_features.add ('write-only' );
1545
+ if (readWrite) all_features.add ('read / write' );
1546
+ return all_features;
1547
+ }
1548
+
1492
1549
@override
1493
1550
ModelElement enclosingElement;
1494
1551
bool get isInherited;
@@ -1519,8 +1576,8 @@ abstract class GetterSetterCombo implements ModelElement {
1519
1576
1520
1577
/// Returns true if both accessors are synthetic.
1521
1578
bool get hasSyntheticAccessors {
1522
- if ((hasPublicGetter && getter.element. isSynthetic) ||
1523
- (hasPublicSetter && setter.element. isSynthetic)) {
1579
+ if ((hasPublicGetter && getter.isSynthetic) ||
1580
+ (hasPublicSetter && setter.isSynthetic)) {
1524
1581
return true ;
1525
1582
}
1526
1583
return false ;
@@ -1537,36 +1594,32 @@ abstract class GetterSetterCombo implements ModelElement {
1537
1594
if (_documentationFrom == null ) {
1538
1595
_documentationFrom = [];
1539
1596
if (hasPublicGetter) {
1540
- _documentationFrom.addAll (getter.documentationFrom.where ((e) =>
1541
- e.computeDocumentationComment != computeDocumentationComment));
1597
+ _documentationFrom.addAll (getter.documentationFrom);
1598
+ } else if (hasPublicSetter) {
1599
+ _documentationFrom.addAll (setter.documentationFrom);
1542
1600
}
1543
- if (hasPublicSetter)
1544
- _documentationFrom.addAll (setter.documentationFrom.where ((e) =>
1545
- e.computeDocumentationComment != computeDocumentationComment));
1546
1601
if (_documentationFrom.length == 0 ||
1547
1602
_documentationFrom.every ((e) => e.documentation == '' ))
1548
1603
_documentationFrom = computeDocumentationFrom;
1549
1604
}
1550
1605
return _documentationFrom;
1551
1606
}
1552
1607
1608
+ bool get hasAccessorsWithDocs =>
1609
+ (hasPublicGetter && getter.documentation.isNotEmpty ||
1610
+ hasPublicSetter && setter.documentation.isNotEmpty);
1611
+ bool get getterSetterBothAvailable => (hasPublicGetter &&
1612
+ getter.documentation.isNotEmpty &&
1613
+ hasPublicSetter &&
1614
+ setter.documentation.isNotEmpty);
1615
+
1553
1616
@override
1554
1617
String get oneLineDoc {
1555
1618
if (_oneLineDoc == null ) {
1556
- bool hasAccessorsWithDocs =
1557
- (hasPublicGetter && getter.oneLineDoc.isNotEmpty ||
1558
- hasPublicSetter && setter.oneLineDoc.isNotEmpty);
1559
1619
if (! hasAccessorsWithDocs) {
1560
1620
_oneLineDoc = _documentation.asOneLiner;
1561
1621
} else {
1562
1622
StringBuffer buffer = new StringBuffer ();
1563
- bool getterSetterBothAvailable = false ;
1564
- if (hasPublicGetter &&
1565
- getter.oneLineDoc.isNotEmpty &&
1566
- hasPublicSetter &&
1567
- setter.oneLineDoc.isNotEmpty) {
1568
- getterSetterBothAvailable = true ;
1569
- }
1570
1623
if (hasPublicGetter && getter.oneLineDoc.isNotEmpty) {
1571
1624
buffer.write ('${getter .oneLineDoc }' );
1572
1625
}
@@ -1582,7 +1635,7 @@ abstract class GetterSetterCombo implements ModelElement {
1582
1635
String get getterSetterDocumentationComment {
1583
1636
var buffer = new StringBuffer ();
1584
1637
1585
- if (hasPublicGetter && ! getter.element. isSynthetic) {
1638
+ if (hasPublicGetter && ! getter.isSynthetic) {
1586
1639
assert (getter.documentationFrom.length == 1 );
1587
1640
// We have to check against dropTextFrom here since documentationFrom
1588
1641
// doesn't yield the real elements for GetterSetterCombos.
@@ -1594,7 +1647,7 @@ abstract class GetterSetterCombo implements ModelElement {
1594
1647
}
1595
1648
}
1596
1649
1597
- if (hasPublicSetter && ! setter.element. isSynthetic) {
1650
+ if (hasPublicSetter && ! setter.isSynthetic) {
1598
1651
assert (setter.documentationFrom.length == 1 );
1599
1652
if (! config.dropTextFrom
1600
1653
.contains (setter.documentationFrom.first.element.library.name)) {
@@ -1629,14 +1682,16 @@ abstract class GetterSetterCombo implements ModelElement {
1629
1682
return null ;
1630
1683
}
1631
1684
1632
- bool get hasExplicitGetter => hasPublicGetter && ! getter.element. isSynthetic;
1685
+ bool get hasExplicitGetter => hasPublicGetter && ! getter.isSynthetic;
1633
1686
1634
- bool get hasExplicitSetter => hasPublicSetter && ! setter.element.isSynthetic;
1635
- bool get hasImplicitSetter => hasPublicSetter && setter.element.isSynthetic;
1687
+ bool get hasExplicitSetter => hasPublicSetter && ! setter.isSynthetic;
1688
+ bool get hasImplicitSetter => hasPublicSetter && setter.isSynthetic;
1689
+ bool get hasImplicitGetter => hasPublicGetter && getter.isSynthetic;
1636
1690
1637
1691
bool get hasGetter => getter != null ;
1638
1692
1639
- bool get hasNoGetterSetter => ! hasExplicitGetter && ! hasExplicitSetter;
1693
+ bool get hasNoGetterSetter => ! hasGetterOrSetter;
1694
+ bool get hasGetterOrSetter => hasExplicitGetter || hasExplicitSetter;
1640
1695
1641
1696
bool get hasSetter => setter != null ;
1642
1697
@@ -4714,15 +4769,7 @@ class TopLevelVariable extends ModelElement
4714
4769
String get kind => 'top-level property' ;
4715
4770
4716
4771
@override
4717
- Set <String > get features {
4718
- Set <String > all_features = super .features;
4719
-
4720
- /// final/const implies read-only, so don't display both strings.
4721
- if (readOnly && ! isFinal && ! isConst) all_features.add ('read-only' );
4722
- if (writeOnly) all_features.add ('write-only' );
4723
- if (readWrite) all_features.add ('read / write' );
4724
- return all_features;
4725
- }
4772
+ Set <String > get features => super .features..addAll (comboFeatures);
4726
4773
4727
4774
@override
4728
4775
String get computeDocumentationComment {
0 commit comments