« blib/lib/PLS/Server/Request/Workspace/DidChangeWatchedFiles.pm
↑ Summary
blib/lib/PLS/Parser/Pod.pm »
| 1 | package PLS::Server::Response::Location; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 13 | ▶ | use parent q(PLS::Server::Response); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 13 | ▶ | use PLS::Parser::Document; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | PLS::Server::Response::Location | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | This is a message from the server to the client providing a location. | ||||||||||||||||||||||||||||
| 17 | This is typically used to provide the location of the definition of a symbol. | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | sub new | ||||||||||||||||||||||||||||
| 22 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 0 | my ($class, $request) = @_; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | my $self = { | ||||||||||||||||||||||||||||
| 26 | id => $request->{id}, | ||||||||||||||||||||||||||||
| 27 | 0 | result => undef | |||||||||||||||||||||||||||
| 28 | }; | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | bless $self, $class; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | my ($line, $character) = @{$request->{params}{position}}{qw(line character)}; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | my $document = PLS::Parser::Document->new(uri => $request->{params}{textDocument}{uri}, line => $line); | |||||||||||||||||||||||||||
| 35 | 0 | ▶ | return $self if (ref $document ne 'PLS::Parser::Document'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | my $results = $document->go_to_definition($line, $character); | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # If there are no results, for a variable, we need to fall back to checking the entire document. | ||||||||||||||||||||||||||||
| 40 | 0 | ▶ | if (ref $results ne 'ARRAY' or not scalar @{$results}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $results ne "ARRAY" or not scalar @{$results;}
MC/DC0%0/2
ref $results ne "ARRAY" or not scalar @{$results;}
ref $results ne "ARRAY"
not scalar @{$results;}
Truth table0%0/3
A or not(B)
A= ref $results ne "ARRAY"B= not scalar @{$results;}
| |||||||||||||||||||||||||||||
| 41 | { | ||||||||||||||||||||||||||||
| 42 | 0 | my @matches = $document->find_elements_at_location($line, $character); | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | if (List::Util::any { $_->variable_name() } @matches) | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | { | ||||||||||||||||||||||||||||
| 46 | 0 | $document = PLS::Parser::Document->new(uri => $request->{params}{textDocument}{uri}); | |||||||||||||||||||||||||||
| 47 | 0 | ▶ | return $self if (ref $document ne 'PLS::Parser::Document'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 0 | $results = $document->go_to_definition($line, $character); | |||||||||||||||||||||||||||
| 49 | } ## end if (List::Util::any { ...}) | ||||||||||||||||||||||||||||
| 50 | } ## end if (ref $results ne 'ARRAY'...) | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if (ref $results eq 'ARRAY') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | { | ||||||||||||||||||||||||||||
| 54 | 0 | foreach my $result (@{$results}) | |||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||
| 56 | 0 | delete @{$result}{qw(package signature kind)}; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | } ## end if (ref $results eq 'ARRAY'...) | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | $self->{result} = $results; | |||||||||||||||||||||||||||
| 61 | 0 | return $self; | |||||||||||||||||||||||||||
| 62 | } ## end sub new | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 13 | 1; | |||||||||||||||||||||||||||