|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 package com.symbian.smt.gui.editors.xmleditor; |
|
19 |
|
20 import org.eclipse.jface.text.TextAttribute; |
|
21 import org.eclipse.jface.text.rules.IRule; |
|
22 import org.eclipse.jface.text.rules.IToken; |
|
23 import org.eclipse.jface.text.rules.RuleBasedScanner; |
|
24 import org.eclipse.jface.text.rules.SingleLineRule; |
|
25 import org.eclipse.jface.text.rules.Token; |
|
26 import org.eclipse.jface.text.rules.WhitespaceRule; |
|
27 |
|
28 /** |
|
29 * @author barbararosi-schwartz |
|
30 * |
|
31 */ |
|
32 public class XMLScanner extends RuleBasedScanner { |
|
33 |
|
34 public XMLScanner(ColorManager manager) { |
|
35 IToken procInstr = new Token(new TextAttribute(manager |
|
36 .getColor(IXMLColorConstants.PROC_INSTR))); |
|
37 |
|
38 IRule[] rules = new IRule[2]; |
|
39 // Add rule for processing instructions |
|
40 rules[0] = new SingleLineRule("<?", "?>", procInstr); |
|
41 // Add generic whitespace rule. |
|
42 rules[1] = new WhitespaceRule(new XMLWhitespaceDetector()); |
|
43 |
|
44 setRules(rules); |
|
45 } |
|
46 } |