2 * $RCSfile: JSPartitionScanner.java,v $
5 * CH-1700 Fribourg, Switzerland
8 *========================================================================
9 * Modifications history
10 *========================================================================
11 * $Log: not supported by cvs2svn $
12 * Revision 1.1 2004/02/26 02:25:42 agfitzp
13 * renamed packages to match xml & css
15 * Revision 1.1 2004/02/05 03:10:08 agfitzp
18 * Revision 1.1.2.1 2003/12/12 21:37:24 agfitzp
19 * Experimental work for Classes view
21 * Revision 1.3 2003/05/30 20:53:09 agfitzp
22 * 0.0.2 : Outlining is now done as the user types. Some other bug fixes.
24 * Revision 1.2 2003/05/28 20:47:58 agfitzp
25 * Outline the document, not the file.
27 * Revision 1.1 2003/05/28 15:17:12 agfitzp
28 * net.sourceforge.phpeclipse.js.core 0.0.1 code base
30 *========================================================================
33 package net.sourceforge.phpeclipse.js.core.parser;
35 import java.util.ArrayList;
36 import java.util.List;
37 //import org.eclipse.jface.text.IDocument;
38 import org.eclipse.jface.text.rules.*;
43 * @author $Author: jsurfer $, $Date: 2004-09-02 18:14:38 $
45 * @version $Revision: 1.1 $
47 public class JSPartitionScanner extends RuleBasedPartitionScanner {
48 public final static String JS_DEFAULT = "__js_default";
49 public final static String JS_COMMENT = "__js_comment";
50 public final static String JS_KEYWORD = "__js_keyword";
51 public final static String JS_STRING = "__js_string";
53 public final static IToken TOKEN_STRING = new Token(JS_STRING);
54 public final static IToken TOKEN_COMMENT = new Token(JS_COMMENT);
55 public final static IToken TOKEN_DEFAULT = new Token(JS_DEFAULT);
56 public final static IToken TOKEN_KEYWORD = new Token(JS_KEYWORD);
59 * Array of keyword token strings.
61 private static String[] keywordTokens= {
63 "case", "catch", "continue",
72 "this", "throw", "try",
78 * Array of constant token strings.
80 private static String[] constantTokens= { "false", "null", "true" };
84 * Creates a new JSPartitionScanner object.
86 public JSPartitionScanner() {
87 List rules = new ArrayList();
89 rules.add(new MultiLineRule("/*", "*/", TOKEN_COMMENT));
90 rules.add(new SingleLineRule("//", "", TOKEN_COMMENT));
91 rules.add(new SingleLineRule("\"", "\"", TOKEN_STRING, '\\'));
92 rules.add(new SingleLineRule("'", "'", TOKEN_STRING, '\\'));
94 PredicateWordRule keywordRule = new PredicateWordRule(new JSWordDetector(), TOKEN_DEFAULT, keywordTokens, TOKEN_KEYWORD);
95 keywordRule.addWords(constantTokens, TOKEN_KEYWORD);
96 rules.add(keywordRule);
102 private void setRuleList(List rules)
104 IPredicateRule[] result = new IPredicateRule[rules.size()];
105 rules.toArray(result);
106 setPredicateRules(result);