Support --skip-removing-unused-imports in google-java-format-diff.py
Fixes #495
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/google-java-format/pull/495 from taesu82:patch-1 91e32d443cf8159a72f05a38146dd9b5d4bf550c
PiperOrigin-RevId: 315560436
diff --git a/scripts/google-java-format-diff.py b/scripts/google-java-format-diff.py
index 4c6724b..1abd037 100755
--- a/scripts/google-java-format-diff.py
+++ b/scripts/google-java-format-diff.py
@@ -57,6 +57,8 @@
help='use AOSP style instead of Google Style (4-space indentation)')
parser.add_argument('--skip-sorting-imports', action='store_true',
help='do not fix the import order')
+ parser.add_argument('--skip-removing-unused-imports', action='store_true',
+ help='do not remove ununsed imports')
parser.add_argument('-b', '--binary', help='path to google-java-format binary')
parser.add_argument('--google-java-format-jar', metavar='ABSOLUTE_PATH', default=None,
help='use a custom google-java-format jar')
@@ -112,6 +114,8 @@
command.append('--aosp')
if args.skip_sorting_imports:
command.append('--skip-sorting-imports')
+ if args.skip_removing_unused_imports:
+ command.append('--skip-removing-unused-imports')
command.extend(lines)
command.append(filename)
p = subprocess.Popen(command, stdout=subprocess.PIPE,