-
Notifications
You must be signed in to change notification settings - Fork 0
/
refactor.pl
executable file
·64 lines (49 loc) · 1.75 KB
/
refactor.pl
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
#! /usr/bin/perl -ni
# refactor.pl - Removes all comments and private methods from a Java source
# Copyright (C) 2017 Filippo Ranza
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#Questo bellissimo programma(pugno nello stomaco dell'ingsw)
#rimuove tutti i commmenti e metodi superflui generati in automatico
#da Umbrello
#Esecuzione
#./refactor.pl file.java ...
#dove file.java sono i file da processare
#è fondamentale,per una corretta esecuzione rendere il file esegibile
#e non lanciarlo tramite perl refactor.pl (non verrebbero usate le corrette opzioni)
BEGIN{
if ($#ARGV == -1 ){
print "USAGE:\n";
print " ./refactor.pl java_source...\n";
print " perl -ni refactor.pl java_souce...\n";
print " Remove all comments,javadoc and private methods\n";
print " from given source file.\n";
print " \n";
print " This tool DOES NOT produce any BACKUP.\n";
print " \n";
print " Use with care.\n";
print "Made with <3 by Filippo Ranza\n";
exit
}
}
if( /^\s*private .+\(.*\)/ ){
$state = 1;
}
elsif( /\}/ and $state == 1 ){
$state = 2;
}
if(/^\s*\// or /^\s*\*/){
$prev = $state;
$state = 4;
}
print unless $state;
$state = 0 if($state == 2);
$state = $prev if($state == 4);