Commit | Line | Data |
c5bf3ed2 |
1 | #!/usr/bin/perl |
2 | |
3 | package Devel::REPL::Plugin::PPI; |
4 | use Devel::REPL::Plugin; |
5 | |
6 | use PPI; |
7 | use PPI::Dumper; |
8 | |
aa8b7647 |
9 | use namespace::autoclean; |
c5bf3ed2 |
10 | |
3a400715 |
11 | sub BEFORE_PLUGIN { |
12 | my $self = shift; |
13 | $self->load_plugin('Turtles'); |
14 | } |
c5bf3ed2 |
15 | |
16 | sub expr_command_ppi { |
17 | my ( $self, $eval, $code ) = @_; |
18 | |
19 | my $document = PPI::Document->new(\$code); |
20 | my $dumper = PPI::Dumper->new($document); |
21 | return $dumper->string; |
22 | } |
23 | |
24 | __PACKAGE__ |
25 | |
26 | __END__ |
27 | |
28 | =pod |
29 | |
30 | =head1 NAME |
31 | |
32 | Devel::REPL::Plugin::PPI - PPI dumping of Perl code |
33 | |
34 | =head1 SYNOPSIS |
35 | |
36 | repl> #ppi Devel::REPL |
37 | PPI::Document |
38 | PPI::Statement |
39 | PPI::Token::Word 'Devel::REPL' |
40 | |
41 | repl> #ppi { |
42 | > warn $]; |
43 | > } |
44 | PPI::Document |
45 | PPI::Statement::Compound |
46 | PPI::Structure::Block { ... } |
47 | PPI::Token::Whitespace '\n' |
48 | PPI::Statement |
49 | PPI::Token::Word 'warn' |
50 | PPI::Token::Whitespace ' ' |
51 | PPI::Token::Magic '$]' |
52 | PPI::Token::Structure ';' |
53 | PPI::Token::Whitespace '\n' |
54 | |
55 | =head1 DESCRIPTION |
56 | |
57 | This plugin provides a C<ppi> command that uses L<PPI::Dumper> to dump |
58 | L<PPI>-parsed Perl documents. |
59 | |
60 | The code is not actually executed, which means that when used with |
61 | L<Deve::REPL::Plugin::OutputCache> there is no new value in C<_>. |
62 | |
63 | =head1 AUTHOR |
64 | |
65 | Shawn M Moore E<lt>sartak@gmail.comE<gt> |
66 | |
67 | =cut |
68 | |
69 | |