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