syntax highlighting and q-quote operator

frido

Member²
Hi, found a bug in Syntax Highlighting (11.0.2.1766):

e.g. developer does not recognize end of quote and rest of package is highlighted as comment:

v := q'[ quote'test' '{}' ]';
I am still marked as comment

adding a blank after close bracket, and highlighting works as expected

v := q'[ quote'test' '{} ' ]';
I am NOT marked AS COMMENT

 
This affects any brackets, e.g.
q'[)']'
q'[>']'

regardless of opening character:
q'#]'#'
q'"]'"'

although using " (doublequote character) has less effect on the code that follows it, because it's not recognised as q-quotes but still seems to make highlighting stop at the end. You can also limit the collateral damage by adding a comment with a single quote after the actual closing quote. This is probably the nearest thing to a workaround for now.

Here the --' comment prevents quote highlighting overrun:

SQL:
declare
    somevar long := q'[blah (blah)' blah]';  --'
begin
    dbms_output.put_line(somevar);
end;

Here the quoting is highlighted incorrectly but at least ends when it should:

SQL:
declare
    somevar long := q'"blah (blah)' blah"';
begin
    dbms_output.put_line(somevar);
end;

PL/SQL Developer version 11.0.2.1766.

I'm guessing the current regex groups together all bracket types without comparing the closing bracket type to the opening one.

Is this fixed in a more recent version?
 
Last edited:
Version 12.0.7.1837 (64-bit) on Windows 10 Pro

The examples by @frido (first post) still behave as reported (not fixed)
 
Frido's and Robert's workarounds work until you can't do either of them. In my case, I've got a regular expression string that can't include an extra space.

For example:

SQL:
DECLARE
   l_string VARCHAR2(2000);
BEGIN
    l_string := q'[SELECT COUNT(*)
              FROM NAME n
             WHERE NOT regexp_like(n.nametag_name, '(GR|GRW)''[0-9]{2}.*')
               AND n.name_type_code = '00']';
END;

The regular expression pattern includes single-quote and left bracket, so
I understand why it's hard to do this. But it'd be nice to have it display correctly.

All the best!

Stew
 
Back
Top