Debian Codegraph @

c++-rename-class-and-file

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 oldname=$1
4 newname=$2
5
6 if [scip-shell system . . `[`. $# != 2 ]; then
7 echoscip-shell system . . echo. "Usage: $0 old_classname new_classname"
8 exit 1
9 fi
10
11 if [scip-shell system . . `[`. -f $oldname.cpp ]; then
12 oldfile=$oldname
13 newfile=$newname
14 else
15 oldfile=`echoscip-shell system . . echo. $oldname | trscip-shell system . . tr. A-Z a-z`
16 newfile=`echoscip-shell system . . echo. $newname | trscip-shell system . . tr. A-Z a-z`
17 fi
18
19 findupscip-shell shell shell-project 0.0.0 findup().() {
20 parg="$1"
21 _hit=""
22 spwd="$PWD"
23 if testscip-shell system . . test. -z "$parg"; then return 1; fi
24
25 while ! testscip-shell system . . test. -e "$parg"; do
26 cd ..
27 if testscip-shell system . . test. "$PWD" = "/scip-shell filesystem . . `/`."; then
28 cd "$spwd"
29 return 1
30 fi
31 done
32 _hit="$PWD/$parg"
33 cd "$spwd"
34 }
35
36 my_mvscip-shell shell shell-project 0.0.0 my_mv().() {
37 _src="$1"
38 _dest="$2"
39 findupscip-shell shell shell-project 0.0.0 findup(). .svn
40 if testscip-shell system . . test. -n "$_hit"; then
41 svn mv "$_src" "$_dest" || mvscip-shell system . . mv. "$_src" "$_dest"
42 return
43 fi
44 findupscip-shell shell shell-project 0.0.0 findup(). .git
45 if testscip-shell system . . test. -n "$_hit"; then
46 gitscip-shell system . . git. mv "$_src" "$_dest" || mvscip-shell system . . mv. "$_src" "$_dest"
47 return
48 fi
49 mvscip-shell system . . mv. "$_src" "$_dest"
50 }
51
52
53 if [scip-shell system . . `[`. ! -f $newfile.h ]; then
54 if [scip-shell system . . `[`. -f ${oldfile}.h ]; then
55 my_mvscip-shell shell shell-project 0.0.0 my_mv(). $oldfile.h $newfile.h
56 fi
57 my_mvscip-shell shell shell-project 0.0.0 my_mv(). $oldfile.cpp $newfile.cpp
58 if [scip-shell system . . `[`. -f ${oldfile}_p.h ]; then
59 my_mvscip-shell shell shell-project 0.0.0 my_mv(). ${oldfile}_p.h ${newfile}_p.h
60 fi
61 if [scip-shell system . . `[`. -f ${oldfile}.ui ]; then
62 my_mvscip-shell shell shell-project 0.0.0 my_mv(). ${oldfile}.ui ${newfile}.ui
63 fi
64 fi
65
66 # Update buildsystem
67 if testscip-shell system . . test. -f CMakeLists.txt; then
68 buildsystemfile=CMakeLists.txt
69 else
70 buildsystemfile=`lsscip-shell system . . ls. -1 *.pro 2>/dev/nullscip-shell filesystem . . `/dev/null`. | headscip-shell system . . head. -n 1`
71 fi
72 if testscip-shell system . . test. -n "$buildsystemfile"; then
73 perlscip-shell system . . perl. -pi -e "s/\b$oldfile\.cpp/$newfile.cpp/;s/\b$oldfile\.h/$newfile\.h/;s/\b$oldfile\.ui/$newfile\.ui/" $buildsystemfile
74 fi
75
76 # Rename class
77 if [scip-shell system . . `[`. -f ${newfile}.h ]; then
78 perlscip-shell system . . perl. -pi -e "s/$oldname/$newname/g" ${newfile}.h
79 fi
80 perlscip-shell system . . perl. -pi -e "s/$oldname/$newname/g" $newfile.cpp
81 if [scip-shell system . . `[`. -f ${newfile}_p.h ]; then
82 perlscip-shell system . . perl. -pi -e "s/$oldname/$newname/g" ${newfile}_p.h
83 fi
84 if [scip-shell system . . `[`. -f ${newfile}.ui ]; then
85 perlscip-shell system . . perl. -pi -e "s/$oldname/$newname/g" ${newfile}.ui
86 fi
87
88 oldinclguard=`echoscip-shell system . . echo. $oldname | trscip-shell system . . tr. a-z A-Z`
89 newinclguard=`echoscip-shell system . . echo. $newname | trscip-shell system . . tr. a-z A-Z`
90 oldinclguard_lower=`echoscip-shell system . . echo. $oldname | trscip-shell system . . tr. A-Z a-z`
91 newinclguard_lower=`echoscip-shell system . . echo. $newname | trscip-shell system . . tr. A-Z a-z`
92
93 # Update include guard
94 if [scip-shell system . . `[`. -f ${newfile}.h ]; then
95 perlscip-shell system . . perl. -pi -e "s/$oldinclguard/$newinclguard/g" $newfile.h
96 perlscip-shell system . . perl. -pi -e "s/$oldinclguard_lower/$newinclguard_lower/g" $newfile.h
97 fi
98 if [scip-shell system . . `[`. -f ${newfile}_p.h ]; then
99 perlscip-shell system . . perl. -pi -e "s/$oldinclguard/$newinclguard/g" ${newfile}_p.h
100 fi
101
102 # Update include in cpp file
103 perlscip-shell system . . perl. -pi -e 's/\b'$oldfile'\.h/'$newfile'\.h/;s/\b'$oldfile'_p\.h/'$newfile'_p\.h/' $newfile.cpp
104
105 perlscip-shell system . . perl. -pi -e 's/\b'moc_$oldfile'\.cpp/'moc_$newfile'\.cpp/' $newfile.cpp