X-Git-Url: http://secure.phpeclipse.com diff --git a/archive/net.sourceforge.phpeclipse.css.ui/src/net/sourceforge/phpeclipse/css/ui/internal/text/CssPartitionScanner.java b/archive/net.sourceforge.phpeclipse.css.ui/src/net/sourceforge/phpeclipse/css/ui/internal/text/CssPartitionScanner.java new file mode 100644 index 0000000..751041b --- /dev/null +++ b/archive/net.sourceforge.phpeclipse.css.ui/src/net/sourceforge/phpeclipse/css/ui/internal/text/CssPartitionScanner.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2003-2004 Christopher Lenz and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Christopher Lenz - initial API and implementation + * + * $Id: CssPartitionScanner.java,v 1.1 2004-09-02 18:11:48 jsurfer Exp $ + */ + +package net.sourceforge.phpeclipse.css.ui.internal.text; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.jface.text.rules.IPredicateRule; +import org.eclipse.jface.text.rules.IToken; +import org.eclipse.jface.text.rules.MultiLineRule; +import org.eclipse.jface.text.rules.RuleBasedPartitionScanner; +import org.eclipse.jface.text.rules.SingleLineRule; +import org.eclipse.jface.text.rules.Token; + +/** + * + */ +public class CssPartitionScanner extends RuleBasedPartitionScanner { + + // Constants --------------------------------------------------------------- + + public static final String CSS_COMMENT = + "__css_comment_partition_content_type"; //$NON-NLS-1$ + + public static final String CSS_STRING = + "__css_string_partition_content_type"; //$NON-NLS-1$ + + // Constructors ------------------------------------------------------------ + + /** + * Constructor. + */ + public CssPartitionScanner() { + + IToken commentToken = new Token(CSS_COMMENT); + IToken stringToken = new Token(CSS_STRING); + + List rules = new ArrayList(); + + rules.add(new MultiLineRule( + "/*", "*/", commentToken)); //$NON-NLS-1$ //$NON-NLS-2$ + + // TODO Strings can be continued over a new line using the escape + // character (#42613) + rules.add(new SingleLineRule( + "\"", "\"", stringToken, '\\')); //$NON-NLS-1$ //$NON-NLS-2$ + rules.add(new SingleLineRule( + "'", "'", stringToken, '\\')); //$NON-NLS-1$ //$NON-NLS-2$ + + setPredicateRules((IPredicateRule[]) + rules.toArray(new IPredicateRule[rules.size()])); + } + +}