LCOV - code coverage report
Current view: top level - src/generator_helpers - additional_extensions_generator_helper.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 25 0.0 %
Date: 2021-10-15 15:56:51 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:enum_assist/src/generator_helpers/helper_core.dart';
       2             : import 'package:enum_assist/src/templates/adaptive_template.dart';
       3             : import 'package:enum_assist/src/util/exceptions.dart';
       4             : 
       5             : /// A generator class for enum extensions
       6             : abstract class AdditionalExtensionsGeneratorHelper implements HelperCore {
       7             :   /// generates extensions code
       8           0 :   String generateAdditionalExtensions() {
       9           0 :     final buffer = StringBuffer();
      10             : 
      11           0 :     for (final extension in config.additionalExtensions) {
      12             :       try {
      13           0 :         buffer.write(
      14           0 :           AdaptiveTemplate(
      15           0 :             enumName,
      16           0 :             fields,
      17           0 :             methodName: extension.methodName,
      18           0 :             docComment: extension.getDocComment(),
      19           0 :             defaultValue: extension.defaultValue,
      20           0 :             methodType: extension.methodType,
      21           0 :             typeAsString: extension.valueType,
      22           0 :             getValue: (field) {
      23             :               final extensionValueConfig =
      24           0 :                   field.getExtensionValue(extension.valueClassType);
      25           0 :               final returnValue = extensionValueConfig?.value;
      26             : 
      27           0 :               if (!extension.isValueTypeNullable && returnValue == null) {
      28           0 :                 throw MissingExtensionValueException(
      29           0 :                   field.wholeName,
      30           0 :                   extension.methodName,
      31             :                 );
      32             :               }
      33             : 
      34             :               return returnValue;
      35             :             },
      36           0 :           ).toString(),
      37             :         );
      38           0 :       } on MissingExtensionValueException catch (e) {
      39           0 :         print(e); // ignore: avoid_print
      40             :         continue;
      41           0 :       } on NullValueException catch (e) {
      42           0 :         print(e); // ignore: avoid_print
      43             :         continue;
      44             :       }
      45             :     }
      46           0 :     return buffer.toString();
      47             :   }
      48             : }

Generated by: LCOV version 1.15