fromAst static method

SwitchStatement? fromAst(
  1. Map? ast
)

Implementation

static SwitchStatement? fromAst(Map? ast) {
  if (ast != null &&
      ast['type'] == astNodeNameValue(AstRuntimeNodeName.SwitchStatement)) {
    var list = ast['body'] as List?;
    var caseList = list
            ?.map<SwitchCase?>((e) => SwitchCase.fromAst(e))
            .where((element) => element != null)
            .map((e) => e!)
            .toList() ??
        [];

    return SwitchStatement(
      AstRuntimeNodeParser.fromAst(ast['checkValue']),
      caseList,
    );
  }
  logDebug(_tag, 'Can not parse ast to SwitchStatement');
  return null;
}