simplify the maintenance of large or complex lists.
By default, perltidy does not add
or delete trailing commas, but it is possible to manipulate them with the
-following set of three related parameters:
+following set of related parameters:
=over 4
Adding or deleting the only comma in a list can have some implications which
need to be explained and possibly controlled.
-The main issue with deleting a lone comma is that if the only comma in a list
-is deleted, then it might not be possible to later add it back automatically
+The main issue with deleting a lone comma is that if it
+is deleted, then it might not be possible add it back automatically
since perltidy uses the existance of commas to help locate lists. For example,
given
then we cannot use the trailing comma controls to add this comma back. The
parameter B<--delete-lone-trailing-commas> allows such a comma to be deleted,
and is on by default, but can be turned off to prevent this. This might
-be useful is if one is experimenting with formatting options and wants
+be useful if one is experimenting with formatting options and wants
to restrict testing to operations which are reversible. Note that this
parameter is a fine-tuning control for B<--delete-trailing-commas> which
must also be set for it to have any effect.
);
However, the parameter B<--add-lone-trailing-commas> must be set to allow such
-a comma to be added. This parameter is off by default. The reason is that
-adding such a comma would prevent the B<--weld-nested-containers> flag from
-operating on this structure. This can be confusing, or undesirable if the
-welding control is also being used. Note that this parameter is a fine-tuning
-control for B<--add-trailing-commas> which must also be set for it to have any
-effect. To illustrate its use:
+a comma to be added. The reason is that adding such a comma would prevent the
+B<--weld-nested-containers> flag from operating on this structure. This can be
+confusing, so this parameter is off by default. Note that this parameter is a
+fine-tuning control for B<--add-trailing-commas> which must also be set for it
+to have any effect. To illustrate its use on the above example:
# perltidy -atc -altc -wtc=b
$self->make_grammar(
},
);
-If we later decide we would prefer to remove this comma to allow welding,
-it can be removed with the control in the next section.
+This comma can be removed to allow welding with the control described in the
+next section.
=item B<-dwic>, B<--delete-weld-interfering-commas>
},
);
-Using B<-dwic> removes the comma and allows welding:
+Adding B<-dwic> removes the comma and allows welding:
# perltidy -wn -dwic
$self->make_grammar( {
--- /dev/null
+$self->make_grammar(
+ {
+ iterator => $self->_iterator,
+ parser => $self,
+ version => $self->version
+ }
+);
--- /dev/null
+-atc -wtc=m
--- /dev/null
+-altc -atc -wtc=m
+++ /dev/null
-$self->make_grammar(
- {
- iterator => $self->_iterator,
- parser => $self,
- version => $self->version
- }
-);
+++ /dev/null
--atc -wtc=m
+++ /dev/null
--altc -atc -wtc=m
--- /dev/null
+$self->make_grammar(
+ {
+ iterator => $self->_iterator,
+ parser => $self,
+ version => $self->version,
+ },
+);
--- /dev/null
+-dtc -wtc=0
--- /dev/null
+-dtc -wtc=0 -ndltc
+++ /dev/null
-$self->make_grammar(
- {
- iterator => $self->_iterator,
- parser => $self,
- version => $self->version,
- },
-);
+++ /dev/null
--dtc -wtc=0
+++ /dev/null
--dtc -wtc=0 -ndltc
--- /dev/null
+$self->make_grammar(
+ {
+ iterator => $self->_iterator,
+ parser => $self,
+ version => $self->version,
+ }
+);
--- /dev/null
+$self->make_grammar(
+ {
+ iterator => $self->_iterator,
+ parser => $self,
+ version => $self->version,
+ },
+);
--- /dev/null
+$self->make_grammar(
+ {
+ iterator => $self->_iterator,
+ parser => $self,
+ version => $self->version
+ }
+);
+++ /dev/null
-$self->make_grammar(
- {
- iterator => $self->_iterator,
- parser => $self,
- version => $self->version,
- }
-);
+++ /dev/null
-$self->make_grammar(
- {
- iterator => $self->_iterator,
- parser => $self,
- version => $self->version,
- },
-);
+++ /dev/null
-$self->make_grammar(
- {
- iterator => $self->_iterator,
- parser => $self,
- version => $self->version
- }
-);
--- /dev/null
+$self->make_grammar(
+ {
+ iterator => $self->_iterator,
+ parser => $self,
+ version => $self->version,
+ },
+);
--- /dev/null
+$self->make_grammar(
+ {
+ iterator => $self->_iterator,
+ parser => $self,
+ version => $self->version
+ }
+);
--- /dev/null
+$self->make_grammar(
+ {
+ iterator => $self->_iterator,
+ parser => $self,
+ version => $self->version
+ },
+);
+++ /dev/null
-$self->make_grammar(
- {
- iterator => $self->_iterator,
- parser => $self,
- version => $self->version,
- },
-);
+++ /dev/null
-$self->make_grammar(
- {
- iterator => $self->_iterator,
- parser => $self,
- version => $self->version
- }
-);
+++ /dev/null
-$self->make_grammar(
- {
- iterator => $self->_iterator,
- parser => $self,
- version => $self->version
- },
-);
../snippets3.t gnu1.def
../snippets30.t git143.def
../snippets30.t git143.git143
-../snippets30.t atlc.atlc1
-../snippets30.t atlc.atlc2
-../snippets30.t atlc.def
-../snippets30.t dtlc.def
-../snippets30.t dtlc.dtlc1
-../snippets30.t dtlc.dtlc2
../snippets30.t git146.def
../snippets30.t git146.git146
+../snippets30.t altc.altc1
+../snippets30.t altc.altc2
+../snippets30.t altc.def
+../snippets30.t dltc.def
+../snippets30.t dltc.dltc1
+../snippets30.t dltc.dltc2
../snippets4.t gnu1.gnu
../snippets4.t gnu2.def
../snippets4.t gnu2.gnu
# Contents:
#1 git143.def
#2 git143.git143
-#3 atlc.atlc1
-#4 atlc.atlc2
-#5 atlc.def
-#6 dtlc.def
-#7 dtlc.dtlc1
-#8 dtlc.dtlc2
-#9 git146.def
-#10 git146.git146
+#3 git146.def
+#4 git146.git146
+#5 altc.altc1
+#6 altc.altc2
+#7 altc.def
+#8 dltc.def
+#9 dltc.dltc1
+#10 dltc.dltc2
# To locate test #13 you can search for its name or the string '#13'
# BEGIN SECTION 1: Parameter combinations #
###########################################
$rparams = {
- 'atlc1' => "-atc -wtc=m",
- 'atlc2' => "-altc -atc -wtc=m",
+ 'altc1' => "-atc -wtc=m",
+ 'altc2' => "-altc -atc -wtc=m",
'def' => "",
- 'dtlc1' => "-dtc -wtc=0",
- 'dtlc2' => "-dtc -wtc=0 -ndltc",
+ 'dltc1' => "-dtc -wtc=0",
+ 'dltc2' => "-dtc -wtc=0 -ndltc",
'git143' => "-atc -wtc=h",
'git146' => <<'----------',
# testing three dash parameters
############################
$rsources = {
- 'atlc' => <<'----------',
+ 'altc' => <<'----------',
$self->make_grammar(
{
iterator => $self->_iterator,
);
----------
- 'dtlc' => <<'----------',
+ 'dltc' => <<'----------',
$self->make_grammar(
{
iterator => $self->_iterator,
#2...........
},
- 'atlc.atlc1' => {
- source => "atlc",
- params => "atlc1",
+ 'git146.def' => {
+ source => "git146",
+ params => "def",
expect => <<'#3...........',
-$self->make_grammar(
- {
- iterator => $self->_iterator,
- parser => $self,
- version => $self->version,
- }
-);
+ my %strips = (
+ 1 => [
+ [ [ 1750, 150, ], [ 1850, 150, ], ],
+ [ [ 1950, 150, ], [ 2050, 150, ], ],
+ ]
+ );
#3...........
},
- 'atlc.atlc2' => {
- source => "atlc",
- params => "atlc2",
+ 'git146.git146' => {
+ source => "git146",
+ params => "git146",
expect => <<'#4...........',
-$self->make_grammar(
- {
- iterator => $self->_iterator,
- parser => $self,
- version => $self->version,
- },
-);
+ my %strips = (
+ 1 => [
+ [ [ 1750, 150, ], [ 1850, 150, ], ],
+ [ [ 1950, 150, ], [ 2050, 150, ], ],
+ ],
+ );
#4...........
},
- 'atlc.def' => {
- source => "atlc",
- params => "def",
+ 'altc.altc1' => {
+ source => "altc",
+ params => "altc1",
expect => <<'#5...........',
$self->make_grammar(
{
iterator => $self->_iterator,
parser => $self,
- version => $self->version
+ version => $self->version,
}
);
#5...........
},
- 'dtlc.def' => {
- source => "dtlc",
- params => "def",
+ 'altc.altc2' => {
+ source => "altc",
+ params => "altc2",
expect => <<'#6...........',
$self->make_grammar(
{
#6...........
},
- 'dtlc.dtlc1' => {
- source => "dtlc",
- params => "dtlc1",
+ 'altc.def' => {
+ source => "altc",
+ params => "def",
expect => <<'#7...........',
$self->make_grammar(
{
#7...........
},
- 'dtlc.dtlc2' => {
- source => "dtlc",
- params => "dtlc2",
+ 'dltc.def' => {
+ source => "dltc",
+ params => "def",
expect => <<'#8...........',
$self->make_grammar(
{
iterator => $self->_iterator,
parser => $self,
- version => $self->version
+ version => $self->version,
},
);
#8...........
},
- 'git146.def' => {
- source => "git146",
- params => "def",
+ 'dltc.dltc1' => {
+ source => "dltc",
+ params => "dltc1",
expect => <<'#9...........',
- my %strips = (
- 1 => [
- [ [ 1750, 150, ], [ 1850, 150, ], ],
- [ [ 1950, 150, ], [ 2050, 150, ], ],
- ]
- );
+$self->make_grammar(
+ {
+ iterator => $self->_iterator,
+ parser => $self,
+ version => $self->version
+ }
+);
#9...........
},
- 'git146.git146' => {
- source => "git146",
- params => "git146",
+ 'dltc.dltc2' => {
+ source => "dltc",
+ params => "dltc2",
expect => <<'#10...........',
- my %strips = (
- 1 => [
- [ [ 1750, 150, ], [ 1850, 150, ], ],
- [ [ 1950, 150, ], [ 2050, 150, ], ],
- ],
- );
+$self->make_grammar(
+ {
+ iterator => $self->_iterator,
+ parser => $self,
+ version => $self->version
+ },
+);
#10...........
},
};