|
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 XMLTagScanner extends RuleBasedScanner { |
|
33 |
|
34 public XMLTagScanner(ColorManager manager) { |
|
35 IToken string = new Token(new TextAttribute(manager |
|
36 .getColor(IXMLColorConstants.STRING))); |
|
37 |
|
38 IRule[] rules = new IRule[3]; |
|
39 |
|
40 // Add rule for double quotes |
|
41 rules[0] = new SingleLineRule("\"", "\"", string, '\\'); |
|
42 // Add a rule for single quotes |
|
43 rules[1] = new SingleLineRule("'", "'", string, '\\'); |
|
44 // Add generic whitespace rule. |
|
45 rules[2] = new WhitespaceRule(new XMLWhitespaceDetector()); |
|
46 |
|
47 setRules(rules); |
|
48 } |
|
49 } |