Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » CombinedWordRule and strange bugs in IPresentationReconciler
CombinedWordRule and strange bugs in IPresentationReconciler [message #12596] Tue, 15 July 2008 21:18 Go to next message
Eclipse UserFriend
Originally posted by: richardepsilonhughes.gmail.com

As some of you probably remember, I'm working on a plugin for converting a
simple XML file describing features of a sourceViewerConfiguration such as
syntax coloration in to a complete editor plugin. I've gotten the first
bare bones of a plug-in working, and I've run in to a very strange bug
that I'm not sure how to fix.

I've set it up so that it reads an XML file, creates a formatting token
with a text attribute, and associates it with several keywords. Using a
CombinedWordRule and a RuleBasedScanner, it checks for those keywords and
highlights them with the text attribute defined in the formatting token.
HOWEVER. There is a problem.

I'm using a simple IWordDetector implementation that uses
Character.isLetter(c) for both isWordPart(char c) and isWordStart(char c).
Let's say one of the keywords is 'try', and I write the word 'country',
the word 'try', and the word 'tryouts'. In 'country' and 'try', the last
three letters (the 'try') will be highlighted. In 'tryouts', however, the
'try' will NOT be highlighted.

I don't know why this is. I suspect it's because the word is scanned from
each character in the word to the end of the word, so a word like country
appears as:

country
ountry
untry
ntry
try

while tryouts appears as

tryouts
ryouts
youts

However, I have no idea why it's happening NOW. I've created a text
editor, and I've given it a SourceViewerConfiguration, and it has a
RuleBasedPartitionScanner that does nothing and puts everyone in
IDocument.DEFAULT_CONTENT_TYPE, and a RuleBasedScanner with that single
CombinedWordRule. This is not a particularly complex arrangement, and it's
more or less, to the best of my knowledge, what goes on in the JDT, but
when I do it, it has this bug.

If you need to see the source code, I've uploaded it to a .zip for your
convenience. It's dependent on a xerces implementation, but you shouldn't
need to worry about that.

https://www.yousendit.com/download/TTdFZUNwYUlCSWV4dnc9PQ
Using WordRule does not fix it. [message #12777 is a reply to message #12596] Thu, 17 July 2008 20:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richardepsilonhughes.gmail.com

I've rebuilt the code, and I'm getting the same results regardless of
whether I use CombinedWordRule or WordRule.

Let me narrow the question: Does anyone have experience with
RuleBasedScanners that include WordRule or CombinedWordRule? Has anyone
experienced a similar problem?

Alternately, can anyone suggest another possible place I can look for
advice?
Does anyone have experience with this? [message #12798 is a reply to message #12777] Fri, 18 July 2008 22:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richardepsilonhughes.gmail.com

I truly need something - I don't need a solution, but I need some idea
where to look for one.
Re: Does anyone have experience with this? [message #13498 is a reply to message #12798] Mon, 21 July 2008 13:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

Richard Hughes wrote:
> I truly need something - I don't need a solution, but I need some idea
> where to look for one.
>

Um, what? I only see the subject and the sentence above.
Please, always quote when replying to a message, so the rest of us see
the context of a thread.

Eric
Re: Does anyone have experience with this? [message #13519 is a reply to message #13498] Mon, 21 July 2008 16:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richardepsilonhughes.gmail.com

Eric Rizzo wrote:

> Richard Hughes wrote:
>> I truly need something - I don't need a solution, but I need some idea
>> where to look for one.
>>

> Um, what? I only see the subject and the sentence above.
> Please, always quote when replying to a message, so the rest of us see
> the context of a thread.

> Eric

Sorry, Eric. I'm still trying to solve the problem described at the
beginning of the thread. :(

I'm trying to see if I can solve it by adding a WhitespaceRule and/or
using setDefaultReturnToken(Token token) to set a default return token for
the rulescanner.
Re: CombinedWordRule and strange bugs in IPresentationReconciler [message #13541 is a reply to message #12596] Mon, 21 July 2008 21:19 Go to previous message
Eclipse UserFriend
Originally posted by: richardepsilonhughes.gmail.com

Richard Hughes wrote:

> As some of you probably remember, I'm working on a plugin for converting a
> simple XML file describing features of a sourceViewerConfiguration such as
> syntax coloration in to a complete editor plugin. I've gotten the first
> bare bones of a plug-in working, and I've run in to a very strange bug
> that I'm not sure how to fix.

> I've set it up so that it reads an XML file, creates a formatting token
> with a text attribute, and associates it with several keywords. Using a
> CombinedWordRule and a RuleBasedScanner, it checks for those keywords and
> highlights them with the text attribute defined in the formatting token.
> HOWEVER. There is a problem.

> I'm using a simple IWordDetector implementation that uses
> Character.isLetter(c) for both isWordPart(char c) and isWordStart(char c).
> Let's say one of the keywords is 'try', and I write the word 'country',
> the word 'try', and the word 'tryouts'. In 'country' and 'try', the last
> three letters (the 'try') will be highlighted. In 'tryouts', however, the
> 'try' will NOT be highlighted.

> I don't know why this is. I suspect it's because the word is scanned from
> each character in the word to the end of the word, so a word like country
> appears as:

> country
> ountry
> untry
> ntry
> try

> while tryouts appears as

> tryouts
> ryouts
> youts

I've found a solution (though probably not THE solution) to my problem. I
altered the WordRule's evaluate(ICharacterScanner scanner) method so that
it checks to make sure that the character immediately prior in the
ICharacterScanner is not potentially part of a word via unread() and an
if-this-then-return.
Using WordRule does not fix it. [message #573383 is a reply to message #12596] Thu, 17 July 2008 20:55 Go to previous message
Richard Hughes is currently offline Richard HughesFriend
Messages: 20
Registered: April 2010
Junior Member
I've rebuilt the code, and I'm getting the same results regardless of
whether I use CombinedWordRule or WordRule.

Let me narrow the question: Does anyone have experience with
RuleBasedScanners that include WordRule or CombinedWordRule? Has anyone
experienced a similar problem?

Alternately, can anyone suggest another possible place I can look for
advice?
Does anyone have experience with this? [message #573420 is a reply to message #12777] Fri, 18 July 2008 22:13 Go to previous message
Richard Hughes is currently offline Richard HughesFriend
Messages: 20
Registered: April 2010
Junior Member
I truly need something - I don't need a solution, but I need some idea
where to look for one.
Re: Does anyone have experience with this? [message #573665 is a reply to message #12798] Mon, 21 July 2008 13:06 Go to previous message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3070
Registered: July 2009
Senior Member
Richard Hughes wrote:
> I truly need something - I don't need a solution, but I need some idea
> where to look for one.
>

Um, what? I only see the subject and the sentence above.
Please, always quote when replying to a message, so the rest of us see
the context of a thread.

Eric
Re: Does anyone have experience with this? [message #573697 is a reply to message #13498] Mon, 21 July 2008 16:13 Go to previous message
Richard Hughes is currently offline Richard HughesFriend
Messages: 20
Registered: April 2010
Junior Member
Eric Rizzo wrote:

> Richard Hughes wrote:
>> I truly need something - I don't need a solution, but I need some idea
>> where to look for one.
>>

> Um, what? I only see the subject and the sentence above.
> Please, always quote when replying to a message, so the rest of us see
> the context of a thread.

> Eric

Sorry, Eric. I'm still trying to solve the problem described at the
beginning of the thread. :(

I'm trying to see if I can solve it by adding a WhitespaceRule and/or
using setDefaultReturnToken(Token token) to set a default return token for
the rulescanner.
Re: CombinedWordRule and strange bugs in IPresentationReconciler [message #573755 is a reply to message #12596] Mon, 21 July 2008 21:19 Go to previous message
Richard Hughes is currently offline Richard HughesFriend
Messages: 20
Registered: April 2010
Junior Member
Richard Hughes wrote:

> As some of you probably remember, I'm working on a plugin for converting a
> simple XML file describing features of a sourceViewerConfiguration such as
> syntax coloration in to a complete editor plugin. I've gotten the first
> bare bones of a plug-in working, and I've run in to a very strange bug
> that I'm not sure how to fix.

> I've set it up so that it reads an XML file, creates a formatting token
> with a text attribute, and associates it with several keywords. Using a
> CombinedWordRule and a RuleBasedScanner, it checks for those keywords and
> highlights them with the text attribute defined in the formatting token.
> HOWEVER. There is a problem.

> I'm using a simple IWordDetector implementation that uses
> Character.isLetter(c) for both isWordPart(char c) and isWordStart(char c).
> Let's say one of the keywords is 'try', and I write the word 'country',
> the word 'try', and the word 'tryouts'. In 'country' and 'try', the last
> three letters (the 'try') will be highlighted. In 'tryouts', however, the
> 'try' will NOT be highlighted.

> I don't know why this is. I suspect it's because the word is scanned from
> each character in the word to the end of the word, so a word like country
> appears as:

> country
> ountry
> untry
> ntry
> try

> while tryouts appears as

> tryouts
> ryouts
> youts

I've found a solution (though probably not THE solution) to my problem. I
altered the WordRule's evaluate(ICharacterScanner scanner) method so that
it checks to make sure that the character immediately prior in the
ICharacterScanner is not potentially part of a word via unread() and an
if-this-then-return.
Previous Topic:Extension point schema for org.eclipse.ui.editors (and others) cannot be found
Next Topic:Problem with icon-states in debugger
Goto Forum:
  


Current Time: Thu Sep 26 20:46:35 GMT 2024

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

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

Back to the top