Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPI/Statement.pm |
Statements | Executed 114591 statements in 377ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
10538 | 5 | 1 | 179ms | 265ms | new | PPI::Statement::
30415 | 1 | 1 | 26.7ms | 26.7ms | __LEXER__normal | PPI::Statement::
1 | 1 | 1 | 3.65ms | 3.71ms | BEGIN@166 | PPI::Statement::
1 | 1 | 1 | 1.51ms | 1.85ms | BEGIN@167 | PPI::Statement::
1 | 1 | 1 | 524µs | 632µs | BEGIN@175 | PPI::Statement::
1 | 1 | 1 | 440µs | 523µs | BEGIN@163 | PPI::Statement::
1 | 1 | 1 | 240µs | 793µs | BEGIN@170 | PPI::Statement::
1 | 1 | 1 | 233µs | 304µs | BEGIN@176 | PPI::Statement::
1 | 1 | 1 | 232µs | 300µs | BEGIN@169 | PPI::Statement::
1 | 1 | 1 | 208µs | 276µs | BEGIN@172 | PPI::Statement::
1 | 1 | 1 | 174µs | 242µs | BEGIN@165 | PPI::Statement::
1 | 1 | 1 | 164µs | 237µs | BEGIN@168 | PPI::Statement::
1 | 1 | 1 | 163µs | 234µs | BEGIN@164 | PPI::Statement::
1 | 1 | 1 | 159µs | 227µs | BEGIN@173 | PPI::Statement::
1 | 1 | 1 | 156µs | 223µs | BEGIN@162 | PPI::Statement::
1 | 1 | 1 | 152µs | 219µs | BEGIN@174 | PPI::Statement::
1 | 1 | 1 | 13µs | 13µs | BEGIN@156 | PPI::Statement::
1 | 1 | 1 | 12µs | 24µs | BEGIN@149 | PPI::Statement::
1 | 1 | 1 | 10µs | 39µs | BEGIN@151 | PPI::Statement::
1 | 1 | 1 | 6µs | 43µs | BEGIN@155 | PPI::Statement::
1 | 1 | 1 | 3µs | 3µs | BEGIN@171 | PPI::Statement::
1 | 1 | 1 | 3µs | 3µs | BEGIN@150 | PPI::Statement::
1 | 1 | 1 | 3µs | 3µs | BEGIN@152 | PPI::Statement::
1 | 1 | 1 | 3µs | 3µs | BEGIN@153 | PPI::Statement::
0 | 0 | 0 | 0s | 0s | _complete | PPI::Statement::
0 | 0 | 0 | 0s | 0s | insert_after | PPI::Statement::
0 | 0 | 0 | 0s | 0s | insert_before | PPI::Statement::
0 | 0 | 0 | 0s | 0s | label | PPI::Statement::
0 | 0 | 0 | 0s | 0s | specialized | PPI::Statement::
0 | 0 | 0 | 0s | 0s | stable | PPI::Statement::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package PPI::Statement; | ||||
2 | |||||
3 | =pod | ||||
4 | |||||
5 | =head1 NAME | ||||
6 | |||||
7 | PPI::Statement - The base class for Perl statements | ||||
8 | |||||
9 | =head1 INHERITANCE | ||||
10 | |||||
11 | PPI::Statement | ||||
12 | isa PPI::Node | ||||
13 | isa PPI::Element | ||||
14 | |||||
15 | =head1 DESCRIPTION | ||||
16 | |||||
17 | PPI::Statement is the root class for all Perl statements. This includes (from | ||||
18 | L<perlsyn>) "Declarations", "Simple Statements" and "Compound Statements". | ||||
19 | |||||
20 | The class PPI::Statement itself represents a "Simple Statement" as defined | ||||
21 | in the L<perlsyn> manpage. | ||||
22 | |||||
23 | =head1 STATEMENT CLASSES | ||||
24 | |||||
25 | Please note that unless documented themselves, these classes are yet to be | ||||
26 | frozen/finalised. Names may change slightly or be added or removed. | ||||
27 | |||||
28 | =head2 L<PPI::Statement::Scheduled> | ||||
29 | |||||
30 | This covers all "scheduled" blocks, chunks of code that are executed separately | ||||
31 | from the main body of the code, at a particular time. This includes all | ||||
32 | C<BEGIN>, C<CHECK>, C<UNITCHECK>, C<INIT> and C<END> blocks. | ||||
33 | |||||
34 | =head2 L<PPI::Statement::Package> | ||||
35 | |||||
36 | A package declaration, as defined in L<perlfunc|perlfunc/package>. | ||||
37 | |||||
38 | =head2 L<PPI::Statement::Include> | ||||
39 | |||||
40 | A statement that loads or unloads another module. | ||||
41 | |||||
42 | This includes 'use', 'no', and 'require' statements. | ||||
43 | |||||
44 | =head2 L<PPI::Statement::Sub> | ||||
45 | |||||
46 | A named subroutine declaration, or forward declaration | ||||
47 | |||||
48 | =head2 L<PPI::Statement::Variable> | ||||
49 | |||||
50 | A variable declaration statement. This could be either a straight | ||||
51 | declaration or also be an expression. | ||||
52 | |||||
53 | This includes all 'my', 'state', 'local' and 'our' statements. | ||||
54 | |||||
55 | =head2 L<PPI::Statement::Compound> | ||||
56 | |||||
57 | This covers the whole family of 'compound' statements, as described in | ||||
58 | L<perlsyn|perlsyn>. | ||||
59 | |||||
60 | This includes all statements starting with 'if', 'unless', 'for', 'foreach' | ||||
61 | and 'while'. Note that this does NOT include 'do', as it is treated | ||||
62 | differently. | ||||
63 | |||||
64 | All compound statements have implicit ends. That is, they do not end with | ||||
65 | a ';' statement terminator. | ||||
66 | |||||
67 | =head2 L<PPI::Statement::Break> | ||||
68 | |||||
69 | A statement that breaks out of a structure. | ||||
70 | |||||
71 | This includes all of 'redo', 'next', 'last' and 'return' statements. | ||||
72 | |||||
73 | =head2 L<PPI::Statement::Given> | ||||
74 | |||||
75 | The kind of statement introduced in Perl 5.10 that starts with 'given'. This | ||||
76 | has an implicit end. | ||||
77 | |||||
78 | =head2 L<PPI::Statement::When> | ||||
79 | |||||
80 | The kind of statement introduced in Perl 5.10 that starts with 'when' or | ||||
81 | 'default'. This also has an implicit end. | ||||
82 | |||||
83 | =head2 L<PPI::Statement::Data> | ||||
84 | |||||
85 | A special statement which encompasses an entire C<__DATA__> block, including | ||||
86 | the initial C<'__DATA__'> token itself and the entire contents. | ||||
87 | |||||
88 | =head2 L<PPI::Statement::End> | ||||
89 | |||||
90 | A special statement which encompasses an entire __END__ block, including | ||||
91 | the initial '__END__' token itself and the entire contents, including any | ||||
92 | parsed PPI::Token::POD that may occur in it. | ||||
93 | |||||
94 | =head2 L<PPI::Statement::Expression> | ||||
95 | |||||
96 | L<PPI::Statement::Expression> is a little more speculative, and is intended | ||||
97 | to help represent the special rules relating to "expressions" such as in: | ||||
98 | |||||
99 | # Several examples of expression statements | ||||
100 | |||||
101 | # Boolean conditions | ||||
102 | if ( expression ) { ... } | ||||
103 | |||||
104 | # Lists, such as for arguments | ||||
105 | Foo->bar( expression ) | ||||
106 | |||||
107 | =head2 L<PPI::Statement::Null> | ||||
108 | |||||
109 | A null statement is a special case for where we encounter two consecutive | ||||
110 | statement terminators. ( ;; ) | ||||
111 | |||||
112 | The second terminator is given an entire statement of its own, but one | ||||
113 | that serves no purpose. Hence a 'null' statement. | ||||
114 | |||||
115 | Theoretically, assuming a correct parsing of a perl file, all null statements | ||||
116 | are superfluous and should be able to be removed without damage to the file. | ||||
117 | |||||
118 | But don't do that, in case PPI has parsed something wrong. | ||||
119 | |||||
120 | =head2 L<PPI::Statement::UnmatchedBrace> | ||||
121 | |||||
122 | Because L<PPI> is intended for use when parsing incorrect or incomplete code, | ||||
123 | the problem arises of what to do with a stray closing brace. | ||||
124 | |||||
125 | Rather than die, it is allocated its own "unmatched brace" statement, | ||||
126 | which really means "unmatched closing brace". An unmatched open brace at the | ||||
127 | end of a file would become a structure with no contents and no closing brace. | ||||
128 | |||||
129 | If the document loaded is intended to be correct and valid, finding a | ||||
130 | L<PPI::Statement::UnmatchedBrace> in the PDOM is generally indicative of a | ||||
131 | misparse. | ||||
132 | |||||
133 | =head2 L<PPI::Statement::Unknown> | ||||
134 | |||||
135 | This is used temporarily mid-parsing to hold statements for which the lexer | ||||
136 | cannot yet determine what class it should be, usually because there are | ||||
137 | insufficient clues, or it might be more than one thing. | ||||
138 | |||||
139 | You should never encounter these in a fully parsed PDOM tree. | ||||
140 | |||||
141 | =head1 METHODS | ||||
142 | |||||
143 | C<PPI::Statement> itself has very few methods. Most of the time, you will be | ||||
144 | working with the more generic L<PPI::Element> or L<PPI::Node> methods, or one | ||||
145 | of the methods that are subclass-specific. | ||||
146 | |||||
147 | =cut | ||||
148 | |||||
149 | 2 | 22µs | 2 | 36µs | # spent 24µs (12+12) within PPI::Statement::BEGIN@149 which was called:
# once (12µs+12µs) by PPI::BEGIN@21 at line 149 # spent 24µs making 1 call to PPI::Statement::BEGIN@149
# spent 12µs making 1 call to strict::import |
150 | 2 | 18µs | 1 | 3µs | # spent 3µs within PPI::Statement::BEGIN@150 which was called:
# once (3µs+0s) by PPI::BEGIN@21 at line 150 # spent 3µs making 1 call to PPI::Statement::BEGIN@150 |
151 | 2 | 20µs | 2 | 69µs | # spent 39µs (10+30) within PPI::Statement::BEGIN@151 which was called:
# once (10µs+30µs) by PPI::BEGIN@21 at line 151 # spent 39µs making 1 call to PPI::Statement::BEGIN@151
# spent 30µs making 1 call to Exporter::import |
152 | 2 | 15µs | 1 | 3µs | # spent 3µs within PPI::Statement::BEGIN@152 which was called:
# once (3µs+0s) by PPI::BEGIN@21 at line 152 # spent 3µs making 1 call to PPI::Statement::BEGIN@152 |
153 | 2 | 21µs | 1 | 3µs | # spent 3µs within PPI::Statement::BEGIN@153 which was called:
# once (3µs+0s) by PPI::BEGIN@21 at line 153 # spent 3µs making 1 call to PPI::Statement::BEGIN@153 |
154 | |||||
155 | 2 | 32µs | 2 | 80µs | # spent 43µs (6+37) within PPI::Statement::BEGIN@155 which was called:
# once (6µs+37µs) by PPI::BEGIN@21 at line 155 # spent 43µs making 1 call to PPI::Statement::BEGIN@155
# spent 37µs making 1 call to vars::import |
156 | # spent 13µs within PPI::Statement::BEGIN@156 which was called:
# once (13µs+0s) by PPI::BEGIN@21 at line 160 | ||||
157 | 1 | 300ns | $VERSION = '1.215'; | ||
158 | 1 | 9µs | @ISA = 'PPI::Node'; | ||
159 | 1 | 4µs | *_PARENT = *PPI::Element::_PARENT; | ||
160 | 1 | 14µs | 1 | 13µs | } # spent 13µs making 1 call to PPI::Statement::BEGIN@156 |
161 | |||||
162 | 2 | 94µs | 1 | 223µs | # spent 223µs (156+67) within PPI::Statement::BEGIN@162 which was called:
# once (156µs+67µs) by PPI::BEGIN@21 at line 162 # spent 223µs making 1 call to PPI::Statement::BEGIN@162 |
163 | 2 | 96µs | 1 | 523µs | # spent 523µs (440+83) within PPI::Statement::BEGIN@163 which was called:
# once (440µs+83µs) by PPI::BEGIN@21 at line 163 # spent 523µs making 1 call to PPI::Statement::BEGIN@163 |
164 | 2 | 89µs | 1 | 234µs | # spent 234µs (163+71) within PPI::Statement::BEGIN@164 which was called:
# once (163µs+71µs) by PPI::BEGIN@21 at line 164 # spent 234µs making 1 call to PPI::Statement::BEGIN@164 |
165 | 2 | 101µs | 1 | 242µs | # spent 242µs (174+68) within PPI::Statement::BEGIN@165 which was called:
# once (174µs+68µs) by PPI::BEGIN@21 at line 165 # spent 242µs making 1 call to PPI::Statement::BEGIN@165 |
166 | 2 | 96µs | 1 | 3.71ms | # spent 3.71ms (3.65+67µs) within PPI::Statement::BEGIN@166 which was called:
# once (3.65ms+67µs) by PPI::BEGIN@21 at line 166 # spent 3.71ms making 1 call to PPI::Statement::BEGIN@166 |
167 | 2 | 1.05ms | 1 | 1.85ms | # spent 1.85ms (1.51+340µs) within PPI::Statement::BEGIN@167 which was called:
# once (1.51ms+340µs) by PPI::BEGIN@21 at line 167 # spent 1.85ms making 1 call to PPI::Statement::BEGIN@167 |
168 | 2 | 94µs | 1 | 237µs | # spent 237µs (164+73) within PPI::Statement::BEGIN@168 which was called:
# once (164µs+73µs) by PPI::BEGIN@21 at line 168 # spent 237µs making 1 call to PPI::Statement::BEGIN@168 |
169 | 2 | 98µs | 1 | 300µs | # spent 300µs (232+68) within PPI::Statement::BEGIN@169 which was called:
# once (232µs+68µs) by PPI::BEGIN@21 at line 169 # spent 300µs making 1 call to PPI::Statement::BEGIN@169 |
170 | 2 | 95µs | 1 | 793µs | # spent 793µs (240+554) within PPI::Statement::BEGIN@170 which was called:
# once (240µs+554µs) by PPI::BEGIN@21 at line 170 # spent 793µs making 1 call to PPI::Statement::BEGIN@170 |
171 | 2 | 19µs | 1 | 3µs | # spent 3µs within PPI::Statement::BEGIN@171 which was called:
# once (3µs+0s) by PPI::BEGIN@21 at line 171 # spent 3µs making 1 call to PPI::Statement::BEGIN@171 |
172 | 2 | 91µs | 1 | 276µs | # spent 276µs (208+68) within PPI::Statement::BEGIN@172 which was called:
# once (208µs+68µs) by PPI::BEGIN@21 at line 172 # spent 276µs making 1 call to PPI::Statement::BEGIN@172 |
173 | 2 | 93µs | 1 | 227µs | # spent 227µs (159+67) within PPI::Statement::BEGIN@173 which was called:
# once (159µs+67µs) by PPI::BEGIN@21 at line 173 # spent 227µs making 1 call to PPI::Statement::BEGIN@173 |
174 | 2 | 87µs | 1 | 219µs | # spent 219µs (152+66) within PPI::Statement::BEGIN@174 which was called:
# once (152µs+66µs) by PPI::BEGIN@21 at line 174 # spent 219µs making 1 call to PPI::Statement::BEGIN@174 |
175 | 2 | 92µs | 1 | 632µs | # spent 632µs (524+108) within PPI::Statement::BEGIN@175 which was called:
# once (524µs+108µs) by PPI::BEGIN@21 at line 175 # spent 632µs making 1 call to PPI::Statement::BEGIN@175 |
176 | 2 | 463µs | 1 | 304µs | # spent 304µs (233+71) within PPI::Statement::BEGIN@176 which was called:
# once (233µs+71µs) by PPI::BEGIN@21 at line 176 # spent 304µs making 1 call to PPI::Statement::BEGIN@176 |
177 | |||||
178 | # "Normal" statements end at a statement terminator ; | ||||
179 | # Some are not, and need the more rigorous _continues to see | ||||
180 | # if we are at an implicit statement boundary. | ||||
181 | 30415 | 85.0ms | # spent 26.7ms within PPI::Statement::__LEXER__normal which was called 30415 times, avg 879ns/call:
# 30415 times (26.7ms+0s) by PPI::Lexer::_lex_statement at line 626 of PPI/Lexer.pm, avg 879ns/call | ||
182 | |||||
- - | |||||
187 | ##################################################################### | ||||
188 | # Constructor | ||||
189 | |||||
190 | # spent 265ms (179+86.4) within PPI::Statement::new which was called 10538 times, avg 25µs/call:
# 7432 times (122ms+63.5ms) by PPI::Lexer::_lex_structure at line 1334 of PPI/Lexer.pm, avg 25µs/call
# 3018 times (56.0ms+22.8ms) by PPI::Lexer::_lex_document at line 290 of PPI/Lexer.pm, avg 26µs/call
# 81 times (450µs+65µs) by PPI::Lexer::_lex_structure at line 1347 of PPI/Lexer.pm, avg 6µs/call
# 6 times (44µs+7µs) by PPI::Lexer::_lex_document at line 304 of PPI/Lexer.pm, avg 9µs/call
# once (96µs+7µs) by PPI::Lexer::_lex_structure at line 1389 of PPI/Lexer.pm | ||||
191 | 10538 | 2.89ms | my $class = shift; | ||
192 | 10538 | 1.30ms | if ( ref $class ) { | ||
193 | PPI::Exception->throw; | ||||
194 | } | ||||
195 | |||||
196 | # Create the object | ||||
197 | 10538 | 17.9ms | my $self = bless { | ||
198 | children => [], | ||||
199 | }, $class; | ||||
200 | |||||
201 | # If we have been passed what should be an initial token, add it | ||||
202 | 10538 | 1.35ms | my $token = shift; | ||
203 | 10538 | 117ms | 31440 | 74.7ms | if ( _INSTANCE($token, 'PPI::Token') ) { # spent 60.4ms making 10538 calls to Params::Util::_INSTANCE, avg 6µs/call
# spent 7.69ms making 10451 calls to UNIVERSAL::isa, avg 736ns/call
# spent 6.54ms making 10451 calls to PPI::Util::TRUE, avg 626ns/call |
204 | # Inlined $self->__add_element(shift); | ||||
205 | 10451 | 95.8ms | 20902 | 19.4ms | Scalar::Util::weaken( # spent 11.9ms making 10451 calls to Scalar::Util::weaken, avg 1µs/call
# spent 7.47ms making 10451 calls to Scalar::Util::refaddr, avg 715ns/call |
206 | $_PARENT{Scalar::Util::refaddr $token} = $self | ||||
207 | ); | ||||
208 | 10451 | 10.1ms | push @{$self->{children}}, $token; | ||
209 | } | ||||
210 | |||||
211 | 10538 | 43.3ms | $self; | ||
212 | } | ||||
213 | |||||
214 | =pod | ||||
215 | |||||
216 | =head2 label | ||||
217 | |||||
218 | One factor common to most statements is their ability to be labeled. | ||||
219 | |||||
220 | The C<label> method returns the label for a statement, if one has been | ||||
221 | defined, but without the trailing colon. Take the following example | ||||
222 | |||||
223 | MYLABEL: while ( 1 .. 10 ) { last MYLABEL if $_ > 5 } | ||||
224 | |||||
225 | For the above statement, the C<label> method would return 'MYLABEL'. | ||||
226 | |||||
227 | Returns false if the statement does not have a label. | ||||
228 | |||||
229 | =cut | ||||
230 | |||||
231 | sub label { | ||||
232 | my $first = shift->schild(1) or return ''; | ||||
233 | $first->isa('PPI::Token::Label') | ||||
234 | ? substr($first, 0, length($first) - 1) | ||||
235 | : ''; | ||||
236 | } | ||||
237 | |||||
238 | =pod | ||||
239 | |||||
240 | =head2 specialized | ||||
241 | |||||
242 | Answer whether this is a plain statement or one that has more | ||||
243 | significance. | ||||
244 | |||||
245 | Returns true if the statement is a subclass of this one, false | ||||
246 | otherwise. | ||||
247 | |||||
248 | =begin testing specialized 22 | ||||
249 | |||||
250 | my $Document = PPI::Document->new(\<<'END_PERL'); | ||||
251 | package Foo; | ||||
252 | use strict; | ||||
253 | ; | ||||
254 | while (1) { last; } | ||||
255 | BEGIN { } | ||||
256 | sub foo { } | ||||
257 | state $x; | ||||
258 | $x = 5; | ||||
259 | END_PERL | ||||
260 | |||||
261 | isa_ok( $Document, 'PPI::Document' ); | ||||
262 | |||||
263 | my $statements = $Document->find('Statement'); | ||||
264 | is( scalar @{$statements}, 10, 'Found the 10 test statements' ); | ||||
265 | |||||
266 | isa_ok( $statements->[0], 'PPI::Statement::Package', 'Statement 1: isa Package' ); | ||||
267 | ok( $statements->[0]->specialized, 'Statement 1: is specialized' ); | ||||
268 | isa_ok( $statements->[1], 'PPI::Statement::Include', 'Statement 2: isa Include' ); | ||||
269 | ok( $statements->[1]->specialized, 'Statement 2: is specialized' ); | ||||
270 | isa_ok( $statements->[2], 'PPI::Statement::Null', 'Statement 3: isa Null' ); | ||||
271 | ok( $statements->[2]->specialized, 'Statement 3: is specialized' ); | ||||
272 | isa_ok( $statements->[3], 'PPI::Statement::Compound', 'Statement 4: isa Compound' ); | ||||
273 | ok( $statements->[3]->specialized, 'Statement 4: is specialized' ); | ||||
274 | isa_ok( $statements->[4], 'PPI::Statement::Expression', 'Statement 5: isa Expression' ); | ||||
275 | ok( $statements->[4]->specialized, 'Statement 5: is specialized' ); | ||||
276 | isa_ok( $statements->[5], 'PPI::Statement::Break', 'Statement 6: isa Break' ); | ||||
277 | ok( $statements->[5]->specialized, 'Statement 6: is specialized' ); | ||||
278 | isa_ok( $statements->[6], 'PPI::Statement::Scheduled', 'Statement 7: isa Scheduled' ); | ||||
279 | ok( $statements->[6]->specialized, 'Statement 7: is specialized' ); | ||||
280 | isa_ok( $statements->[7], 'PPI::Statement::Sub', 'Statement 8: isa Sub' ); | ||||
281 | ok( $statements->[7]->specialized, 'Statement 8: is specialized' ); | ||||
282 | isa_ok( $statements->[8], 'PPI::Statement::Variable', 'Statement 9: isa Variable' ); | ||||
283 | ok( $statements->[8]->specialized, 'Statement 9: is specialized' ); | ||||
284 | is( ref $statements->[9], 'PPI::Statement', 'Statement 10: is a simple Statement' ); | ||||
285 | ok( ! $statements->[9]->specialized, 'Statement 10: is not specialized' ); | ||||
286 | |||||
287 | =end testing | ||||
288 | |||||
289 | =cut | ||||
290 | |||||
291 | # Yes, this is doing precisely what it's intending to prevent | ||||
292 | # client code from doing. However, since it's here, if the | ||||
293 | # implementation changes, code outside PPI doesn't care. | ||||
294 | sub specialized { | ||||
295 | __PACKAGE__ ne ref $_[0]; | ||||
296 | } | ||||
297 | |||||
298 | =pod | ||||
299 | |||||
300 | =head2 stable | ||||
301 | |||||
302 | Much like the L<PPI::Document> method of the same name, the ->stable | ||||
303 | method converts a statement to source and back again, to determine if | ||||
304 | a modified statement is still legal, and won't be interpreted in a | ||||
305 | different way. | ||||
306 | |||||
307 | Returns true if the statement is stable, false if not, or C<undef> on | ||||
308 | error. | ||||
309 | |||||
310 | =cut | ||||
311 | |||||
312 | sub stable { | ||||
313 | die "The ->stable method has not yet been implemented"; | ||||
314 | } | ||||
315 | |||||
- - | |||||
320 | ##################################################################### | ||||
321 | # PPI::Element Methods | ||||
322 | |||||
323 | # Is the statement complete. | ||||
324 | # By default for a statement, we need a semi-colon at the end. | ||||
325 | sub _complete { | ||||
326 | my $self = shift; | ||||
327 | my $semi = $self->schild(-1); | ||||
328 | return !! ( | ||||
329 | defined $semi | ||||
330 | and | ||||
331 | $semi->isa('PPI::Token::Structure') | ||||
332 | and | ||||
333 | $semi->content eq ';' | ||||
334 | ); | ||||
335 | } | ||||
336 | |||||
337 | # You can insert either a statement or a non-significant token. | ||||
338 | sub insert_before { | ||||
339 | my $self = shift; | ||||
340 | my $Element = _INSTANCE(shift, 'PPI::Element') or return undef; | ||||
341 | if ( $Element->isa('PPI::Statement') ) { | ||||
342 | return $self->__insert_before($Element); | ||||
343 | } elsif ( $Element->isa('PPI::Token') and ! $Element->significant ) { | ||||
344 | return $self->__insert_before($Element); | ||||
345 | } | ||||
346 | ''; | ||||
347 | } | ||||
348 | |||||
349 | # As above, you can insert a statement, or a non-significant token | ||||
350 | sub insert_after { | ||||
351 | my $self = shift; | ||||
352 | my $Element = _INSTANCE(shift, 'PPI::Element') or return undef; | ||||
353 | if ( $Element->isa('PPI::Statement') ) { | ||||
354 | return $self->__insert_after($Element); | ||||
355 | } elsif ( $Element->isa('PPI::Token') and ! $Element->significant ) { | ||||
356 | return $self->__insert_after($Element); | ||||
357 | } | ||||
358 | ''; | ||||
359 | } | ||||
360 | |||||
361 | 1 | 2µs | 1; | ||
362 | |||||
363 | =pod | ||||
364 | |||||
365 | =head1 TO DO | ||||
366 | |||||
367 | - Complete, freeze and document the remaining classes | ||||
368 | |||||
369 | =head1 SUPPORT | ||||
370 | |||||
371 | See the L<support section|PPI/SUPPORT> in the main module. | ||||
372 | |||||
373 | =head1 AUTHOR | ||||
374 | |||||
375 | Adam Kennedy E<lt>adamk@cpan.orgE<gt> | ||||
376 | |||||
377 | =head1 COPYRIGHT | ||||
378 | |||||
379 | Copyright 2001 - 2011 Adam Kennedy. | ||||
380 | |||||
381 | This program is free software; you can redistribute | ||||
382 | it and/or modify it under the same terms as Perl itself. | ||||
383 | |||||
384 | The full text of the license can be found in the | ||||
385 | LICENSE file included with this module. | ||||
386 | |||||
387 | =cut |