Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ogobrecht opened this issue Jun 13, 2019 · 8 comments

Comments

@ogobrecht
Copy link

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

image

@zabel-xyz
Copy link
Owner

zabel-xyz commented Jun 13, 2019

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

@ogobrecht
Copy link
Author

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
Copy link
Owner

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

@ogobrecht
Copy link
Author

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
Copy link
Owner

You have 2 sources to adapt:

  • for syntax highlighting: plsql.tmLanguage
    You can add something like this: (It's limited, but that's how vscode works now)
  <dict>
            <key>begin</key>
            <string>q'(\^\!|\[|\{|#|&lt;|&gt;|\||\()</string>
            <key>end</key>
            <string>(\^\!|\]|\}|#|&lt;|&gt;|\||\))'</string>
            <key>name</key>
            <string>string.quoted.alternative.oracle</string>
   </dict>

  • 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
Copy link
Author

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

ogobrecht added a commit to ogobrecht/plsql-language that referenced this issue Jun 23, 2019
@neilfernandez
Copy link

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

@KarlisVe
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants