emitStatements method

  1. @override
String emitStatements(
  1. String moduleUrl,
  2. List<Statement> stmts
)
override

Implementation

@override
String emitStatements(
  String moduleUrl,
  List<o.Statement> stmts,
) {
  final srcParts = <String>[];
  final converter = _DartEmitterVisitor(
    moduleUrl,
    emitNullSafeSyntax: emitNullSafeSyntax,
  );
  final ctx = EmitterVisitorContext.createRoot();
  converter.visitAllStatements(stmts, ctx);
  converter.importsWithPrefixes.forEach((importedModuleUrl, prefix) {
    var importPath = getImportModulePath(moduleUrl, importedModuleUrl);
    srcParts.add(prefix.isEmpty
        ? "import '$importPath';"
        : "import '$importPath' as $prefix;");
  });
  srcParts.add(ctx.toSource());
  return srcParts.join('\n');
}