SYNOPSIS

  # finds declaration of variable at cursor
  my $declaration = PPIx::EditorTools::FindVariableDeclaration->new->find(
    code =>
      "package TestPackage;\nuse strict;\nBEGIN {
        $^W = 1;
}\nmy \$x=1;\n\$x++;"
    line => 5,
    column => 2,
  );
  my $location = $declaration->element->location;

DESCRIPTION

Finds the location of a variable declaration.

METHODS

new()

Constructor. Generally shouldn't be called with any arguments. Accepts either a \*(C`PPI::Document\*(C' to process or a string containing the code (which will be converted into a \*(C`PPI::Document\*(C') to process. Searches for the variable declaration and returns a \*(C`PPIx::EditorTools::ReturnObject\*(C' with the declaration (\*(C`PPI::Statement::Variable\*(C') available via the \*(C`element\*(C' accessor. Croaks with a \*(L"no token\*(R" exception if no token is found at the location. Croaks with a \*(L"no declaration\*(R" exception if unable to find the declaration.

RELATED TO PPIx::EditorTools::FindVariableDeclaration…

This class inherits from \*(C`PPIx::EditorTools\*(C'. Also see App::EditorTools, Padre, and \s-1PPI\s0.