Error recovery
To generate meaningful results, this plugin must be able to parse your code correctly. Unfortunately, SQL syntax is very complex and has thousands of variations. Since most of the coding rules target common SQL commands, it's not viable to implement the full SQL syntax.
The error recovery mechanism allows the parser to ignore invalid or unrecognized syntax and still analyze other commands in the file.
Example:
declare
x varchar2(10);
begin
x := 'foo' -- missing semicolon
end;
declare
x varchar2(10);
begin
x := 'bar';
end;
If error recovery is disabled, the parser will raise the following error on line 5 and the file will be ignored:
com.sonar.sslr.api.RecognitionException: Parse error at line 5 column 0:
1: declare
2: x varchar2(10);
3: begin
4: x := 'foo'
--> end;
6:
7: declare
8: x varchar2(10);
9: begin
10: x := 'bar';
11: end;
12: EOF
When error recovery is enabled, the parser will ignore the first anonymous block (lines 1-5) and will parse the second block correctly. This will be the resulting AST:
FILE_INPUT
RECOVERY (line 1)
COMPILATION_UNIT (line 7)
ANONYMOUS_BLOCK
...