diff options
author | Karl Berry <karl@freefriends.org> | 2018-04-28 21:57:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-04-28 21:57:31 +0000 |
commit | 1d47aeb4b6825139fc0f32c3549fbdf3fef6bb5c (patch) | |
tree | 13c5e17fc806f1d51e1d1a91c14b16e6a30b4fbb /Master/texmf-dist/scripts/latexindent/LatexIndent/HiddenChildren.pm | |
parent | b14146667f4cd6cbc5d5821c88e47096df3c78b5 (diff) |
latexindent (28apr18)
git-svn-id: svn://tug.org/texlive/trunk@47471 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/latexindent/LatexIndent/HiddenChildren.pm')
-rw-r--r-- | Master/texmf-dist/scripts/latexindent/LatexIndent/HiddenChildren.pm | 82 |
1 files changed, 43 insertions, 39 deletions
diff --git a/Master/texmf-dist/scripts/latexindent/LatexIndent/HiddenChildren.pm b/Master/texmf-dist/scripts/latexindent/LatexIndent/HiddenChildren.pm index af7d513809d..768ec1651f9 100644 --- a/Master/texmf-dist/scripts/latexindent/LatexIndent/HiddenChildren.pm +++ b/Master/texmf-dist/scripts/latexindent/LatexIndent/HiddenChildren.pm @@ -101,48 +101,52 @@ sub update_family_tree{ # loop through the hash $logger->trace("*Updating FamilyTree...") if $is_t_switch_active; while( my ($idToSearch,$ancestorToSearch)= each %familyTree){ + $logger->trace("*current ID: $idToSearch") if($is_t_switch_active); foreach(@{${$ancestorToSearch}{ancestors}}){ my $ancestorID = ${$_}{ancestorID}; - $logger->trace("current ID: $idToSearch, ancestor: $ancestorID") if($is_t_switch_active); - if($familyTree{$ancestorID}){ - $logger->trace("$ancestorID is a key within familyTree, grabbing its ancestors") if($is_t_switch_active); - my $naturalAncestors = q(); - foreach(@{${$familyTree{$idToSearch}}{ancestors}}){ - $naturalAncestors .= "---".${$_}{ancestorID} if(${$_}{type} eq "natural"); - } - foreach(@{${$familyTree{$ancestorID}}{ancestors}}){ - $logger->trace("ancestor of *hidden* child: ${$_}{ancestorID}") if($is_t_switch_active); - my $newAncestorId = ${$_}{ancestorID}; - my $type; - if($naturalAncestors =~ m/$ancestorID/){ - $type = "natural"; - } else { - $type = "adopted"; - } - my $matched = grep { $_->{ancestorID} eq $newAncestorId } @{${$familyTree{$idToSearch}}{ancestors}}; - push(@{${$familyTree{$idToSearch}}{ancestors}},{ancestorID=>${$_}{ancestorID},ancestorIndentation=>${$_}{ancestorIndentation},type=>$type}) unless($matched); - } - } else { - my $naturalAncestors = q(); - foreach(@{${$familyTree{$idToSearch}}{ancestors}}){ - $naturalAncestors .= "---".${$_}{ancestorID} if(${$_}{type} eq "natural"); - } - $logger->trace("natural ancestors of $ancestorID: $naturalAncestors") if($is_t_switch_active); - foreach(@{${$allChildren{$ancestorID}}{ancestors}}){ - my $newAncestorId = ${$_}{ancestorID}; - my $type; - if($naturalAncestors =~ m/$newAncestorId/){ - $type = "natural"; - } else { - $type = "adopted"; - } - my $matched = grep { $_->{ancestorID} eq $newAncestorId } @{${$familyTree{$idToSearch}}{ancestors}}; - unless($matched){ - $logger->trace("ancestor of UNHIDDEN child: ${$_}{ancestorID}") if($is_t_switch_active); - push(@{${$familyTree{$idToSearch}}{ancestors}},{ancestorID=>${$_}{ancestorID},ancestorIndentation=>${$_}{ancestorIndentation},type=>$type}); + + # construct the natural ancestors + my $naturalAncestors = q(); + foreach(@{${$familyTree{$idToSearch}}{ancestors}}){ + $naturalAncestors .= "---".${$_}{ancestorID} if(${$_}{type} eq "natural"); + } + + # we only need to update the family tree if the $ancestorID is *not* a natural + # ancestor, otherwise everything will be taken care of by the natural ancestor + if($naturalAncestors !~ m/$ancestorID/){ + $logger->trace("ancestor: $ancestorID") if($is_t_switch_active); + if($familyTree{$ancestorID}){ + $logger->trace("$ancestorID is a key within familyTree, grabbing its ancestors") if($is_t_switch_active); + foreach(@{${$familyTree{$ancestorID}}{ancestors}}){ + $logger->trace("ancestor of *hidden* child: ${$_}{ancestorID}") if($is_t_switch_active); + my $newAncestorId = ${$_}{ancestorID}; + my $type; + if($naturalAncestors =~ m/$ancestorID/){ + $type = "natural"; + } else { + $type = "adopted"; + } + my $matched = grep { $_->{ancestorID} eq $newAncestorId } @{${$familyTree{$idToSearch}}{ancestors}}; + push(@{${$familyTree{$idToSearch}}{ancestors}},{ancestorID=>${$_}{ancestorID},ancestorIndentation=>${$_}{ancestorIndentation},type=>$type}) unless($matched); } - } - } + } else { + $logger->trace("natural ancestors of $ancestorID: $naturalAncestors") if($is_t_switch_active); + foreach(@{${$allChildren{$ancestorID}}{ancestors}}){ + my $newAncestorId = ${$_}{ancestorID}; + my $type; + if($naturalAncestors =~ m/$newAncestorId/){ + $type = "natural"; + } else { + $type = "adopted"; + } + my $matched = grep { $_->{ancestorID} eq $newAncestorId } @{${$familyTree{$idToSearch}}{ancestors}}; + unless($matched){ + $logger->trace("ancestor of UNHIDDEN child: ${$_}{ancestorID}") if($is_t_switch_active); + push(@{${$familyTree{$idToSearch}}{ancestors}},{ancestorID=>${$_}{ancestorID},ancestorIndentation=>${$_}{ancestorIndentation},type=>$type}); + } + } + } + } } } |