Padre::Task::FindUnmatchedBrace - C<PPI> based unmatched brace finder


Padre documentation Contained in the Padre distribution.

Index


Code Index:

NAME

Top

Padre::Task::FindUnmatchedBrace - PPI based unmatched brace finder

SYNOPSIS

Top

  my $task = Padre::Task::FindUnmatchedBrace->new(
          document => $padre_document,
  );
  $task->schedule;

DESCRIPTION

Top

Finds the location of unmatched braces in a Padre::Document::Perl. If there is no unmatched brace, a message box tells the user about that glorious fact. If there is one, the cursor will jump to it.

SEE ALSO

Top

This class inherits from Padre::Task::PPI.

AUTHOR

Top

Steffen Mueller smueller@cpan.org

COPYRIGHT AND LICENSE

Top


Padre documentation Contained in the Padre distribution.
package Padre::Task::FindUnmatchedBrace;

use 5.008;
use strict;
use warnings;
use Padre::Task::PPI ();
use Padre::Logger;

our $VERSION = '0.86';
our @ISA     = 'Padre::Task::PPI';

sub process {
	TRACE('process') if DEBUG;
	my $self   = shift;
	my $ppi    = shift or return;
	my $result = eval {
		require PPIx::EditorTools::FindUnmatchedBrace;
		PPIx::EditorTools::FindUnmatchedBrace->new->find( ppi => $ppi );
	};
	if ($@) {
		$self->{error} = $@;
		return;
	}

	# An undef brace throws a die here.
	# undef = no error found.
	if ( defined $result ) {

		# Remember for gui update
		$self->{location} = $result->element->location;
	}

	return;
}

1;

__END__

# Copyright 2008-2011 The Padre development team as listed in Padre.pm.
# LICENSE
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl 5 itself.