SYNOPSIS

  my $brace = PPIx::EditorTools::FindUnmatchedBrace->new->find(
        code => "package TestPackage;\nsub x { 1;\n"
      );
  my $location = $brace->element->location;
  my $ppi      = $brace->element->ppi;

DESCRIPTION

Retuning a simple \*(C`PPI::Element\*(C' from many of the \*(C`PPIx::EditorTools\*(C' methods often results in the loss of the overall context for that element. \*(C`PPIx::EditorTools::ReturnObject\*(C' provides an object that can be passed around which retains the overall context.

For example, in \*(C`PPIx::EditorTools::FindUnmatchedBrace\*(C' if the unmatched brace were returned by its \*(C`PPI::Structure::Block\*(C' the containing \*(C`PPI::Document\*(C' is likely to go out of scope, thus the \*(C`location\*(C' method no longer returns a valid location (rather it returns undef). Using the \*(C`ReturnObject\*(C' preserves the \*(C`PPI::Document\*(C' and the containing context.

METHODS

new()

Constructor which should be used by \*(C`PPIx::EditorTools\*(C'. Accepts the following named parameters:

ppi

A \*(C`PPI::Document\*(C' representing the (possibly modified) code.

code

A string representing the (possibly modified) code.

element

A \*(C`PPI::Element\*(C' or a subclass thereof representing the interesting element.

ppi

Accessor to retrieve the \*(C`PPI::Document\*(C'. May create the \*(C`PPI::Document\*(C' from the $code string (lazily) if needed.

code

Accessor to retrieve the string representation of the code. May be retrieved from the \*(C`PPI::Document\*(C' via the serialize method (lazily) if needed.

RELATED TO PPIx::EditorTools::ReturnObject…

\*(C`PPIx::EditorTools\*(C', App::EditorTools, Padre, and \s-1PPI\s0.