Detect COBOL variable in EXEC SQL, provides go to def, show refs and hover#375
Conversation
EXEC SQL, provides go to def, show refs and hover
|
Should be draft until #370 is merged. |
|
This seems to target #327, no? If yes I suggest to reference that in the commit message and/or in this PR as related issue. |
|
This PR introduces dependencies between libraries that I'd like to avoid as they would impair further extensibility of the LSP server. In addition the parser for SQL is not hardened against errors in SQL syntax. Those issues need to be fixed before this PR can be merged. |
|
I still wonder if it wouldn't be "simple" to not fully parse the SQL stuff (which can be quite useful if it provides completions and co) but just scan it for any doublecolon+word - and add those as a reference for "word".... |
This enables renaming of such variables at no extra cost. Otherwise the `:` would be removed upon symbol rename.
|
just checked with last CD build, CTRL+click does not work (so I guess references won't work either), tested on bind variables ( EXEC SQL AT :DB
FETCH MYCUR
INTO
:FLD1,
:FLD2
END-EXEC.and also not in the declaration EXEC SQL VAR TABFLD1 IS CHAR END-EXEC.Should it? |
Implicitly declared variables are not supported yet: only references to COBOL variables for which there is a corresponding COBOL declaration can be navigated (and renamed) in this way. I guess this will be future work (and this limitation will need to be documented in the |
|
for the cursors, sure - but FL1 and FLD2 are indeed variables that are part of EXEC SQL BEGIN DECLARE SECTION END-EXEC.
*
01 DB PIC X(010).
01 FLD1 PIC X(018).
01 FLD2 PIC X(026).
*
01 MYTAB.
03 MYKEY.
05 FLD3 PIC X(006).
05 FLD4 PIC X(008).
*
03 MYDATA.
05 ...
*
EXEC SQL VAR FLD3 IS CHAR END-EXEC.
EXEC SQL VAR FLD4 IS CHAR END-EXEC.
*
EXEC SQL END DECLARE SECTION END-EXEC.
EXEC SQL INCLUDE SQLCA END-EXEC.
*
EXEC SQL AT :DBS
DECLARE MYCUR CURSOR FOR
SELECT
FLD1, FLD2 FROM TAB
WHERE
TFL3
|| TFL4
>=
:FLD3
|| :FLD4
ORDER BY
TFL3
|| TFL4
ASC
END-EXEC. |
All of this snippet is in |
|
yes (that's the place Pro*COB expects it; it possibly doesn't care and only searches for EXEC SQL ... END-EXEC and EXEC SQL DECLARE ... END DECLARE) |
Add-on to #370,
reactivate Sql preproc in the LSP and add references and location to cobol vars in sql exec blocks
The completion seems to fails inside such exec blocks -> the parser needs to be more robust
The new completion test needs to pass before merging this