Created
April 20, 2012 09:09
-
-
Save artemave/2427250 to your computer and use it in GitHub Desktop.
Filter out the code you don't need to read in java source code, to get better idea on sloc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use File::Basename; | |
for my $fname (@ARGV) { | |
open(my $file, $fname) or die $!; | |
my $in_constructor = 0; | |
my $fbase_name = basename($fname, '.java'); | |
while(<$file>) { | |
if (/^[\s\t]*public *$fbase_name/) { | |
$in_constructor = 1; | |
} | |
if (/[\s\t]*}/) { | |
$in_constructor = 0; | |
} | |
next if $in_constructor; # assumes constructor only assigns fileds | |
next if /^[\s\t]*$/; # blank lines | |
next if /^[\s\t]*@/; # @Autowired, @Compenent, etc. | |
next if /^[\s\t]*import/; # imports | |
next if /^[\s\t]*(public|private|static|package)/; # fields and method declacations | |
print $_; | |
} | |
close $file; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment