in scripts/sync_nullability_annotations.py [0:0]
def find_m_file_for_h_file(h_file_path, all_m_files):
# Check in the same folder
m_file_path = h_file_path.replace(".h", ".m")
if os.path.exists(m_file_path):
return m_file_path
# Check in the whole project
m_file_basename = os.path.basename(h_file_path).replace(".h", ".m")
# How many implementations file have this name?
matches = [f for f in all_m_files if f.endswith(m_file_basename)]
matches_count = len(matches)
if matches_count == 1:
return matches[0]
# Finding 0 matches is fine since many header files won't match a corresponding m file, ex TestTools-Bridging-Header.h
# but finding more than one match would be weird
if matches_count > 1:
print(f"More than one match found for {m_file_basename}. Matches: {matches}")
return None