-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind-java-imports.sh
More file actions
executable file
·71 lines (63 loc) · 1.4 KB
/
find-java-imports.sh
File metadata and controls
executable file
·71 lines (63 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -e
SED_EXT=-r
case $(uname) in
Darwin*)
SED_EXT=-E
esac
export SED_EXT
BIN="$(cd "$(dirname "$0")" ; pwd)"
source "${BIN}/debug.sh"
SILENT='true'
TRACE='false'
if [ ".$1" = '.-v' ]
then
shift
SILENT='false'
if [ ".$1" = '.-v' ]
then
shift
TRACE='true'
set -x
fi
fi
declare -a SED_ARGS
if [ ".$1" = '.-f' ]
then
shift
SED_FILE="$1"
shift
debug 'SED_FILE' "${SED_FILE}"
OIFS="${IFS}"
IFS=$'\n'
declare -a SED_COMMANDS=($(<"${SED_FILE}"))
IFS="$OIFS"
for SED_COMMAND in "${SED_COMMANDS[@]}"
do
if [ -n "${SED_COMMAND}" -a ".${SED_COMMAND}" = ".${SED_COMMAND#\#}" ]
then
SED_ARGS[${#SED_ARGS[@]}]='-e'
SED_ARGS[${#SED_ARGS[@]}]="${SED_COMMAND}"
fi
done < "${SED_FILE}"
fi
debug 'SED_ARGS' "${SED_ARGS[@]}"
for D in "$@"
do
(
cd "${D}"
"${BIN}/sfind-grep.sh" '^import\>' * -name '*.java' \
| tr '/' '.' \
| sed "${SED_EXT}" \
-e '/^NO/s/[/][^/:]*:/:/' \
-e 's/:[0-9]*:/:/' \
-e '/:.*static/s/[.][^.]*$//' \
-e 's/:import */:/' \
-e 's/:static */:/' \
-e '/^NO/s/[.][^.]*$//' \
-e 's/^/:/' \
"${SED_ARGS[@]}" \
| sort | uniq \
| "${BIN}/filter-java-imports.py"
)
done