6466d72fd0065feb9c8186410fec9d7864d0da16
[phpeclipse.git] / net.sourceforge.phpeclipse.xml.ui / src / net / sourceforge / phpeclipse / xml / ui / internal / text / XMLTagScanner.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: XMLTagScanner.java,v 1.1 2004-09-02 18:28:03 jsurfer Exp $
12  */
13
14 package net.sourceforge.phpeclipse.xml.ui.internal.text;
15
16 import java.util.Map;
17
18 import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
19 import org.eclipse.jface.text.rules.IRule;
20 import org.eclipse.jface.text.rules.IToken;
21 import org.eclipse.jface.text.rules.Token;
22 import org.eclipse.jface.text.rules.WordRule;
23
24 import net.sourceforge.phpeclipse.xml.ui.text.IXMLSyntaxConstants;
25
26 /**
27  * @author Igor Malinin
28  */
29 public class XMLTagScanner extends BufferedRuleBasedScanner {
30
31         /**
32          * Creates a color token scanner.
33          */
34         public XMLTagScanner(Map tokens) {
35                 setDefaultReturnToken((Token) tokens.get(
36                                 IXMLSyntaxConstants.XML_DEFAULT));
37
38                 IToken tag = (Token) tokens.get(IXMLSyntaxConstants.XML_TAG);
39                 IToken attribute = (Token) tokens.get(IXMLSyntaxConstants.XML_ATT_NAME);
40
41                 IRule[] rules = { new XMLTagRule(tag),
42                                 new WordRule(new NameDetector(), attribute),};
43
44                 setRules(rules);
45         }
46 }