5c56abfb8d629cc7030bd8d2b32933ca91bd91bf
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / editors / PHPPartitionScanner.java
1 package net.sourceforge.phpeclipse.editors;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import org.eclipse.jface.text.IDocument;
7 import org.eclipse.jface.text.rules.*;
8
9 public class PHPPartitionScanner extends RuleBasedPartitionScanner {
10         public final static String HTML_COMMENT = "__html_comment";
11         public final static String HTML_TAG = "__tag";
12         public final static String PHP_COMMENT = "__php_comment";
13         public final static String PHP_STRING = "__php_string";
14
15         public PHPPartitionScanner() {
16
17                 List rules = new ArrayList();
18
19                 IToken php_tag = new Token(HTML_TAG);
20                 IToken php_comment = new Token(PHP_COMMENT);
21                 IToken html_comment = new Token(HTML_COMMENT);
22
23                 rules.add(new MultiLineRule("<!--", "-->", html_comment));
24                 rules.add(new MultiLineRule("/*", "*/", php_comment));
25                 rules.add(new MultiLineRule("<script", "script>", php_tag));
26
27                 //              rules.add(new TagRule(tag));
28
29                 IPredicateRule[] result = new IPredicateRule[rules.size()];
30                 rules.toArray(result);
31                 setPredicateRules(result);
32         }
33 }