diff --git a/lib/src/generator/templates.dart b/lib/src/generator/templates.dart index f358ab801b..02af10dabb 100644 --- a/lib/src/generator/templates.dart +++ b/lib/src/generator/templates.dart @@ -47,6 +47,7 @@ const _visibleTypes = { Constructor, DefinedElementType, Documentable, + ElementType, Enum, Extension, FeatureSet, diff --git a/lib/src/generator/templates.runtime_renderers.dart b/lib/src/generator/templates.runtime_renderers.dart index f524624927..4583151033 100644 --- a/lib/src/generator/templates.runtime_renderers.dart +++ b/lib/src/generator/templates.runtime_renderers.dart @@ -50,7 +50,8 @@ class _Renderer_Accessor extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.definingCombo, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['GetterSetterCombo']); }, ), 'element': Property( @@ -62,7 +63,9 @@ class _Renderer_Accessor extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, + getters: _invisibleGetters['PropertyAccessorElement']); }, ), 'enclosingCombo': Property( @@ -82,7 +85,8 @@ class _Renderer_Accessor extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.enclosingCombo, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['GetterSetterCombo']); }, ), 'enclosingElement': Property( @@ -242,7 +246,8 @@ class _Renderer_Accessor extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.originalMember, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['ExecutableMember']); }, ), 'referenceChildren': Property( @@ -255,7 +260,7 @@ class _Renderer_Accessor extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'referenceParents': Property( @@ -266,8 +271,10 @@ class _Renderer_Accessor extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), 'sourceCode': Property( @@ -331,7 +338,8 @@ class _Renderer_Annotation extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.annotation, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['ElementAnnotation']); }, ), 'hashCode': Property( @@ -342,7 +350,8 @@ class _Renderer_Annotation extends RendererBase { isNullValue: (CT_ c) => c.hashCode == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.hashCode, ast, r.template, parent: r); + return renderSimple(c.hashCode, ast, r.template, + parent: r, getters: _invisibleGetters['int']); }, ), 'isPublic': Property( @@ -429,7 +438,7 @@ class _Renderer_Annotation extends RendererBase { isNullValue: (CT_ c) => c.modelType == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.modelType, ast, r.template, + return _render_ElementType(c.modelType, ast, r.template, parent: r); }, ), @@ -443,7 +452,7 @@ class _Renderer_Annotation extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.packageGraph, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['PackageGraph']); }, ), 'parameterText': Property( @@ -524,7 +533,7 @@ class _Renderer_Callable extends RendererBase { isNullValue: (CT_ c) => c.returnType == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.returnType, ast, r.template, + return _render_ElementType(c.returnType, ast, r.template, parent: r); }, ), @@ -537,7 +546,8 @@ class _Renderer_Callable extends RendererBase { isNullValue: (CT_ c) => c.type == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.type, ast, r.template, parent: r); + return renderSimple(c.type, ast, r.template, + parent: r, getters: _invisibleGetters['FunctionType']); }, ), }); @@ -594,7 +604,7 @@ class _Renderer_Canonicalization extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.commentRefs, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'isCanonical': Property( @@ -830,7 +840,8 @@ class _Renderer_Category extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.categoryDefinition, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['CategoryDefinition']); }, ), 'categoryIndex': Property( @@ -842,7 +853,7 @@ class _Renderer_Category extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.categoryIndex, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['int']); }, ), 'categoryLabel': Property( @@ -887,7 +898,7 @@ class _Renderer_Category extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.commentRefs, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'config': Property( @@ -899,7 +910,9 @@ class _Renderer_Category extends RendererBase { isNullValue: (CT_ c) => c.config == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.config, ast, r.template, parent: r); + return renderSimple(c.config, ast, r.template, + parent: r, + getters: _invisibleGetters['DartdocOptionContext']); }, ), 'constants': Property( @@ -936,7 +949,7 @@ class _Renderer_Category extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.documentationFile, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['File']); }, ), 'documentationFrom': Property( @@ -947,8 +960,9 @@ class _Renderer_Category extends RendererBase { c, remainingNames, 'List'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.documentationFrom.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.documentationFrom.map((e) => renderSimple( + e, ast, r.template, + parent: r, getters: _invisibleGetters['Locatable'])); }, ), 'documentedWhere': Property( @@ -961,7 +975,8 @@ class _Renderer_Category extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.documentedWhere, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['DocumentLocation']); }, ), 'element': Property( @@ -972,7 +987,8 @@ class _Renderer_Category extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, getters: _invisibleGetters['Element']); }, ), 'enclosingElement': Property( @@ -992,7 +1008,7 @@ class _Renderer_Category extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.enclosingElement, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Warnable']); }, ), 'enclosingName': Property( @@ -1256,7 +1272,7 @@ class _Renderer_Category extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.packageGraph, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['PackageGraph']); }, ), 'properties': Property( @@ -1282,7 +1298,7 @@ class _Renderer_Category extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'referenceParents': Property( @@ -1293,8 +1309,10 @@ class _Renderer_Category extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), 'sortKey': Property( @@ -1662,7 +1680,8 @@ class _Renderer_Class extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, getters: _invisibleGetters['ClassElement']); }, ), 'enclosingElement': Property( @@ -2128,8 +2147,10 @@ class _Renderer_Class extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), 'superChain': Property( @@ -2518,7 +2539,8 @@ class _Renderer_CommentReferable extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, getters: _invisibleGetters['Element']); }, ), 'library': Property( @@ -2551,7 +2573,7 @@ class _Renderer_CommentReferable extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.packageGraph, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['PackageGraph']); }, ), 'referenceChildren': Property( @@ -2564,7 +2586,7 @@ class _Renderer_CommentReferable extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'referenceParents': Property( @@ -2575,8 +2597,10 @@ class _Renderer_CommentReferable extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), 'scope': Property( @@ -2587,7 +2611,8 @@ class _Renderer_CommentReferable extends RendererBase { isNullValue: (CT_ c) => c.scope == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.scope, ast, r.template, parent: r); + return renderSimple(c.scope, ast, r.template, + parent: r, getters: _invisibleGetters['Scope']); }, ), }); @@ -2632,7 +2657,8 @@ class _Renderer_Constructor extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.characterLocation, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['CharacterLocation']); }, ), 'element': Property( @@ -2644,7 +2670,9 @@ class _Renderer_Constructor extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, + getters: _invisibleGetters['ConstructorElement']); }, ), 'enclosingElement': Property( @@ -2863,7 +2891,7 @@ class _Renderer_Constructor extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'referenceParents': Property( @@ -2874,8 +2902,10 @@ class _Renderer_Constructor extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), 'shortName': Property( @@ -3210,8 +3240,9 @@ class _Renderer_Container extends RendererBase { c, remainingNames, 'Set'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.allElements.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.allElements.map((e) => renderSimple( + e, ast, r.template, + parent: r, getters: _invisibleGetters['Element'])); }, ), 'allModelElements': Property( @@ -3237,7 +3268,7 @@ class _Renderer_Container extends RendererBase { (CT_ c, RendererBase r, List ast) { return renderSimple( c.allModelElementsByNamePart, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'constantFields': Property( @@ -3674,7 +3705,7 @@ class _Renderer_Container extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'referenceParents': Property( @@ -3685,8 +3716,10 @@ class _Renderer_Container extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), 'staticAccessors': Property( @@ -3781,7 +3814,8 @@ class _Renderer_ContainerAccessor extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.characterLocation, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['CharacterLocation']); }, ), 'enclosingElement': Property( @@ -3913,8 +3947,9 @@ class _Renderer_ContainerMember extends RendererBase { c, remainingNames, 'Set'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.features.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.features.map((e) => renderSimple( + e, ast, r.template, + parent: r, getters: _invisibleGetters['Feature'])); }, ), 'isExtended': Property( @@ -3964,7 +3999,8 @@ class _Renderer_DefinedElementType extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, getters: _invisibleGetters['Element']); }, ), 'instantiatedType': Property( @@ -3976,7 +4012,7 @@ class _Renderer_DefinedElementType extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.instantiatedType, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['DartType']); }, ), 'isParameterType': Property( @@ -4042,7 +4078,7 @@ class _Renderer_DefinedElementType extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'referenceParents': Property( @@ -4053,8 +4089,10 @@ class _Renderer_DefinedElementType extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), 'typeArguments': Property( @@ -4065,8 +4103,8 @@ class _Renderer_DefinedElementType extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.typeArguments.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.typeArguments.map((e) => + _render_ElementType(e, ast, r.template, parent: r)); }, ), }); @@ -4109,7 +4147,9 @@ class _Renderer_Documentable extends RendererBase { isNullValue: (CT_ c) => c.config == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.config, ast, r.template, parent: r); + return renderSimple(c.config, ast, r.template, + parent: r, + getters: _invisibleGetters['DartdocOptionContext']); }, ), 'documentation': Property( @@ -4242,7 +4282,7 @@ class _Renderer_Documentable extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.packageGraph, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['PackageGraph']); }, ), }); @@ -4329,7 +4369,8 @@ class _Renderer_DocumentationComment renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.modelElementRenderer, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['ModelElementRenderer']); }, ), 'pathContext': Property( @@ -4341,7 +4382,7 @@ class _Renderer_DocumentationComment renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.pathContext, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Context']); }, ), 'sourceFileName': Property( @@ -4380,6 +4421,14 @@ class _Renderer_DocumentationComment } } +String _render_ElementType( + ElementType context, List ast, Template template, + {RendererBase parent}) { + var renderer = _Renderer_ElementType(context, parent, template); + renderer.renderBlock(ast); + return renderer.buffer.toString(); +} + class _Renderer_ElementType extends RendererBase { static final Map _propertyMapCache = {}; static Map> propertyMap() => @@ -4405,7 +4454,7 @@ class _Renderer_ElementType extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.instantiatedType, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['DartType']); }, ), 'isTypedef': Property( @@ -4505,7 +4554,7 @@ class _Renderer_ElementType extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.packageGraph, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['PackageGraph']); }, ), 'returnedFrom': Property( @@ -4524,7 +4573,7 @@ class _Renderer_ElementType extends RendererBase { isNullValue: (CT_ c) => c.returnedFrom == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.returnedFrom, ast, r.template, + return _render_ElementType(c.returnedFrom, ast, r.template, parent: r); }, ), @@ -4536,7 +4585,8 @@ class _Renderer_ElementType extends RendererBase { isNullValue: (CT_ c) => c.type == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.type, ast, r.template, parent: r); + return renderSimple(c.type, ast, r.template, + parent: r, getters: _invisibleGetters['DartType']); }, ), 'typeArguments': Property( @@ -4547,8 +4597,8 @@ class _Renderer_ElementType extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.typeArguments.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.typeArguments.map((e) => + _render_ElementType(e, ast, r.template, parent: r)); }, ), }); @@ -4785,7 +4835,7 @@ class _Renderer_Extension extends RendererBase { isNullValue: (CT_ c) => c.extendedType == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.extendedType, ast, r.template, + return _render_ElementType(c.extendedType, ast, r.template, parent: r); }, ), @@ -4895,7 +4945,7 @@ class _Renderer_Extension extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'typeParameters': Property( @@ -4964,7 +5014,7 @@ class _Renderer_ExtensionTarget extends RendererBase { isNullValue: (CT_ c) => c.modelType == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.modelType, ast, r.template, + return _render_ElementType(c.modelType, ast, r.template, parent: r); }, ), @@ -5363,7 +5413,7 @@ class _Renderer_Feature extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.sortGroup, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['int']); }, ), }); @@ -5444,7 +5494,7 @@ class _Renderer_FeatureSet extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.packageGraph, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['PackageGraph']); }, ), }); @@ -5529,8 +5579,9 @@ class _Renderer_Field extends RendererBase { c, remainingNames, 'Set'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.features.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.features.map((e) => renderSimple( + e, ast, r.template, + parent: r, getters: _invisibleGetters['Feature'])); }, ), 'field': Property( @@ -5542,7 +5593,8 @@ class _Renderer_Field extends RendererBase { isNullValue: (CT_ c) => c.field == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.field, ast, r.template, parent: r); + return renderSimple(c.field, ast, r.template, + parent: r, getters: _invisibleGetters['FieldElement']); }, ), 'fileName': Property( @@ -5715,7 +5767,7 @@ class _Renderer_Field extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.overriddenElement, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Inheritable']); }, ), 'setter': Property( @@ -6161,7 +6213,8 @@ class _Renderer_GetterSetterCombo extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.characterLocation, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['CharacterLocation']); }, ), 'constantInitializer': Property( @@ -6174,7 +6227,7 @@ class _Renderer_GetterSetterCombo extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.constantInitializer, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Expression']); }, ), 'constantValue': Property( @@ -6448,7 +6501,7 @@ class _Renderer_GetterSetterCombo extends RendererBase { isNullValue: (CT_ c) => c.modelType == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.modelType, ast, r.template, + return _render_ElementType(c.modelType, ast, r.template, parent: r); }, ), @@ -6508,7 +6561,7 @@ class _Renderer_GetterSetterCombo extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'referenceParents': Property( @@ -6519,8 +6572,10 @@ class _Renderer_GetterSetterCombo extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), 'setter': Property( @@ -6620,7 +6675,7 @@ class _Renderer_Indexable extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.overriddenDepth, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['int']); }, ), }); @@ -6673,8 +6728,9 @@ class _Renderer_Inheritable extends RendererBase { c, remainingNames, 'Set'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.features.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.features.map((e) => renderSimple( + e, ast, r.template, + parent: r, getters: _invisibleGetters['Feature'])); }, ), 'inheritance': Property( @@ -6719,7 +6775,7 @@ class _Renderer_Inheritable extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.overriddenDepth, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['int']); }, ), 'overriddenElement': Property( @@ -6739,7 +6795,7 @@ class _Renderer_Inheritable extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.overriddenElement, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Inheritable']); }, ), }); @@ -6956,7 +7012,8 @@ class _Renderer_Library extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.characterLocation, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['CharacterLocation']); }, ), 'classes': Property( @@ -6982,7 +7039,8 @@ class _Renderer_Library extends RendererBase { (CT_ c, RendererBase r, List ast) { return renderSimple( c.compilationUnitElement, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['CompilationUnitElement']); }, ), 'constants': Property( @@ -7027,7 +7085,9 @@ class _Renderer_Library extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, + getters: _invisibleGetters['LibraryElement']); }, ), 'enclosingElement': Property( @@ -7180,7 +7240,8 @@ class _Renderer_Library extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.inheritanceManager, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['InheritanceManager3']); }, ), 'isAnonymous': Property( @@ -7272,7 +7333,7 @@ class _Renderer_Library extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.modelElementsMap, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['HashMap']); }, ), 'modelElementsNameMap': Property( @@ -7285,7 +7346,7 @@ class _Renderer_Library extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.modelElementsNameMap, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['HashMap']); }, ), 'name': Property( @@ -7369,7 +7430,7 @@ class _Renderer_Library extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.packageMeta, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['PackageMeta']); }, ), 'packageName': Property( @@ -7402,7 +7463,7 @@ class _Renderer_Library extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.prefixToLibrary, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'properties': Property( @@ -7428,7 +7489,7 @@ class _Renderer_Library extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'referenceParents': Property( @@ -7439,8 +7500,10 @@ class _Renderer_Library extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), 'sdkLib': Property( @@ -7452,7 +7515,8 @@ class _Renderer_Library extends RendererBase { isNullValue: (CT_ c) => c.sdkLib == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.sdkLib, ast, r.template, parent: r); + return renderSimple(c.sdkLib, ast, r.template, + parent: r, getters: _invisibleGetters['SdkLibrary']); }, ), 'typeSystem': Property( @@ -7465,7 +7529,7 @@ class _Renderer_Library extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.typeSystem, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['TypeSystem']); }, ), 'typedefs': Property( @@ -7580,7 +7644,7 @@ class _Renderer_LibraryContainer extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.packageGraph, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['PackageGraph']); }, ), 'publicLibraries': Property( @@ -7844,8 +7908,9 @@ class _Renderer_Locatable extends RendererBase { c, remainingNames, 'List'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.documentationFrom.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.documentationFrom.map((e) => renderSimple( + e, ast, r.template, + parent: r, getters: _invisibleGetters['Locatable'])); }, ), 'documentationIsLocal': Property( @@ -7988,7 +8053,7 @@ class _Renderer_MarkdownFileDocumentation renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.documentationFile, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['File']); }, ), 'documentedWhere': Property( @@ -8001,7 +8066,8 @@ class _Renderer_MarkdownFileDocumentation renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.documentedWhere, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['DocumentLocation']); }, ), 'hasDocumentation': Property( @@ -8121,7 +8187,8 @@ class _Renderer_Method extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.characterLocation, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['CharacterLocation']); }, ), 'element': Property( @@ -8133,7 +8200,8 @@ class _Renderer_Method extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, getters: _invisibleGetters['MethodElement']); }, ), 'enclosingElement': Property( @@ -8165,8 +8233,9 @@ class _Renderer_Method extends RendererBase { c, remainingNames, 'Set'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.features.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.features.map((e) => renderSimple( + e, ast, r.template, + parent: r, getters: _invisibleGetters['Feature'])); }, ), 'filePath': Property( @@ -8305,7 +8374,8 @@ class _Renderer_Method extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.originalMember, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['ExecutableMember']); }, ), 'overriddenElement': Property( @@ -8338,7 +8408,7 @@ class _Renderer_Method extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'referenceParents': Property( @@ -8349,8 +8419,10 @@ class _Renderer_Method extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), 'typeParameters': Property( @@ -8919,7 +8991,8 @@ class _Renderer_ModelElement extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.characterLocation, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['CharacterLocation']); }, ), 'commentRefs': Property( @@ -8932,7 +9005,7 @@ class _Renderer_ModelElement extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.commentRefs, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'compilationUnitElement': Property( @@ -8946,7 +9019,8 @@ class _Renderer_ModelElement extends RendererBase { (CT_ c, RendererBase r, List ast) { return renderSimple( c.compilationUnitElement, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['CompilationUnitElement']); }, ), 'computeDocumentationFrom': Property( @@ -8970,7 +9044,9 @@ class _Renderer_ModelElement extends RendererBase { isNullValue: (CT_ c) => c.config == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.config, ast, r.template, parent: r); + return renderSimple(c.config, ast, r.template, + parent: r, + getters: _invisibleGetters['DartdocOptionContext']); }, ), 'definingLibrary': Property( @@ -9086,7 +9162,8 @@ class _Renderer_ModelElement extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, getters: _invisibleGetters['Element']); }, ), 'exportedInLibraries': Property( @@ -9129,8 +9206,9 @@ class _Renderer_ModelElement extends RendererBase { c, remainingNames, 'Set'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.features.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.features.map((e) => renderSimple( + e, ast, r.template, + parent: r, getters: _invisibleGetters['Feature'])); }, ), 'featuresAsString': Property( @@ -9630,7 +9708,7 @@ class _Renderer_ModelElement extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.modelNode, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['ModelNode']); }, ), 'name': Property( @@ -9681,7 +9759,7 @@ class _Renderer_ModelElement extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.originalMember, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Member']); }, ), 'package': Property( @@ -9714,7 +9792,7 @@ class _Renderer_ModelElement extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.packageGraph, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['PackageGraph']); }, ), 'parameters': Property( @@ -9738,7 +9816,7 @@ class _Renderer_ModelElement extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.pathContext, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Context']); }, ), 'sourceCode': Property( @@ -9842,7 +9920,9 @@ class _Renderer_ModelFunction extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, + getters: _invisibleGetters['FunctionElement']); }, ), 'isStatic': Property( @@ -9913,7 +9993,9 @@ class _Renderer_ModelFunctionTyped extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, + getters: _invisibleGetters['FunctionTypedElement']); }, ), 'enclosingElement': Property( @@ -10032,7 +10114,7 @@ class _Renderer_ModelFunctionTyped extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'referenceParents': Property( @@ -10043,8 +10125,10 @@ class _Renderer_ModelFunctionTyped extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), 'typeParameters': Property( @@ -10183,7 +10267,8 @@ class _Renderer_Object extends RendererBase { isNullValue: (CT_ c) => c.hashCode == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.hashCode, ast, r.template, parent: r); + return renderSimple(c.hashCode, ast, r.template, + parent: r, getters: _invisibleGetters['int']); }, ), 'runtimeType': Property( @@ -10195,7 +10280,7 @@ class _Renderer_Object extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.runtimeType, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Type']); }, ), }); @@ -10417,7 +10502,7 @@ class _Renderer_Package extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.commentRefs, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'config': Property( @@ -10429,7 +10514,9 @@ class _Renderer_Package extends RendererBase { isNullValue: (CT_ c) => c.config == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.config, ast, r.template, parent: r); + return renderSimple(c.config, ast, r.template, + parent: r, + getters: _invisibleGetters['DartdocOptionContext']); }, ), 'containerOrder': Property( @@ -10515,7 +10602,7 @@ class _Renderer_Package extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.documentationFile, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['File']); }, ), 'documentationFrom': Property( @@ -10526,8 +10613,9 @@ class _Renderer_Package extends RendererBase { c, remainingNames, 'List'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.documentationFrom.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.documentationFrom.map((e) => renderSimple( + e, ast, r.template, + parent: r, getters: _invisibleGetters['Locatable'])); }, ), 'documentedCategories': Property( @@ -10564,7 +10652,8 @@ class _Renderer_Package extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.documentedWhere, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['DocumentLocation']); }, ), 'element': Property( @@ -10575,7 +10664,8 @@ class _Renderer_Package extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, getters: _invisibleGetters['Element']); }, ), 'enclosingElement': Property( @@ -10595,7 +10685,7 @@ class _Renderer_Package extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.enclosingElement, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Warnable']); }, ), 'enclosingName': Property( @@ -10881,7 +10971,7 @@ class _Renderer_Package extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.nameToCategory, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'oneLineDoc': Property( @@ -10934,7 +11024,7 @@ class _Renderer_Package extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.packageGraph, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['PackageGraph']); }, ), 'packageMeta': Property( @@ -10947,7 +11037,7 @@ class _Renderer_Package extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.packageMeta, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['PackageMeta']); }, ), 'packagePath': Property( @@ -10992,7 +11082,7 @@ class _Renderer_Package extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'referenceParents': Property( @@ -11003,8 +11093,10 @@ class _Renderer_Package extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), 'toolInvocationIndex': Property( @@ -11016,7 +11108,7 @@ class _Renderer_Package extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.toolInvocationIndex, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['int']); }, ), 'usedAnimationIdsByHref': Property( @@ -11030,7 +11122,7 @@ class _Renderer_Package extends RendererBase { (CT_ c, RendererBase r, List ast) { return renderSimple( c.usedAnimationIdsByHref, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'version': Property( @@ -11317,7 +11409,9 @@ class _Renderer_Parameter extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, + getters: _invisibleGetters['ParameterElement']); }, ), 'enclosingElement': Property( @@ -11376,7 +11470,8 @@ class _Renderer_Parameter extends RendererBase { isNullValue: (CT_ c) => c.hashCode == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.hashCode, ast, r.template, parent: r); + return renderSimple(c.hashCode, ast, r.template, + parent: r, getters: _invisibleGetters['int']); }, ), 'href': Property( @@ -11487,7 +11582,7 @@ class _Renderer_Parameter extends RendererBase { isNullValue: (CT_ c) => c.modelType == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.modelType, ast, r.template, + return _render_ElementType(c.modelType, ast, r.template, parent: r); }, ), @@ -11501,7 +11596,8 @@ class _Renderer_Parameter extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.originalMember, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['ParameterMember']); }, ), 'referenceChildren': Property( @@ -11514,7 +11610,7 @@ class _Renderer_Parameter extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'referenceParents': Property( @@ -11525,8 +11621,10 @@ class _Renderer_Parameter extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), }); @@ -11929,7 +12027,8 @@ class _Renderer_SourceCodeMixin extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.characterLocation, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['CharacterLocation']); }, ), 'element': Property( @@ -11940,7 +12039,8 @@ class _Renderer_SourceCodeMixin extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, getters: _invisibleGetters['Element']); }, ), 'hasSourceCode': Property( @@ -11979,7 +12079,7 @@ class _Renderer_SourceCodeMixin extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.modelNode, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['ModelNode']); }, ), 'sourceCode': Property( @@ -12040,8 +12140,9 @@ class _Renderer_String extends RendererBase { self.renderSimpleVariable(c, remainingNames, 'List'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.codeUnits.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.codeUnits.map((e) => renderSimple( + e, ast, r.template, + parent: r, getters: _invisibleGetters['int'])); }, ), 'hashCode': Property( @@ -12052,7 +12153,8 @@ class _Renderer_String extends RendererBase { isNullValue: (CT_ c) => c.hashCode == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.hashCode, ast, r.template, parent: r); + return renderSimple(c.hashCode, ast, r.template, + parent: r, getters: _invisibleGetters['int']); }, ), 'isEmpty': Property( @@ -12077,7 +12179,8 @@ class _Renderer_String extends RendererBase { isNullValue: (CT_ c) => c.length == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.length, ast, r.template, parent: r); + return renderSimple(c.length, ast, r.template, + parent: r, getters: _invisibleGetters['int']); }, ), 'runes': Property( @@ -12087,8 +12190,8 @@ class _Renderer_String extends RendererBase { self.renderSimpleVariable(c, remainingNames, 'Runes'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.runes.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.runes.map((e) => renderSimple(e, ast, r.template, + parent: r, getters: _invisibleGetters['int'])); }, ), }); @@ -12280,7 +12383,8 @@ class _Renderer_TemplateData renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.htmlOptions, ast, r.template, - parent: r); + parent: r, + getters: _invisibleGetters['TemplateOptions']); }, ), 'includeVersion': Property( @@ -13306,8 +13410,9 @@ class _Renderer_TopLevelVariable extends RendererBase { c, remainingNames, 'Set'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.features.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.features.map((e) => renderSimple( + e, ast, r.template, + parent: r, getters: _invisibleGetters['Feature'])); }, ), 'fileName': Property( @@ -13503,7 +13608,7 @@ class _Renderer_TypeParameter extends RendererBase { isNullValue: (CT_ c) => c.boundType == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.boundType, ast, r.template, + return _render_ElementType(c.boundType, ast, r.template, parent: r); }, ), @@ -13516,7 +13621,9 @@ class _Renderer_TypeParameter extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, + getters: _invisibleGetters['TypeParameterElement']); }, ), 'enclosingElement': Property( @@ -13647,7 +13754,7 @@ class _Renderer_TypeParameter extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'referenceParents': Property( @@ -13658,8 +13765,10 @@ class _Renderer_TypeParameter extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), }); @@ -13827,7 +13936,7 @@ class _Renderer_Typedef extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.aliasedType, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['DartType']); }, ), 'asCallable': Property( @@ -13860,7 +13969,9 @@ class _Renderer_Typedef extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, + getters: _invisibleGetters['TypeAliasElement']); }, ), 'enclosingElement': Property( @@ -14005,7 +14116,7 @@ class _Renderer_Typedef extends RendererBase { isNullValue: (CT_ c) => c.modelType == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.modelType, ast, r.template, + return _render_ElementType(c.modelType, ast, r.template, parent: r); }, ), @@ -14039,7 +14150,7 @@ class _Renderer_Typedef extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'referenceParents': Property( @@ -14050,8 +14161,10 @@ class _Renderer_Typedef extends RendererBase { c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), 'typeParameters': Property( @@ -14305,7 +14418,8 @@ class _Renderer_UndefinedElementType isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, getters: _invisibleGetters['Element']); }, ), 'instantiatedType': Property( @@ -14317,7 +14431,7 @@ class _Renderer_UndefinedElementType renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.instantiatedType, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['DartType']); }, ), 'isPublic': Property( @@ -14396,7 +14510,7 @@ class _Renderer_UndefinedElementType renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.referenceChildren, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Map']); }, ), 'referenceParents': Property( @@ -14407,8 +14521,10 @@ class _Renderer_UndefinedElementType c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.referenceParents.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.referenceParents.map((e) => renderSimple( + e, ast, r.template, + parent: r, + getters: _invisibleGetters['CommentReferable'])); }, ), 'typeArguments': Property( @@ -14419,8 +14535,8 @@ class _Renderer_UndefinedElementType c, remainingNames, 'Iterable'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.typeArguments.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.typeArguments.map((e) => + _render_ElementType(e, ast, r.template, parent: r)); }, ), }); @@ -14453,7 +14569,8 @@ class _Renderer_Warnable extends RendererBase { isNullValue: (CT_ c) => c.element == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.element, ast, r.template, parent: r); + return renderSimple(c.element, ast, r.template, + parent: r, getters: _invisibleGetters['Element']); }, ), 'enclosingElement': Property( @@ -14473,7 +14590,7 @@ class _Renderer_Warnable extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.enclosingElement, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Warnable']); }, ), 'package': Property( @@ -14511,3 +14628,701 @@ class _Renderer_Warnable extends RendererBase { } } } + +const _invisibleGetters = { + 'CategoryDefinition': { + 'hashCode', + 'runtimeType', + 'name', + 'documentationMarkdown', + 'displayName' + }, + 'CharacterLocation': { + 'hashCode', + 'runtimeType', + 'lineNumber', + 'columnNumber' + }, + 'ClassElement': { + 'hashCode', + 'runtimeType', + 'accessors', + 'allSupertypes', + 'constructors', + 'displayName', + 'enclosingElement', + 'fields', + 'hasNonFinalField', + 'hasStaticMember', + 'interfaces', + 'isAbstract', + 'isDartCoreObject', + 'isEnum', + 'isMixin', + 'isMixinApplication', + 'isValidMixin', + 'methods', + 'mixins', + 'name', + 'superclassConstraints', + 'supertype', + 'thisType', + 'unnamedConstructor' + }, + 'CommentReferable': { + 'scope', + 'referenceChildren', + 'referenceParents', + 'library', + 'element', + 'packageGraph' + }, + 'CompilationUnitElement': { + 'hashCode', + 'runtimeType', + 'accessors', + 'enclosingElement', + 'enums', + 'extensions', + 'functions', + 'functionTypeAliases', + 'hasLoadLibraryFunction', + 'lineInfo', + 'mixins', + 'session', + 'topLevelVariables', + 'typeAliases', + 'types' + }, + 'ConstructorElement': { + 'hashCode', + 'runtimeType', + 'declaration', + 'displayName', + 'enclosingElement', + 'isConst', + 'isDefaultConstructor', + 'isFactory', + 'name', + 'nameEnd', + 'periodOffset', + 'redirectedConstructor', + 'returnType' + }, + 'Context': {'hashCode', 'runtimeType', 'style', 'current', 'separator'}, + 'DartType': { + 'hashCode', + 'runtimeType', + 'aliasArguments', + 'aliasElement', + 'displayName', + 'element', + 'isBottom', + 'isDartAsyncFuture', + 'isDartAsyncFutureOr', + 'isDartCoreBool', + 'isDartCoreDouble', + 'isDartCoreFunction', + 'isDartCoreInt', + 'isDartCoreIterable', + 'isDartCoreList', + 'isDartCoreMap', + 'isDartCoreNull', + 'isDartCoreNum', + 'isDartCoreObject', + 'isDartCoreSet', + 'isDartCoreString', + 'isDartCoreSymbol', + 'isDynamic', + 'isVoid', + 'name', + 'nullabilitySuffix' + }, + 'DartdocOptionContext': { + 'hashCode', + 'runtimeType', + 'optionSet', + 'context', + 'allowTools', + 'ambiguousReexportScorerMinConfidence', + 'autoIncludeDependencies', + 'categoryOrder', + 'categories', + 'dropTextFrom', + 'examplePathPrefix', + 'exclude', + 'excludePackages', + 'experimentalReferenceLookup', + 'flutterRoot', + 'hideSdkText', + 'include', + 'includeExternal', + 'includeSource', + 'injectHtml', + 'excludeFooterVersion', + 'tools', + 'inputDir', + 'linkToRemote', + 'linkToUrl', + 'nodoc', + 'output', + 'packageMeta', + 'packageOrder', + 'sdkDocs', + 'resourceProvider', + 'sdkDir', + 'showUndocumentedCategories', + 'topLevelPackageMeta', + 'useCategories', + 'validateLinks', + 'showStats', + 'format', + 'useBaseHref' + }, + 'DocumentLocation': {'hashCode', 'runtimeType', 'index'}, + 'Element': { + 'hashCode', + 'runtimeType', + 'context', + 'declaration', + 'displayName', + 'documentationComment', + 'enclosingElement', + 'hasAlwaysThrows', + 'hasDeprecated', + 'hasDoNotStore', + 'hasFactory', + 'hasInternal', + 'hasIsTest', + 'hasIsTestGroup', + 'hasJS', + 'hasLiteral', + 'hasMustCallSuper', + 'hasNonVirtual', + 'hasOptionalTypeArgs', + 'hasOverride', + 'hasProtected', + 'hasRequired', + 'hasSealed', + 'hasVisibleForTemplate', + 'hasVisibleForTesting', + 'id', + 'isPrivate', + 'isPublic', + 'isSynthetic', + 'kind', + 'library', + 'location', + 'metadata', + 'name', + 'nameLength', + 'nameOffset', + 'session', + 'source' + }, + 'ElementAnnotation': { + 'hashCode', + 'runtimeType', + 'constantEvaluationErrors', + 'element', + 'isAlwaysThrows', + 'isDeprecated', + 'isDoNotStore', + 'isFactory', + 'isImmutable', + 'isInternal', + 'isIsTest', + 'isIsTestGroup', + 'isJS', + 'isLiteral', + 'isMustCallSuper', + 'isNonVirtual', + 'isOptionalTypeArgs', + 'isOverride', + 'isProtected', + 'isProxy', + 'isRequired', + 'isSealed', + 'isTarget', + 'isVisibleForTemplate', + 'isVisibleForTesting' + }, + 'ExecutableMember': { + 'hashCode', + 'runtimeType', + 'isLegacy', + 'context', + 'declaration', + 'displayName', + 'documentationComment', + 'enclosingElement', + 'hasAlwaysThrows', + 'hasDeprecated', + 'hasDoNotStore', + 'hasFactory', + 'hasInternal', + 'hasIsTest', + 'hasIsTestGroup', + 'hasJS', + 'hasLiteral', + 'hasMustCallSuper', + 'hasNonVirtual', + 'hasOptionalTypeArgs', + 'hasOverride', + 'hasProtected', + 'hasRequired', + 'hasSealed', + 'hasVisibleForTemplate', + 'hasVisibleForTesting', + 'id', + 'isPrivate', + 'isPublic', + 'isSynthetic', + 'kind', + 'library', + 'librarySource', + 'location', + 'metadata', + 'name', + 'nameLength', + 'nameOffset', + 'session', + 'source', + 'substitution', + 'typeParameters', + 'hasImplicitReturnType', + 'isAbstract', + 'isAsynchronous', + 'isExternal', + 'isGenerator', + 'isOperator', + 'isSimplyBounded', + 'isStatic', + 'isSynchronous', + 'parameters', + 'returnType', + 'type' + }, + 'Expression': { + 'hashCode', + 'runtimeType', + 'inConstantContext', + 'isAssignable', + 'precedence', + 'staticParameterElement', + 'staticType', + 'unParenthesized' + }, + 'Feature': { + 'hashCode', + 'runtimeType', + 'featurePrefix', + 'sortGroup', + 'name', + 'linkedName', + 'linkedNameWithParameters', + 'isPublic' + }, + 'FieldElement': { + 'hashCode', + 'runtimeType', + 'declaration', + 'isAbstract', + 'isCovariant', + 'isEnumConstant', + 'isExternal', + 'isStatic' + }, + 'File': { + 'hashCode', + 'runtimeType', + 'changes', + 'lengthSync', + 'modificationStamp' + }, + 'FunctionElement': {'hashCode', 'runtimeType', 'isEntryPoint'}, + 'FunctionType': { + 'hashCode', + 'runtimeType', + 'element', + 'namedParameterTypes', + 'normalParameterNames', + 'normalParameterTypes', + 'optionalParameterNames', + 'optionalParameterTypes', + 'parameters', + 'returnType', + 'typeArguments', + 'typeFormals' + }, + 'FunctionTypedElement': { + 'hashCode', + 'runtimeType', + 'parameters', + 'returnType', + 'type' + }, + 'GetterSetterCombo': { + 'getter', + 'setter', + 'annotations', + 'allAccessors', + 'comboFeatures', + 'isInherited', + 'constantInitializer', + 'characterLocation', + 'constantValue', + 'constantValueTruncated', + 'constantValueBase', + 'hasPublicGetter', + 'hasPublicSetter', + 'isPublic', + 'documentationFrom', + 'hasAccessorsWithDocs', + 'getterSetterBothAvailable', + 'oneLineDoc', + 'getterSetterDocumentationComment', + 'modelType', + 'isCallable', + 'parameters', + 'linkedParamsNoMetadata', + 'hasExplicitGetter', + 'hasExplicitSetter', + 'hasGetter', + 'hasNoGetterSetter', + 'hasGetterOrSetter', + 'hasSetter', + 'hasPublicGetterNoSetter', + 'arrow', + 'readOnly', + 'readWrite', + 'writeOnly', + 'referenceChildren', + 'referenceParents', + 'enclosingElement' + }, + 'HashMap': {'hashCode', 'runtimeType'}, + 'Inheritable': { + 'isInherited', + 'isCovariant', + 'features', + 'canonicalLibrary', + 'inheritance', + 'overriddenElement', + 'isOverride', + 'overriddenDepth' + }, + 'InheritanceManager3': {'hashCode', 'runtimeType'}, + 'LibraryElement': { + 'hashCode', + 'runtimeType', + 'definingCompilationUnit', + 'entryPoint', + 'exportedLibraries', + 'exportNamespace', + 'exports', + 'featureSet', + 'hasExtUri', + 'hasLoadLibraryFunction', + 'identifier', + 'importedLibraries', + 'imports', + 'isBrowserApplication', + 'isDartAsync', + 'isDartCore', + 'isInSdk', + 'isNonNullableByDefault', + 'languageVersion', + 'loadLibraryFunction', + 'parts', + 'prefixes', + 'publicNamespace', + 'scope', + 'session', + 'topLevelElements', + 'typeProvider', + 'typeSystem', + 'units' + }, + 'Locatable': { + 'hashCode', + 'runtimeType', + 'documentationFrom', + 'documentationIsLocal', + 'fullyQualifiedName', + 'href', + 'location' + }, + 'Map': { + 'hashCode', + 'runtimeType', + 'entries', + 'keys', + 'values', + 'length', + 'isEmpty', + 'isNotEmpty' + }, + 'Member': { + 'hashCode', + 'runtimeType', + 'isLegacy', + 'context', + 'declaration', + 'displayName', + 'documentationComment', + 'enclosingElement', + 'hasAlwaysThrows', + 'hasDeprecated', + 'hasDoNotStore', + 'hasFactory', + 'hasInternal', + 'hasIsTest', + 'hasIsTestGroup', + 'hasJS', + 'hasLiteral', + 'hasMustCallSuper', + 'hasNonVirtual', + 'hasOptionalTypeArgs', + 'hasOverride', + 'hasProtected', + 'hasRequired', + 'hasSealed', + 'hasVisibleForTemplate', + 'hasVisibleForTesting', + 'id', + 'isPrivate', + 'isPublic', + 'isSynthetic', + 'kind', + 'library', + 'librarySource', + 'location', + 'metadata', + 'name', + 'nameLength', + 'nameOffset', + 'session', + 'source', + 'substitution' + }, + 'MethodElement': {'hashCode', 'runtimeType', 'declaration'}, + 'ModelElementRenderer': {'hashCode', 'runtimeType'}, + 'ModelNode': { + 'hashCode', + 'runtimeType', + 'commentRefs', + 'element', + 'resourceProvider', + 'sourceCode' + }, + 'PackageGraph': { + 'hashCode', + 'runtimeType', + 'specialClasses', + 'allImplementorsAdded', + 'allExtensionsAdded', + 'allLibraries', + 'allConstructedModelElements', + 'allInheritableElements', + 'packageMeta', + 'config', + 'rendererFactory', + 'packageMetaProvider', + 'hasEmbedderSdk', + 'packageMap', + 'sdk', + 'allLibrariesAdded', + 'name', + 'element', + 'implementors', + 'documentedExtensions', + 'extensions', + 'findRefElementCache', + 'defaultPackageName', + 'defaultPackage', + 'hasFooterVersion', + 'packageGraph', + 'resourceProvider', + 'sdkLibrarySources', + 'packageWarningCounter', + 'packages', + 'publicPackages', + 'localPackages', + 'documentedPackages', + 'libraryElementReexportedBy', + 'allHrefs', + 'libraries', + 'publicLibraries', + 'localLibraries', + 'localPublicLibraries', + 'inheritThrough', + 'invisibleAnnotations', + 'allModelElements', + 'allLocalModelElements', + 'allCanonicalModelElements', + 'referenceChildren', + 'referenceParents' + }, + 'PackageMeta': { + 'hashCode', + 'runtimeType', + 'dir', + 'resourceProvider', + 'pathContext', + 'isSdk', + 'needsPubGet', + 'requiresFlutter', + 'name', + 'hostedAt', + 'version', + 'description', + 'homepage', + 'isValid', + 'resolvedDir' + }, + 'ParameterElement': { + 'hashCode', + 'runtimeType', + 'declaration', + 'defaultValueCode', + 'hasDefaultValue', + 'isCovariant', + 'isInitializingFormal', + 'isNamed', + 'isNotOptional', + 'isOptional', + 'isOptionalNamed', + 'isOptionalPositional', + 'isPositional', + 'isRequiredNamed', + 'isRequiredPositional', + 'name', + 'parameterKind', + 'parameters', + 'typeParameters' + }, + 'ParameterMember': { + 'hashCode', + 'runtimeType', + 'isLegacy', + 'context', + 'declaration', + 'displayName', + 'documentationComment', + 'enclosingElement', + 'hasAlwaysThrows', + 'hasDeprecated', + 'hasDoNotStore', + 'hasFactory', + 'hasInternal', + 'hasIsTest', + 'hasIsTestGroup', + 'hasJS', + 'hasLiteral', + 'hasMustCallSuper', + 'hasNonVirtual', + 'hasOptionalTypeArgs', + 'hasOverride', + 'hasProtected', + 'hasRequired', + 'hasSealed', + 'hasVisibleForTemplate', + 'hasVisibleForTesting', + 'id', + 'isPrivate', + 'isPublic', + 'isSynthetic', + 'kind', + 'library', + 'librarySource', + 'location', + 'metadata', + 'name', + 'nameLength', + 'nameOffset', + 'session', + 'source', + 'substitution', + 'hasImplicitType', + 'isConst', + 'isConstantEvaluated', + 'isFinal', + 'isLate', + 'isStatic', + 'type', + 'typeParameters', + 'defaultValueCode', + 'hasDefaultValue', + 'isCovariant', + 'isInitializingFormal', + 'parameterKind', + 'parameters' + }, + 'PropertyAccessorElement': { + 'hashCode', + 'runtimeType', + 'correspondingGetter', + 'correspondingSetter', + 'declaration', + 'enclosingElement', + 'isGetter', + 'isSetter', + 'variable' + }, + 'Scope': {'hashCode', 'runtimeType'}, + 'SdkLibrary': { + 'hashCode', + 'runtimeType', + 'category', + 'isDart2JsLibrary', + 'isDocumented', + 'isImplementation', + 'isInternal', + 'isShared', + 'isVmLibrary', + 'path', + 'shortName' + }, + 'TemplateOptions': { + 'hashCode', + 'runtimeType', + 'relCanonicalPrefix', + 'toolVersion', + 'useBaseHref', + 'customHeaderContent', + 'customFooterContent', + 'customInnerFooterText' + }, + 'Type': {'hashCode', 'runtimeType'}, + 'TypeAliasElement': { + 'hashCode', + 'runtimeType', + 'aliasedElement', + 'aliasedType', + 'enclosingElement', + 'name' + }, + 'TypeParameterElement': { + 'hashCode', + 'runtimeType', + 'bound', + 'declaration', + 'displayName', + 'name' + }, + 'TypeSystem': {'hashCode', 'runtimeType'}, + 'Warnable': {'element', 'enclosingElement', 'package'}, + 'int': { + 'hashCode', + 'runtimeType', + 'isNaN', + 'isNegative', + 'isInfinite', + 'isFinite', + 'sign', + 'isEven', + 'isOdd', + 'bitLength' + }, +}; diff --git a/lib/src/mustachio/renderer_base.dart b/lib/src/mustachio/renderer_base.dart index 56cbc9eafb..13af3517e6 100644 --- a/lib/src/mustachio/renderer_base.dart +++ b/lib/src/mustachio/renderer_base.dart @@ -147,7 +147,14 @@ abstract class RendererBase { /// The output buffer into which [context] is rendered, using a template. final buffer = StringBuffer(); - RendererBase(this.context, this.parent, this._template); + final Set _invisibleGetters; + + RendererBase( + this.context, + this.parent, + this._template, { + Set invisibleGetters = const {}, + }) : _invisibleGetters = invisibleGetters; Template get template => _template; @@ -172,21 +179,28 @@ abstract class RendererBase { if (names.length == 1 && names.single == '.') { return context.toString(); } - var property = getProperty(names.first); - if (property != null) { - var remainingNames = [...names.skip(1)]; - try { - return property.renderVariable(context, property, remainingNames); - } on PartialMustachioResolutionError catch (e) { - // The error thrown by [Property.renderVariable] does not have all of - // the names required for a decent error. We throw a new error here. - throw MustachioResolutionError(node.keySpan.message( - "Failed to resolve '${e.name}' on ${e.contextType} while resolving " - '$remainingNames as a property chain on any types in the context ' - "chain: $contextChainString, after first resolving '${names.first}' " - 'to a property on $T')); + var firstName = names.first; + try { + var property = getProperty(firstName); + if (property != null) { + var remainingNames = [...names.skip(1)]; + try { + return property.renderVariable(context, property, remainingNames); + } on PartialMustachioResolutionError catch (e) { + // The error thrown by [Property.renderVariable] does not have all of + // the names required for a decent error. We throw a new error here. + throw MustachioResolutionError(node.keySpan.message( + "Failed to resolve '${e.name}' on ${e.contextType} while " + 'resolving $remainingNames as a property chain on any types in ' + 'the context chain: $contextChainString, after first resolving ' + "'$firstName' to a property on $T")); + } } - } else if (parent != null) { + } on _MustachioResolutionErrorWithoutSpan catch (e) { + throw MustachioResolutionError(node.keySpan.message(e.message)); + } + + if (parent != null) { return parent.getFields(node); } else { throw MustachioResolutionError(node.keySpan.message( @@ -268,31 +282,52 @@ abstract class RendererBase { } String renderSimple(Object context, List ast, Template template, - {RendererBase parent}) { - var renderer = SimpleRenderer(context, parent, template); + {@required RendererBase parent, Set getters}) { + var renderer = SimpleRenderer(context, parent, template, getters); renderer.renderBlock(ast); return renderer.buffer.toString(); } class SimpleRenderer extends RendererBase { - SimpleRenderer(Object context, RendererBase parent, Template template) - : super(context, parent, template); + SimpleRenderer( + Object context, + RendererBase parent, + Template template, + Set invisibleGetters, + ) : super(context, parent, template, invisibleGetters: invisibleGetters); @override - Property getProperty(String key) => null; + Property getProperty(String key) { + if (_invisibleGetters.contains(key)) { + throw MustachioResolutionError(_failedKeyVisibilityMessage(key)); + } else { + return null; + } + } @override String getFields(Variable node) { var names = node.key; - if (names.length == 1 && names.single == '.') { + var firstName = node.key.first; + if (names.length == 1 && firstName == '.') { return context.toString(); - } - if (parent != null) { + } else if (_invisibleGetters.contains(firstName)) { + throw MustachioResolutionError(_failedKeyVisibilityMessage(firstName)); + } else if (parent != null) { return parent.getFields(node); } else { return 'null'; } } + + String _failedKeyVisibilityMessage(String name) { + var type = context.runtimeType; + return '[$name] is a getter on $type, which is not visible to Mustache. ' + 'To render [$name] on $type, make it visible to Mustache via the ' + '`visibleTypes` parameter on `@Renderer`; to render [$name] on a ' + 'different type up in the context stack, perhaps provide [$name] via ' + 'a different name.'; + } } /// An individual property of objects of type [T], including functions for @@ -346,7 +381,7 @@ class Property { class MustachioResolutionError extends Error { final String message; - MustachioResolutionError([this.message]); + MustachioResolutionError(this.message); @override String toString() => 'MustachioResolutionError: $message'; @@ -362,6 +397,17 @@ class PartialMustachioResolutionError extends Error { PartialMustachioResolutionError(this.name, this.contextType); } +/// A Mustachio resolution error which is thrown in a position where the AST +/// node is not known. +/// +/// This error should be caught and "re-thrown" as a [MustachioResolutionError] +/// with a message derived from a [SourceSpan]. +class _MustachioResolutionErrorWithoutSpan extends Error { + final String message; + + _MustachioResolutionErrorWithoutSpan(this.message); +} + extension MapExtensions on Map> { Property getValue(String name) { if (containsKey(name)) { diff --git a/test/mustachio/foo.dart b/test/mustachio/foo.dart index ead8841876..08d046155d 100644 --- a/test/mustachio/foo.dart +++ b/test/mustachio/foo.dart @@ -17,6 +17,7 @@ class Foo extends FooBase { @override Baz baz; Property1 p1; + int length; } class Bar { diff --git a/test/mustachio/foo.runtime_renderers.dart b/test/mustachio/foo.runtime_renderers.dart index 1461d6da75..aa602d3f85 100644 --- a/test/mustachio/foo.runtime_renderers.dart +++ b/test/mustachio/foo.runtime_renderers.dart @@ -89,7 +89,8 @@ class Renderer_Bar extends RendererBase { isNullValue: (CT_ c) => c.s2 == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.s2, ast, r.template, parent: r); + return renderSimple(c.s2, ast, r.template, + parent: r, getters: _invisibleGetters['String']); }, ), }); @@ -210,8 +211,20 @@ class Renderer_Foo extends RendererBase { self.renderSimpleVariable(c, remainingNames, 'List'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.l1.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.l1.map((e) => renderSimple(e, ast, r.template, + parent: r, getters: _invisibleGetters['int'])); + }, + ), + 'length': Property( + getValue: (CT_ c) => c.length, + renderVariable: (CT_ c, Property self, + List remainingNames) => + self.renderSimpleVariable(c, remainingNames, 'int'), + isNullValue: (CT_ c) => c.length == null, + renderValue: + (CT_ c, RendererBase r, List ast) { + return renderSimple(c.length, ast, r.template, + parent: r, getters: _invisibleGetters['int']); }, ), 'p1': Property( @@ -241,7 +254,8 @@ class Renderer_Foo extends RendererBase { isNullValue: (CT_ c) => c.s1 == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.s1, ast, r.template, parent: r); + return renderSimple(c.s1, ast, r.template, + parent: r, getters: _invisibleGetters['String']); }, ), }); @@ -352,7 +366,8 @@ class Renderer_Object extends RendererBase { isNullValue: (CT_ c) => c.hashCode == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.hashCode, ast, r.template, parent: r); + return renderSimple(c.hashCode, ast, r.template, + parent: r, getters: _invisibleGetters['int']); }, ), 'runtimeType': Property( @@ -364,7 +379,7 @@ class Renderer_Object extends RendererBase { renderValue: (CT_ c, RendererBase r, List ast) { return renderSimple(c.runtimeType, ast, r.template, - parent: r); + parent: r, getters: _invisibleGetters['Type']); }, ), }); @@ -457,7 +472,8 @@ class Renderer_Property2 extends RendererBase { isNullValue: (CT_ c) => c.s == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.s, ast, r.template, parent: r); + return renderSimple(c.s, ast, r.template, + parent: r, getters: _invisibleGetters['String']); }, ), }); @@ -499,7 +515,8 @@ class Renderer_Property3 extends RendererBase { isNullValue: (CT_ c) => c.s == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.s, ast, r.template, parent: r); + return renderSimple(c.s, ast, r.template, + parent: r, getters: _invisibleGetters['String']); }, ), }); @@ -517,3 +534,28 @@ class Renderer_Property3 extends RendererBase { } } } + +const _invisibleGetters = { + 'String': { + 'hashCode', + 'runtimeType', + 'length', + 'isEmpty', + 'isNotEmpty', + 'codeUnits', + 'runes' + }, + 'Type': {'hashCode', 'runtimeType'}, + 'int': { + 'hashCode', + 'runtimeType', + 'isNaN', + 'isNegative', + 'isInfinite', + 'isFinite', + 'sign', + 'isEven', + 'isOdd', + 'bitLength' + }, +}; diff --git a/test/mustachio/runtime_renderer_builder_test.dart b/test/mustachio/runtime_renderer_builder_test.dart index 25909d6f41..4d0bf7a507 100644 --- a/test/mustachio/runtime_renderer_builder_test.dart +++ b/test/mustachio/runtime_renderer_builder_test.dart @@ -131,8 +131,8 @@ class Baz {} self.renderSimpleVariable(c, remainingNames, 'List'), renderIterable: (CT_ c, RendererBase r, List ast) { - return c.l1.map( - (e) => renderSimple(e, ast, r.template, parent: r)); + return c.l1.map((e) => renderSimple(e, ast, r.template, + parent: r, getters: _invisibleGetters['int'])); }, ), ''')); @@ -148,7 +148,8 @@ class Baz {} isNullValue: (CT_ c) => c.s1 == null, renderValue: (CT_ c, RendererBase r, List ast) { - return renderSimple(c.s1, ast, r.template, parent: r); + return renderSimple(c.s1, ast, r.template, + parent: r, getters: _invisibleGetters['String']); }, ), ''')); diff --git a/test/mustachio/runtime_renderer_render_test.dart b/test/mustachio/runtime_renderer_render_test.dart index 561a923032..0c93c7a74f 100644 --- a/test/mustachio/runtime_renderer_render_test.dart +++ b/test/mustachio/runtime_renderer_render_test.dart @@ -25,12 +25,13 @@ void main() { test('property map contains all public getters', () { var propertyMap = Renderer_Foo.propertyMap(); - expect(propertyMap.keys, hasLength(7)); + expect(propertyMap.keys, hasLength(8)); expect(propertyMap['b1'], isNotNull); expect(propertyMap['s1'], isNotNull); expect(propertyMap['l1'], isNotNull); expect(propertyMap['baz'], isNotNull); expect(propertyMap['p1'], isNotNull); + expect(propertyMap['length'], isNotNull); expect(propertyMap['hashCode'], isNotNull); expect(propertyMap['runtimeType'], isNotNull); }); @@ -516,6 +517,36 @@ line 1, column 9 of ${fooTemplateFile.path}: Failed to resolve 's2' as a propert contains('Failed to resolve [length] property chain on String')))); }); + test('Renderer throws when a SimpleRenderer variable key shadows another key', + () async { + var fooTemplateFile = getFile('/project/foo.mustache') + ..writeAsStringSync('Text {{#s1}} {{length}} {{/s1}}'); + var fooTemplate = await Template.parse(fooTemplateFile); + var foo = Foo()..s1 = 'String'; + expect( + () => renderFoo(foo, fooTemplate), + throwsA(const TypeMatcher().having( + (e) => e.message, + 'message', + contains('[length] is a getter on String, which is not visible to ' + 'Mustache.')))); + }); + + test('Renderer throws when a SimpleRenderer section key shadows another key', + () async { + var fooTemplateFile = getFile('/project/foo.mustache') + ..writeAsStringSync('Text {{#s1}} {{#length}}Inner{{/length}} {{/s1}}'); + var fooTemplate = await Template.parse(fooTemplateFile); + var foo = Foo()..s1 = 'String'; + expect( + () => renderFoo(foo, fooTemplate), + throwsA(const TypeMatcher().having( + (e) => e.message, + 'message', + contains('[length] is a getter on String, which is not visible to ' + 'Mustache.')))); + }); + test('Template parser throws when it cannot read a template', () async { var barTemplateFile = getFile('/project/src/bar.mustache'); expect( diff --git a/tool/mustachio/codegen_runtime_renderer.dart b/tool/mustachio/codegen_runtime_renderer.dart index 5faff4a21a..cdf15ec7b9 100644 --- a/tool/mustachio/codegen_runtime_renderer.dart +++ b/tool/mustachio/codegen_runtime_renderer.dart @@ -59,6 +59,9 @@ class RuntimeRenderersBuilder { /// Whether renderer classes are public. This should only be true for testing. final bool _rendererClassesArePublic; + /// A mapping of getter names on classes which are not "visible." + final Map> _invisibleGetters = {}; + RuntimeRenderersBuilder(this._sourceUri, this._typeProvider, this._typeSystem, this._allVisibleElements, {bool rendererClassesArePublic = false}) @@ -106,6 +109,8 @@ import '${p.basename(_sourceUri.path)}'; } } + _writeInvisibleGetters(); + return _buffer.toString(); } @@ -509,12 +514,23 @@ renderVariable: // TODO(srawlins): Find a solution for this. We can track all of the // concrete types substituted for `E` for example. if (innerType is! TypeParameterType) { - var rendererName = - _typeToRenderFunctionName[innerType.element] ?? 'renderSimple'; + var renderFunctionName = _typeToRenderFunctionName[innerType.element]; + String renderCall; + if (renderFunctionName == null) { + var typeName = innerType.element.name; + if (innerType is InterfaceType) { + _invisibleGetters.putIfAbsent( + typeName, () => innerType.element.allAccessorNames); + } + renderCall = 'renderSimple(e, ast, r.template, parent: r, ' + "getters: _invisibleGetters['$typeName'])"; + } else { + renderCall = '$renderFunctionName(e, ast, r.template, parent: r)'; + } _buffer.writeln(''' renderIterable: ($_contextTypeVariable c, RendererBase<$_contextTypeVariable> r, List ast) { - return c.$getterName.map((e) => $rendererName(e, ast, r.template, parent: r)); + return c.$getterName.map((e) => $renderCall); }, '''); } @@ -526,20 +542,45 @@ renderIterable: // TODO(srawlins): Find a solution for this. We can track all of the // concrete types substituted for `E` for example. if (getterName is! TypeParameterType) { - var rendererName = - _typeToRenderFunctionName[getterType.element] ?? 'renderSimple'; + var renderFunctionName = _typeToRenderFunctionName[getterType.element]; + String renderCall; + if (renderFunctionName == null) { + var typeName = getterType.element.name; + if (getterType is InterfaceType) { + _invisibleGetters.putIfAbsent( + typeName, () => getterType.element.allAccessorNames); + } + renderCall = + 'renderSimple(c.$getterName, ast, r.template, parent: r, ' + "getters: _invisibleGetters['$typeName'])"; + } else { + renderCall = + '$renderFunctionName(c.$getterName, ast, r.template, parent: r)'; + } _buffer.writeln(''' isNullValue: ($_contextTypeVariable c) => c.$getterName == null, renderValue: ($_contextTypeVariable c, RendererBase<$_contextTypeVariable> r, List ast) { - return $rendererName(c.$getterName, ast, r.template, parent: r); + return $renderCall; }, '''); } } _buffer.writeln('),'); } + + /// Writes the mapping of invisible getters, used to report simple renderer + /// errors. + void _writeInvisibleGetters() { + _buffer.write('const _invisibleGetters = {'); + for (var class_ in _invisibleGetters.keys.toList()..sort()) { + _buffer.write("'$class_':"); + var getters = _invisibleGetters[class_]; + _buffer.write('{${getters.map((e) => "'$e'").join(', ')}},'); + } + _buffer.write('};'); + } } /// A container with the information needed to distinguish one @@ -624,3 +665,15 @@ class _RendererInfo { ]); } } + +extension on ClassElement { + /// Returns a set of the names of all accessors on this [ClassElement], including supertypes. + Set get allAccessorNames { + return { + ...?supertype?.element?.allAccessorNames, + ...accessors + .where((e) => e.isPublic && !e.isStatic && !e.isSetter) + .map((e) => e.name), + }; + } +}