generateAstMapByCompilation function

Future<Map> generateAstMapByCompilation(
  1. CompilationUnit compilationUnit,
  2. String path, {
  3. String? sourcePath,
})

Implementation

Future<Map> generateAstMapByCompilation(CompilationUnit compilationUnit, String path, {String? sourcePath}) async {
  try {
    //遍历AST
    var astData = compilationUnit.accept(
        CustomAstVisitor(sourcePath, await File(path).readAsString()));
    return Future.value(astData);
  } catch (e) {
    stdout.writeln('Visit dart ast error: ${e.toString()}');
  }
  return Future.value();
}