Skip to content

Commit 9704ed4

Browse files
committed
Fix deduplication logic
1 parent 3310ee9 commit 9704ed4

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tool/mustachio/codegen_runtime_renderer.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,11 @@ String _simpleResolveErrorMessage(List<String> key, String type) =>
106106
while (_typesToProcess.isNotEmpty) {
107107
var info = _typesToProcess.removeFirst();
108108

109-
if (info.isFullRenderer && !builtRenderers.contains(info._contextClass)) {
109+
if (info.isFullRenderer) {
110+
var buildOnlyPublicFunction =
111+
builtRenderers.contains(info._contextClass);
112+
_buildRenderer(info, buildOnlyPublicFunction: buildOnlyPublicFunction);
110113
builtRenderers.add(info._contextClass);
111-
_buildRenderer(info);
112114
}
113115
}
114116

@@ -218,14 +220,19 @@ String _simpleResolveErrorMessage(List<String> key, String type) =>
218220
return _isVisibleToMustache(element.supertype.element);
219221
}
220222

221-
/// Builds both the render function and the renderer class for [renderer].
223+
/// Builds render functions and the renderer class for [renderer].
222224
///
223225
/// The function and the class are each written as Dart code to [_buffer].
224226
///
225227
/// If [renderer] also specifies a `publicApiFunctionName`, then a public API
226228
/// function (which renders a context object using a template file at a path,
227229
/// rather than an AST) is also written.
228-
void _buildRenderer(_RendererInfo renderer) {
230+
///
231+
/// If [buildOnlyPublicFunction] is true, then the private render function and
232+
/// renderer classes are not built, having been built for a different
233+
/// [_RendererInfo].
234+
void _buildRenderer(_RendererInfo renderer,
235+
{@required bool buildOnlyPublicFunction}) {
229236
var typeName = renderer._typeName;
230237
var typeWithVariables = '$typeName${renderer._typeVariablesString}';
231238

@@ -238,6 +245,8 @@ String ${renderer.publicApiFunctionName}${renderer._typeParametersString}(
238245
''');
239246
}
240247

248+
if (buildOnlyPublicFunction) return;
249+
241250
// Write out the render function.
242251
_buffer.writeln('''
243252
String ${renderer._renderFunctionName}${renderer._typeParametersString}(

0 commit comments

Comments
 (0)