Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipse-dev] Problem using org.eclipse.jface.text.rules package

Hi:

I am writing a class to parse types (in eiffel) which have the following
rules:
[A-Z]{A-Z,0-9,'_'}* 
In English, all caps starting with a letter and allowing numbers and
underscore.

I have created an EiffelType Detector as follows:

//import statements and comments here ...public class EiffelTypeDetector
implements IWordDetector {

	/**
	 * uppercase letter
	 * @see org.eclipse.jface.text.rules.IWordDetector#isWordStart(char)
	 */
	public boolean isWordStart(char c) {
		return Character.isUpperCase(c);
	}

	/**
	 * uppercase letter or number
	 * @see org.eclipse.jface.text.rules.IWordDetector#isWordPart(char)
	 */
	public boolean isWordPart(char c) {
		return (Character.isUpperCase(c) || Character.isDigit(c) || (c ==
'_'));
	}

}

As you can see... it seems pretty trivial, but here's the weird thing...

I have created a class called EiffelCodeScanner which extends
RuleBasedScanner and included the following code in the constructor

WordRule typeRule = new WordRule(new EiffelTypeDetector(), type);

		rules.add(typeRule);

		IRule[] result= new IRule[rules.size()];
		rules.toArray(result);
		setRules(result);

Now when I run my editor, it works as expected, except words like
HAPPynewyear have HAPP highlighted which is wrong!

What else do I have to do to ensure that ALL letters of the word must be
capitalized?

Thanks,

-- 
Dave Makalsky <dm@xxxxxxxxxxx>



Back to the top