generate function

Future generate(
  1. String path
)

Implementation

Future generate(String path) async {
  if (path.isEmpty) {
    stdout.writeln('No file found');
  } else {
    await _handleError(path);
    if (exitCode == 2) {
      try {
        var parseResult =
            parseFile(path: path, featureSet: FeatureSet.fromEnableFlags([]));
        var compilationUnit = parseResult.unit;
        //遍历AST
        var astData = compilationUnit.accept(YZWidgetAstVisitor());
        stdout.writeln(jsonEncode(astData));
        return Future.value(jsonEncode(astData));
      } catch (e) {
        stdout.writeln('Parse file error: ${e.toString()}');
      }
    }
  }
  return Future.value();
}