visitElement method

  1. @override
String visitElement(
  1. ElementAst astNode, [
  2. StringBuffer? context
])
override

Visits all element ASTs.

Implementation

@override
String visitElement(ElementAst astNode, [StringBuffer? context]) {
  context ??= StringBuffer();
  context
    ..write('<')
    ..write(astNode.name);
  if (astNode.annotations.isNotEmpty) {
    context
      ..write(' ')
      ..writeAll(astNode.annotations.map(visitAnnotation), ' ');
  }
  if (astNode.attributes.isNotEmpty) {
    context
      ..write(' ')
      ..writeAll(astNode.attributes.map(visitAttribute), ' ');
  }
  if (astNode.events.isNotEmpty) {
    context
      ..write(' ')
      ..writeAll(astNode.events.map(visitEvent), ' ');
  }
  if (astNode.properties.isNotEmpty) {
    context
      ..write(' ')
      ..writeAll(astNode.properties.map(visitProperty), ' ');
  }
  if (astNode.references.isNotEmpty) {
    context
      ..write(' ')
      ..writeAll(astNode.references.map(visitReference), ' ');
  }
  if (astNode.bananas.isNotEmpty) {
    context
      ..write(' ')
      ..writeAll(astNode.bananas.map(visitBanana), ' ');
  }
  if (astNode.stars.isNotEmpty) {
    context
      ..write(' ')
      ..writeAll(astNode.stars.map(visitStar), ' ');
  }

  if (astNode.isSynthetic) {
    context.write(astNode.isVoidElement ? '/>' : '>');
  } else {
    context.write(astNode.endToken!.lexeme);
  }

  if (astNode.childNodes.isNotEmpty) {
    context.writeAll(astNode.childNodes.map((c) => c.accept(this)));
  }
  if (astNode.closeComplement != null) {
    context.write(visitCloseElement(astNode.closeComplement!));
  }
  return context.toString();
}