Padre::Task::SyntaxChecker - Generic syntax-checking background processing task
package Padre::Task::SyntaxChecker::MyLanguage; use base 'Padre::Task::SyntaxChecker'; sub run { my $self = shift; my $doc_text = $self->{text}; # black magic here $self->{syntax_check} = ...; return 1; }; 1; # elsewhere: # by default, the text of the current document # will be fetched as will the document's notebook page. my $task = Padre::Task::SyntaxChecker::MyLanguage->new(); $task->schedule; my $task2 = Padre::Task::SyntaxChecker::MyLanguage->new( text => Padre::Current->document->text_get, editor => Padre::Current->editor, ); $task2->schedule;
This is a base class for all tasks that need to do expensive syntax checking in a background task.
You can either let Padre::Task::SyntaxChecker fetch the Perl code for parsing from the current document or specify it as the "text" parameter to the constructor.
Padre::Task::SyntaxChecker
text
To create a syntax checker for a given document type Foo, you create a subclass Padre::Task::SyntaxChecker::Foo and implement the run method which uses the $self->{text} attribute of the task object for its nefarious syntax checking purposes and then stores the result in the $self->{syntax_check} attribute of the object. The result should be a data structure of the form defined in the documentation of the Padre::Document::check_syntax method. See Padre::Document.
Foo
Padre::Task::SyntaxChecker::Foo
run
$self->{text}
$self->{syntax_check}
Padre::Document::check_syntax
This base class implements all logic necessary to update the GUI with the syntax check results in a finish() hook. If you want to implement your own finish(), make sure to call $self->SUPER::finish for this reason.
finish()
$self->SUPER::finish
This class inherits from Padre::Task and its instances can be scheduled using Padre::TaskManager.
Padre::Task
Padre::TaskManager
The transfer of the objects to and from the worker threads is implemented with Storable.
Steffen Mueller smueller@cpan.org
smueller@cpan.org
Copyright 2008-2009 The Padre development team as listed in Padre.pm.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself.
To install Padre, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Padre
CPAN shell
perl -MCPAN -e shell install Padre
For more information on module installation, please visit the detailed CPAN module installation guide.