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
9 * Christopher Lenz - initial API and implementation
11 * $Id: CssPartitionScanner.java,v 1.1 2004-09-02 18:11:48 jsurfer Exp $
14 package net.sourceforge.phpeclipse.css.ui.internal.text;
16 import java.util.ArrayList;
17 import java.util.List;
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;
29 public class CssPartitionScanner extends RuleBasedPartitionScanner {
31 // Constants ---------------------------------------------------------------
33 public static final String CSS_COMMENT =
34 "__css_comment_partition_content_type"; //$NON-NLS-1$
36 public static final String CSS_STRING =
37 "__css_string_partition_content_type"; //$NON-NLS-1$
39 // Constructors ------------------------------------------------------------
44 public CssPartitionScanner() {
46 IToken commentToken = new Token(CSS_COMMENT);
47 IToken stringToken = new Token(CSS_STRING);
49 List rules = new ArrayList();
51 rules.add(new MultiLineRule(
52 "/*", "*/", commentToken)); //$NON-NLS-1$ //$NON-NLS-2$
54 // TODO Strings can be continued over a new line using the escape
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$
61 setPredicateRules((IPredicateRule[])
62 rules.toArray(new IPredicateRule[rules.size()]));