visitTypeDefinitionStatement method

  1. @override
void visitTypeDefinitionStatement(
  1. TypeDefinitionStatement statement
)
override

Implementation

@override
void visitTypeDefinitionStatement(TypeDefinitionStatement statement) {
  _context.addLast(statement);
  _currentDefinitionTypes = [];

  if (statement.variants case [final variant]) {
    variant.accept(this);
  } else {
    final topClass = ClassBuilder(name: statement.name.lexeme);

    _pushClass(topClass);
    topClass.sealed = true;

    final typeParameters = statement.typeParameters;

    if (typeParameters != null) {
      for (final parameter in typeParameters) {
        final type = resolver.annotations[parameter]!;
        _currentDefinitionTypes!.add(type);
        parameter.accept(this);
      }
    }

    _popClass();

    for (final variant in statement.variants) {
      variant.accept(this);
    }
  }

  _currentDefinitionTypes = null;
  _context.removeLast();
}