| 1 | package PLS::Server::Request::Workspace::DidChangeWatchedFiles; | ||||||||||
| 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 'PLS::Server::Request'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 13 | ▶ | use List::Util qw(any uniq); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 13 | ▶ | use Path::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 13 | ▶ | use PLS::Parser::Index; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 13 | ▶ | use PLS::Server::Request::TextDocument::PublishDiagnostics; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | =head1 NAME | ||||||||||
| 15 | |||||||||||
| 16 | PLS::Server::Request::Workspace::DidChangeWatchedFiles | ||||||||||
| 17 | |||||||||||
| 18 | =head1 DESCRIPTION | ||||||||||
| 19 | |||||||||||
| 20 | This is a notification from the client to the server indicating | ||||||||||
| 21 | that one or more files that the server watched have changed. | ||||||||||
| 22 | |||||||||||
| 23 | The server queues up these files to be re-indexed. | ||||||||||
| 24 | |||||||||||
| 25 | =cut | ||||||||||
| 26 | |||||||||||
| 27 | sub service | ||||||||||
| 28 | 0 | ▶ | { | ||||||||
|
Subroutine
service: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||
| 29 | 0 | my ($self, $server) = @_; | |||||||||
| 30 | |||||||||||
| 31 | 0 | ▶ | return if (ref $self->{params}{changes} ne 'ARRAY'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | |||||||||||
| 33 | 0 | my $index = PLS::Parser::Index->new(); | |||||||||
| 34 | |||||||||||
| 35 | 0 | my @changed_files; | |||||||||
| 36 | |||||||||||
| 37 | 0 | foreach my $change (@{$self->{params}{changes}}) | |||||||||
| 38 | { | ||||||||||
| 39 | 0 | my $file = URI->new($change->{uri}); | |||||||||
| 40 | 0 | ▶ | next if (ref $file ne 'URI::file'); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | |||||||||||
| 42 | 0 | ▶ | if ($change->{type} == 3) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | { | ||||||||||
| 44 | 0 | $index->cleanup_file($file->file); | |||||||||
| 45 | 0 | next; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 0 | ▶ | next if ($file->file =~ /\/\.pls-tmp-[^\/]*$/); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | next unless $index->is_perl_file($file->file); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | 0 | ▶ | next if $index->is_ignored($file->file); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | |||||||||||
| 53 | 0 | push @changed_files, $change->{uri}; | |||||||||
| 54 | } ## end foreach my $change (@{$self...}) | ||||||||||
| 55 | |||||||||||
| 56 | 0 | @changed_files = uniq @changed_files; | |||||||||
| 57 | 0 | ▶ | $index->index_files(@changed_files)->then(sub { Future->wait_all(@_) })->retain() if (scalar @changed_files); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||
| 58 | |||||||||||
| 59 | 0 | return; | |||||||||
| 60 | } ## end sub service | ||||||||||
| 61 | |||||||||||
| 62 | 13 | 1; | |||||||||