Index: pkg/analyzer/test/src/summary/element_text.dart |
diff --git a/pkg/analyzer/test/src/summary/element_text.dart b/pkg/analyzer/test/src/summary/element_text.dart |
index 24e5794ee50de03d8e1ccc30762e746292fffec5..f3aa81fbccc01e518f98cfab0cb4513c79ba7b9c 100644 |
--- a/pkg/analyzer/test/src/summary/element_text.dart |
+++ b/pkg/analyzer/test/src/summary/element_text.dart |
@@ -53,8 +53,13 @@ void applyCheckElementTextReplacements() { |
* actual text with the given [expected] one. |
*/ |
void checkElementText(LibraryElement library, String expected, |
- {bool withOffsets: false}) { |
- var writer = new _ElementWriter(withOffsets: withOffsets); |
+ {bool withOffsets: false, |
+ bool withSyntheticAccessors: false, |
+ bool withSyntheticFields: false}) { |
+ var writer = new _ElementWriter( |
+ withOffsets: withOffsets, |
+ withSyntheticAccessors: withSyntheticAccessors, |
+ withSyntheticFields: withSyntheticFields); |
writer.writeLibraryElement(library); |
String actualText = writer.buffer.toString(); |
@@ -117,14 +122,21 @@ void checkElementText(LibraryElement library, String expected, |
class _ElementWriter { |
final bool withOffsets; |
final bool withConstElements; |
+ final bool withSyntheticAccessors; |
+ final bool withSyntheticFields; |
final StringBuffer buffer = new StringBuffer(); |
- _ElementWriter({this.withOffsets: false, this.withConstElements: true}); |
+ _ElementWriter( |
+ {this.withOffsets: false, |
+ this.withConstElements: true, |
+ this.withSyntheticAccessors, |
+ this.withSyntheticFields: false}); |
bool isDynamicType(DartType type) => type is DynamicTypeImpl; |
- bool isEnumElement(Element e) { |
- return e is ClassElement && e.isEnum; |
+ bool isEnumField(Element e) { |
+ Element enclosing = e.enclosingElement; |
+ return enclosing is ClassElement && enclosing.isEnum; |
} |
void newLineIfNotEmpty() { |
@@ -175,7 +187,7 @@ class _ElementWriter { |
buffer.writeln(' {'); |
- e.fields.forEach(writeFieldElement); |
+ e.fields.forEach(writePropertyInducingElement); |
e.accessors.forEach(writePropertyAccessorElement); |
if (e.isEnum) { |
@@ -410,22 +422,6 @@ class _ElementWriter { |
} |
} |
- void writeFieldElement(FieldElement e) { |
- if (e.isSynthetic && !isEnumElement(e.enclosingElement)) { |
- return; |
- } |
- |
- writeDocumentation(e, ' '); |
- writeMetadata(e, ' ', '\n'); |
- |
- buffer.write(' '); |
- |
- writeIf(e.isStatic, 'static '); |
- writeIf(e is FieldElementImpl && e.isCovariant, 'covariant '); |
- |
- writePropertyInducingElement(e); |
- } |
- |
void writeFunctionElement(FunctionElement e) { |
writeIf(e.isExternal, 'external '); |
@@ -623,7 +619,7 @@ class _ElementWriter { |
} |
void writePropertyAccessorElement(PropertyAccessorElement e) { |
- if (e.isSynthetic) { |
+ if (e.isSynthetic && !withSyntheticAccessors) { |
return; |
} |
@@ -633,10 +629,12 @@ class _ElementWriter { |
buffer.write(' '); |
+ writeIf(e.isSynthetic, 'synthetic '); |
writeIf(e.isStatic, 'static '); |
} else { |
writeDocumentation(e); |
writeMetadata(e, '', '\n'); |
+ writeIf(e.isSynthetic, 'synthetic '); |
} |
writeIf(e.isExternal, 'external '); |
@@ -669,9 +667,27 @@ class _ElementWriter { |
} |
void writePropertyInducingElement(PropertyInducingElement e) { |
+ if (e.isSynthetic && !withSyntheticFields && !isEnumField(e)) { |
+ return; |
+ } |
+ |
DartType type = e.type; |
expect(type, isNotNull); |
+ if (e.enclosingElement is ClassElement) { |
+ writeDocumentation(e, ' '); |
+ writeMetadata(e, ' ', '\n'); |
+ |
+ buffer.write(' '); |
+ |
+ writeIf(e.isSynthetic, 'synthetic '); |
+ writeIf(e.isStatic, 'static '); |
+ writeIf(e is FieldElementImpl && e.isCovariant, 'covariant '); |
+ } else { |
+ writeDocumentation(e); |
+ writeMetadata(e, '', '\n'); |
+ } |
+ |
writeIf(e.isFinal, 'final '); |
writeIf(e.isConst, 'const '); |
writeType2(type); |
@@ -693,15 +709,6 @@ class _ElementWriter { |
buffer.writeln(';'); |
} |
- void writeTopLevelVariableElement(TopLevelVariableElement e) { |
- if (e.isSynthetic) { |
- return; |
- } |
- writeDocumentation(e); |
- writeMetadata(e, '', '\n'); |
- writePropertyInducingElement(e); |
- } |
- |
void writeType(DartType type) { |
if (type is InterfaceType) { |
buffer.write(type.element.name); |
@@ -739,7 +746,7 @@ class _ElementWriter { |
e.functionTypeAliases.forEach(writeFunctionTypeAliasElement); |
e.enums.forEach(writeClassElement); |
e.types.forEach(writeClassElement); |
- e.topLevelVariables.forEach(writeTopLevelVariableElement); |
+ e.topLevelVariables.forEach(writePropertyInducingElement); |
e.accessors.forEach(writePropertyAccessorElement); |
e.functions.forEach(writeFunctionElement); |
} |