intial source from ttp://www.sf.net/projects/wdte
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.css.ui / src / net / sourceforge / phpeclipse / css / ui / internal / text / CssPartitionScanner.java
1 /*
2  * Copyright (c) 2003-2004 Christopher Lenz and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     Christopher Lenz - initial API and implementation
10  * 
11  * $Id: CssPartitionScanner.java,v 1.1 2004-09-02 18:11:48 jsurfer Exp $
12  */
13
14 package net.sourceforge.phpeclipse.css.ui.internal.text;
15
16 import java.util.ArrayList;
17 import java.util.List;
18
19 import org.eclipse.jface.text.rules.IPredicateRule;
20 import org.eclipse.jface.text.rules.IToken;
21 import org.eclipse.jface.text.rules.MultiLineRule;
22 import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
23 import org.eclipse.jface.text.rules.SingleLineRule;
24 import org.eclipse.jface.text.rules.Token;
25
26 /**
27  * 
28  */
29 public class CssPartitionScanner extends RuleBasedPartitionScanner {
30
31         // Constants ---------------------------------------------------------------
32
33         public static final String CSS_COMMENT =
34                 "__css_comment_partition_content_type"; //$NON-NLS-1$
35
36         public static final String CSS_STRING =
37                 "__css_string_partition_content_type"; //$NON-NLS-1$
38
39         // Constructors ------------------------------------------------------------
40
41         /**
42          * Constructor.
43          */
44         public CssPartitionScanner() {
45
46                 IToken commentToken = new Token(CSS_COMMENT);
47                 IToken stringToken = new Token(CSS_STRING);
48
49                 List rules = new ArrayList();
50
51                 rules.add(new MultiLineRule(
52                         "/*", "*/", commentToken)); //$NON-NLS-1$ //$NON-NLS-2$
53
54                 // TODO Strings can be continued over a new line using the escape 
55                 // character (#42613)
56                 rules.add(new SingleLineRule(
57                         "\"", "\"", stringToken, '\\')); //$NON-NLS-1$ //$NON-NLS-2$
58                 rules.add(new SingleLineRule(
59                         "'", "'", stringToken, '\\')); //$NON-NLS-1$ //$NON-NLS-2$
60
61                 setPredicateRules((IPredicateRule[])
62                         rules.toArray(new IPredicateRule[rules.size()]));
63         }
64
65 }