Mercurial > projects > dwt-addons
diff dwtx/jface/text/rules/WordRule.d @ 162:1a5b8f8129df
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 08 Sep 2008 00:51:37 +0200 |
parents | f70d9508c95c |
children | eb98a5cbfd78 |
line wrap: on
line diff
--- a/dwtx/jface/text/rules/WordRule.d Wed Aug 27 14:49:30 2008 +0200 +++ b/dwtx/jface/text/rules/WordRule.d Mon Sep 08 00:51:37 2008 +0200 @@ -61,7 +61,7 @@ public class WordRule : IRule { /** Internal setting for the un-initialized column constraint. */ - protected static final int UNDEFINED= -1; + protected static const int UNDEFINED= -1; /** The word detector used by this rule. */ protected IWordDetector fDetector; @@ -70,9 +70,9 @@ /** The column constraint. */ protected int fColumn= UNDEFINED; /** The table of predefined words and token for this rule. */ - protected Map fWords= new HashMap(); + protected Map fWords; /** Buffer used for pattern detection. */ - private StringBuffer fBuffer= new StringBuffer(); + private StringBuffer fBuffer; /** * Tells whether this rule is case sensitive. * @since 3.3 @@ -119,8 +119,11 @@ * @since 3.3 */ public this(IWordDetector detector, IToken defaultToken, bool ignoreCase) { - Assert.isNotNull(detector); - Assert.isNotNull(defaultToken); + fWords= new HashMap(); + fBuffer= new StringBuffer(); + + Assert.isNotNull(cast(Object)detector); + Assert.isNotNull(cast(Object)defaultToken); fDetector= detector; fDefaultToken= defaultToken; @@ -134,10 +137,10 @@ * @param token the token to be returned if the word has been found, may not be <code>null</code> */ public void addWord(String word, IToken token) { - Assert.isNotNull(word); - Assert.isNotNull(token); + //Assert.isNotNull(word); + Assert.isNotNull(cast(Object)token); - fWords.put(word, token); + fWords.put(word, cast(Object)token); } /** @@ -159,23 +162,23 @@ */ public IToken evaluate(ICharacterScanner scanner) { int c= scanner.read(); - if (c !is ICharacterScanner.EOF && fDetector.isWordStart(cast(wchar) c)) { + if (c !is ICharacterScanner.EOF && fDetector.isWordStart(cast(char) c)) { if (fColumn is UNDEFINED || (fColumn is scanner.getColumn() - 1)) { - fBuffer.setLength(0); + fBuffer.truncate(0); do { - fBuffer.append(cast(wchar) c); + fBuffer.append(cast(char) c); c= scanner.read(); - } while (c !is ICharacterScanner.EOF && fDetector.isWordPart(cast(wchar) c)); + } while (c !is ICharacterScanner.EOF && fDetector.isWordPart(cast(char) c)); scanner.unread(); String buffer= fBuffer.toString(); IToken token= cast(IToken)fWords.get(buffer); - + if(fIgnoreCase) { Iterator iter= fWords.keySet().iterator(); while (iter.hasNext()) { - String key= cast(String)iter.next(); + String key= stringcast(iter.next()); if(buffer.equalsIgnoreCase(key)) { token= cast(IToken)fWords.get(key); break; @@ -183,7 +186,7 @@ } } else token= cast(IToken)fWords.get(buffer); - + if (token !is null) return token;