I propose you this patch that add control for PL/SQL structure.
This patch detects errors into the PL/SQL structure (ex: IF without THEN or END IF, CASE without END CASE and so on) via the "CheckThisStatement" method (i.e. whether PL/SQL is well formed or not)
For now, I use two vectors to store all structs, but I plan to switch onto your new SparseState class. That's my next job ;)
I add also a patch for sql keyword.
The overview of this patch :
- for each new lines, lexer resets several flag, set counters and delete old data into 2 vectors (all data that concern the next lines, that going to be parse by the lexer) via pmethod "prepareSQLStatesForLine".
- lexer detects usefull sql keywords.
- lexer adds it into SQLStates obecjt via "AddStatements" method, the return of this method gives (overwrite) the actual type of plsql statement (ex: one "IF" can be for "IF ... THEN" or "IF ... EXISTS", idem for "PROCEDURE" can be PROCEDURE SPEC or PROCEDURE BODY).
- If the structure of PL/SQL is not well formed, then the return of "AddStatements" method is PLSQL_NOT_WELL_FORMED. The lexer could change the color line in this case (not yet implemented).
List of new features :
- better folding for "case when", anymore limitation with folding into exception block.
- better folding for "case" with first "when", there is anymore SC_MARKNUM_FOLDERMIDTAIL on the first "when then".
- detect PL/SQL not well formed.
- remove "statementFound" flag that be removed by classic mecanism (ex : "if (levelCurrent > levelNext) levelCurrent = levelNext;" like bracket folding).
- replace 2 vectors (statementsStack and linesPosition) by your new SparseState class.
- add error managment. By the way, how can I change the style of line into "void SCI_METHOD Fold(...)" method ? I try LexAccessor::SetLineState (int,int) without success...