parseDataClass property

AnalysisResult get parseDataClass

Use JsonVisitor to collect Metadata from dart class.

Implementation

AnalysisResult get parseDataClass {
  final visitor = JsonVisitor();
  if (!_visitFile(visitor)) {
    return const AnalysisResult(parent: null);
  }

  _importRegex
      .allMatches(readAsStringSync())
      .map((e) => e.group(2))
      .map((directive) =>
          File("${parent.absolute.path}${Platform.pathSeparator}$directive"))
      .where((file) => file.existsSync())
      .toList()
      .forEach((element) => element._visitFile(visitor));

  final types = visitor.collected;
  final parentType = types.removeAt(0);
  final result = AnalysisResult(
      parent: parentType,
      childrenCustomTypes: types.whereType<CustomType>().toSet(),
      childrenEnumTypes: types.whereType<EnumType>().toSet());

  if (parentType is CustomType) {
    return result.normalizeParentTypeMembers;
  } else {
    return result;
  }
}