PPIx-Utilities-1.001000000755000766000766 011475602445 14513 5ustar00elliotelliot000000000000PPIx-Utilities-1.001000/Build.PL000444000766000766 631211475602445 16146 0ustar00elliotelliot000000000000#!perl # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/Build.PL $ # $Date: 2009-06-26 10:48:29 -0400 (Fri, 26 Jun 2009) $ # $Author: clonezone $ # $Revision: 3365 $ use 5.006001; use strict; use warnings; use Module::Build; my $class = Module::Build->subclass( code => <<'END_SUBCLASS' ); sub ACTION_authortest { my ($self) = @_; $self->depends_on('build'); $self->depends_on('manifest'); $self->depends_on('distmeta'); $self->test_files( qw< t xt/author > ); $self->recursive_test_files(1); $self->depends_on('test'); return; } # end ACTION_authortest() sub ACTION_distdir { my ($self) = @_; $self->depends_on('authortest'); return $self->SUPER::ACTION_distdir(); } # end ACTION_distdir END_SUBCLASS my $ppi_version = '1.208'; my $builder = $class->new( module_name => 'PPIx::Utilities', dist_author => 'Elliot Shank ', license => 'perl', dynamic_config => 0, create_license => 1, create_makefile_pl => 'traditional', create_packlist => 1, create_readme => 1, sign => 0, requires => { 'base' => 0, 'Exception::Class' => 0, 'Exporter' => 0, 'PPI' => $ppi_version, 'PPI::Document::Fragment' => $ppi_version, 'Readonly' => 0, 'Scalar::Util' => 0, 'strict' => 0, 'Task::Weaken' => 0, # Ensure a proper Scalar::Util. 'warnings' => 0, }, build_requires => { 'Data::Dumper' => 0, 'PPI::Document' => $ppi_version, 'PPI::Dumper' => $ppi_version, 'Test::Deep' => 0, 'Test::More' => 0, }, recommends => { 'Readonly::XS' => 0, }, meta_merge => { resources => { license => 'http://dev.perl.org/licenses/', repository => 'http://guest@perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/', MailingList => 'http://perlcritic.tigris.org/servlets/SummarizeList?listName=users', }, no_index => { file => [ ], directory => [ qw< t xt > ], }, }, add_to_cleanup => [ qw< LICENSE MANIFEST MANIFEST.bak META.yml Makefile Makefile.old Makefile.PL pod2htm?.tmp pm_to_blib README PPIx-Utilities-* >, ], ); $builder->create_build_script(); ############################################################################## # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 78 # indent-tabs-mode: nil # c-indentation-style: bsd # End: # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : PPIx-Utilities-1.001000/Changes000444000766000766 66111475602445 16126 0ustar00elliotelliot000000000000[1.1.0] Released on 2010-12-01 Add support for Const::Fast to PPIx::Utilities::Statement. [1.0.1] Released on 2010-03-14. Add to no_index to META.yml. [1.0.0] Released on 2010-03-14. Initial version. # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/Task-Perl-Critic/Changes $ # $Date: 2009-05-31 20:20:42 -0500 (Sun, 31 May 2009) $ # $Author: clonezone $ # $Revision: 3341 $ PPIx-Utilities-1.001000/LICENSE000444000766000766 4347211475602445 15707 0ustar00elliotelliot000000000000This software is copyright (c) 2010 by nobody. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2010 by nobody. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2010 by nobody. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End PPIx-Utilities-1.001000/Makefile.PL000444000766000766 161011475602445 16620 0ustar00elliotelliot000000000000# Note: this file was auto-generated by Module::Build::Compat version 0.36_17 use ExtUtils::MakeMaker; WriteMakefile ( 'NAME' => 'PPIx::Utilities', 'VERSION_FROM' => 'lib/PPIx/Utilities.pm', 'PREREQ_PM' => { 'Data::Dumper' => 0, 'Exception::Class' => 0, 'Exporter' => 0, 'PPI' => '1.208', 'PPI::Document' => '1.208', 'PPI::Document::Fragment' => '1.208', 'PPI::Dumper' => '1.208', 'Readonly' => 0, 'Scalar::Util' => 0, 'Task::Weaken' => 0, 'Test::Deep' => 0, 'Test::More' => 0, 'base' => 0, 'strict' => 0, 'warnings' => 0 }, 'INSTALLDIRS' => 'site', 'EXE_FILES' => [], 'PL_FILES' => {} ) ; PPIx-Utilities-1.001000/MANIFEST000444000766000766 103311475602445 15776 0ustar00elliotelliot000000000000Build.PL Changes lib/PPIx/Utilities.pm lib/PPIx/Utilities/Exception/Bug.pm lib/PPIx/Utilities/Node.pm lib/PPIx/Utilities/Statement.pm MANIFEST This list of files t/split-ppi-node-by-namespace.t xt/author/consistent_version_numbers.t xt/author/copyright.t xt/author/distribution.t xt/author/kwalitee.t xt/author/perlcritic-code.t xt/author/perlcritic-tests.t xt/author/perlcriticrc-code xt/author/perlcriticrc-tests xt/author/pod_coverage.t xt/author/pod_syntax.t xt/author/README xt/author/stop-words Makefile.PL README LICENSE META.yml PPIx-Utilities-1.001000/META.yml000444000766000766 242611475602445 16125 0ustar00elliotelliot000000000000--- abstract: 'Extensions to L.' author: - 'Elliot Shank ' build_requires: Data::Dumper: 0 PPI::Document: 1.208 PPI::Dumper: 1.208 Test::Deep: 0 Test::More: 0 configure_requires: Module::Build: 0.36 dynamic_config: 0 generated_by: 'Module::Build version 0.3617' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: PPIx-Utilities no_index: directory: - t - xt file: [] provides: PPIx::Utilities: file: lib/PPIx/Utilities.pm version: 1.001000 PPIx::Utilities::Exception::Bug: file: lib/PPIx/Utilities/Exception/Bug.pm version: 1.001000 PPIx::Utilities::Node: file: lib/PPIx/Utilities/Node.pm version: 1.001000 PPIx::Utilities::Statement: file: lib/PPIx/Utilities/Statement.pm version: 1.001000 recommends: Readonly::XS: 0 requires: Exception::Class: 0 Exporter: 0 PPI: 1.208 PPI::Document::Fragment: 1.208 Readonly: 0 Scalar::Util: 0 Task::Weaken: 0 base: 0 strict: 0 warnings: 0 resources: MailingList: http://perlcritic.tigris.org/servlets/SummarizeList?listName=users license: http://dev.perl.org/licenses/ repository: http://guest@perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/ version: 1.001000 PPIx-Utilities-1.001000/README000444000766000766 206511475602445 15533 0ustar00elliotelliot000000000000NAME PPIx::Utilities - Extensions to PPI. VERSION This document describes PPIx::Utilities version 1.1.0. SYNOPSIS This module does nothing but act as a handle for the PPIx-Utilities distribution. DESCRIPTION This is a collection of functions for dealing with PPI objects, many of which originated in Perl::Critic. They are organized into modules by the kind of PPI class they relate to, by replacing the "PPI" at the front of the module name with "PPIx::Utilities", e.g. functionality related to PPI::Nodes is in PPIx::Utilities::Node. INTERFACE None. BUGS AND LIMITATIONS Please report any bugs or feature requests to "bug-ppix-utilities@rt.cpan.org", or through the web interface at . AUTHOR Elliot Shank "" COPYRIGHT Copyright (c) 2009-2010, Elliot Shank. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. PPIx-Utilities-1.001000/lib000755000766000766 011475602445 15261 5ustar00elliotelliot000000000000PPIx-Utilities-1.001000/lib/PPIx000755000766000766 011475602445 16101 5ustar00elliotelliot000000000000PPIx-Utilities-1.001000/lib/PPIx/Utilities.pm000444000766000766 346511475602445 20557 0ustar00elliotelliot000000000000package PPIx::Utilities; use 5.006001; use strict; use warnings; our $VERSION = '1.001000'; 1; __END__ =head1 NAME PPIx::Utilities - Extensions to L. =head1 VERSION This document describes PPIx::Utilities version 1.1.0. =head1 SYNOPSIS This module does nothing but act as a handle for the PPIx-Utilities distribution. =head1 DESCRIPTION This is a collection of functions for dealing with L objects, many of which originated in L. They are organized into modules by the kind of PPI class they relate to, by replacing the "PPI" at the front of the module name with "PPIx::Utilities", e.g. functionality related to Ls is in L. =head1 INTERFACE None. =head1 BUGS AND LIMITATIONS Please report any bugs or feature requests to C, or through the web interface at L. =head1 AUTHOR Elliot Shank C<< >> =head1 COPYRIGHT Copyright (c) 2009-2010, Elliot Shank. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. =cut ############################################################################## # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/lib/PPIx/Utilities.pm $ # $Date: 2010-12-01 20:31:47 -0600 (Wed, 01 Dec 2010) $ # $Author: clonezone $ # $Revision: 4001 $ ############################################################################## # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 70 # indent-tabs-mode: nil # c-indentation-style: bsd # End: # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab : PPIx-Utilities-1.001000/lib/PPIx/Utilities000755000766000766 011475602445 20054 5ustar00elliotelliot000000000000PPIx-Utilities-1.001000/lib/PPIx/Utilities/Node.pm000444000766000766 2125111475602445 21455 0ustar00elliotelliot000000000000package PPIx::Utilities::Node; use 5.006001; use strict; use warnings; our $VERSION = '1.001000'; use Readonly; use PPI::Document::Fragment 1.208 qw< >; use Scalar::Util qw< refaddr >; use PPIx::Utilities::Exception::Bug qw< >; use base 'Exporter'; Readonly::Array our @EXPORT_OK => qw< split_ppi_node_by_namespace >; sub split_ppi_node_by_namespace { my ($node) = @_; # Ensure we don't screw up the original. $node = $node->clone(); # We want to make sure that we have locations prior to things being split # up, if we can, but don't worry about it if we don't. eval { $node->location(); }; ## no critic (RequireCheckingReturnValueOfEval) if ( my $single_namespace = _split_ppi_node_by_namespace_single($node) ) { return $single_namespace; } # end if my %nodes_by_namespace; _split_ppi_node_by_namespace_in_lexical_scope( $node, 'main', undef, \%nodes_by_namespace, ); return \%nodes_by_namespace; } # end split_ppi_node_by_namespace() # Handle the case where there's only one. sub _split_ppi_node_by_namespace_single { my ($node) = @_; my $package_statements = $node->find('PPI::Statement::Package'); if ( not $package_statements or not @{$package_statements} ) { return { main => [$node] }; } # end if if (@{$package_statements} == 1) { my $package_statement = $package_statements->[0]; my $package_address = refaddr $package_statement; # Yes, child and not schild. my $first_child = $node->child(0); if ( $package_address == refaddr $node or $first_child and $package_address == refaddr $first_child ) { return { $package_statement->namespace() => [$node] }; } # end if } # end if return; } # end _split_ppi_node_by_namespace_single() sub _split_ppi_node_by_namespace_in_lexical_scope { my ($node, $initial_namespace, $initial_fragment, $nodes_by_namespace) = @_; my %scope_fragments_by_namespace; # I certainly hope a value isn't going to exist at address 0. my $initial_fragment_address = refaddr $initial_fragment || 0; my ($namespace, $fragment) = ($initial_namespace, $initial_fragment); if ($initial_fragment) { $scope_fragments_by_namespace{$namespace} = $initial_fragment; } # end if foreach my $child ( $node->children() ) { if ( $child->isa('PPI::Statement::Package') ) { if ($fragment) { _push_fragment($nodes_by_namespace, $namespace, $fragment); undef $fragment; } # end if $namespace = $child->namespace(); } elsif ( $child->isa('PPI::Statement::Compound') or $child->isa('PPI::Statement::Given') or $child->isa('PPI::Statement::When') ) { my $block; my @components = $child->children(); while (not $block and my $component = shift @components) { if ( $component->isa('PPI::Structure::Block') ) { $block = $component; } # end if } # end while if ($block) { if (not $fragment) { $fragment = _get_fragment_for_split_ppi_node( $nodes_by_namespace, \%scope_fragments_by_namespace, $namespace, ); } # end if _split_ppi_node_by_namespace_in_lexical_scope( $block, $namespace, $fragment, $nodes_by_namespace, ); } # end if } # end if $fragment = _get_fragment_for_split_ppi_node( $nodes_by_namespace, \%scope_fragments_by_namespace, $namespace, ); if ($initial_fragment_address != refaddr $fragment) { # Need to fix these to use exceptions. Thankfully the P::C tests # will insist that this happens. $child->remove() or PPIx::Utilities::Exception::Bug->throw( 'Could not remove child from parent.' ); $fragment->add_element($child) or PPIx::Utilities::Exception::Bug->throw( 'Could not add child to fragment.' ); } # end if } # end foreach return; } # end _split_ppi_node_by_namespace_in_lexical_scope() sub _get_fragment_for_split_ppi_node { my ($nodes_by_namespace, $scope_fragments_by_namespace, $namespace) = @_; my $fragment; if ( not $fragment = $scope_fragments_by_namespace->{$namespace} ) { $fragment = PPI::Document::Fragment->new(); $scope_fragments_by_namespace->{$namespace} = $fragment; _push_fragment($nodes_by_namespace, $namespace, $fragment); } # end if return $fragment; } # end _get_fragment_for_split_ppi_node() # Due to $fragment being passed into recursive calls to # _split_ppi_node_by_namespace_in_lexical_scope(), we can end up attempting to # put the same fragment into a namespace's nodes multiple times. sub _push_fragment { my ($nodes_by_namespace, $namespace, $fragment) = @_; my $nodes = $nodes_by_namespace->{$namespace} ||= []; if (not @{$nodes} or refaddr $nodes->[-1] != refaddr $fragment) { push @{$nodes}, $fragment; } # end if return; } # end _push_fragment() 1; __END__ =head1 NAME PPIx::Utilities::Node - Extensions to L. =head1 VERSION This document describes PPIx::Utilities::Node version 1.1.0. =head1 SYNOPSIS use PPIx::Utilities::Node qw< split_ppi_node_by_namespace >; my $dom = PPI::Document->new("..."); while ( my ($namespace, $sub_doms) = each split_ppi_node_by_namespace($dom) ) { foreach my $sub_dom ( @{$sub_doms} ) { ... } } =head1 DESCRIPTION This is a collection of functions for dealing with Ls. =head1 INTERFACE Nothing is exported by default. =head2 split_ppi_node_by_namespace($node) Returns the sub-trees for each namespace in the node as a reference to a hash of references to arrays of Ls. Say we've got the following code: #!perl my $x = blah(); package Foo; my $y = blah_blah(); { say 'Whee!'; package Bar; something(); } thingy(); package Baz; da_da_da(); package Foo; foreach ( blrfl() ) { ... } Calling this function on a L for the above returns a value that looks like this, using multi-line string literals for the actual code parts instead of PPI trees to make this easier to read: { main => [ q< #!perl my $x = blah(); >, ], Foo => [ q< package Foo; my $y = blah_blah(); { say 'Whee!'; } thingy(); >, q< package Foo; foreach ( blrfl() ) { ... } >, ], Bar => [ q< package Bar; something(); >, ], Baz => [ q< package Baz; da_da_da(); >, ], } Note that the return value contains copies of the original nodes, and not the original nodes themselves due to the need to handle namespaces that are not file-scoped. (Notice how the first element for "Foo" above differs from the original code.) =head1 BUGS AND LIMITATIONS Please report any bugs or feature requests to C, or through the web interface at L. =head1 AUTHOR Elliot Shank C<< >> =head1 COPYRIGHT Copyright (c)2009-2010, Elliot Shank C<< >>. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. =cut ############################################################################## # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/lib/PPIx/Utilities/Node.pm $ # $Date: 2010-12-01 20:31:47 -0600 (Wed, 01 Dec 2010) $ # $Author: clonezone $ # $Revision: 4001 $ ############################################################################## # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 70 # indent-tabs-mode: nil # c-indentation-style: bsd # End: # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround: PPIx-Utilities-1.001000/lib/PPIx/Utilities/Statement.pm000444000766000766 1275011475602445 22540 0ustar00elliotelliot000000000000############################################################################## # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/lib/PPIx/Utilities/Statement.pm $ # $Date: 2010-11-13 14:25:12 -0600 (Sat, 13 Nov 2010) $ # $Author: clonezone $ # $Revision: 3990 $ ############################################################################## package PPIx::Utilities::Statement; use 5.006001; use strict; use warnings; our $VERSION = '1.001000'; use Readonly; use PPI 1.208 qw< >; # Just for the version check. use base 'Exporter'; our @EXPORT_OK = qw( get_constant_name_elements_from_declaring_statement ); Readonly::Hash my %IS_COMMA => ( q[,] => 1, q[=>] => 1 ); sub get_constant_name_elements_from_declaring_statement { my ($element) = @_; return if not $element; return if not $element->isa('PPI::Statement'); if ( $element->isa('PPI::Statement::Include') ) { my $pragma; if ( $pragma = $element->pragma() and $pragma eq 'constant' ) { return _get_constant_names_from_constant_pragma($element); } # end if } elsif ( not $element->specialized() and $element->schildren() > 2 ) { my $supposed_constant_function = $element->schild(0)->content(); my $declaring_scope = $element->schild(1)->content(); if ( ( $supposed_constant_function eq 'const' or $supposed_constant_function =~ m< \A Readonly \b >xms ) and ($declaring_scope eq 'our' or $declaring_scope eq 'my') ) { return $element->schild(2); } # end if } # end if return; } # end get_constant_name_elements_from_declaring_statement() sub _get_constant_names_from_constant_pragma { my ($include) = @_; my @arguments = $include->arguments() or return; my $follower = $arguments[0]; return if not defined $follower; # We test for a 'PPI::Structure::Block' in the following because some # versions of PPI parse the last element of 'use constant { ONE => 1, TWO # => 2 }' as a block rather than a constructor. As of PPI 1.206, PPI # handles the above correctly, but still blows it on 'use constant 1.16 { # ONE => 1, TWO => 2 }'. if ( $follower->isa( 'PPI::Structure::Constructor' ) or $follower->isa( 'PPI::Structure::Block' ) ) { my $statement = $follower->schild( 0 ) or return; $statement->isa( 'PPI::Statement' ) or return; my @elements; my $inx = 0; foreach my $child ( $statement->schildren() ) { if (not $inx % 2) { push @{ $elements[ $inx ] ||= [] }, $child; } # end if if ( $IS_COMMA{ $child->content() } ) { $inx++; } # end if } # end foreach return map { ( $_ and @{$_} == 2 and '=>' eq $_->[1]->content() and $_->[0]->isa( 'PPI::Token::Word' ) ) ? $_->[0] : () } @elements; } else { return $follower; } # end if return $follower; } # end _get_constant_names_from_constant_pragma() 1; __END__ =pod =for stopwords =head1 NAME PPIx::Utilities::Statement - Extensions to L. =head1 VERSION This document describes PPIx::Utilities::Statement version 1.1.0. =head1 SYNOPSIS use PPI::Document qw< >; use PPIx::Utilities::Statement qw< get_constant_name_elements_from_declaring_statement >; my $document = PPI::Document->new(\'Readonly::Scalar my $THINGY => 47.2;'); # Returns the PPI::Token::Symbol for "$THINGY". my ($constant) = get_constant_name_elements_from_declaring_statement( $document->schild(0) ); =head1 DESCRIPTION This is a collection of functions for dealing with Ls. =head1 INTERFACE Nothing is exported by default. =head2 C Given a L, if the statement is a L or L declaration statement or a C, returns the names of the things being defined. Given use constant 1.16 FOO => 'bar'; this will return the L containing C<'FOO'>. Given use constant 1.16 { FOO => 'bar', 'BAZ' => 'burfle' }; this will return a list of the Ls containing C<'FOO'> and C<'BAZ'>. Similarly, given Readonly::Hash my %FOO => ( bar => 'baz' ); or const my %FOO => ( bar => 'baz' ); this will return the L containing C<'%FOO'>. =head1 BUGS AND LIMITATIONS Please report any bugs or feature requests to C, or through the web interface at L. =head1 AUTHOR Thomas R. Wyant, III C<< >> =head1 COPYRIGHT Copyright (c) 2009-2010 Thomas R. Wyant, III. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. =cut # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 78 # indent-tabs-mode: nil # c-indentation-style: bsd # End: # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : PPIx-Utilities-1.001000/lib/PPIx/Utilities/Exception000755000766000766 011475602445 22012 5ustar00elliotelliot000000000000PPIx-Utilities-1.001000/lib/PPIx/Utilities/Exception/Bug.pm000444000766000766 324511475602445 23226 0ustar00elliotelliot000000000000############################################################################## # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/lib/PPIx/Utilities/Exception/Bug.pm $ # $Date: 2010-12-01 20:31:47 -0600 (Wed, 01 Dec 2010) $ # $Author: clonezone $ # $Revision: 4001 $ ############################################################################## package PPIx::Utilities::Exception::Bug; use 5.006001; use strict; use warnings; our $VERSION = '1.001000'; use Exception::Class ( 'PPIx::Utilities::Exception::Bug' => { isa => 'Exception::Class::Base', description => 'A bug in either PPIx::Utilities or PPI.', }, ); 1; __END__ =pod =for stopwords =head1 NAME PPIx::Utilities::Exception::Bug - A problem identified by L. =head1 VERSION This document describes PPIx::Utilities::Exception::Bug version 1.1.0. =head1 DESCRIPTION This represents a bug in either this module or in L. Something that should never have happened, did happen. =head1 METHODS None other than those inherited from L. =head1 AUTHOR Elliot Shank =head1 COPYRIGHT Copyright (c) 2010 Elliot Shank. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. =cut # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 78 # indent-tabs-mode: nil # c-indentation-style: bsd # End: # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : PPIx-Utilities-1.001000/t000755000766000766 011475602445 14756 5ustar00elliotelliot000000000000PPIx-Utilities-1.001000/t/split-ppi-node-by-namespace.t000444000766000766 11441711475602445 22556 0ustar00elliotelliot000000000000#!/usr/bin/env perl use 5.006001; use strict; use warnings; our $VERSION = '1.001000'; use Readonly; use Data::Dumper qw< >; use PPI::Document qw< >; use PPI::Dumper qw< >; use PPIx::Utilities::Node qw< split_ppi_node_by_namespace >; use Test::Deep qw< cmp_deeply >; use Test::More tests => 10; Readonly::Scalar my $DUMP_INDENT => 4; { my $source = <<'END_SOURCE'; package Foo; $x = 1; while (1) { $y = 2 } until (1) { $z = 3 } if (1) { $w = 4 } unless (1) { $v = 5 } for (1) { $u = 6 } foreach (1) { $t = 7 } given (1) { $s = 8 } when (1) { $r = 9 } END_SOURCE my %expected = ( Foo => [ <<'END_EXPECTED' ], PPI::Document PPI::Statement::Package [ 1, 1, 1 ] PPI::Token::Word 'package' [ 1, 8, 8 ] PPI::Token::Whitespace ' ' [ 1, 9, 9 ] PPI::Token::Word 'Foo' [ 1, 12, 12 ] PPI::Token::Structure ';' [ 1, 13, 13 ] PPI::Token::Whitespace '\n' PPI::Statement [ 2, 1, 1 ] PPI::Token::Symbol '$x' [ 2, 3, 3 ] PPI::Token::Whitespace ' ' [ 2, 4, 4 ] PPI::Token::Operator '=' [ 2, 5, 5 ] PPI::Token::Whitespace ' ' [ 2, 6, 6 ] PPI::Token::Number '1' [ 2, 7, 7 ] PPI::Token::Structure ';' [ 2, 8, 8 ] PPI::Token::Whitespace '\n' PPI::Statement::Compound [ 3, 1, 1 ] PPI::Token::Word 'while' [ 3, 6, 6 ] PPI::Token::Whitespace ' ' PPI::Structure::Condition ( ... ) PPI::Statement::Expression [ 3, 8, 8 ] PPI::Token::Number '1' [ 3, 10, 10 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 3, 12, 12 ] PPI::Token::Whitespace ' ' PPI::Statement [ 3, 13, 13 ] PPI::Token::Symbol '$y' [ 3, 15, 15 ] PPI::Token::Whitespace ' ' [ 3, 16, 16 ] PPI::Token::Operator '=' [ 3, 17, 17 ] PPI::Token::Whitespace ' ' [ 3, 18, 18 ] PPI::Token::Number '2' [ 3, 19, 19 ] PPI::Token::Whitespace ' ' [ 3, 21, 21 ] PPI::Token::Whitespace '\n' PPI::Statement::Compound [ 4, 1, 1 ] PPI::Token::Word 'until' [ 4, 6, 6 ] PPI::Token::Whitespace ' ' PPI::Structure::Condition ( ... ) PPI::Statement::Expression [ 4, 8, 8 ] PPI::Token::Number '1' [ 4, 10, 10 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 4, 12, 12 ] PPI::Token::Whitespace ' ' PPI::Statement [ 4, 13, 13 ] PPI::Token::Symbol '$z' [ 4, 15, 15 ] PPI::Token::Whitespace ' ' [ 4, 16, 16 ] PPI::Token::Operator '=' [ 4, 17, 17 ] PPI::Token::Whitespace ' ' [ 4, 18, 18 ] PPI::Token::Number '3' [ 4, 19, 19 ] PPI::Token::Whitespace ' ' [ 4, 21, 21 ] PPI::Token::Whitespace '\n' PPI::Statement::Compound [ 5, 1, 1 ] PPI::Token::Word 'if' [ 5, 3, 3 ] PPI::Token::Whitespace ' ' PPI::Structure::Condition ( ... ) PPI::Statement::Expression [ 5, 5, 5 ] PPI::Token::Number '1' [ 5, 7, 7 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 5, 9, 9 ] PPI::Token::Whitespace ' ' PPI::Statement [ 5, 10, 10 ] PPI::Token::Symbol '$w' [ 5, 12, 12 ] PPI::Token::Whitespace ' ' [ 5, 13, 13 ] PPI::Token::Operator '=' [ 5, 14, 14 ] PPI::Token::Whitespace ' ' [ 5, 15, 15 ] PPI::Token::Number '4' [ 5, 16, 16 ] PPI::Token::Whitespace ' ' [ 5, 18, 18 ] PPI::Token::Whitespace '\n' PPI::Statement::Compound [ 6, 1, 1 ] PPI::Token::Word 'unless' [ 6, 7, 7 ] PPI::Token::Whitespace ' ' PPI::Structure::Condition ( ... ) PPI::Statement::Expression [ 6, 9, 9 ] PPI::Token::Number '1' [ 6, 11, 11 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 6, 13, 13 ] PPI::Token::Whitespace ' ' PPI::Statement [ 6, 14, 14 ] PPI::Token::Symbol '$v' [ 6, 16, 16 ] PPI::Token::Whitespace ' ' [ 6, 17, 17 ] PPI::Token::Operator '=' [ 6, 18, 18 ] PPI::Token::Whitespace ' ' [ 6, 19, 19 ] PPI::Token::Number '5' [ 6, 20, 20 ] PPI::Token::Whitespace ' ' [ 6, 22, 22 ] PPI::Token::Whitespace '\n' PPI::Statement::Compound [ 7, 1, 1 ] PPI::Token::Word 'for' [ 7, 4, 4 ] PPI::Token::Whitespace ' ' PPI::Structure::List ( ... ) PPI::Statement [ 7, 6, 6 ] PPI::Token::Number '1' [ 7, 8, 8 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 7, 10, 10 ] PPI::Token::Whitespace ' ' PPI::Statement [ 7, 11, 11 ] PPI::Token::Symbol '$u' [ 7, 13, 13 ] PPI::Token::Whitespace ' ' [ 7, 14, 14 ] PPI::Token::Operator '=' [ 7, 15, 15 ] PPI::Token::Whitespace ' ' [ 7, 16, 16 ] PPI::Token::Number '6' [ 7, 17, 17 ] PPI::Token::Whitespace ' ' [ 7, 19, 19 ] PPI::Token::Whitespace '\n' PPI::Statement::Compound [ 8, 1, 1 ] PPI::Token::Word 'foreach' [ 8, 8, 8 ] PPI::Token::Whitespace ' ' PPI::Structure::List ( ... ) PPI::Statement [ 8, 10, 10 ] PPI::Token::Number '1' [ 8, 12, 12 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 8, 14, 14 ] PPI::Token::Whitespace ' ' PPI::Statement [ 8, 15, 15 ] PPI::Token::Symbol '$t' [ 8, 17, 17 ] PPI::Token::Whitespace ' ' [ 8, 18, 18 ] PPI::Token::Operator '=' [ 8, 19, 19 ] PPI::Token::Whitespace ' ' [ 8, 20, 20 ] PPI::Token::Number '7' [ 8, 21, 21 ] PPI::Token::Whitespace ' ' [ 8, 23, 23 ] PPI::Token::Whitespace '\n' PPI::Statement::Given [ 9, 1, 1 ] PPI::Token::Word 'given' [ 9, 6, 6 ] PPI::Token::Whitespace ' ' PPI::Structure::Given ( ... ) PPI::Statement::Expression [ 9, 8, 8 ] PPI::Token::Number '1' [ 9, 10, 10 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 9, 12, 12 ] PPI::Token::Whitespace ' ' PPI::Statement [ 9, 13, 13 ] PPI::Token::Symbol '$s' [ 9, 15, 15 ] PPI::Token::Whitespace ' ' [ 9, 16, 16 ] PPI::Token::Operator '=' [ 9, 17, 17 ] PPI::Token::Whitespace ' ' [ 9, 18, 18 ] PPI::Token::Number '8' [ 9, 19, 19 ] PPI::Token::Whitespace ' ' [ 9, 21, 21 ] PPI::Token::Whitespace '\n' PPI::Statement::When [ 10, 1, 1 ] PPI::Token::Word 'when' [ 10, 5, 5 ] PPI::Token::Whitespace ' ' PPI::Structure::When ( ... ) PPI::Statement::Expression [ 10, 7, 7 ] PPI::Token::Number '1' [ 10, 9, 9 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 10, 11, 11 ] PPI::Token::Whitespace ' ' PPI::Statement [ 10, 12, 12 ] PPI::Token::Symbol '$r' [ 10, 14, 14 ] PPI::Token::Whitespace ' ' [ 10, 15, 15 ] PPI::Token::Operator '=' [ 10, 16, 16 ] PPI::Token::Whitespace ' ' [ 10, 17, 17 ] PPI::Token::Number '9' [ 10, 18, 18 ] PPI::Token::Whitespace ' ' [ 10, 20, 20 ] PPI::Token::Whitespace '\n' END_EXPECTED ); _test($source, \%expected, 'Single namespace.'); } # end scope block { my $source = <<'END_SOURCE'; $x = 1; END_SOURCE my %expected = ( main => [ <<'END_EXPECTED' ], PPI::Document PPI::Statement [ 1, 1, 1 ] PPI::Token::Symbol '$x' [ 1, 3, 3 ] PPI::Token::Whitespace ' ' [ 1, 4, 4 ] PPI::Token::Operator '=' [ 1, 5, 5 ] PPI::Token::Whitespace ' ' [ 1, 6, 6 ] PPI::Token::Number '1' [ 1, 7, 7 ] PPI::Token::Structure ';' [ 1, 8, 8 ] PPI::Token::Whitespace '\n' END_EXPECTED ); _test($source, \%expected, 'Default namespace.'); } # end scope block { my $source = <<'END_SOURCE'; $x = 1; package Foo; $y = 2; END_SOURCE my %expected = ( main => [ <<'END_EXPECTED_MAIN' ], PPI::Document::Fragment PPI::Statement [ 1, 1, 1 ] PPI::Token::Symbol '$x' [ 1, 3, 3 ] PPI::Token::Whitespace ' ' [ 1, 4, 4 ] PPI::Token::Operator '=' [ 1, 5, 5 ] PPI::Token::Whitespace ' ' [ 1, 6, 6 ] PPI::Token::Number '1' [ 1, 7, 7 ] PPI::Token::Structure ';' [ 1, 8, 8 ] PPI::Token::Whitespace '\n' [ 2, 1, 1 ] PPI::Token::Whitespace '\n' END_EXPECTED_MAIN Foo => [ <<'END_EXPECTED_FOO' ], PPI::Document::Fragment PPI::Statement::Package [ 3, 1, 1 ] PPI::Token::Word 'package' [ 3, 8, 8 ] PPI::Token::Whitespace ' ' [ 3, 9, 9 ] PPI::Token::Word 'Foo' [ 3, 12, 12 ] PPI::Token::Structure ';' [ 3, 13, 13 ] PPI::Token::Whitespace '\n' [ 4, 1, 1 ] PPI::Token::Whitespace '\n' PPI::Statement [ 5, 1, 1 ] PPI::Token::Symbol '$y' [ 5, 3, 3 ] PPI::Token::Whitespace ' ' [ 5, 4, 4 ] PPI::Token::Operator '=' [ 5, 5, 5 ] PPI::Token::Whitespace ' ' [ 5, 6, 6 ] PPI::Token::Number '2' [ 5, 7, 7 ] PPI::Token::Structure ';' [ 5, 8, 8 ] PPI::Token::Whitespace '\n' END_EXPECTED_FOO ); _test($source, \%expected, 'Simple multiple namespaces: default followed by non-default.'); } # end scope block { my $source = <<'END_SOURCE'; package Foo; $x = 1; package main; $y = 2; END_SOURCE my %expected = ( main => [ <<'END_EXPECTED_MAIN' ], PPI::Document::Fragment PPI::Statement::Package [ 4, 1, 1 ] PPI::Token::Word 'package' [ 4, 8, 8 ] PPI::Token::Whitespace ' ' [ 4, 9, 9 ] PPI::Token::Word 'main' [ 4, 13, 13 ] PPI::Token::Structure ';' [ 4, 14, 14 ] PPI::Token::Whitespace '\n' [ 5, 1, 1 ] PPI::Token::Whitespace '\n' PPI::Statement [ 6, 1, 1 ] PPI::Token::Symbol '$y' [ 6, 3, 3 ] PPI::Token::Whitespace ' ' [ 6, 4, 4 ] PPI::Token::Operator '=' [ 6, 5, 5 ] PPI::Token::Whitespace ' ' [ 6, 6, 6 ] PPI::Token::Number '2' [ 6, 7, 7 ] PPI::Token::Structure ';' [ 6, 8, 8 ] PPI::Token::Whitespace '\n' END_EXPECTED_MAIN Foo => [ <<'END_EXPECTED_FOO' ], PPI::Document::Fragment PPI::Statement::Package [ 1, 1, 1 ] PPI::Token::Word 'package' [ 1, 8, 8 ] PPI::Token::Whitespace ' ' [ 1, 9, 9 ] PPI::Token::Word 'Foo' [ 1, 12, 12 ] PPI::Token::Structure ';' [ 1, 13, 13 ] PPI::Token::Whitespace '\n' PPI::Statement [ 2, 1, 1 ] PPI::Token::Symbol '$x' [ 2, 3, 3 ] PPI::Token::Whitespace ' ' [ 2, 4, 4 ] PPI::Token::Operator '=' [ 2, 5, 5 ] PPI::Token::Whitespace ' ' [ 2, 6, 6 ] PPI::Token::Number '1' [ 2, 7, 7 ] PPI::Token::Structure ';' [ 2, 8, 8 ] PPI::Token::Whitespace '\n' [ 3, 1, 1 ] PPI::Token::Whitespace '\n' END_EXPECTED_FOO ); _test($source, \%expected, 'Simple multiple namespaces: non-default followed by default.'); } # end scope block { my $source = <<'END_SOURCE'; $x = 1; package Foo; $y = 2; package main; $z = 3; package Foo; $w = 4; package main; $v = 5; END_SOURCE my %expected = ( main => [ <<'END_EXPECTED_MAIN' ], PPI::Document::Fragment PPI::Statement [ 1, 1, 1 ] PPI::Token::Symbol '$x' [ 1, 3, 3 ] PPI::Token::Whitespace ' ' [ 1, 4, 4 ] PPI::Token::Operator '=' [ 1, 5, 5 ] PPI::Token::Whitespace ' ' [ 1, 6, 6 ] PPI::Token::Number '1' [ 1, 7, 7 ] PPI::Token::Structure ';' [ 1, 8, 8 ] PPI::Token::Whitespace '\n' PPI::Statement::Package [ 4, 1, 1 ] PPI::Token::Word 'package' [ 4, 8, 8 ] PPI::Token::Whitespace ' ' [ 4, 9, 9 ] PPI::Token::Word 'main' [ 4, 13, 13 ] PPI::Token::Structure ';' [ 4, 14, 14 ] PPI::Token::Whitespace '\n' PPI::Statement [ 5, 1, 1 ] PPI::Token::Symbol '$z' [ 5, 3, 3 ] PPI::Token::Whitespace ' ' [ 5, 4, 4 ] PPI::Token::Operator '=' [ 5, 5, 5 ] PPI::Token::Whitespace ' ' [ 5, 6, 6 ] PPI::Token::Number '3' [ 5, 7, 7 ] PPI::Token::Structure ';' [ 5, 8, 8 ] PPI::Token::Whitespace '\n' PPI::Statement::Package [ 8, 1, 1 ] PPI::Token::Word 'package' [ 8, 8, 8 ] PPI::Token::Whitespace ' ' [ 8, 9, 9 ] PPI::Token::Word 'main' [ 8, 13, 13 ] PPI::Token::Structure ';' [ 8, 14, 14 ] PPI::Token::Whitespace '\n' PPI::Statement [ 9, 1, 1 ] PPI::Token::Symbol '$v' [ 9, 3, 3 ] PPI::Token::Whitespace ' ' [ 9, 4, 4 ] PPI::Token::Operator '=' [ 9, 5, 5 ] PPI::Token::Whitespace ' ' [ 9, 6, 6 ] PPI::Token::Number '5' [ 9, 7, 7 ] PPI::Token::Structure ';' [ 9, 8, 8 ] PPI::Token::Whitespace '\n' END_EXPECTED_MAIN Foo => [ <<'END_EXPECTED_FOO' ], PPI::Document::Fragment PPI::Statement::Package [ 2, 1, 1 ] PPI::Token::Word 'package' [ 2, 8, 8 ] PPI::Token::Whitespace ' ' [ 2, 9, 9 ] PPI::Token::Word 'Foo' [ 2, 12, 12 ] PPI::Token::Structure ';' [ 2, 13, 13 ] PPI::Token::Whitespace '\n' PPI::Statement [ 3, 1, 1 ] PPI::Token::Symbol '$y' [ 3, 3, 3 ] PPI::Token::Whitespace ' ' [ 3, 4, 4 ] PPI::Token::Operator '=' [ 3, 5, 5 ] PPI::Token::Whitespace ' ' [ 3, 6, 6 ] PPI::Token::Number '2' [ 3, 7, 7 ] PPI::Token::Structure ';' [ 3, 8, 8 ] PPI::Token::Whitespace '\n' PPI::Statement::Package [ 6, 1, 1 ] PPI::Token::Word 'package' [ 6, 8, 8 ] PPI::Token::Whitespace ' ' [ 6, 9, 9 ] PPI::Token::Word 'Foo' [ 6, 12, 12 ] PPI::Token::Structure ';' [ 6, 13, 13 ] PPI::Token::Whitespace '\n' PPI::Statement [ 7, 1, 1 ] PPI::Token::Symbol '$w' [ 7, 3, 3 ] PPI::Token::Whitespace ' ' [ 7, 4, 4 ] PPI::Token::Operator '=' [ 7, 5, 5 ] PPI::Token::Whitespace ' ' [ 7, 6, 6 ] PPI::Token::Number '4' [ 7, 7, 7 ] PPI::Token::Structure ';' [ 7, 8, 8 ] PPI::Token::Whitespace '\n' END_EXPECTED_FOO ); _test( $source, \%expected, 'Simple multiple namespaces: back and forth between two.', ); } # end scope block { my $source = <<'END_SOURCE'; $x = 1; { package Foo; $a = 17; } $y = 2; END_SOURCE my %expected = ( main => [ <<'END_EXPECTED_MAIN' ], PPI::Document::Fragment PPI::Statement [ 1, 1, 1 ] PPI::Token::Symbol '$x' [ 1, 3, 3 ] PPI::Token::Whitespace ' ' [ 1, 4, 4 ] PPI::Token::Operator '=' [ 1, 5, 5 ] PPI::Token::Whitespace ' ' [ 1, 6, 6 ] PPI::Token::Number '1' [ 1, 7, 7 ] PPI::Token::Structure ';' [ 1, 8, 8 ] PPI::Token::Whitespace '\n' [ 2, 1, 1 ] PPI::Token::Whitespace '\n' PPI::Statement::Compound PPI::Structure::Block { ... } [ 3, 2, 2 ] PPI::Token::Whitespace '\n' [ 4, 1, 1 ] PPI::Token::Whitespace ' ' [ 6, 2, 2 ] PPI::Token::Whitespace '\n' [ 7, 1, 1 ] PPI::Token::Whitespace '\n' PPI::Statement [ 8, 1, 1 ] PPI::Token::Symbol '$y' [ 8, 3, 3 ] PPI::Token::Whitespace ' ' [ 8, 4, 4 ] PPI::Token::Operator '=' [ 8, 5, 5 ] PPI::Token::Whitespace ' ' [ 8, 6, 6 ] PPI::Token::Number '2' [ 8, 7, 7 ] PPI::Token::Structure ';' [ 8, 8, 8 ] PPI::Token::Whitespace '\n' END_EXPECTED_MAIN Foo => [ <<'END_EXPECTED_FOO' ], PPI::Document::Fragment PPI::Statement::Package [ 4, 5, 5 ] PPI::Token::Word 'package' [ 4, 12, 12 ] PPI::Token::Whitespace ' ' [ 4, 13, 13 ] PPI::Token::Word 'Foo' [ 4, 16, 16 ] PPI::Token::Structure ';' [ 4, 17, 17 ] PPI::Token::Whitespace '\n' [ 5, 1, 1 ] PPI::Token::Whitespace ' ' PPI::Statement [ 5, 5, 5 ] PPI::Token::Symbol '$a' [ 5, 7, 7 ] PPI::Token::Whitespace ' ' [ 5, 8, 8 ] PPI::Token::Operator '=' [ 5, 9, 9 ] PPI::Token::Whitespace ' ' [ 5, 10, 10 ] PPI::Token::Number '17' [ 5, 12, 12 ] PPI::Token::Structure ';' [ 5, 13, 13 ] PPI::Token::Whitespace '\n' END_EXPECTED_FOO ); _test($source, \%expected, 'Single lexically scoped namespace: scope block.'); } # end scope block { my $source = <<'END_SOURCE'; $x = 1; foreach qw< l m n > { package Foo; $a = 17; } $y = 2; END_SOURCE my %expected = ( main => [ <<'END_EXPECTED_MAIN' ], PPI::Document::Fragment PPI::Statement [ 1, 1, 1 ] PPI::Token::Symbol '$x' [ 1, 3, 3 ] PPI::Token::Whitespace ' ' [ 1, 4, 4 ] PPI::Token::Operator '=' [ 1, 5, 5 ] PPI::Token::Whitespace ' ' [ 1, 6, 6 ] PPI::Token::Number '1' [ 1, 7, 7 ] PPI::Token::Structure ';' [ 1, 8, 8 ] PPI::Token::Whitespace '\n' [ 2, 1, 1 ] PPI::Token::Whitespace '\n' PPI::Statement::Compound [ 3, 1, 1 ] PPI::Token::Word 'foreach' [ 3, 8, 8 ] PPI::Token::Whitespace ' ' [ 3, 9, 9 ] PPI::Token::QuoteLike::Words 'qw< l m n >' [ 3, 20, 20 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 3, 22, 22 ] PPI::Token::Whitespace '\n' [ 4, 1, 1 ] PPI::Token::Whitespace ' ' [ 6, 2, 2 ] PPI::Token::Whitespace '\n' [ 7, 1, 1 ] PPI::Token::Whitespace '\n' PPI::Statement [ 8, 1, 1 ] PPI::Token::Symbol '$y' [ 8, 3, 3 ] PPI::Token::Whitespace ' ' [ 8, 4, 4 ] PPI::Token::Operator '=' [ 8, 5, 5 ] PPI::Token::Whitespace ' ' [ 8, 6, 6 ] PPI::Token::Number '2' [ 8, 7, 7 ] PPI::Token::Structure ';' [ 8, 8, 8 ] PPI::Token::Whitespace '\n' END_EXPECTED_MAIN Foo => [ <<'END_EXPECTED_FOO' ], PPI::Document::Fragment PPI::Statement::Package [ 4, 5, 5 ] PPI::Token::Word 'package' [ 4, 12, 12 ] PPI::Token::Whitespace ' ' [ 4, 13, 13 ] PPI::Token::Word 'Foo' [ 4, 16, 16 ] PPI::Token::Structure ';' [ 4, 17, 17 ] PPI::Token::Whitespace '\n' [ 5, 1, 1 ] PPI::Token::Whitespace ' ' PPI::Statement [ 5, 5, 5 ] PPI::Token::Symbol '$a' [ 5, 7, 7 ] PPI::Token::Whitespace ' ' [ 5, 8, 8 ] PPI::Token::Operator '=' [ 5, 9, 9 ] PPI::Token::Whitespace ' ' [ 5, 10, 10 ] PPI::Token::Number '17' [ 5, 12, 12 ] PPI::Token::Structure ';' [ 5, 13, 13 ] PPI::Token::Whitespace '\n' END_EXPECTED_FOO ); _test( $source, \%expected, 'Single lexically scoped namespace: foreach loop.', ); } # end scope block { my $source = <<'END_SOURCE'; $x = 1; given qw< l m n > { package Foo; $a = 17; } $y = 2; END_SOURCE my %expected = ( main => [ <<'END_EXPECTED_MAIN' ], PPI::Document::Fragment PPI::Statement [ 1, 1, 1 ] PPI::Token::Symbol '$x' [ 1, 3, 3 ] PPI::Token::Whitespace ' ' [ 1, 4, 4 ] PPI::Token::Operator '=' [ 1, 5, 5 ] PPI::Token::Whitespace ' ' [ 1, 6, 6 ] PPI::Token::Number '1' [ 1, 7, 7 ] PPI::Token::Structure ';' [ 1, 8, 8 ] PPI::Token::Whitespace '\n' [ 2, 1, 1 ] PPI::Token::Whitespace '\n' PPI::Statement::Given [ 3, 1, 1 ] PPI::Token::Word 'given' [ 3, 6, 6 ] PPI::Token::Whitespace ' ' [ 3, 7, 7 ] PPI::Token::QuoteLike::Words 'qw< l m n >' [ 3, 18, 18 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 3, 20, 20 ] PPI::Token::Whitespace '\n' [ 4, 1, 1 ] PPI::Token::Whitespace ' ' [ 6, 2, 2 ] PPI::Token::Whitespace '\n' [ 7, 1, 1 ] PPI::Token::Whitespace '\n' PPI::Statement [ 8, 1, 1 ] PPI::Token::Symbol '$y' [ 8, 3, 3 ] PPI::Token::Whitespace ' ' [ 8, 4, 4 ] PPI::Token::Operator '=' [ 8, 5, 5 ] PPI::Token::Whitespace ' ' [ 8, 6, 6 ] PPI::Token::Number '2' [ 8, 7, 7 ] PPI::Token::Structure ';' [ 8, 8, 8 ] PPI::Token::Whitespace '\n' END_EXPECTED_MAIN Foo => [ <<'END_EXPECTED_FOO' ], PPI::Document::Fragment PPI::Statement::Package [ 4, 5, 5 ] PPI::Token::Word 'package' [ 4, 12, 12 ] PPI::Token::Whitespace ' ' [ 4, 13, 13 ] PPI::Token::Word 'Foo' [ 4, 16, 16 ] PPI::Token::Structure ';' [ 4, 17, 17 ] PPI::Token::Whitespace '\n' [ 5, 1, 1 ] PPI::Token::Whitespace ' ' PPI::Statement [ 5, 5, 5 ] PPI::Token::Symbol '$a' [ 5, 7, 7 ] PPI::Token::Whitespace ' ' [ 5, 8, 8 ] PPI::Token::Operator '=' [ 5, 9, 9 ] PPI::Token::Whitespace ' ' [ 5, 10, 10 ] PPI::Token::Number '17' [ 5, 12, 12 ] PPI::Token::Structure ';' [ 5, 13, 13 ] PPI::Token::Whitespace '\n' END_EXPECTED_FOO ); _test( $source, \%expected, 'Single lexically scoped namespace: given.', ); } # end scope block { my $source = <<'END_SOURCE'; $x = 1; when qw< l m n > { package Foo; $a = 17; } $y = 2; END_SOURCE my %expected = ( main => [ <<'END_EXPECTED_MAIN' ], PPI::Document::Fragment PPI::Statement [ 1, 1, 1 ] PPI::Token::Symbol '$x' [ 1, 3, 3 ] PPI::Token::Whitespace ' ' [ 1, 4, 4 ] PPI::Token::Operator '=' [ 1, 5, 5 ] PPI::Token::Whitespace ' ' [ 1, 6, 6 ] PPI::Token::Number '1' [ 1, 7, 7 ] PPI::Token::Structure ';' [ 1, 8, 8 ] PPI::Token::Whitespace '\n' [ 2, 1, 1 ] PPI::Token::Whitespace '\n' PPI::Statement::When [ 3, 1, 1 ] PPI::Token::Word 'when' [ 3, 5, 5 ] PPI::Token::Whitespace ' ' [ 3, 6, 6 ] PPI::Token::QuoteLike::Words 'qw< l m n >' [ 3, 17, 17 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 3, 19, 19 ] PPI::Token::Whitespace '\n' [ 4, 1, 1 ] PPI::Token::Whitespace ' ' [ 6, 2, 2 ] PPI::Token::Whitespace '\n' [ 7, 1, 1 ] PPI::Token::Whitespace '\n' PPI::Statement [ 8, 1, 1 ] PPI::Token::Symbol '$y' [ 8, 3, 3 ] PPI::Token::Whitespace ' ' [ 8, 4, 4 ] PPI::Token::Operator '=' [ 8, 5, 5 ] PPI::Token::Whitespace ' ' [ 8, 6, 6 ] PPI::Token::Number '2' [ 8, 7, 7 ] PPI::Token::Structure ';' [ 8, 8, 8 ] PPI::Token::Whitespace '\n' END_EXPECTED_MAIN Foo => [ <<'END_EXPECTED_FOO' ], PPI::Document::Fragment PPI::Statement::Package [ 4, 5, 5 ] PPI::Token::Word 'package' [ 4, 12, 12 ] PPI::Token::Whitespace ' ' [ 4, 13, 13 ] PPI::Token::Word 'Foo' [ 4, 16, 16 ] PPI::Token::Structure ';' [ 4, 17, 17 ] PPI::Token::Whitespace '\n' [ 5, 1, 1 ] PPI::Token::Whitespace ' ' PPI::Statement [ 5, 5, 5 ] PPI::Token::Symbol '$a' [ 5, 7, 7 ] PPI::Token::Whitespace ' ' [ 5, 8, 8 ] PPI::Token::Operator '=' [ 5, 9, 9 ] PPI::Token::Whitespace ' ' [ 5, 10, 10 ] PPI::Token::Number '17' [ 5, 12, 12 ] PPI::Token::Structure ';' [ 5, 13, 13 ] PPI::Token::Whitespace '\n' END_EXPECTED_FOO ); _test( $source, \%expected, 'Single lexically scoped namespace: when.', ); } # end scope block { my $source = <<'END_SOURCE'; given (0) { package Foo; when (1) { package main; } when (2) { package main; } default { package main; while (3) { package Foo; package Bar; package Foo; package main; foreach (4) { package Foo; } } } } END_SOURCE my %expected = ( main => [ <<'END_EXPECTED_MAIN', PPI::Document::Fragment PPI::Statement::Given [ 1, 1, 1 ] PPI::Token::Word 'given' [ 1, 6, 6 ] PPI::Token::Whitespace ' ' PPI::Structure::Given ( ... ) PPI::Statement::Expression [ 1, 8, 8 ] PPI::Token::Number '0' [ 1, 10, 10 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 1, 12, 12 ] PPI::Token::Whitespace '\n' [ 2, 1, 1 ] PPI::Token::Whitespace ' ' [ 21, 2, 2 ] PPI::Token::Whitespace '\n' END_EXPECTED_MAIN <<'END_EXPECTED_MAIN', PPI::Document::Fragment PPI::Statement::Package [ 4, 9, 9 ] PPI::Token::Word 'package' [ 4, 16, 16 ] PPI::Token::Whitespace ' ' [ 4, 17, 17 ] PPI::Token::Word 'main' [ 4, 21, 21 ] PPI::Token::Structure ';' [ 4, 22, 22 ] PPI::Token::Whitespace '\n' [ 5, 1, 1 ] PPI::Token::Whitespace ' ' END_EXPECTED_MAIN <<'END_EXPECTED_MAIN', PPI::Document::Fragment PPI::Statement::Package [ 7, 9, 9 ] PPI::Token::Word 'package' [ 7, 16, 16 ] PPI::Token::Whitespace ' ' [ 7, 17, 17 ] PPI::Token::Word 'main' [ 7, 21, 21 ] PPI::Token::Structure ';' [ 7, 22, 22 ] PPI::Token::Whitespace '\n' [ 8, 1, 1 ] PPI::Token::Whitespace ' ' END_EXPECTED_MAIN <<'END_EXPECTED_MAIN', PPI::Document::Fragment PPI::Statement::Package [ 10, 9, 9 ] PPI::Token::Word 'package' [ 10, 16, 16 ] PPI::Token::Whitespace ' ' [ 10, 17, 17 ] PPI::Token::Word 'main' [ 10, 21, 21 ] PPI::Token::Structure ';' [ 10, 22, 22 ] PPI::Token::Whitespace '\n' [ 11, 1, 1 ] PPI::Token::Whitespace ' ' PPI::Statement::Compound [ 11, 9, 9 ] PPI::Token::Word 'while' [ 11, 14, 14 ] PPI::Token::Whitespace ' ' PPI::Structure::Condition ( ... ) PPI::Statement::Expression [ 11, 16, 16 ] PPI::Token::Number '3' [ 11, 18, 18 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 11, 20, 20 ] PPI::Token::Whitespace '\n' [ 12, 1, 1 ] PPI::Token::Whitespace ' ' PPI::Statement::Package [ 15, 13, 13 ] PPI::Token::Word 'package' [ 15, 20, 20 ] PPI::Token::Whitespace ' ' [ 15, 21, 21 ] PPI::Token::Word 'main' [ 15, 25, 25 ] PPI::Token::Structure ';' [ 15, 26, 26 ] PPI::Token::Whitespace '\n' [ 16, 1, 1 ] PPI::Token::Whitespace ' ' PPI::Statement::Compound [ 16, 13, 13 ] PPI::Token::Word 'foreach' [ 16, 20, 20 ] PPI::Token::Whitespace ' ' PPI::Structure::List ( ... ) PPI::Statement [ 16, 22, 22 ] PPI::Token::Number '4' [ 16, 24, 24 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 16, 26, 26 ] PPI::Token::Whitespace '\n' [ 17, 1, 1 ] PPI::Token::Whitespace ' ' [ 18, 14, 14 ] PPI::Token::Whitespace '\n' [ 19, 1, 1 ] PPI::Token::Whitespace ' ' [ 19, 10, 10 ] PPI::Token::Whitespace '\n' [ 20, 1, 1 ] PPI::Token::Whitespace ' ' END_EXPECTED_MAIN ], Foo => [ <<'END_EXPECTED_FOO', PPI::Document::Fragment PPI::Statement::Package [ 2, 5, 5 ] PPI::Token::Word 'package' [ 2, 12, 12 ] PPI::Token::Whitespace ' ' [ 2, 13, 13 ] PPI::Token::Word 'Foo' [ 2, 16, 16 ] PPI::Token::Structure ';' [ 2, 17, 17 ] PPI::Token::Whitespace '\n' [ 3, 1, 1 ] PPI::Token::Whitespace ' ' PPI::Statement::When [ 3, 5, 5 ] PPI::Token::Word 'when' [ 3, 9, 9 ] PPI::Token::Whitespace ' ' PPI::Structure::When ( ... ) PPI::Statement::Expression [ 3, 11, 11 ] PPI::Token::Number '1' [ 3, 13, 13 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 3, 15, 15 ] PPI::Token::Whitespace '\n' [ 4, 1, 1 ] PPI::Token::Whitespace ' ' [ 5, 6, 6 ] PPI::Token::Whitespace '\n' [ 6, 1, 1 ] PPI::Token::Whitespace ' ' PPI::Statement::When [ 6, 5, 5 ] PPI::Token::Word 'when' [ 6, 9, 9 ] PPI::Token::Whitespace ' ' PPI::Structure::When ( ... ) PPI::Statement::Expression [ 6, 11, 11 ] PPI::Token::Number '2' [ 6, 13, 13 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 6, 15, 15 ] PPI::Token::Whitespace '\n' [ 7, 1, 1 ] PPI::Token::Whitespace ' ' [ 8, 6, 6 ] PPI::Token::Whitespace '\n' [ 9, 1, 1 ] PPI::Token::Whitespace ' ' PPI::Statement::When [ 9, 5, 5 ] PPI::Token::Word 'default' [ 9, 12, 12 ] PPI::Token::Whitespace ' ' PPI::Structure::Block { ... } [ 9, 14, 14 ] PPI::Token::Whitespace '\n' [ 10, 1, 1 ] PPI::Token::Whitespace ' ' [ 20, 6, 6 ] PPI::Token::Whitespace '\n' END_EXPECTED_FOO <<'END_EXPECTED_FOO', PPI::Document::Fragment PPI::Statement::Package [ 12, 13, 13 ] PPI::Token::Word 'package' [ 12, 20, 20 ] PPI::Token::Whitespace ' ' [ 12, 21, 21 ] PPI::Token::Word 'Foo' [ 12, 24, 24 ] PPI::Token::Structure ';' [ 12, 25, 25 ] PPI::Token::Whitespace '\n' [ 13, 1, 1 ] PPI::Token::Whitespace ' ' PPI::Statement::Package [ 14, 13, 13 ] PPI::Token::Word 'package' [ 14, 20, 20 ] PPI::Token::Whitespace ' ' [ 14, 21, 21 ] PPI::Token::Word 'Foo' [ 14, 24, 24 ] PPI::Token::Structure ';' [ 14, 25, 25 ] PPI::Token::Whitespace '\n' [ 15, 1, 1 ] PPI::Token::Whitespace ' ' END_EXPECTED_FOO <<'END_EXPECTED_FOO', PPI::Document::Fragment PPI::Statement::Package [ 17, 17, 17 ] PPI::Token::Word 'package' [ 17, 24, 24 ] PPI::Token::Whitespace ' ' [ 17, 25, 25 ] PPI::Token::Word 'Foo' [ 17, 28, 28 ] PPI::Token::Structure ';' [ 17, 29, 29 ] PPI::Token::Whitespace '\n' [ 18, 1, 1 ] PPI::Token::Whitespace ' ' END_EXPECTED_FOO ], Bar => [ <<'END_EXPECTED_BAR' ], PPI::Document::Fragment PPI::Statement::Package [ 13, 13, 13 ] PPI::Token::Word 'package' [ 13, 20, 20 ] PPI::Token::Whitespace ' ' [ 13, 21, 21 ] PPI::Token::Word 'Bar' [ 13, 24, 24 ] PPI::Token::Structure ';' [ 13, 25, 25 ] PPI::Token::Whitespace '\n' [ 14, 1, 1 ] PPI::Token::Whitespace ' ' END_EXPECTED_BAR ); _test( $source, \%expected, 'Heavilly nested namespaces.', ); } # end scope block sub _test { my ($source, $expected_ref, $test_name) = @_; my $document = PPI::Document->new(\$source); my %expanded_expected; while ( my ($namespace, $strings) = each %{$expected_ref} ) { $expanded_expected{$namespace} = [ map { [ split m/ \n /xms ] } @{$strings} ]; } # end while my $got = split_ppi_node_by_namespace($document); my %got_expanded; while ( my ($namespace, $ppi_doms) = each %{$got} ) { $got_expanded{$namespace} = [ map { [ map { _expand_tabs($_) } _new_dumper($_)->list() ] } @{$ppi_doms} ]; } # end while cmp_deeply(\%got_expanded, \%expanded_expected, $test_name) or diag( Data::Dumper->Dump( [\%got_expanded, \%expanded_expected], [ qw ], ) ); return; } # end _test() sub _new_dumper { my ($node) = @_; return PPI::Dumper->new($node, indent => $DUMP_INDENT, locations => 1); } # end _new_dumper() # Why Adam had to put @#$^@#$&^ hard tabs in his dumper output, I don't know. sub _expand_tabs { my ($string) = @_; while ( $string =~ s< \A ( [^\t]* ) ( \t+ ) > <$1 . ( ' ' x (length($2) * $DUMP_INDENT - length($1) % $DUMP_INDENT) )>xmse ) { # Nothing here. } # end while return $string; } # end _expand_tabs() # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/t/split-ppi-node-by-namespace.t $ # $Date: 2010-11-13 14:25:12 -0600 (Sat, 13 Nov 2010) $ # $Author: clonezone $ # $Revision: 3990 $ # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 78 # indent-tabs-mode: nil # c-indentation-style: bsd # End: # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab : PPIx-Utilities-1.001000/xt000755000766000766 011475602445 15146 5ustar00elliotelliot000000000000PPIx-Utilities-1.001000/xt/author000755000766000766 011475602445 16450 5ustar00elliotelliot000000000000PPIx-Utilities-1.001000/xt/author/consistent_version_numbers.t000444000766000766 334611475602445 24471 0ustar00elliotelliot000000000000#!/usr/bin/env perl # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/xt/author/consistent_version_numbers.t $ # $Date: 2010-11-13 14:25:12 -0600 (Sat, 13 Nov 2010) $ # $Author: clonezone $ # $Revision: 3990 $ # Taken from # http://www.chrisdolan.net/talk/index.php/2005/11/14/private-regression-tests/. use 5.006; use strict; use warnings; our $VERSION = '1.001000'; use File::Find; use File::Slurp; use Test::More qw(no_plan); my $last_version = undef; find({wanted => \&check_version, no_chdir => 1}, 'blib'); if (! defined $last_version) { ## no critic (RequireInterpolationOfMetachars) fail('Failed to find any files with $VERSION'); ## use critic } # end if sub check_version { # $_ is the full path to the file return if ! m{blib/script/}xms && ! m{ [.] pm \z}xms; my $content = read_file($_); # only look at perl scripts, not sh scripts return if m{blib/script/}xms && $content !~ m/\A \#![^\r\n]+?perl/xms; my @version_lines = $content =~ m/ ( [^\n]* \$VERSION [^\n]* ) /gxms; if (@version_lines == 0) { fail($_); } # end if foreach my $line (@version_lines) { if (!defined $last_version) { $last_version = shift @version_lines; pass($_); } else { is($line, $last_version, $_); } # end if } # end foreach return; } # end check_version() # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 78 # indent-tabs-mode: nil # c-indentation-style: bsd # End: # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : PPIx-Utilities-1.001000/xt/author/copyright.t000444000766000766 613111475602445 21003 0ustar00elliotelliot000000000000#!/usr/bin/env perl # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/xt/author/copyright.t $ # $Date: 2010-12-01 20:31:47 -0600 (Wed, 01 Dec 2010) $ # $Author: clonezone $ # $Revision: 4001 $ # Taken from # http://www.chrisdolan.net/talk/index.php/2005/11/14/private-regression-tests/. ## no critic (ProhibitFlagComments, ProhibitUnusualDelimiters, RequireBracesForMultiline) ## TODO: enable these once the policies accept other braces. use 5.006; use strict; use warnings; our $VERSION = '1.001000'; use File::Find; use File::Slurp; use Readonly; use Test::More qw(no_plan); Readonly my $LOCALTIME_YEAR_FIELD_NUMBER => 5; Readonly my $LOCALTIME_YEAR_OFFSET => 1900; my $this_year = (localtime)[$LOCALTIME_YEAR_FIELD_NUMBER] + $LOCALTIME_YEAR_OFFSET; my $copyrights_found = 0; find({wanted => \&check_file, no_chdir => 1}, 'blib'); foreach ( grep { m/^readme/ixms } read_dir(q<.>) ) { check_file(); } # end foreach ok($copyrights_found != 0, 'found a copyright statement'); sub check_file { # $_ is the path to a filename, relative to the root of the # distribution # Only test plain files return if (! -f $_); # Filter the list of filenames return if not m< ^ (?: README.* # docs | .*/scripts/[^/]+ # programs | .*/script/[^/]+ # programs | .*/bin/[^/]+ # programs | .* [.] (?: pl # program ext | pm # module ext | html # doc ext | 3pm # doc ext | [13] # doc ext ) ) $ >xms; ## use critic my $content = read_file($_); # Note: man pages will fail to match if the correct form of the # copyright symbol is used because the man page translators don't # handle UTF-8. # # For some reason, Vim writes a bad utf8 version of the copyright sign # if I attempt to modify the line. So, disable the violation. *sigh* ## no critic (ProhibitEscapedMetacharacters) my @copyright_years = $content =~ m/ (?: copyright | \(c\) ) \s* (?: \d{4} \\? - )? (\d{4}) /gixms; if (0 < grep {$_ ne $this_year} @copyright_years) { fail("$_ copyrights: @copyright_years"); } elsif (0 == @copyright_years) { pass("$_, no copyright found"); } else { pass($_); } # end if return $copyrights_found += @copyright_years; } # end check_file() # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 78 # indent-tabs-mode: nil # c-indentation-style: bsd # End: # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : PPIx-Utilities-1.001000/xt/author/distribution.t000444000766000766 155311475602445 21515 0ustar00elliotelliot000000000000#!/usr/bin/env perl # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/xt/author/distribution.t $ # $Date: 2010-11-13 14:25:12 -0600 (Sat, 13 Nov 2010) $ # $Author: clonezone $ # $Revision: 3990 $ # Taken from # http://www.chrisdolan.net/talk/index.php/2005/11/14/private-regression-tests/. use 5.006; use strict; use warnings; our $VERSION = '1.001000'; # No POD coverage due to complaints about builtins when using Fatal. use Test::Distribution ( distversion => 1, not => 'podcover' ); # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 78 # indent-tabs-mode: nil # c-indentation-style: bsd # End: # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : PPIx-Utilities-1.001000/xt/author/kwalitee.t000444000766000766 124711475602445 20603 0ustar00elliotelliot000000000000#!/usr/bin/env perl # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/xt/author/kwalitee.t $ # $Date: 2010-11-13 14:25:12 -0600 (Sat, 13 Nov 2010) $ # $Author: clonezone $ # $Revision: 3990 $ use 5.006; use strict; use warnings; our $VERSION = '1.001000'; use Test::More; use Test::Kwalitee; # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 78 # indent-tabs-mode: nil # c-indentation-style: bsd # End: # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : PPIx-Utilities-1.001000/xt/author/perlcritic-code.t000444000766000766 141111475602445 22037 0ustar00elliotelliot000000000000#!/usr/bin/env perl # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/xt/author/perlcritic-code.t $ # $Date: 2010-11-13 14:25:12 -0600 (Sat, 13 Nov 2010) $ # $Author: clonezone $ # $Revision: 3990 $ use 5.006; use strict; use warnings; our $VERSION = '1.001000'; use Test::Perl::Critic ( -severity => 1, -profile => 'xt/author/perlcriticrc-code' ); all_critic_ok( qw< lib bin > ); # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 78 # indent-tabs-mode: nil # c-indentation-style: bsd # End: # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : PPIx-Utilities-1.001000/xt/author/perlcritic-tests.t000444000766000766 141011475602445 22266 0ustar00elliotelliot000000000000#!/usr/bin/env perl # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/xt/author/perlcritic-tests.t $ # $Date: 2010-11-13 14:25:12 -0600 (Sat, 13 Nov 2010) $ # $Author: clonezone $ # $Revision: 3990 $ use 5.006; use strict; use warnings; our $VERSION = '1.001000'; use Test::Perl::Critic ( -severity => 1, -profile => 'xt/author/perlcriticrc-tests' ); all_critic_ok( qw< t xt > ); # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 78 # indent-tabs-mode: nil # c-indentation-style: bsd # End: # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : PPIx-Utilities-1.001000/xt/author/perlcriticrc-code000444000766000766 242611475602445 22131 0ustar00elliotelliot000000000000############################################################################## # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/xt/author/perlcriticrc-code $ # $Date: 2010-02-21 18:23:20 -0600 (Sun, 21 Feb 2010) $ # $Author: clonezone $ # $Revision: 3776 $ ############################################################################## profile-strictness = fatal severity = 1 theme = core + more verbose = %f: %m at line %l, column %c. %e. (Severity: %s, %p)\n #----------------------------------------------------------------------------- [BuiltinFunctions::ProhibitStringyEval] allow_includes = 1 [CodeLayout::ProhibitHardTabs] allow_leading_tabs = 0 [CodeLayout::ProhibitQuotedWordLists] strict = 1 [-CodeLayout::RequireTidyCode] [Documentation::PodSpelling] stop_words_file = xt/author/stop-words [Documentation::RequirePodSections] lib_sections = NAME|DESCRIPTION|AUTHOR|COPYRIGHT script_sections = NAME|DESCRIPTION|AUTHOR|COPYRIGHT [InputOutput::RequireCheckedSyscalls] functions = :builtins exclude_functions = print [Miscellanea::RequireRcsKeywords] keywords = URL Date Author Revision [RegularExpressions::ProhibitUnusualDelimiters] allow_all_brackets = 1 [RegularExpressions::RequireBracesForMultiline] allow_all_brackets = 1 PPIx-Utilities-1.001000/xt/author/perlcriticrc-tests000444000766000766 264011475602445 22357 0ustar00elliotelliot000000000000############################################################################## # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/xt/author/perlcriticrc-tests $ # $Date: 2009-06-26 11:12:12 -0400 (Fri, 26 Jun 2009) $ # $Author: clonezone $ # $Revision: 3366 $ ############################################################################## profile-strictness = quiet severity = 1 theme = core + more verbose = %f: %m at line %l, column %c. %e. (Severity: %s, %p)\n #----------------------------------------------------------------------------- [CodeLayout::ProhibitQuotedWordLists] strict = 1 [CodeLayout::ProhibitHardTabs] allow_leading_tabs = 0 [-CodeLayout::RequireTidyCode] [ControlStructures::ProhibitPostfixControls] flowcontrol = warn die carp croak cluck confess goto exit plan skip [Documentation::PodSpelling] stop_words = [-Documentation::RequirePodSections] [-ErrorHandling::RequireUseOfExceptions] [InputOutput::RequireCheckedSyscalls] functions = :builtins exclude_functions = print [Miscellanea::RequireRcsKeywords] keywords = URL Date Author Revision # Character length is not a proper measure of complexity. [-RegularExpressions::ProhibitComplexRegexes] [RegularExpressions::ProhibitUnusualDelimiters] allow_all_brackets = 1 [RegularExpressions::RequireBracesForMultiline] allow_all_brackets = 1 # Tests are allowed to peek. [-Subroutines::ProtectPrivateSubs] PPIx-Utilities-1.001000/xt/author/pod_coverage.t000444000766000766 156311475602445 21434 0ustar00elliotelliot000000000000#!/usr/bin/env perl # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/xt/author/pod_coverage.t $ # $Date: 2010-11-13 14:25:12 -0600 (Sat, 13 Nov 2010) $ # $Author: clonezone $ # $Revision: 3990 $ use 5.006; use strict; use warnings; our $VERSION = '1.001000'; use Test::More; use Test::Pod::Coverage; my @trusted_methods = qw< description >; my $method_string = join q< | >, @trusted_methods; my $regex = qr< \A (?: $method_string ) \z >xms; all_pod_coverage_ok( { trustme => [$regex] } ); # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 78 # indent-tabs-mode: nil # c-indentation-style: bsd # End: # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : PPIx-Utilities-1.001000/xt/author/pod_syntax.t000444000766000766 127111475602445 21163 0ustar00elliotelliot000000000000#!/usr/bin/env perl # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/xt/author/pod_syntax.t $ # $Date: 2010-11-13 14:25:12 -0600 (Sat, 13 Nov 2010) $ # $Author: clonezone $ # $Revision: 3990 $ use 5.006; use strict; use warnings; our $VERSION = '1.001000'; use Test::More; use Test::Pod; all_pod_files_ok(); # Local Variables: # mode: cperl # cperl-indent-level: 4 # fill-column: 78 # indent-tabs-mode: nil # c-indentation-style: bsd # End: # setup vim: set filetype=perl tabstop=4 softtabstop=4 expandtab : # setup vim: set shiftwidth=4 shiftround textwidth=78 nowrap autoindent : # setup vim: set foldmethod=indent foldlevel=0 : PPIx-Utilities-1.001000/xt/author/README000444000766000766 56011475602445 17446 0ustar00elliotelliot000000000000This directory contains tests that should only be run on a developer's machine because they aren't relevant during installation or that they are likely to fail anywhere other than the developer's machine. For example, using Test::Perl::Critic can produce errors when the locally installed version of Perl::Critic is different than the one on the developer's machine. PPIx-Utilities-1.001000/xt/author/stop-words000444000766000766 222111475602445 20646 0ustar00elliotelliot000000000000accessor accessors ActiveState autoflushes AUTOLOAD backticks bareword barewords BBEdit bitwise boolean booleans builtin CGI colour colours config CPAN CVS dereference dereferencing Dolan Dominus elsif evaluatable exponentials filehandle filehandles filename filenames globals globbing Guzis hashref Hasselbacher HEREDOC HEREDOCs IDE lvalue Maxia Mehner memoization metacharacters Metadata metadata misterwhipple multi-line mutators namespace namespaces octothorp PBP pbp perl perlcritic perlcriticrc perldoc Perlish perlmonk perls PDK PolicyListing POSIX postfix PPI PPIx PPI's pragma pragmas pragmata prepend prepending programmatically ProhibitPunctuationVars quotish readline Readonly refactor refactoring regex regexes runtime Schwartzian severities sigil sigils SQL STDERR STDIN STDOUT stringification subdirectories superclass superclasses TerMarsch Thalhammer TODO typeglob UI unblessed undef unescaped unparsed vice-versa whitespace Wyant # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/PPIx-Utilities/xt/author/stop-words $ # $Date: 2010-02-21 18:23:20 -0600 (Sun, 21 Feb 2010) $ # $Author: clonezone $ # $Revision: 3776 $