summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/sortmethods.pl117
-rw-r--r--sources/prefs/VSPrefs.java3
2 files changed, 118 insertions, 2 deletions
diff --git a/scripts/sortmethods.pl b/scripts/sortmethods.pl
new file mode 100644
index 0000000..29800bd
--- /dev/null
+++ b/scripts/sortmethods.pl
@@ -0,0 +1,117 @@
+#!/usr/bin/perl
+
+# Automatically sorts the functions of a java class alphanumerical
+# (C) 2008 by Paul C. Buetow
+
+use strict;
+use warnings;
+
+use File::Find;
+
+my @files;
+
+sub usage () {
+ return "Usage: perl $0 <sourcedir>\n";
+}
+
+sub process (@) {
+ my ($file, @input) = @_;
+
+ my $package;
+ my @imports;
+ my $classOrInterface;
+ my @variables;
+ my @constructors;
+ my @methods;
+
+ my $isMethod = 0;
+ my $isInnerClass = 0;
+ my $methodparant = 0;
+
+ for (@input) {
+ if (/^package/) {
+ $package = $_;
+
+ } elsif (/^import/) {
+ push @imports, $_;
+
+ } elsif (/^[^ ].*class/) {
+ $classOrInterface = $_;
+
+ } elsif (/^[^ ].*interface/) {
+ $classOrInterface = $_;
+
+ } elsif (!$isMethod && /;/ && !/{/) {
+ push @variables, $_;
+
+ } elsif (!$isMethod && !/;/ && /{/) {
+ $methodparant = 0;
+ ++$methodparant while /{/g;
+ --$methodparant while /}/g;
+ my ($name) = /(\w*?\(.*) {/i;
+ next unless defined $name;
+ $isMethod = 1;
+ my %method = (
+ name => $name,
+ prototype => $_,
+ code => [],
+ );
+ push @methods, \%method;
+
+ } elsif ($isMethod) {
+ ++$methodparant while /{/g;
+ --$methodparant while /}/g;
+
+ $isMethod = 0 if $methodparant == 0;
+ push @{$methods[-1]->{code}}, $_;
+ }
+ }
+
+ die "undef package in $file\n" unless defined $package;
+ die "undef classOrInterface in $file\n" unless defined $classOrInterface;
+
+ my @output = ();
+
+ push @output, $package;
+ push @output, "\n";
+
+ if (@imports) {
+ push @output, sort @imports;
+ push @output, "\n";
+ }
+
+ push @output, $classOrInterface;
+
+ if (@variables) {
+ push @output, sort @variables;
+ push @output, "\n";
+ }
+
+ if (@methods) {
+ push @output,
+ map { "@" .$_->{name} . "=>". $_->{prototype}, @{$_->{code}}, "\n" }
+ sort { $a->{name} cmp $b->{name} } @methods;
+ }
+
+ push @output, "}\n";
+
+ return @output;
+}
+
+my $startDir = shift || die usage();
+find(sub { push @files, $File::Find::name if /\.java$/ }, $startDir);
+
+for (@files) {
+ open my $file, $_ or die "$!: $_\n";
+ my @input = <$file>;
+ close $file;
+
+ my @output = process($_, @input);
+ print @output;
+
+ print "=================== END $_\n";
+}
+
+
+=cut
+
diff --git a/sources/prefs/VSPrefs.java b/sources/prefs/VSPrefs.java
index 15241e0..24d5d54 100644
--- a/sources/prefs/VSPrefs.java
+++ b/sources/prefs/VSPrefs.java
@@ -438,8 +438,7 @@ public abstract class VSPrefs implements Serializable {
objectOutputStream.writeObject(units);
}
- @SuppressWarnings("unchecked")
- public synchronized void readObject(ObjectInputStream objectInputStream)
+ @SuppressWarnings("unchecked") public synchronized void readObject(ObjectInputStream objectInputStream)
throws IOException, ClassNotFoundException {
booleanPrefs = (HashMap<String,Boolean>) objectInputStream.readObject();
colorPrefs = (HashMap<String,Color>) objectInputStream.readObject();