public XMLStringPartitionScanner() { IPredicateRule[] rules = new IPredicateRule[6]; rules[0] = new MultiLineRule("\"", "\"", new Token(XML_STRING), '\\', true); //$NON-NLS-1$ //$NON-NLS-2$ rules[1] = new MultiLineRule("\'", "\'", new Token(XML_STRING), '\\', true); //$NON-NLS-1$ //$NON-NLS-2$ rules[2] = new MultiLineRule("<!--", "-->", new Token(XMLPartitionScanner.XML_COMMENT)); //$NON-NLS-1$//$NON-NLS-2$ rules[3] = new MultiLineRule("<?", "?>", new Token(XMLPartitionScanner.XML_COMMENT)); //$NON-NLS-1$ //$NON-NLS-2$ rules[4] = new MultiLineRule("<description>", "</description>", new Token(CUSTOM_TAG)); //$NON-NLS-1$//$NON-NLS-2$ rules[5] = new MultiLineRule("href=\"", "\"", new Token(XMLPartitionScanner.XML_COMMENT)); //$NON-NLS-1$ //$NON-NLS-2$ setPredicateRules(rules); } }
@Override public TextAttribute getData() { return (TextAttribute) super.getData(); }
/** * Re-initializes the data of this token. The token may not represent * undefined, whitespace, or EOF. * * @param data to be attached to the token * @since 2.0 */ public void setData(Object data) { Assert.isTrue(isOther()); fData= data; }
private void addToken(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) { if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) { RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey); if (fColorManager instanceof IColorManagerExtension) { IColorManagerExtension ext= (IColorManagerExtension) fColorManager; ext.unbindColor(colorKey); ext.bindColor(colorKey, rgb); } } if (!fNeedsLazyColorLoading) fTokenMap.put(colorKey, new Token(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey))); else { Token token= fTokenMap.get(colorKey); if (token != null) token.setData(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey)); } }
private void addToken(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) { if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) { RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey); if (fColorManager instanceof IColorManagerExtension) { IColorManagerExtension ext= (IColorManagerExtension) fColorManager; ext.unbindColor(colorKey); ext.bindColor(colorKey, rgb); } } if (!fNeedsLazyColorLoading) fTokenMap.put(colorKey, new Token(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey))); else { Token token= fTokenMap.get(colorKey); if (token != null) token.setData(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey)); } }
private void adaptToStyleChange(Token token, PropertyChangeEvent event, int styleAttribute) { boolean eventValue= false; Object value= event.getNewValue(); if (value instanceof Boolean) eventValue= ((Boolean) value).booleanValue(); else if (IPreferenceStore.TRUE.equals(value)) eventValue= true; Object data= token.getData(); if (data instanceof TextAttribute) { TextAttribute oldAttr= (TextAttribute) data; boolean activeValue= (oldAttr.getStyle() & styleAttribute) == styleAttribute; if (activeValue != eventValue) token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute)); } } /**
private void addToken(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) { if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) { RGB rgb= PreferenceConverter.getColor(fPreferenceStore, colorKey); if (fColorManager instanceof IColorManagerExtension) { IColorManagerExtension ext= (IColorManagerExtension) fColorManager; ext.unbindColor(colorKey); ext.bindColor(colorKey, rgb); } } if (!fNeedsLazyColorLoading) fTokenMap.put(colorKey, new Token(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey))); else { Token token= ((Token)fTokenMap.get(colorKey)); if (token != null) token.setData(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey)); } }
private void adaptToStyleChange(Token token, PropertyChangeEvent event, int styleAttribute) { boolean eventValue= false; Object value= event.getNewValue(); if (value instanceof Boolean) eventValue= ((Boolean) value).booleanValue(); else if (IPreferenceStore.TRUE.equals(value)) eventValue= true; Object data= token.getData(); if (data instanceof TextAttribute) { TextAttribute oldAttr= (TextAttribute) data; boolean activeValue= (oldAttr.getStyle() & styleAttribute) == styleAttribute; if (activeValue != eventValue) token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute)); } } /**
/** * Re-initializes the data of this token. The token may not represent * undefined, whitespace, or EOF. * * @param data to be attached to the token * @since 2.0 */ public void setData(Object data) { Assert.isTrue(isOther()); fData= data; }
private void adaptToStyleChange(Token token, PropertyChangeEvent event, int styleAttribute) { boolean eventValue= false; Object value= event.getNewValue(); if (value instanceof Boolean) eventValue= ((Boolean) value).booleanValue(); else if (IPreferenceStore.TRUE.equals(value)) eventValue= true; Object data= token.getData(); if (data instanceof TextAttribute) { TextAttribute oldAttr= (TextAttribute) data; boolean activeValue= (oldAttr.getStyle() & styleAttribute) == styleAttribute; if (activeValue != eventValue) token.setData(new TextAttribute(oldAttr.getForeground(), oldAttr.getBackground(), eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr.getStyle() & ~styleAttribute)); } } /**
/** * Re-initializes the data of this token. The token may not represent * undefined, whitespace, or EOF. * * @param data to be attached to the token * @since 2.0 */ public void setData(Object data) { Assert.isTrue(isOther()); fData= data; }
public IToken nextToken() { if (!tokenReturned) { tokenReturned = true; return new Token(getAttribute(DefaultHighlightingConfiguration.DEFAULT_ID)); } return Token.EOF; }
protected void adaptToStyleChange(PropertyChangeEvent event, Token token, int styleAttribute) { if (token == null) { return; } boolean eventValue = false; Object value = event.getNewValue(); if (value instanceof Boolean) { eventValue = ((Boolean) value).booleanValue(); } else if (IPreferenceStore.TRUE.equals(value)) { eventValue = true; } TextAttribute attr = (TextAttribute) token.getData(); boolean activeValue = (attr.getStyle() & styleAttribute) == styleAttribute; if (activeValue != eventValue) { token.setData(new TextAttribute(attr.getForeground(), attr.getBackground(), eventValue ? attr.getStyle() | styleAttribute : attr.getStyle() & ~styleAttribute)); } }
/** * Re-initializes the data of this token. The token may not represent * undefined, whitespace, or EOF. * * @param data to be attached to the token * @since 2.0 */ public void setData(Object data) { Assert.isTrue(isOther()); fData= data; }
public IToken nextToken() { if (lastComputed == null || lastComputed.partitions == null || ++index >= lastComputed.partitions.length) { return Token.EOF; } return new Token(lastComputed.partitions[index].getType()); }
protected void adaptToStyleChange(PropertyChangeEvent event, Token token, int styleAttribute) { if (token == null) return; boolean eventValue = false; Object value = event.getNewValue(); if (value instanceof Boolean) eventValue = ((Boolean) value).booleanValue(); TextAttribute attr = (TextAttribute) token.getData(); boolean activeValue = (attr.getStyle() & styleAttribute) == styleAttribute; if (activeValue != eventValue) { Color foreground = attr.getForeground(); Color background = attr.getBackground(); int style = eventValue ? attr.getStyle() | styleAttribute : attr.getStyle() & ~styleAttribute; token.setData(new TextAttribute(foreground, background, style)); } }
public NoHighlightScanner() { setDefaultReturnToken(new Token("sourcetext")); } }