| 1 | package PLS::Server::Response::Completion; | ||||||||||||||||||||||||||||||||||||||||||
| 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 | 13 | ▶ | use feature 'state'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 13 | ▶ | use Pod::Functions; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 13 | ▶ | use List::Util; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 13 | ▶ | use Module::CoreList; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 13 | ▶ | use Module::Metadata; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 13 | ▶ | use ExtUtils::Installed; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 13 | ▶ | use PLS::Parser::Document; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 13 | ▶ | use PLS::Parser::PackageSymbols; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 13 | ▶ | use PLS::Parser::Pod; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 13 | ▶ | use PLS::Server::State; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | PLS::Server::Response::Completion | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | This is a message from the server to the client with a list | ||||||||||||||||||||||||||||||||||||||||||
| 27 | of completion items for the current location. | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=17 SCAR=57.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my ($class, $request) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my $self = bless {id => $request->{id}, result => undef}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $document = PLS::Parser::Document->new(uri => $request->{params}{textDocument}{uri}, line => $request->{params}{position}{line}); | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | return $self if (ref $document ne 'PLS::Parser::Document'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my ($range, $arrow, $package, $filter) = $document->find_word_under_cursor(@{$request->{params}{position}}{qw(line character)}); | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | return $self if (ref $range ne 'HASH'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $range->{start}{line} = $request->{params}{position}{line}; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $range->{end}{line} = $request->{params}{position}{line}; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $range->{end}{character} = $request->{params}{position}{character}; | |||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | $package =~ s/::$// if (length $package); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my @results; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my $full_text = $document->get_full_text(); | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my @futures; | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | if ($filter =~ /^[\$\@\%]/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | push @results, @{get_variables($document, $filter, $full_text)}; | |||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||
| 59 | else | ||||||||||||||||||||||||||||||||||||||||||
| 60 | { | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my @this_document_packages; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my @packages = @{get_packages($document, $full_text, \@this_document_packages)}; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if (not $arrow) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | { | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | push @results, @packages; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | push @results, @{get_keywords()}; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if (length $package) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | { | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | push @futures, get_package_functions($package, $filter, $arrow); | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | push @results, @{get_subroutines($document, $arrow, $full_text, $this_document_packages[0])}; | |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | if ($filter) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | { | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | push @results, @{get_constants($document, $filter, $full_text)}; | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | # Imported functions can't be called with an arrow | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | push @futures, get_imported_package_functions($document, $full_text) unless $arrow; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | } ## end if ($filter) | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | } ## end else[ if ($filter =~ /^[\$\@\%]/...)] | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | push @results, @{Future->wait_all(@futures)->then( | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | [map { @{$_->result} } grep { $_->is_ready } @_] | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | )->get() | |||||||||||||||||||||||||||||||||||||||||
| 92 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my %unique_by_detail; | |||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | foreach my $result (@results) | |||||||||||||||||||||||||||||||||||||||||
| 97 | { | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my $new_text = $result->{label}; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | $new_text = $result->{insertText} if (length $result->{insertText}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | delete $result->{insertText}; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | next if (exists $result->{detail} and length $result->{detail} and $unique_by_detail{$result->{detail}}++); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $result->{"detail"} and length $result->{"detail"} and $unique_by_detail{$result->{"detail"}}++
exists $result->{"detail"} and length $result->{"detail"}
MC/DC0%0/3
exists $result->{"detail"} and length $result->{"detail"} and $unique_by_detail{$result->{"detail"}}++
exists $result->{"detail"}
length $result->{"detail"}
$unique_by_detail{$result->{"detail"}}++
Truth table0%0/4
A and B and C
A= exists $result->{"detail"}B= length $result->{"detail"}C= $unique_by_detail{$result->{"detail"}}++
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | push @{$self->{result}}, {%{$result}, textEdit => {newText => $new_text, range => $range}}; | |||||||||||||||||||||||||||||||||||||||||
| 104 | } ## end foreach my $result (@results...) | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | if (not $arrow and not $package and $filter !~ /^\%\@/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$arrow or $package or $filter =~ /^\%\@/
$arrow or $package
MC/DC0%0/3
$arrow or $package or $filter =~ /^\%\@/
$arrow
$package
$filter =~ /^\%\@/
Truth table0%0/4
A or B or C
A= $arrowB= $packageC= $filter =~ /^\%\@/
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | { | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | push @{$self->{result}}, get_snippets(); | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } ## end sub new | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | sub get_keywords | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_keywords: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | state @keywords; | |||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | return \@keywords if (scalar @keywords); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my %seen_keywords; | |||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | foreach my $family (keys %Pod::Functions::Kinds) ## no critic (ProhibitPackageVars) | |||||||||||||||||||||||||||||||||||||||||
| 123 | { | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | foreach my $sub (@{$Pod::Functions::Kinds{$family}}) ## no critic (ProhibitPackageVars) | |||||||||||||||||||||||||||||||||||||||||
| 125 | { | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | next if $sub =~ /\s+/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | next if $seen_keywords{$sub}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | push @keywords, {label => $sub, kind => 14}; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } ## end foreach my $sub (@{$Pod::Functions::Kinds...}) | ||||||||||||||||||||||||||||||||||||||||||
| 130 | } ## end foreach my $family (keys %Pod::Functions::Kinds...) | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | foreach my $keyword ( | |||||||||||||||||||||||||||||||||||||||||
| 133 | qw(cmp continue default do else elsif eq for foreach ge given gt if le lock lt ne not or package sub unless until when while x xor -r -w -x -o -R -W -X -O -e -z -s -f -d -l -p -S -b -c -t -u -g -k -T -B -M -A -C) | ||||||||||||||||||||||||||||||||||||||||||
| 134 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 135 | { | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | next if $seen_keywords{$keyword}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | push @keywords, {label => $keyword, kind => 14}; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } ## end foreach my $keyword (...) | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | return \@keywords; | |||||||||||||||||||||||||||||||||||||||||
| 141 | } ## end sub get_keywords | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | sub get_package_functions | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_package_functions: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my ($package, $filter, $arrow) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | return Future->done([]) unless (length $package); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | return PLS::Parser::PackageSymbols::get_package_symbols($PLS::Server::State::CONFIG, $package)->then( | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my ($functions) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | return Future->done([]) if (ref $functions ne 'HASH'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | my $separator = $arrow ? '->' : '::'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | my @functions; | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | foreach my $package_name (keys %{$functions}) | |||||||||||||||||||||||||||||||||||||||||
| 159 | { | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | foreach my $name (@{$functions->{$package_name}}) | |||||||||||||||||||||||||||||||||||||||||
| 161 | { | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $fully_qualified = join $separator, $package_name, $name; | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | my $result = { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | label => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | # If there is an arrow, we need to make sure to sort all the methods in this package to the top | ||||||||||||||||||||||||||||||||||||||||||
| 168 | sortText => $arrow ? "0000$name" : $fully_qualified, | ||||||||||||||||||||||||||||||||||||||||||
| 169 | kind => 3 | ||||||||||||||||||||||||||||||||||||||||||
| 170 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if ($arrow) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | { | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $result->{insertText} = $name; | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | else | ||||||||||||||||||||||||||||||||||||||||||
| 177 | { | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $result->{insertText} = $fully_qualified; | |||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | if ($arrow) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | { | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $result->{filterText} = $name; | |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | else | ||||||||||||||||||||||||||||||||||||||||||
| 186 | { | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $result->{filterText} = $fully_qualified; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | push @functions, $result; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } ## end foreach my $name (@{$functions...}) | ||||||||||||||||||||||||||||||||||||||||||
| 192 | } ## end foreach my $package_name (keys...) | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | return Future->done(\@functions); | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 197 | } ## end sub get_package_functions | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | sub get_imported_package_functions | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_imported_package_functions: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my ($document, $full_text) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my $imports = $document->get_imports($full_text); | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | return Future->done([]) if (ref $imports ne 'ARRAY' or not scalar @{$imports}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $imports ne "ARRAY" or not scalar @{$imports;}
MC/DC0%0/2
ref $imports ne "ARRAY" or not scalar @{$imports;}
ref $imports ne "ARRAY"
not scalar @{$imports;}
Truth table0%0/3
A or not(B)
A= ref $imports ne "ARRAY"B= not scalar @{$imports;}
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | return PLS::Parser::PackageSymbols::get_imported_package_symbols($PLS::Server::State::CONFIG, @{$imports})->then( | |||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my ($imported_functions) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | my @results; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | foreach my $package_name (keys %{$imported_functions}) | |||||||||||||||||||||||||||||||||||||||||
| 212 | { | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | foreach my $subroutine (@{$imported_functions->{$package_name}}) | |||||||||||||||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my $result = { | |||||||||||||||||||||||||||||||||||||||||
| 216 | kind => 3, | ||||||||||||||||||||||||||||||||||||||||||
| 217 | label => $subroutine, | ||||||||||||||||||||||||||||||||||||||||||
| 218 | data => [$package_name], | ||||||||||||||||||||||||||||||||||||||||||
| 219 | detail => "${package_name}::${subroutine}", | ||||||||||||||||||||||||||||||||||||||||||
| 220 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | $result->{labelDetails} = {description => "${package_name}::${subroutine}"} | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if $PLS::Server::State::CLIENT_CAPABILITIES->{textDocument}{completion}{completionItem}{labelDetailsSupport}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | push @results, $result; | |||||||||||||||||||||||||||||||||||||||||
| 225 | } ## end foreach my $subroutine (@{$imported_functions...}) | ||||||||||||||||||||||||||||||||||||||||||
| 226 | } ## end foreach my $package_name (keys...) | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | return Future->done(\@results); | |||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 230 | } ## end sub get_imported_package_functions | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | sub get_subroutines | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_subroutines: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my ($document, $arrow, $full_text, $this_document_package) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my %subroutines; | |||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | foreach my $sub (@{$document->get_subroutines_fast($full_text)}) | |||||||||||||||||||||||||||||||||||||||||
| 239 | { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | next if ($sub =~ /\n/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $subroutines{$sub} = {label => $sub, kind => 3}; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | $subroutines{$sub}{data} = [$this_document_package] if (length $this_document_package); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | } ## end foreach my $sub (@{$document...}) | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | # Add subroutines to the list, uniquifying and keeping track of the packages in which | ||||||||||||||||||||||||||||||||||||||||||
| 246 | # it is defined so that resolve can find the documentation. | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | foreach my $sub (keys %{$document->{index}->subs}) | |||||||||||||||||||||||||||||||||||||||||
| 248 | { | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | foreach my $data (@{$document->{index}->subs->{$sub}}) | |||||||||||||||||||||||||||||||||||||||||
| 250 | { | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | my $result = $subroutines{$sub} // {label => $sub, kind => $data->{kind}, data => []}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$subroutines{$sub} // {"label", $sub, "kind", $data->{"kind"}, "data", []}
MC/DC0%0/1
$subroutines{$sub} // {"label", $sub, "kind", $data->{"kind"}, "data", []}
$subroutines{$sub}
Truth table0%0/2
A
A= $subroutines{$sub}
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if (length $data->{package}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | { | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | push @{$result->{data}}, $data->{package}; | |||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $subroutines{$sub} = $result; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } ## end foreach my $data (@{$document...}) | ||||||||||||||||||||||||||||||||||||||||||
| 260 | } ## end foreach my $sub (keys %{$document...}) | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | # If the subroutine is only defined in one place, include the package name as the detail. | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | foreach my $sub (keys %subroutines) | |||||||||||||||||||||||||||||||||||||||||
| 264 | { | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if (exists $subroutines{$sub}{data} and ref $subroutines{$sub}{data} eq 'ARRAY' and scalar @{$subroutines{$sub}{data}} == 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $subroutines{$sub}{"data"} and ref $subroutines{$sub}{"data"} eq "ARRAY" and scalar @{$subroutines{$sub}{"data"};} == 1
exists $subroutines{$sub}{"data"} and ref $subroutines{$sub}{"data"} eq "ARRAY"
MC/DC0%0/3
exists $subroutines{$sub}{"data"} and ref $subroutines{$sub}{"data"} eq "ARRAY" and scalar @{$subroutines{$sub}{"data"};} == 1
exists $subroutines{$sub}{"data"}
ref $subroutines{$sub}{"data"} eq "ARRAY"
scalar @{$subroutines{$sub}{"data"};} == 1
Truth table0%0/4
A and B and C
A= exists $subroutines{$sub}{"data"}B= ref $subroutines{$sub}{"data"} eq "ARRAY"C= scalar @{$subroutines{$sub}{"data"};} == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | { | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $subroutines{$sub}{detail} = $subroutines{$sub}{data}[0] . "::${sub}"; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | } ## end foreach my $sub (keys %subroutines...) | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | return [values %subroutines]; | |||||||||||||||||||||||||||||||||||||||||
| 272 | } ## end sub get_subroutines | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | sub get_packages | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_packages: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my ($document, $full_text, $this_document_packages) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my @packages; | |||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my $core_modules = PLS::Server::Cache::get_core_modules(); | |||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $ext_modules = PLS::Server::Cache::get_ext_modules(); | |||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | @{$this_document_packages} = @{$document->get_packages_fast($full_text)}; | |||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | push @packages, @{$this_document_packages}; | |||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | foreach my $pack (@{$core_modules}, @{$ext_modules}) | |||||||||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | next if ($pack =~ /\n/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | push @packages, $pack; | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | if (ref $document->{index} eq 'PLS::Parser::Index') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | { | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | push @packages, @{$document->{index}->get_all_packages()}; | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | return [map { {label => $_, kind => 7} } List::Util::uniq sort @packages]; | |||||||||||||||||||||||||||||||||||||||||
| 298 | } ## end sub get_packages | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | sub get_constants | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_constants: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my ($document, $filter, $full_text) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | my %seen_constants; | |||||||||||||||||||||||||||||||||||||||||
| 305 | my @constants; | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | foreach my $constant (@{$document->get_constants_fast($full_text)}) | |||||||||||||||||||||||||||||||||||||||||
| 308 | { | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | next if $seen_constants{$constant}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | next if ($constant =~ /\n/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | push @constants, {label => $constant, kind => 21}; | |||||||||||||||||||||||||||||||||||||||||
| 312 | } ## end foreach my $constant (@{$document...}) | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | return \@constants; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } ## end sub get_constants | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | sub get_variables | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_variables: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my ($document, $full_text) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | my @variables; | |||||||||||||||||||||||||||||||||||||||||
| 322 | my %seen_variables; | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | foreach my $variable (@{PLS::Server::Cache::get_builtin_variables()}, @{$document->get_variables_fast($full_text)}) | |||||||||||||||||||||||||||||||||||||||||
| 325 | { | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | next if $seen_variables{$variable}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | next if ($variable =~ /\n/); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | push @variables, | |||||||||||||||||||||||||||||||||||||||||
| 329 | { | ||||||||||||||||||||||||||||||||||||||||||
| 330 | label => $variable, | ||||||||||||||||||||||||||||||||||||||||||
| 331 | kind => 6 | ||||||||||||||||||||||||||||||||||||||||||
| 332 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | # add other variable forms to the list for arrays and hashes | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | if ($variable =~ /^[\@\%]/) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | { | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | my $name = $variable =~ s/^[\@\%]/\$/r; | |||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | my $append = $variable =~ /^\@/ ? '[' : '{'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | push @variables, | |||||||||||||||||||||||||||||||||||||||||
| 340 | { | ||||||||||||||||||||||||||||||||||||||||||
| 341 | label => $variable, | ||||||||||||||||||||||||||||||||||||||||||
| 342 | insertText => $name . $append, | ||||||||||||||||||||||||||||||||||||||||||
| 343 | filterText => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 344 | kind => 6 | ||||||||||||||||||||||||||||||||||||||||||
| 345 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 346 | } ## end if ($variable =~ /^[\@\%]/...) | ||||||||||||||||||||||||||||||||||||||||||
| 347 | } ## end foreach my $variable (@{PLS::Server::Cache::get_builtin_variables...}) | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | return \@variables; | |||||||||||||||||||||||||||||||||||||||||
| 350 | } ## end sub get_variables | ||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | sub get_snippets | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_snippets: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | state @snippets; | |||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | return @snippets if (scalar @snippets); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | @snippets = ( | |||||||||||||||||||||||||||||||||||||||||
| 359 | { | ||||||||||||||||||||||||||||||||||||||||||
| 360 | label => 'sub', | ||||||||||||||||||||||||||||||||||||||||||
| 361 | detail => 'Insert subroutine', | ||||||||||||||||||||||||||||||||||||||||||
| 362 | kind => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 363 | insertTextFormat => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 364 | insertText => "sub \$1\n{\n\t\$0\n}", | ||||||||||||||||||||||||||||||||||||||||||
| 365 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 366 | { | ||||||||||||||||||||||||||||||||||||||||||
| 367 | label => 'foreach', | ||||||||||||||||||||||||||||||||||||||||||
| 368 | detail => 'Insert foreach loop', | ||||||||||||||||||||||||||||||||||||||||||
| 369 | kind => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 370 | insertTextFormat => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 371 | insertText => "foreach my \$1 (\$2)\n{\n\t\$0\n}", | ||||||||||||||||||||||||||||||||||||||||||
| 372 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 373 | { | ||||||||||||||||||||||||||||||||||||||||||
| 374 | label => 'for', | ||||||||||||||||||||||||||||||||||||||||||
| 375 | detail => 'Insert C-style for loop', | ||||||||||||||||||||||||||||||||||||||||||
| 376 | kind => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 377 | insertTextFormat => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 378 | insertText => "for (\$1 ; \$2 ; \$3)\n{\n\t\$0\n}", | ||||||||||||||||||||||||||||||||||||||||||
| 379 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 380 | { | ||||||||||||||||||||||||||||||||||||||||||
| 381 | label => 'while', | ||||||||||||||||||||||||||||||||||||||||||
| 382 | detail => 'Insert while statement', | ||||||||||||||||||||||||||||||||||||||||||
| 383 | kind => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 384 | insertTextFormat => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 385 | insertText => "while (\$1)\n{\n\t\$0\n}", | ||||||||||||||||||||||||||||||||||||||||||
| 386 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 387 | { | ||||||||||||||||||||||||||||||||||||||||||
| 388 | label => 'if', | ||||||||||||||||||||||||||||||||||||||||||
| 389 | detail => 'Insert if statement', | ||||||||||||||||||||||||||||||||||||||||||
| 390 | kind => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 391 | insertTextFormat => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 392 | insertText => "if (\$1)\n{\n\t\$0\n}", | ||||||||||||||||||||||||||||||||||||||||||
| 393 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 394 | { | ||||||||||||||||||||||||||||||||||||||||||
| 395 | label => 'elsif', | ||||||||||||||||||||||||||||||||||||||||||
| 396 | detail => 'Insert elsif statement', | ||||||||||||||||||||||||||||||||||||||||||
| 397 | kind => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 398 | insertTextFormat => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 399 | insertText => "elsif (\$1)\n{\n\t\$0\n}", | ||||||||||||||||||||||||||||||||||||||||||
| 400 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 401 | { | ||||||||||||||||||||||||||||||||||||||||||
| 402 | label => 'else', | ||||||||||||||||||||||||||||||||||||||||||
| 403 | detail => 'Insert else statement', | ||||||||||||||||||||||||||||||||||||||||||
| 404 | kind => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 405 | insertTextFormat => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 406 | insertText => "else\n{\n\t\$0\n}", | ||||||||||||||||||||||||||||||||||||||||||
| 407 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 408 | { | ||||||||||||||||||||||||||||||||||||||||||
| 409 | label => 'package', | ||||||||||||||||||||||||||||||||||||||||||
| 410 | detail => 'Create a new package', | ||||||||||||||||||||||||||||||||||||||||||
| 411 | kind => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 412 | insertTextFormat => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 413 | insertText => "package \$1;\n\nuse strict;\nuse warnings;\n\n\$0\n\n1;", | ||||||||||||||||||||||||||||||||||||||||||
| 414 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 415 | { | ||||||||||||||||||||||||||||||||||||||||||
| 416 | label => 'open my $fh, ...', ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||||||||||||||||||
| 417 | filterText => 'open', | ||||||||||||||||||||||||||||||||||||||||||
| 418 | sortText => 'open', | ||||||||||||||||||||||||||||||||||||||||||
| 419 | detail => 'Insert an open statement', | ||||||||||||||||||||||||||||||||||||||||||
| 420 | kind => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 421 | insertTextFormat => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 422 | insertText => q[open $1, '${2|<,>,>>,+<,+>,\|-,-\|,>&,<&=,>>&=|}', $3], ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||||||||||||||||||
| 423 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 424 | { | ||||||||||||||||||||||||||||||||||||||||||
| 425 | label => 'do { local $/; <$fh> }', ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||||||||||||||||||
| 426 | filterText => 'do', | ||||||||||||||||||||||||||||||||||||||||||
| 427 | sortText => 'do1', | ||||||||||||||||||||||||||||||||||||||||||
| 428 | detail => 'Slurp an entire filehandle', | ||||||||||||||||||||||||||||||||||||||||||
| 429 | kind => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 430 | insertTextFormat => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 431 | insertText => 'do { local $/; <$1> }' ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||||||||||||||||||
| 432 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 433 | { | ||||||||||||||||||||||||||||||||||||||||||
| 434 | label => 'while (my $line = <$fh>) { ... }', ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||||||||||||||||||
| 435 | filterText => 'while', | ||||||||||||||||||||||||||||||||||||||||||
| 436 | sortText => 'while1', | ||||||||||||||||||||||||||||||||||||||||||
| 437 | detail => 'Iterate through a filehandle line-by-line', | ||||||||||||||||||||||||||||||||||||||||||
| 438 | kind => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 439 | insertTextFormat => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 440 | insertText => "while (my \$1 = <\$2>)\n{\n\t\$0\n}" | ||||||||||||||||||||||||||||||||||||||||||
| 441 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 442 | { | ||||||||||||||||||||||||||||||||||||||||||
| 443 | label => 'my ($param1, $param2, ...) = @_;', ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||||||||||||||||||
| 444 | filterText => 'my', | ||||||||||||||||||||||||||||||||||||||||||
| 445 | sortText => 'my1', | ||||||||||||||||||||||||||||||||||||||||||
| 446 | detail => 'Get subroutine parameters', | ||||||||||||||||||||||||||||||||||||||||||
| 447 | kind => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 448 | insertTextFormat => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 449 | insertText => "my (\$1) = \@_;\n\n" | ||||||||||||||||||||||||||||||||||||||||||
| 450 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 451 | { | ||||||||||||||||||||||||||||||||||||||||||
| 452 | label => '$? >> 8', ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||||||||||||||||||
| 453 | filterText => '$?', ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||||||||||||||||||
| 454 | sortText => '$?', ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||||||||||||||||||
| 455 | detail => 'Get exit code', | ||||||||||||||||||||||||||||||||||||||||||
| 456 | kind => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 457 | insertTextFormat => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 458 | insertText => '? >> 8' | ||||||||||||||||||||||||||||||||||||||||||
| 459 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 460 | { | ||||||||||||||||||||||||||||||||||||||||||
| 461 | label => 'sort { $a <=> $b } ...', ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||||||||||||||||||
| 462 | filterText => 'sort', | ||||||||||||||||||||||||||||||||||||||||||
| 463 | sortText => 'sort1', | ||||||||||||||||||||||||||||||||||||||||||
| 464 | detail => 'Sort numerically ascending', | ||||||||||||||||||||||||||||||||||||||||||
| 465 | kind => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 466 | insertTextFormat => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 467 | insertText => 'sort { \$a <=> \$b } $1' ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||||||||||||||||||
| 468 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 469 | { | ||||||||||||||||||||||||||||||||||||||||||
| 470 | label => 'reverse sort { $a <=> $b } ...', ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||||||||||||||||||
| 471 | filterText => 'sort', | ||||||||||||||||||||||||||||||||||||||||||
| 472 | sortText => 'sort2', | ||||||||||||||||||||||||||||||||||||||||||
| 473 | detail => 'Sort numerically descending', | ||||||||||||||||||||||||||||||||||||||||||
| 474 | kind => 15, | ||||||||||||||||||||||||||||||||||||||||||
| 475 | insertTextFormat => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 476 | insertText => 'reverse sort { \$a <=> \$b } $1' ## no critic (RequireInterpolationOfMetachars) | ||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||
| 478 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | return @snippets; | |||||||||||||||||||||||||||||||||||||||||
| 481 | } ## end sub get_snippets | ||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||