--- trunk/lib/Frey/PPI.pm 2008/11/08 16:12:39 331 +++ trunk/lib/Frey/PPI.pm 2008/11/16 17:39:39 362 @@ -13,12 +13,24 @@ documentation => 'Name of class to parse', ); -sub attribute_order { +my $ppi_doc; + +sub doc { my ( $self ) = @_; - my $doc = PPI::Document->new( $self->class_path( $self->class ) ) || die $!; + if ( ! $ppi_doc ) { + warn "# parse ", $self->class; + my $doc = PPI::Document->new( $self->class_path( $self->class ) ) || die $!; + $doc->prune('PPI::Token::Whitespace'); + $ppi_doc = $doc; + } + return $ppi_doc; +} + +sub attribute_order { + my ( $self ) = @_; - $doc->prune('PPI::Token::Whitespace'); + my $doc = $self->doc; my @attribute_order; @@ -38,7 +50,22 @@ sub data { my $self = shift; - [ $self->attribute_order ]; + my $doc = $self->doc; + my $include; + $doc->find( sub { + my ($doc,$el) = @_; + if ( $el->isa('PPI::Statement::Include') ) { + warn dump( $el->module, $el->type, $el->pragma ); + push @{ $include->{ $el->type } }, $el->module + } + return 1; + }); + warn "# ", $self->class, " ", dump( $include ) if $self->debug; + + return { + include => $include, + doc => $doc, + }; } 1;