richterger / Perl-LanguageServer

Language Server for Perl
Other
224 stars 53 forks source link

package related errors are not recoverable #14

Open slymz opened 4 years ago

slymz commented 4 years ago

If a package has a legitimate Perl error, the client of the package shows "Compilation failed to require", which upon fixing the error is not recovered, unless the client is edited or VS Code session is reloaded.

Take this example:

# File Bar.pm
package Bar;
sub BarFun   # error: no open brace
    print "hello from Bar::BarFun\n";
}
1;

and, the client:

# File foo.pl
use Bar;

when the code is in this state and VS Code is loaded for the very first time, Perl Language server populates the "Problems" pane with two errors:

Bar.pm (1)
   Illegal declaration of subroutine Bar::BarFun at - line 3.

foo.pl (2)
   Compilation failed in require at - line 1.
   BEGIN failed--compilation aborted at - line 1.

Clicking on the first one conveniently takes us to the problem spot. Apply the fix by adding the brace. And Problem pane updates to showing only foo.pl errors.

Here is the problem: The "Problems" with foo.pl never goes away.

There seems to be only two workarounds:

  1. Edit foo.pl. Remove that exact use line, and add it back.
  2. Reload window.

Neither of these are ideal because, respectively:

  1. Large projects may have 100s of call sites. Problems pane have 100s of "failed in require" errors in 100s of files. They can not all be edited.
  2. Reloading kills any active terminals, and triggers reparsing. Again large projects suffer, terminal and other ephemeral content is lost.

If there is another workaround for this, it would be very helpful. Otherwise, please consider this Issue as a feature request to support updating of clients of a given module when module is changed.

Thanks!

richterger commented 4 years ago

That error messages from foo.pl are not cleared is a know problem, but hard to fix.

Any patches are welcome...