1 11 package org.eclipse.pde.internal.ui.editor.text; 12 13 import org.eclipse.jface.text.rules.IRule; 14 import org.eclipse.jface.text.rules.SingleLineRule; 15 import org.eclipse.jface.text.rules.Token; 16 import org.eclipse.jface.text.rules.WhitespaceRule; 17 import org.eclipse.jface.util.PropertyChangeEvent; 18 19 public class XMLScanner extends BasePDEScanner { 20 private Token fProcInstr; 21 22 public XMLScanner(IColorManager manager) { 23 super(manager); 24 } 25 26 protected void initialize() { 27 fProcInstr = new Token(createTextAttribute(IPDEColorConstants.P_PROC_INSTR)); 28 29 IRule[] rules = new IRule[2]; 30 rules[0] = new SingleLineRule("<?", "?>", fProcInstr); rules[1] = new WhitespaceRule(new XMLWhitespaceDetector()); 34 setRules(rules); 35 setDefaultReturnToken(new Token(createTextAttribute(IPDEColorConstants.P_DEFAULT))); 36 } 37 38 protected Token getTokenAffected(PropertyChangeEvent event) { 39 if (event.getProperty().startsWith(IPDEColorConstants.P_PROC_INSTR)) 40 return fProcInstr; 41 return (Token)fDefaultReturnToken; 42 } 43 44 public boolean affectsTextPresentation(String property) { 45 return property.startsWith(IPDEColorConstants.P_DEFAULT) 46 || property.startsWith(IPDEColorConstants.P_PROC_INSTR); 47 } 48 49 } 50 | Popular Tags |