Subject: | "$a = 1 if ($a == 2)" vs "$a = 1 if $a == 2" |
PPI misses the
PPI::Structure::Condition ( ... )
when you leave of the parantheses on "$a = 1 if ($a == 2)" vs "$a = 1 if $a == 2":
"$a = 1 if $a == 2":
PPI::Document
PPI::Statement
PPI::Token::Symbol '$s'
PPI::Token::Whitespace ' '
PPI::Token::Operator '='
PPI::Token::Whitespace ' '
PPI::Token::Number '1'
PPI::Token::Whitespace ' '
PPI::Token::Word 'if'
PPI::Token::Whitespace ' '
PPI::Token::Symbol '$a'
PPI::Token::Whitespace ' '
PPI::Token::Operator '=='
PPI::Token::Whitespace ' '
PPI::Token::Number '9'
"$a = 1 if ($a == 2)":
PPI::Document
PPI::Statement
PPI::Token::Symbol '$s'
PPI::Token::Whitespace ' '
PPI::Token::Operator '='
PPI::Token::Whitespace ' '
PPI::Token::Number '1'
PPI::Token::Whitespace ' '
PPI::Token::Word 'if'
PPI::Token::Whitespace ' '
PPI::Structure::Condition ( ... )
PPI::Statement::Expression
PPI::Token::Symbol '$a'
PPI::Token::Whitespace ' '
PPI::Token::Operator '=='
PPI::Token::Whitespace ' '
PPI::Token::Number '9'
This makes it very hard to recognize the statement from third-party code, even though Perl treats both constructs the same.
Just including a "::Condition" would inject "()" if you do a $element->content(), though, so I am unsure what the best solution is. A "silent" or "invisible" flag on PPI::Statement::Condition?
Best wishes,
Tels