2 * Created on May 13, 2003
3 *========================================================================
4 * Modifications history
5 *========================================================================
6 * $Log: not supported by cvs2svn $
7 * Revision 1.1 2004/02/26 02:25:42 agfitzp
8 * renamed packages to match xml & css
10 * Revision 1.1 2004/02/05 03:10:08 agfitzp
13 * Revision 1.1.2.1 2003/12/12 21:37:24 agfitzp
14 * Experimental work for Classes view
16 * Revision 1.2 2003/05/30 20:53:09 agfitzp
17 * 0.0.2 : Outlining is now done as the user types. Some other bug fixes.
19 *========================================================================
21 package net.sourceforge.phpeclipse.js.core.parser;
23 import org.eclipse.jface.text.rules.ICharacterScanner;
24 import org.eclipse.jface.text.rules.IPredicateRule;
25 import org.eclipse.jface.text.rules.IToken;
26 import org.eclipse.jface.text.rules.Token;
27 import org.eclipse.jface.text.rules.WordRule;
28 import org.eclipse.jface.text.rules.IWordDetector;
33 public class PredicateWordRule extends WordRule implements IPredicateRule {
36 * @see org.eclipse.jface.text.rules.IPredicateRule#getSuccessToken()
39 protected IToken successToken = Token.UNDEFINED;
41 public void addWords(String[] tokens, IToken token)
43 for (int i = 0; i < tokens.length; i++) {
44 addWord(tokens[i], token);
49 public IToken getSuccessToken() {
54 * @see org.eclipse.jface.text.rules.IPredicateRule#evaluate(org.eclipse.jface.text.rules.ICharacterScanner, boolean)
56 public IToken evaluate(ICharacterScanner scanner, boolean resume) {
57 successToken = this.evaluate(scanner, resume);//true);
62 * Creates a rule which, with the help of an word detector, will return the token
63 * associated with the detected word. If no token has been associated, the scanner
64 * will be rolled back and an undefined token will be returned in order to allow
65 * any subsequent rules to analyze the characters.
67 * @param detector the word detector to be used by this rule, may not be <code>null</code>
72 public PredicateWordRule(IWordDetector detector) {
77 * Creates a rule which, with the help of an word detector, will return the token
78 * associated with the detected word. If no token has been associated, the
79 * specified default token will be returned.
81 * @param detector the word detector to be used by this rule, may not be <code>null</code>
82 * @param defaultToken the default token to be returned on success
83 * if nothing else is specified, may not be <code>null</code>
87 public PredicateWordRule(IWordDetector detector, IToken defaultToken) {
88 super(detector, defaultToken);
92 public PredicateWordRule(IWordDetector detector, String tokenString, IToken tokenType) {
94 this.addWord(tokenString, tokenType);
97 public PredicateWordRule(IWordDetector detector, String[] tokens, IToken tokenType) {
99 this.addWords(tokens, tokenType);
102 public PredicateWordRule(IWordDetector detector, IToken defaultToken, String[] tokens, IToken tokenType) {
103 super(detector, defaultToken);
104 this.addWords(tokens, tokenType);