Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Building an SQL TextEditor
Building an SQL TextEditor [message #448798] Tue, 02 May 2006 18:03 Go to next message
Eclipse UserFriend
I'm building a colored style text editor for SQL.
The codeScanner class (SQLCodeScanner in my case) extends RuleBasedScanner.
So, I have a WorldRule that loads the array of sql reserved words.
The big problem is that SQL is case insensitive and the Eclipse class in charge of doing the comparison between the input (typed stuff) and the WorldRule is strict (case sensitive), and I could not find out which class does the job or how to make the comparison as case insensitive.

So, how can I make this comparison as a case insensitive one?
Thanks for any help.
Re: Building an SQL TextEditor [message #448803 is a reply to message #448798] Wed, 03 May 2006 05:25 Go to previous messageGo to next message
Eclipse UserFriend
Antonio,

you could write your own IgnoreCaseWordRule, that would lowercase any
keywords it manages.

-tom

Antonio Gurisatti wrote:
> I'm building a colored style text editor for SQL.
> The codeScanner class (SQLCodeScanner in my case) extends RuleBasedScanner.
> So, I have a WorldRule that loads the array of sql reserved words.
> The big problem is that SQL is case insensitive and the Eclipse class in charge of doing the comparison between the input (typed stuff) and the WorldRule is strict (case sensitive), and I could not find out which class does the job or how to make the comparison as case insensitive.
>
> So, how can I make this comparison as a case insensitive one?
> Thanks for any help.
Re: Building an SQL TextEditor [message #448807 is a reply to message #448798] Wed, 03 May 2006 09:31 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

I don't think its that easy. As I see it, the problem is not with the key words. It is with the user typed words. A user might type something like "select" or "SELECT" or "Select" or "seLect", etc. So, you should convert the user typed characters to the same case used to load the keywords and only for comparison purposes, leaving the typed characters just like they are.

Thanks,
AG
Re: Building an SQL TextEditor [message #448811 is a reply to message #448807] Wed, 03 May 2006 09:59 Go to previous messageGo to next message
Eclipse UserFriend
Antonio Gurisatti wrote:
> I don't think its that easy. As I see it, the problem is not with the key words. It is with the user typed words. A user might type something like "select" or "SELECT" or "Select" or "seLect", etc. So, you should convert the user typed characters to the same case used to load the keywords and only for comparison purposes, leaving the typed characters just like they are.

Yes - just create a copy of WordRule, and do convert every word to lower
case before accessing the hashmap storing the (also lower-cased) keywords.

-t
Re: Building an SQL TextEditor [message #448813 is a reply to message #448811] Wed, 03 May 2006 10:19 Go to previous messageGo to next message
Eclipse UserFriend
Tom,

The idea sounds logical but I didn't exactly understood it. I dont exactly understand what you mean by "create a copy": copy the eclipses source? or create my own class extending WorldRule?

Thanks a lot.
AG
Re: Building an SQL TextEditor [message #448815 is a reply to message #448813] Wed, 03 May 2006 11:10 Go to previous messageGo to next message
Eclipse UserFriend
Antonio Gurisatti wrote:
> The idea sounds logical but I didn't exactly understood it. I dont
> exactly understand what you mean by "create a copy": copy the
> eclipses source?

Yes.

> or create my own class extending WorldRule?

You could also do that and override #addWord() and #evaluate() - not
much to gain by doing that, though, as you'd have to copy most of
#evaluate().

-tom
Re: Building an SQL TextEditor [message #448834 is a reply to message #448813] Thu, 04 May 2006 05:03 Go to previous message
Eclipse UserFriend
See method evaluate() in org.eclipse.jface.text.rules.WordRule

You will find string
IToken token= (IToken) fWords.get(fBuffer.toString());

In your own WordRule just override this method and replace this string with
IToken token = (IToken ) fWords.get(fBuffer.toString().toLowerCase());

Of course, your syntax vocabulary should be in lower case.

Good luck,
Andrey
Previous Topic:Update Eclipse Product by webstart
Next Topic:Error dialog box while navigating thru the Preference Nodes
Goto Forum:
  


Current Time: Sun Aug 31 14:21:23 EDT 2025

Powered by FUDForum. Page generated in 0.05186 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top