Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


#784 [SQL] Add control for PL/SQL structure

Neil Hodgson
Scintilla (356)

Hello Neil,
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...


1 2 3 > >> (Page 1 of 3)
  • patch #0

  • patch #0 for

  • test files

  • Neil Hodgson
    Neil Hodgson

    • assigned_to: nobody --> nyamatongwe
  • Neil Hodgson
    Neil Hodgson

    For the accented characters in your name to show correctly the file needs a UTF-8 coding cookie in the first two lines like:
    // -*- coding: utf-8 -*-

    The split into lex and fold phases is trying to make things simpler by having folding work on completed lexical information. Changing the styles in the fold phase, while possible, goes against this and will cause problems for you and make it harder for others to maintain.

    An approach that may be more compatible with the standard flow would be to use the IDocument::Decoration* methods to place decorations over the errors. There have not been any use of these up to now as they were included to match a similar feature in LexPython used to indicate bad whitespace but LexPython hasn't been converted to a lexer object yet. You'll be a pioneer here so read up on decorations in the Scintilla documentation.

  • >IDocument::Decoration*
    I've just tested, that' exactly what I was lookin for!!!
    Many Thx.

  • You can find the new patch with the cookie and the Decoration, that works :)
    But another question, is it possible to change the color of decoration?

  • patch #1

  • The new patch where decoration can be modified by the application.

1 2 3 > >> (Page 1 of 3)