getMissingFieldsInHashCode function

Set<String> getMissingFieldsInHashCode(
  1. ClassDeclaration classDecl,
  2. MethodDeclaration hashCodeMethod
)

Returns the set of fields that are missing from an existing hashCode getter

Implementation

Set<String> getMissingFieldsInHashCode(
  ClassDeclaration classDecl,
  MethodDeclaration hashCodeMethod,
) {
  final classFieldNames = getClassFields(classDecl).map((field) => field.name);

  final hashCodeFieldNames = getFieldsInFunctionBody(hashCodeMethod);

  return classFieldNames
      .where((field) => !hashCodeFieldNames.contains(field))
      .toSet();
}