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