1JAVA_REMOVE_ANNOTATI(7) Java Packages Tools JAVA_REMOVE_ANNOTATI(7)
2
3
4
6 java_remove_annotations - remove imports and annotations from Java
7 source files
8
10 %java_remove_annotations [list of file paths]... [-n <list of class
11 names>...] [-p <list of patterns>...]
12
14 This macro removes import statements as well as usage of annotations
15 from Java source files. The does the same as java_remove_imports and on
16 top of that finds all uses of annotations and matches the content
17 between the @ symbol and either ending with whitespace or with an
18 opening parethesis (.
19
20 In case of match, the script also removes the block of paretheses that
21 follows the matched annotation, if it is present.
22
23 If the file path is a directory, recursively finds all Java source
24 files inside. If not specified, runs in the current working directory.
25
26 -n
27 List of simple class names to be matched against the simple names
28 of imported symbols. Names are matched for exact equality.
29
30 -p
31 List of patterns to be matched against found annotations. The
32 script uses the string.find function from Lua to match each found
33 annotation against every pattern.
34
36 Example of usage:
37
38 %java_remove_annotations -n Nullable
39
40 Examples of patterns:
41
42 • Annotations present in Java source file:
43
44 1) @SuppressWarnings
45 2) @SuppressFBWarnings(value = {"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
46 3) @org.junit.Test
47 4) @org.junit.jupiter.api.Test
48
49 • Names used to match:
50
51 Name '@SuppressWarnings' matches 1)
52 Name 'Test' matches 3), 4).
53
54 Name 'junit' does not match anything.
55
56 • Patterns used to match:
57
58 Pattern 'SuppressWarnings' matches 1).
59 Pattern 'Suppress' matches 1), 2).
60 Pattern 'org[.]junit[.]Test' matches 3).
61 Pattern 'junit' matches 3), 4).
62
63 Pattern '@SuppressWarnings' does not match anything.
64 Pattern 'EI_EXPOSE_REP' does not match anything.
65
67 Written by Marián Konček.
68
70 Bugs should be reported through Java Packages Tools issue tracker at
71 Github: https://github.com/fedora-java/javapackages/issues.
72
74 java_remove_imports(7).
75
76
77
78JAVAPACKAGES 01/25/2023 JAVA_REMOVE_ANNOTATI(7)