LCOV - code coverage report
Current view: top level - code_generators - code_generator.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 1 16 6.2 %
Date: 2021-10-28 15:15:49 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:widgetbook_generator/code_generators/properties/property.dart';
       2             : 
       3             : abstract class CodeGenerator {
       4           2 :   CodeGenerator({
       5             :     required this.instanceName,
       6             :     this.trailingComma = true,
       7             :     this.properties = const <Property>[],
       8             :   });
       9             : 
      10             :   final String instanceName;
      11             :   final bool trailingComma;
      12             :   final List<Property> properties;
      13             : 
      14           0 :   void addProperty(Property property) {
      15           0 :     properties.add(property);
      16             :   }
      17             : 
      18           0 :   String propertiesToCode() {
      19             :     final codeForProperties =
      20           0 :         properties.map((property) => property.toCode()).toList();
      21             : 
      22           0 :     return codeForProperties.join(',\n');
      23             :   }
      24             : 
      25           0 :   String toCode() {
      26           0 :     final stringBuffer = StringBuffer()
      27           0 :       ..write(instanceName)
      28           0 :       ..write('(')
      29           0 :       ..write(
      30           0 :         propertiesToCode(),
      31             :       );
      32             : 
      33           0 :     if (trailingComma && properties.isNotEmpty) {
      34           0 :       stringBuffer.write(',');
      35             :     }
      36             : 
      37           0 :     stringBuffer.write(')');
      38           0 :     return stringBuffer.toString();
      39             :   }
      40             : }

Generated by: LCOV version 1.15