public final class RoutineBodyRecovery extends Object
CREATE/ALTER PROCEDURE, FUNCTION or
TRIGGER) whose body holds statements the grammar rejects. Without recovery such a routine fails as a whole
and keeps no body statement, so one statement GSP cannot parse loses the lineage of every other statement in it.
For each syntax error the statement around it is found -- the innermost statement inside the innermost
BEGIN ... END (or BEGIN TRY/CATCH) block that holds the error, delimited by the vendor's own raw
statement splitter -- and its tokens are returned. TGSqlParser makes them ignorable
(TBaseType.sqlpluscmd, as CREATE TABLE recovery does for options it cannot parse) and parses the routine
again: the same statement over the same tokens, so every position stays the original one. Whenever something is
uncertain -- an error in the routine's header, a block structure that does not balance, an error no statement
holds -- no token is returned and the routine fails as it always did.
| Modifier and Type | Method and Description |
|---|---|
static boolean |
appliesTo(EDbVendor vendor,
ESqlStatementType type)
The vendors and statement types the recovery applies to: T-SQL routines.
|
static List<TSourceToken> |
tokensToIgnore(TCustomSqlStatement routine,
List<TSyntaxError> errors,
EDbVendor vendor)
The tokens of the statements that hold
errors, to make ignorable so that the rest of routine
parses; empty when any error cannot be placed in a statement of the routine's body, or when the body's blocks do
not balance (no region is certain then, and the whole body is no statement to skip). |
public static boolean appliesTo(EDbVendor vendor, ESqlStatementType type)
public static List<TSourceToken> tokensToIgnore(TCustomSqlStatement routine, List<TSyntaxError> errors, EDbVendor vendor)
errors, to make ignorable so that the rest of routine
parses; empty when any error cannot be placed in a statement of the routine's body, or when the body's blocks do
not balance (no region is certain then, and the whole body is no statement to skip).