File: StaticMethod.pm

package info (click to toggle)
plsense 0.3.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,012 kB
  • sloc: perl: 9,767; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 1,119 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package PlSense::Plugin::CodeAssistant::StaticMethod;

use parent qw{ PlSense::Plugin::CodeAssistant };
use strict;
use warnings;
use Class::Std;
use PlSense::Logger;
use PlSense::Util;
{
    sub is_only_valid_context {
        my ($self, $code, $tok) = @_;

        my $input = "";
        if ( $tok && $tok->isa("PPI::Token::Word") ) {
            $input = "".$tok->content."";
            $tok = $tok->previous_sibling;
        }
        if ( ! $tok || ! $tok->isa("PPI::Token::Operator") || $tok->content ne '->' ) { return; }
        $tok = $tok->previous_sibling;
        if ( ! $tok || ! $tok->isa("PPI::Token::Word") ) { return; }
        my $mdl = mdlkeeper->get_module("".$tok->content."") or return;
        $self->set_input($input);
        logger->info("Match context : input[$input]");

        logger->notice("Found static method of [".$mdl->get_name."]");
        my $currmdl = addrfinder->get_currentmodule;
        STATIC_METHOD:
        foreach my $mtd ( $mdl->get_static_methods($currmdl) ) {
            $self->push_candidate($mtd->get_name, $mtd);
        }
        return 1;
    }
}

1;

__END__