1JAVA_REMOVE_IMPORTS(7) Jurand JAVA_REMOVE_IMPORTS(7)
2
3
4
6 java_remove_imports - remove import statements from Java source files
7
9 %java_remove_imports [optional flags] <matcher>... [file path]...
10
12 This macro removes import statements from Java source files. The script
13 matches all non-whitespace content following the import [static]
14 statement against all patterns provided via the -p flag and all simple
15 class names against names provided by the -n flag.
16
17 File path arguments are handled the following way:
18
19 • Symlinks are ignored
20
21 • Regular files are handled regardless of the file name
22
23 • Directories are traversed recursively and all .java files are
24 handled
25
26 Arguments can be specified in arbitrary order.
27
28 Matcher is one of:
29
30 -n <name>
31 Simple class name to be matched against the simple names of
32 imported symbols. Names are matched for exact equality. Can be
33 specified multiple times.
34
35 -p <pattern>
36 Regex patterns to be matched against imported symbols. Each
37 imported symbol found in the code is matched against each pattern.
38 Can be specified multiple times.
39
40 Optional flags:
41
42 -s, --strict
43 Fail if any of the user provided arguments were redundant.
44
46 Example of usage:
47
48 %java_remove_imports src -n Nullable
49
50 Examples of patterns:
51
52 • Import statements present in Java source file:
53
54 1) import java.lang.Runnable;
55 2) import java.util.List;
56 3) import static java.util.*;
57 4) import static java.lang.String.valueOf;
58 5) import com.google.common.util.concurrent.Service;
59
60 • Names used to match:
61
62 Name 'Runnable' matches 1)
63 Name 'String' matches 4)
64
65 Name 'util' does not match anything.
66 Name '*' does not match anything.
67 Name 'valueOf' does not match anything.
68
69 • Patterns used to match:
70
71 Pattern 'Runnable' matches 1).
72 Pattern '[*]' matches 3).
73 Pattern 'java[.]util' matches 2), 3).
74 Pattern 'util' matches 2), 3), 5).
75 Patterns 'java', 'java.*' match 1) - 4).
76
77 Pattern 'static' does not match anything.
78
80 Written by Marián Konček.
81
83 Bugs should be reported through the issue tracker at GitHub:
84 https://github.com/fedora-java/jurand/issues.
85
87 java_remove_annotations(7).
88
89
90
91JURAND 07/20/2023 JAVA_REMOVE_IMPORTS(7)