Subject: | option to 'group' package elements as children |
let's say i have the following extremely simple module:
package Baz;
use strict;
sub foo
{
}
1;
the parsed document looks like this:
PPI::Document
PPI::Statement::Package
PPI::Statement::Include
PPI::Statement::Sub
PPI::Structure::Block { ... }
PPI::Statement
would it be possible to add an option that would force the package body
(all the includes, subroutines, etc) to become a child node of the
package element?
in order for me to build a proper outline view, etc in eclipse, i need
to build an AST representation that does that.
the code i have right now loops over the document elements and each time
i sees a package node, it associates all the nodes that come after that
with that package until it sees the next package statement or that the
module has ended.
it would be easier for me to construct the AST representation if all of
those items were children of the package they belong to, as opposed to
'top level' nodes in the document.
of course, maybe it would be better to have a discussion about how i
build the AST representation to see if there is actually a better way
that i could be interacting with PPI to build it.
this is a rough approximation of the xml i am trying to produce that i
can deserialize into the AST on the eclipse side:
<module>
<package nameEnd="11" sourceEnd="41" name="Baz" nameStart="8"
sourceStart="0">
<include sourceStart="14" sourceEnd="25" name="strict"
nameStart="18" nameEnd="24" />
<sub nameEnd="35" sourceEnd="38" name="foo" nameStart="32"
sourceStart="28" />
</package>
</module>
so you guys can see what i'm shooting for.