Improvements and bug fix to group_files_by_directory()
Improvements and bug fix to group_files_by_directory()

- The method is documented as taking strings or Files. If a path wasn't covered
  by one of the extensions, the error path would end up calling f.path on the
  input, and that would have blown up if given a string, preventing the real
  error info from being reported.
- Flip the order of the file and extension loops so we can track if a file
  didn't match the extension. This lets us only collect the misses and
  not have to rebuild the entire depset to see then check to see if
  something wasn't processed and then go back and find it.
- Also by flipping the order of the loops, we can skip checking the remaining
  extensions as soon as the path was found to match.

PiperOrigin-RevId: 192150736

bazelbuild/rules_apple,bazelbuild/rules_apple,bazelbuild/rules_apple,bazelbuild/rules_apple