1 19 20 package org.netbeans.lib.lexer.token; 21 22 import org.netbeans.api.lexer.PartType; 23 import org.netbeans.api.lexer.TokenId; 24 import org.netbeans.lib.lexer.LexerUtilsConstants; 25 import org.netbeans.lib.lexer.PreprocessedTextStorage; 26 import org.netbeans.spi.lexer.CharPreprocessor; 27 import org.netbeans.spi.lexer.TokenPropertyProvider; 28 29 41 42 public final class ComplexToken<T extends TokenId> extends PreprocessedTextToken<T> { 43 44 private final TokenPropertyProvider propertyProvider; 46 private final CharSequence customText; 48 private final PartType partType; 50 public ComplexToken(T id, int length, 51 TokenPropertyProvider propertyProvider, CharSequence customText, PartType partType) { 52 super(id, length); 53 this.propertyProvider = propertyProvider; 54 this.customText = customText; 55 this.partType = partType; 56 } 57 58 @Override 59 public boolean hasProperties() { 60 return (propertyProvider != null); 61 } 62 63 @Override 64 public Object getProperty(Object key) { 65 return (propertyProvider != null) ? propertyProvider.getValue(this, key) : null; 66 } 67 68 @Override 69 public CharSequence text() { 70 return (customText != null) ? customText : super.text(); 71 } 72 73 @Override 74 public PartType partType() { 75 return partType; 76 } 77 78 @Override 79 protected String dumpInfoTokenType() { 80 return "PPrT"; } 82 83 } 84 | Popular Tags |