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