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
9 * Igor Malinin - initial contribution
11 * $Id: DeclScanner.java,v 1.3 2006-10-21 23:14:13 pombredanne Exp $
14 package net.sourceforge.phpeclipse.xml.ui.internal.text;
18 import net.sourceforge.phpeclipse.xml.ui.text.IXMLSyntaxConstants;
20 import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
21 import org.eclipse.jface.text.rules.IRule;
22 import org.eclipse.jface.text.rules.IToken;
23 import org.eclipse.jface.text.rules.MultiLineRule;
24 import org.eclipse.jface.text.rules.Token;
25 import org.eclipse.jface.text.rules.WordRule;
28 * @author Igor Malinin
30 public class DeclScanner extends BufferedRuleBasedScanner {
33 * Creates a color scanner for XML text or attribute value.
35 public DeclScanner(Map tokens) {
36 IToken decl = (Token) tokens.get(IXMLSyntaxConstants.XML_DECL);
38 setDefaultReturnToken(decl);
40 IToken markup = (Token) tokens.get(IXMLSyntaxConstants.XML_ATT_NAME);
42 WordRule rule = new WordRule(new NmtokenDetector(), markup);
43 rule.addWord("ATTLIST", decl);
44 rule.addWord("CDATA", decl);
45 rule.addWord("DOCTYPE", decl);
46 rule.addWord("ELEMENT", decl);
47 rule.addWord("EMPTY", decl);
48 rule.addWord("ENTITY", decl);
49 rule.addWord("FIXED", decl);
50 rule.addWord("ID", decl);
51 rule.addWord("IDREF", decl);
52 rule.addWord("IDREFS", decl);
53 rule.addWord("IMPLIED", decl);
54 rule.addWord("PCDATA", decl);
55 rule.addWord("PUBLIC", decl);
56 rule.addWord("REQUIRED", decl);
57 rule.addWord("SYSTEM", decl);
59 IToken string = (Token) tokens.get(IXMLSyntaxConstants.XML_ATT_VALUE);
60 IToken entity = (Token) tokens.get(IXMLSyntaxConstants.XML_ENTITY);
62 IRule[] rules = { rule, new MultiLineRule("\"", "\"", string),
63 new MultiLineRule("'", "'", string),
64 new EntityRule('%', entity), };