1 | package de.uka.ipd.sdq.pcm.gmf.resource.editors; |
2 | |
3 | import org.eclipse.jface.text.TextAttribute; |
4 | import org.eclipse.jface.text.rules.IRule; |
5 | import org.eclipse.jface.text.rules.IToken; |
6 | import org.eclipse.jface.text.rules.RuleBasedScanner; |
7 | import org.eclipse.jface.text.rules.SingleLineRule; |
8 | import org.eclipse.jface.text.rules.Token; |
9 | import org.eclipse.jface.text.rules.WhitespaceRule; |
10 | |
11 | public class XMLTagScanner extends RuleBasedScanner { |
12 | |
13 | public XMLTagScanner(ColorManager manager) { |
14 | IToken string = |
15 | new Token( |
16 | new TextAttribute(manager.getColor(IXMLColorConstants.STRING))); |
17 | |
18 | IRule[] rules = new IRule[3]; |
19 | |
20 | // Add rule for double quotes |
21 | rules[0] = new SingleLineRule("\"", "\"", string, '\\'); |
22 | // Add a rule for single quotes |
23 | rules[1] = new SingleLineRule("'", "'", string, '\\'); |
24 | // Add generic whitespace rule. |
25 | rules[2] = new WhitespaceRule(new XMLWhitespaceDetector()); |
26 | |
27 | setRules(rules); |
28 | } |
29 | } |