intellij-xquery icon indicating copy to clipboard operation
intellij-xquery copied to clipboard

Recover parsing state on errors.

Open rhdunn opened this issue 8 years ago • 2 comments

If the intellij-xquery parser encounters an error, the code that follows the error point is not parsed correctly. This has the following effects:

  1. Subsequent errors are masked by the starting error -- this is worse if the initial error is due to a problem with the xquery parser (like issue #198).
  2. Information in the module such as functions that follow the error is not processed -- this causes calls to those functions to be incorrectly reported as errors.
  3. Automatic indentation is broken when entering code after the point of the error.

It would be helpful for the parser to recover as close as possible to the next valid start/recover point. I understand that this will be complex.

At the basic level, this should be able to recover to the start of the next statement such as if, for, let, and declare function statements.

rhdunn avatar Jun 24 '16 09:06 rhdunn

Unfortunately with the very context-sensitive nature of the language and with the fact that in Main Module you can have any expression at the end of the file, it's nearly impossible to get this done right. If you could please prepare some examples with the expected behaviour it would be much easier to at least check if this is achievable.

ligasgr avatar Jun 24 '16 23:06 ligasgr

The immediate case is related to issue #198:

declare function a($x, $y) {
    if ($x < (2*$y)) then
        $y
    else
        $x
};

declare function b($x) {
    ()
};

Here, the code in the $x and $y part of the if will not be validated, and function b will not be exposed to the user when referring to it in another module.

rhdunn avatar Jun 25 '16 05:06 rhdunn