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