File Coverage

blib/lib/PLS/Server/Response/Resolve.pm
Criterion Covered Total %
statement 24 66 36.3
branch 0 26 0.0
condition 0 13 0.0
subroutine 8 9 88.8
pod 0 1 0.0
total 32 115 27.8


line stmt bran cond sub pod time code
1             package PLS::Server::Response::Resolve;
2              
3 11     11   69 use strict;
  11         23  
  11         500  
4 11     11   67 use warnings;
  11         22  
  11         582  
5              
6 11     11   65 use parent 'PLS::Server::Response';
  11         23  
  11         65  
7              
8 11     11   7682 use PLS::Parser::Index;
  11         54  
  11         650  
9 11     11   7106 use PLS::Parser::Pod::Package;
  11         64  
  11         593  
10 11     11   6954 use PLS::Parser::Pod::Subroutine;
  11         73  
  11         529  
11 11     11   86 use PLS::Parser::Pod::Builtin;
  11         30  
  11         301  
12 11     11   6231 use PLS::Parser::Pod::Variable;
  11         51  
  11         10207  
13              
14             =head1 NAME
15              
16             PLS::Server::Response::Resolve
17              
18             =head1 DESCRIPTION
19              
20             This is a message from the server to the client with documentation
21             about the currently selected completion item.
22              
23             =cut
24              
25             sub new
26             {
27 0     0 0   my ($class, $request) = @_;
28              
29 0           my $self = {id => $request->{id}, result => undef};
30 0           bless $self, $class;
31              
32 0           my $index = PLS::Parser::Index->new();
33 0           my $kind = $request->{params}{kind};
34              
35 0 0 0       if ($kind == 6)
    0          
    0          
    0          
36             {
37 0           my $pod = PLS::Parser::Pod::Variable->new(variable => $request->{params}{label});
38 0           my $ok = $pod->find();
39              
40 0 0         if ($ok)
41             {
42 0           $self->{result} = $request->{params};
43 0           $self->{result}{documentation} = {kind => 'markdown', value => ${$pod->{markdown}}};
  0            
44             }
45             } ## end if ($kind == 6)
46             elsif ($kind == 7)
47             {
48 0           my $pod = PLS::Parser::Pod::Package->new(index => $index, package => $request->{params}{label});
49 0           my $ok = $pod->find();
50              
51 0 0         if ($ok)
52             {
53 0           $self->{result} = $request->{params};
54             $self->{result}{documentation} =
55 0           {kind => 'markdown', value => ${$pod->{markdown}}};
  0            
56             } ## end if ($ok)
57             } ## end elsif ($kind == 7)
58             elsif ($kind == 3 or $kind == 21)
59             {
60 0           my ($package, $subroutine);
61              
62 0 0 0       if ($request->{params}{label} =~ /->/ or ($request->{params}{sortText} // '') =~ /->/)
    0 0        
      0        
      0        
63             {
64 0 0         my $label = $request->{params}{label} =~ /->/ ? $request->{params}{label} : $request->{params}{sortText};
65 0           ($package, $subroutine) = split /->/, $label;
66 0           $package = [$package];
67             } ## end if ($request->{params}...)
68             elsif ($request->{params}{label} =~ /::/ or ($request->{params}{filterText} // '') =~ /::/)
69             {
70 0 0         my $label = $request->{params}{label} =~ /::/ ? $request->{params}{label} : $request->{params}{filterText};
71 0           my @parts = split /::/, $label;
72 0           $subroutine = pop @parts;
73 0           $package = [join '::', @parts];
74             } ## end elsif ($request->{params}...)
75             else
76             {
77 0           $subroutine = $request->{params}{label};
78             $package = $request->{params}{data}
79 0 0         if (ref $request->{params}{data} eq 'ARRAY');
80             } ## end else[ if ($request->{params}...)]
81              
82 0           my $pod = PLS::Parser::Pod::Subroutine->new(index => $index, packages => $package, subroutine => $subroutine);
83 0           my $ok = $pod->find();
84              
85 0 0         if ($ok)
86             {
87 0           $self->{result} = $request->{params};
88 0           $self->{result}{documentation} = {kind => 'markdown', value => ${$pod->{markdown}}};
  0            
89             }
90             } ## end elsif ($kind == 3 or $kind...)
91             elsif ($kind == 14)
92             {
93 0           my $pod = PLS::Parser::Pod::Builtin->new(function => $request->{params}{label});
94 0           my $ok = $pod->find();
95              
96 0 0         if ($ok)
97             {
98 0           $self->{result} = $request->{params};
99 0           $self->{result}{documentation} = {kind => 'markdown', value => ${$pod->{markdown}}};
  0            
100             }
101             } ## end elsif ($kind == 14)
102              
103 0           return $self;
104             } ## end sub new
105              
106             1;