zabel-xyz / plsql-language

plsql-language for vscode
MIT License
78 stars 27 forks source link

Alternative quoting mechanism (''q'') for string literals is breaking symbol recognition and syntax highlighting #81

Open ogobrecht opened 5 years ago

ogobrecht commented 5 years ago

Hi again,

when using alternative quoting the symbol recognition is broken and the syntax highlighting is also not working correct.

For a description of the feature please see this Live SQL example from Steven Feuerstein.

Following a code example which is working in SQL Developer without problems (see screenshots below).

Thank you in advance and kind regards Ottmar

CREATE OR REPLACE PACKAGE demo IS
  PROCEDURE with_alternative_quotes;  
  PROCEDURE symbol_not_recognized;  
END demo;
/

CREATE OR REPLACE PACKAGE BODY demo IS

  PROCEDURE with_alternative_quotes IS
    v_example VARCHAR2(32767);
  BEGIN
    v_example := q'^

Some multiline text to demonstrate the alternative quoting.

We use here a single ' quote to show that for example SQL-Developer is 
able to compile this package.

If we use inside our text pairing quotes it should not break anything:

```sql
DECLARE
  v_test varchar2(1000);
BEGIN
v_test := 
    q'(Some text with a single ' quote.)' ||
    q'[Some text with a single ' quote.]' ||
    q'{Some text with a single ' quote.}' ||
    q'<Some text with a single ' quote.>' ||
END;

End of the story. <-- This "end" inside the text breaks the symbol recognition!

If you remove it, the symbol recognition is working again. Syntax highlighting is not working at all with alternative quotes.

Seems that we have a combined error: The wrong string literal recognition with alternative quotes is breaking the syntax highlighting and the symbol recognition.

More examples here: https://livesql.oracle.com/apex/livesql/file/content_CIREYU9EA54EOKQ7LAMZKRF6P.html

^'; END with_alternative_quotes;

PROCEDURE symbol_not_recognized IS BEGIN NULL; END symbol_not_recognized;

END demo; /



![image](https://user-images.githubusercontent.com/10425445/59429995-57b2bb80-8de1-11e9-9d87-f459a72feaf9.png)

![image](https://user-images.githubusercontent.com/10425445/59430303-343c4080-8de2-11e9-9f8a-2f8778c9bb4c.png)
zabel-xyz commented 5 years ago

This feature is not supported yet. I need to improve regExpParser

ogobrecht commented 5 years ago

Hi,

thank you. This feature is used very often these days - in dynamic SQL, templates and also in simple strings to avoid the escape hell by double, triple or even more single quotes. The readability and maintainability of code is much better with it. For me (and may be for many others) it is essential to support this.

If I can help you please let me know - at least for testing or may be also for coding.

Kind regards Ottmar

zabel-xyz commented 5 years ago

If you know well regexp, you can always make a PR, to help me to implement such a feature. Thank you.

ogobrecht commented 5 years ago

Hi,

I am totally new to extension development for VS Code. Anyway, I will try it. You will here from me - either with questions or a solution.

Best regards Ottmar

zabel-xyz commented 5 years ago

You have 2 sources to adapt:


- for symbol recognition: **main\src\lib\regEx\RegExParser.ts** 
 Some regular expression are used to parse a text and create a tree of symbols.
 (This tree is used to display symbol, navigate...)
ogobrecht commented 5 years ago

Hi,

thanks for the infos. I will definitly try it and come back to you. Please do not wonder when it takes a little bit longer (have to finish some things before on my own projects). You will hear from me...

Best regards Ottmar

neilfernandez commented 4 years ago

I am having the same issue and I have the most recent version. Just wondering how do I modify/find plsql.tmLanguage?

KarlisVe commented 3 years ago

Problem is actual.

Extension does not support Alternative Quoting Mechanism (''Q'') for String Literals https://livesql.oracle.com/apex/livesql/file/content_CIREYU9EA54EOKQ7LAMZKRF6P.html e.g. select q'[It's not working]' from dual image image