genTreeField method

void genTreeField (Contexts env, Output output, String fieldName, dynamic fieldValue)

Build the subtree for a fieldName, fieldValue

Implementation

void genTreeField(
    Contexts env, Output output, String fieldName, dynamic fieldValue) {
  final String tabStr = '  ' * env.tabLevel;

  if (fieldValue == null) {
  } else if (fieldValue is String) {
    if (fieldValue.isNotEmpty) {
      output.add('$tabStr.$fieldName: String ($fieldValue)\n');
    }
  } else if (fieldValue is num) {
    output.add('$tabStr.$fieldName: num (${fieldValue.toString()})\n');
  } else if (fieldValue is Node) {
    fieldValue.genTree(env, output, '.$fieldName: ');
  } else if (fieldValue is List && fieldValue.isEmpty) {
  } else if (fieldValue is List && fieldValue.isNotEmpty) {
    output.add('$tabStr.$fieldName: \n');
    env.tabLevel++;
    if (fieldValue.first is Node) {
      fieldValue.forEach((dynamic e) {
        // Node
        e.genTree(env, output, '- ');
      });
    } else if (fieldValue.first is MixinArgs) {
      fieldValue.forEach((dynamic a) {
        // MixinArgs
        a.genTree(env, output, '- ');
      });
    } else if (fieldValue.first is String) {
      final String tabStr = '  ' * env.tabLevel;
      fieldValue.forEach((dynamic s) {
        // String
        output.add('$tabStr- String ($s)\n');
      });
    } else if (fieldValue.first is num) {
      final String tabStr = '  ' * env.tabLevel;
      fieldValue.forEach((dynamic n) {
        // num
        output.add('$tabStr- num (${n.toString()})\n');
      });
    } else {
      output.add('*** field type not implemented ***');
    }
    env.tabLevel--;
  } else {
    output.add('$tabStr.$fieldName: ***********\n');
  }
}