Syntax Highlighting SQL - HINT

Syntax highlighting, code folding, brace matching, code indenting, and function list

Syntax Highlighting SQL - HINT

Postby MarcS » Wed Mar 12, 2008 9:20 am

We make extensive use of HINTs in our SQL-statements.
Hints look like comments, but are a bit different: /*+ hint */
Notice the + sign in the beginnen.

If we're to open a SQL-file with comments and hints the all look alike and could be confusing for the reader.

Is there any way to add this to the language-definition(s) for syntax-highlighting?
If so: how.

Marc
MarcS
Newbie
 
Posts: 3
Joined: Wed Mar 12, 2008 9:15 am

Re: Syntax Highlighting SQL - HINT

Postby Bego » Wed Mar 12, 2008 1:04 pm

Hi Marc,

1st I am no syntax highlighting specialist at all.
But the hint collides with the
Code: Select all
Block Comment On = /* Block Comment Off = */

setting because the + sign is recognized as one possible content of the comment.
And the content of the comment is no more interpreted once again by syntax coloring, so I can't figure out a proper solution here ...
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany

Re: Syntax Highlighting SQL - HINT

Postby pietzcker » Wed Mar 12, 2008 3:45 pm

Well, another example for the need to make regexes available for wordfiles (in other areas than function/member/variable strings). If UE were to accept regexes, you could go and define your block comments as "/\*(?!\+)", and bam! - only /* not followed by a + will match. Write to IDM and request this feature.
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm

Re: Syntax Highlighting SQL - HINT

Postby MarcS » Thu Mar 13, 2008 2:22 am

Bego: Well, that's what I figured out too, I was hoping to find some guru's here who had the same problem and solved it for me :D

Pietzcker: So actually you were waiting for me to do the request :D

But all in all thanks for the fast responses.
MarcS
Newbie
 
Posts: 3
Joined: Wed Mar 12, 2008 9:15 am

Re: Syntax Highlighting SQL - HINT

Postby pietzcker » Thu Mar 13, 2008 3:24 am

MarcS wrote:So actually you were waiting for me to do the request :D


Waiting, no - hoping, yes. I myself have made that request already (and several times, too), but the more people ask for it at IDM support, the higher the chance that it will get pushed upwards on the to-do list. So if you add your voice to the choir, we might get lucky faster.

Best regards,
Tim
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm

Re: Syntax Highlighting SQL - HINT

Postby Mofi » Thu Mar 13, 2008 4:03 am

There is no need for a regular expression to solve this syntax highlighting problem. Use following in your language definition line:

Block Comment On = /*+ Block Comment Off = */ Block Comment On Alt = /* Block Comment Off Alt = */ NestBlockComments

Now hints, line comments and alternate line comments are highlighted with the comment color and block comments with the alternate block comment color. NestBlockComments makes sure that this highlighting works also if a hint is inside a block comment. Don't know if SQL has also line comments and you are not happy that hints and line comments have the same color. But this cannot be changed, sorry.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4062
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Syntax Highlighting SQL - HINT

Postby pietzcker » Thu Mar 13, 2008 7:36 am

Good to know that there is a workaround. But if there was a third kind of comment/hint, this workaround would fail. If comment detection were regex-based, it would be a lot more elegant. Same thing with nested comments, multi-line strings etc. - using regexes would make things easier for the developers and more transparent for us users. No need to make UE's code more and more baroque in order to comply with all kinds of special situations - just hand it to the regex engine.

Slowly, this thread is drifting into the My Two Cents forum... :)
Tim
User avatar
pietzcker
Master
Master
 
Posts: 241
Joined: Sun Aug 22, 2004 11:00 pm

Re: Syntax Highlighting SQL - HINT

Postby MarcS » Thu Mar 13, 2008 9:26 am

I've received the same workaround from the tech guys as Mofi posted.

Now that we know there is some kind of workaround we've added it and granted ourselves a few days to evaluate it before we're pass it on to the rest of our gang.

True that line comments & hints now look alike, and that could be more confusing than that we've planned.

Still, I second pietzcker motion: regexp will give us more power 8)
MarcS
Newbie
 
Posts: 3
Joined: Wed Mar 12, 2008 9:15 am


Return to Syntax Highlighting