CombinedWordRule and strange bugs in IPresentationReconciler [message #573021] |
Tue, 15 July 2008 21:18 |
Richard Hughes Messages: 20 Registered: April 2010 |
Junior Member |
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.02843 seconds