1 11 package org.eclipse.jdt.internal.ui.propertiesfileeditor; 12 13 import org.eclipse.jface.text.rules.ICharacterScanner; 14 import org.eclipse.jface.text.rules.IToken; 15 import org.eclipse.jface.text.rules.IWordDetector; 16 import org.eclipse.jface.text.rules.WordPatternRule; 17 18 26 public final class ArgumentRule extends WordPatternRule { 27 28 private static class ArgumentDetector implements IWordDetector { 29 30 33 public boolean isWordStart(char c) { 34 return '{' == c; 35 } 36 37 40 public boolean isWordPart(char c) { 41 return c == '}' || Character.isDigit(c); 42 } 43 } 44 45 46 private int fCount= 0; 47 48 53 public ArgumentRule(IToken token) { 54 super(new ArgumentDetector(), "{", "}", token); } 56 57 60 protected boolean endSequenceDetected(ICharacterScanner scanner) { 61 fCount++; 62 63 if (scanner.read() == '}') 64 return fCount > 2; 65 66 scanner.unread(); 67 return super.endSequenceDetected(scanner); 68 } 69 70 73 protected boolean sequenceDetected(ICharacterScanner scanner, char[] sequence, boolean eofAllowed) { 74 fCount= 0; 75 return super.sequenceDetected(scanner, sequence, eofAllowed); 76 } 77 } 78 | Popular Tags |