| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package PerlTidy::Options; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
33306
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
55
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
56
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1000
|
use Data::Dumper; |
|
|
2
|
|
|
|
|
9984
|
|
|
|
2
|
|
|
|
|
111
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
1029
|
use PerlTidy::Run; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
30
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use Log::Log4perl qw(get_logger); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# types are |
|
13
|
|
|
|
|
|
|
# posInteger - 0..+ - default is value listed |
|
14
|
|
|
|
|
|
|
# undef - option has effect if preent, takes no parameters |
|
15
|
|
|
|
|
|
|
# TODO - flag - option takes -X flags - TODO |
|
16
|
|
|
|
|
|
|
# string - a ... string |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# rather than leave the order of the sections upto the hash retrieval order, |
|
19
|
|
|
|
|
|
|
# we explicitly return the list ordering we require - careful if |
|
20
|
|
|
|
|
|
|
# new versions of perltidty introduce new formatting sections. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my @sections = (); |
|
23
|
|
|
|
|
|
|
my %nameType = (); # contains option names and the values they can take |
|
24
|
|
|
|
|
|
|
my %nameSection = (); # contains option names and the section they are in |
|
25
|
|
|
|
|
|
|
my %sectionNameType = (); # HoH of sections, the options in that section and the values they can take |
|
26
|
|
|
|
|
|
|
my %nameRange = (); # some options are more than just string, int or boolean - they are here |
|
27
|
|
|
|
|
|
|
my %nameDefault = (); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# ask PerlTidy::Run module everything it knows about options and defaults |
|
30
|
|
|
|
|
|
|
# and populate data structures as required. |
|
31
|
|
|
|
|
|
|
# There may be strong coupling between PerlTidy::Run and PerlTidy::Options, but they cooperate a lot |
|
32
|
|
|
|
|
|
|
# and we are trying to isolate interactions with executing perltidy to PerlTidy::Run, and handling those perltidy's options to here |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
INIT { |
|
35
|
1
|
|
|
1
|
|
13
|
PerlTidy::Run->collectOptionStructures( |
|
36
|
|
|
|
|
|
|
types => \%nameType, |
|
37
|
|
|
|
|
|
|
sections => \%nameSection, |
|
38
|
|
|
|
|
|
|
ranges => \%nameRange, |
|
39
|
|
|
|
|
|
|
defaults => \%nameDefault, |
|
40
|
|
|
|
|
|
|
sectionNameType => \%sectionNameType, |
|
41
|
|
|
|
|
|
|
sectionList => \@sections, |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub getSections { |
|
46
|
0
|
|
|
0
|
0
|
|
return @sections; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub getSection { |
|
50
|
0
|
|
|
0
|
0
|
|
my (undef, %args) = @_; |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my ($name) = @args{qw(name)}; |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
0
|
0
|
|
|
|
return unless $name and exists $nameSection{$name}; |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return $nameSection{$name}; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub getEntries { |
|
60
|
0
|
|
|
0
|
0
|
|
my (undef, %args) = @_; |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my ($section) = @args{qw(section)}; |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return keys %{$sectionNameType{$section}}; |
|
|
0
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub getValueType { |
|
68
|
0
|
|
|
0
|
0
|
|
my (undef, %args) = @_; |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my ($section, $entry, $asReference) = @args{qw(section entry asReference)}; |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
my $type = $sectionNameType{$section}{$entry}; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
if ($asReference) { |
|
75
|
0
|
|
|
|
|
|
return $type; |
|
76
|
|
|
|
|
|
|
} else { |
|
77
|
0
|
|
0
|
|
|
|
return ref($type) || $type; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# same as getValueType, but doesnt need a section |
|
82
|
|
|
|
|
|
|
sub getType { |
|
83
|
0
|
|
|
0
|
0
|
|
my (undef, %args) = @_; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my ($entry) = @args{qw( entry )}; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return $nameType{$entry}; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub getDefaultValue { |
|
91
|
0
|
|
|
0
|
0
|
|
my (undef, %args) = @_; |
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my ($entry) = @args{qw(entry)}; |
|
94
|
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
|
return unless defined $entry;; |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
if(exists $nameDefault{$entry}) { |
|
|
|
0
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return $nameDefault{$entry}; |
|
99
|
|
|
|
|
|
|
} elsif ( exists $nameRange{$entry}) { |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# is a ref and is therefore an array ref |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# if this is a request for the output-line-endings default, lets do a little work |
|
104
|
|
|
|
|
|
|
# to provide a useful default for the platform we're running on. |
|
105
|
|
|
|
|
|
|
# also, move the platform to the top of the list |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# note : output-line-endings is currently unsupported in tidyview |
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
0
|
|
|
|
|
if ($entry eq 'output-line-ending') { |
|
110
|
0
|
0
|
|
|
|
|
my $platform = |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
($^O =~ m/(?:dos)/i ) ? 'dos' : |
|
112
|
|
|
|
|
|
|
($^O =~ m/(?:win32)/i) ? 'win' : |
|
113
|
|
|
|
|
|
|
($^O eq 'MacOS' ) ? 'mac' : 'unix'; |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
__PACKAGE__->_reorderEntries( |
|
116
|
|
|
|
|
|
|
listRef => $nameRange{$entry}, |
|
117
|
|
|
|
|
|
|
toBeMoved => $platform |
|
118
|
|
|
|
|
|
|
); |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
return $platform; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# just return the first one in the list |
|
124
|
0
|
|
|
|
|
|
return $nameRange{$entry}->[0]; |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
} else { |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# not in defaults or range. |
|
129
|
|
|
|
|
|
|
# set a value of '' for string |
|
130
|
|
|
|
|
|
|
# and 0 for boolean and integer |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
my $type = $nameType{$entry}; |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
0
|
|
|
|
|
return unless defined $type; |
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
0
|
|
|
|
|
return $type =~ m/^=(?:!|i)$/ ? 0 : ''; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub _reorderEntries { |
|
141
|
0
|
|
|
0
|
|
|
my (undef, %args) = @_; |
|
142
|
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
my ($list, $toBeMoved) = @args{qw(listRef toBeMoved)}; |
|
144
|
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
@$list = ($toBeMoved, grep {$_ ne $toBeMoved} @$list); # remove from list |
|
|
0
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
1; |