A massive organize imports and formatting of the sources using default Eclipse code...
[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.2 2006-10-21 23:19:32 pombredanne 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
38                                 .get(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 = { new XMLTagRule(tag), new SmartyTagRule(smartyTag),
45                                 new WordRule(new NameDetector(), attribute), };
46
47                 setRules(rules);
48         }
49 }