my $infile = $self -> infile ; my $outfile = $self -> outfile ; print STDERR "infile=$infile outfile=$outfile\n" ; my $ifh = aio_open ($infile, IO::AIO::O_WRONLY | IO::AIO::O_TRUNC | IO::AIO::O_CREAT, 0600) or die "open $infile failed ($!)" ; aio_write ($ifh, undef, undef, $text, 0) ; aio_close ($ifh) ; # my $oldstderr ; # open($oldstderr, ">&", \*STDERR) or die "Can't dup STDERR: $!"; # open(STDERR, '>', $outfile) or die "Can't redirect STDERR: $!"; # print STDERR "start\n" ; # my $pid = spawnp "perl", ["perl", "-c", $infile]; # open(STDERR, ">&", $oldstderr) or die "Can't dup \$oldstderr: $!"; #my $pid = spawnp "cmd", ["cmd", '/C', "perl -c $infile 2> $outfile"]; my $pid = spawnp $workspace -> perlcmd, [$workspace -> perlcmd, ] print STDERR "pid=$pid\n" ; my $w = AnyEvent->child (pid => $pid, cb => rouse_cb) ; my $ret = rouse_wait ; undef $w ; #Coro::AnyEvent::sleep (1) ; #print STDERR "wait\n" ; #waitpid ($pid, 0) ; #my $ret = $? ; my $rc = $ret >> 8; print STDERR "perl -c rc=$rc\n" ; #aio_slurp ($outfile, 0, 0, $errout) ; aio_load ($outfile, $errout) ; print STDERR "errout = $errout\n" ; #return ; #my ($rc, $diags) = rouse_wait ; my $diags = [] ; print STDERR "---perl -c rc=$rc\n" ; return if ($rc == 0) ; my $result = { method => 'textDocument/publishDiagnostics', params => { uri => $uri, diagnostics => $diags, }, } ; $self -> send_notification ($result) ; } # my $cv = run_cmd [$workspace -> perlcmd, '-c'], # # "<", \$text, # "2>", \$errout # ; # $cv->cb (sub # { # shift->recv and die "perl -c failed"; # print "-------->$errout\n"; # }); # return ;
AnyEvent::Util::fork_call (sub { print STDERR "open3 start c $$\n" ; IO::AIO::reinit ;
my($wtr, $rdr, $err); #return ;
# use Symbol 'gensym'; $err = gensym; my $pid = open3($wtr, $rdr, $err, $workspace -> perlcmd, '-c') or die "Cannot run " . $workspace -> perlcmd ; #cede () ; print STDERR "write start pid=$pid\n" ; syswrite ($wtr, $text . "\n__END__\n") ; print STDERR "close start\n" ; close ($wtr) ; print STDERR "write done\n" ; #my $errout = unblock $err ; my @diags ; my $line ; # while ($line = $errout -> readline) while ($line = <$rdr>) { $line =~ s/\s*$// ; print STDERR $line, "\n" ; next if ($line =~ /had compilation errors/) ; my $lineno = 0 ; $lineno = $1 if ($line =~ / line (\d+),/) ; my $diag = { # range: Range; # severity?: number; # code?: number | string; # source?: string; # message: string; # relatedInformation?: DiagnosticRelatedInformation[]; range => { start => { line => $lineno-1, character => 0 }, end => { line => $lineno+0, character => 0 }}, message => $line, } ; push @diags, $diag ; }
print STDERR "EOF\n" ; waitpid( $pid, 0 ); my $rc = $? >> 8; print STDERR "perl -c rc=$rc\n" ; return ($rc, \@diags) ; }, rouse_cb ) ; my ($rc, $diags) = rouse_wait ; print STDERR "---perl -c rc=$rc\n" ; return if ($rc == 0) ; my $result = { method => 'textDocument/publishDiagnostics', params => { uri => $uri, diagnostics => $diags, }, } ; $self -> send_notification ($result) ; }
1 POD Error
The following errors were encountered while parsing the POD:
=pod directives shouldn't be over one line long! Ignoring all 3 lines of content
To install Perl::LanguageServer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Perl::LanguageServer
CPAN shell
perl -MCPAN -e shell install Perl::LanguageServer
For more information on module installation, please visit the detailed CPAN module installation guide.