2 * Created on May 13, 2003
3 *========================================================================
4 * Modifications history
5 *========================================================================
6 * $Log: not supported by cvs2svn $
7 * Revision 1.1 2004/09/02 18:14:38 jsurfer
8 * intial source from ttp://www.sf.net/projects/wdte
10 * Revision 1.1 2004/02/26 02:25:42 agfitzp
11 * renamed packages to match xml & css
13 * Revision 1.1 2004/02/05 03:10:08 agfitzp
16 * Revision 1.1.2.1 2003/12/12 21:37:24 agfitzp
17 * Experimental work for Classes view
19 * Revision 1.2 2003/05/30 20:53:09 agfitzp
20 * 0.0.2 : Outlining is now done as the user types. Some other bug fixes.
22 *========================================================================
24 package net.sourceforge.phpeclipse.js.core.parser;
26 import org.eclipse.jface.text.rules.ICharacterScanner;
27 import org.eclipse.jface.text.rules.IPredicateRule;
28 import org.eclipse.jface.text.rules.IToken;
29 import org.eclipse.jface.text.rules.IWordDetector;
30 import org.eclipse.jface.text.rules.Token;
31 import org.eclipse.jface.text.rules.WordRule;
36 public class PredicateWordRule extends WordRule implements IPredicateRule {
39 * @see org.eclipse.jface.text.rules.IPredicateRule#getSuccessToken()
42 protected IToken successToken = Token.UNDEFINED;
44 public void addWords(String[] tokens, IToken token)
46 for (int i = 0; i < tokens.length; i++) {
47 addWord(tokens[i], token);
52 public IToken getSuccessToken() {
57 * @see org.eclipse.jface.text.rules.IPredicateRule#evaluate(org.eclipse.jface.text.rules.ICharacterScanner, boolean)
59 public IToken evaluate(ICharacterScanner scanner, boolean resume) {
60 successToken = this.evaluate(scanner, resume);//true);
65 * Creates a rule which, with the help of an word detector, will return the token
66 * associated with the detected word. If no token has been associated, the scanner
67 * will be rolled back and an undefined token will be returned in order to allow
68 * any subsequent rules to analyze the characters.
70 * @param detector the word detector to be used by this rule, may not be <code>null</code>
75 public PredicateWordRule(IWordDetector detector) {
80 * Creates a rule which, with the help of an word detector, will return the token
81 * associated with the detected word. If no token has been associated, the
82 * specified default token will be returned.
84 * @param detector the word detector to be used by this rule, may not be <code>null</code>
85 * @param defaultToken the default token to be returned on success
86 * if nothing else is specified, may not be <code>null</code>
90 public PredicateWordRule(IWordDetector detector, IToken defaultToken) {
91 super(detector, defaultToken);
95 public PredicateWordRule(IWordDetector detector, String tokenString, IToken tokenType) {
97 this.addWord(tokenString, tokenType);
100 public PredicateWordRule(IWordDetector detector, String[] tokens, IToken tokenType) {
102 this.addWords(tokens, tokenType);
105 public PredicateWordRule(IWordDetector detector, IToken defaultToken, String[] tokens, IToken tokenType) {
106 super(detector, defaultToken);
107 this.addWords(tokens, tokenType);