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 XMLScanner extends RuleBasedScanner { |
12 | |
13 | public XMLScanner(ColorManager manager) { |
14 | IToken procInstr = |
15 | new Token( |
16 | new TextAttribute( |
17 | manager.getColor(IXMLColorConstants.PROC_INSTR))); |
18 | |
19 | IRule[] rules = new IRule[2]; |
20 | //Add rule for processing instructions |
21 | rules[0] = new SingleLineRule("<?", "?>", procInstr); |
22 | // Add generic whitespace rule. |
23 | rules[1] = new WhitespaceRule(new XMLWhitespaceDetector()); |
24 | |
25 | setRules(rules); |
26 | } |
27 | } |