intial source from htp://www.sf.net/projects/wdte
[phpeclipse.git] / net.sourceforge.phpeclipse.smarty.ui / src / net / sourceforge / phpdt / smarty / ui / internal / text / SmartyTagScanner.java
1 /*
2  * Copyright (c) 2002-2004 Widespace, OU 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  *     Igor Malinin - initial contribution
10  *
11  * $Id: SmartyTagScanner.java,v 1.1 2004-09-02 18:25:04 jsurfer Exp $
12  */
13
14 package net.sourceforge.phpdt.smarty.ui.internal.text;
15
16 import java.util.Map;
17
18 import net.sourceforge.phpeclipse.xml.ui.internal.text.NameDetector;
19 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLTagRule;
20 import net.sourceforge.phpeclipse.xml.ui.text.IXMLSyntaxConstants;
21
22 import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
23 import org.eclipse.jface.text.rules.IRule;
24 import org.eclipse.jface.text.rules.IToken;
25 import org.eclipse.jface.text.rules.Token;
26 import org.eclipse.jface.text.rules.WordRule;
27
28 /**
29  * @author Igor Malinin
30  */
31 public class SmartyTagScanner extends BufferedRuleBasedScanner {
32    
33         /**
34          * Creates a color token scanner.
35          */
36         public SmartyTagScanner(Map tokens) {
37                 setDefaultReturnToken((Token) tokens.get(
38                                 IXMLSyntaxConstants.XML_DEFAULT));
39
40                 IToken tag = (Token) tokens.get(IXMLSyntaxConstants.XML_TAG);
41                 IToken smartyTag = (Token) tokens.get(IXMLSyntaxConstants.XML_SMARTY);
42                 IToken attribute = (Token) tokens.get(IXMLSyntaxConstants.XML_ATT_NAME);
43
44                 IRule[] rules = { 
45                     new XMLTagRule(tag),
46                     new SmartyTagRule(smartyTag),
47                         new WordRule(new NameDetector(), attribute),};
48
49                 setRules(rules);
50         }
51 }