@Override public boolean is(int type, char[] lexeme) { if (this.getType()==type && textCount==lexeme.length) { for (int i=0; i<textCount; i++) { if (text[textOffset+i]!=lexeme[i]) { return false; } } return true; } return false; }
@Override public boolean isWhitespace() { return getType()==WHITESPACE; }
@Override public boolean isPaintable() { return getType()>Token.NULL; }
@Override public boolean isIdentifier() { return getType()==IDENTIFIER; }
@Override public boolean is(int type, String lexeme) { return this.getType()==type && textCount==lexeme.length() && lexeme.equals(getLexeme()); }
@Override public boolean isSingleChar(int type, char ch) { return this.getType()==type && isSingleChar(ch); }
@Override public boolean isRightCurly() { return getType()==SEPARATOR && isSingleChar('}'); }
@Override public boolean isLeftCurly() { return getType()==SEPARATOR && isSingleChar('{'); }
/** * Returns this token as a <code>String</code>, which is useful for * debugging. * * @return A string describing this token. */ @Override public String toString() { return "[Token: " + (getType()==Token.NULL ? "<null token>" : "text: '" + (text==null ? "<null>" : getLexeme() + "'; " + "offset: " + getOffset() + "; type: " + getType() + "; " + "isPaintable: " + isPaintable() + "; nextToken==null: " + (nextToken==null))) + "]"; }
@Override public int getOffsetBeforeX(RSyntaxTextArea textArea, TabExpander e, float startX, float endBeforeX) { FontMetrics fm = textArea.getFontMetricsForTokenType(getType()); int i = textOffset; int stop = i + textCount; float x = startX; while (i<stop) { if (text[i]=='\t') { x = e.nextTabStop(x, 0); } else { x += fm.charWidth(text[i]); } if (x>endBeforeX) { // If not even the first character fits into the space, go // ahead and say the first char does fit so we don't go into // an infinite loop. int intoToken = Math.max(i-textOffset, 1); return getOffset() + intoToken; } i++; } // If we got here, the whole token fit in (endBeforeX-startX) pixels. return getOffset() + textCount - 1; }
TabExpander e, float x0) { float width = x0; FontMetrics fm = textArea.getFontMetricsForTokenType(getType()); if (fm != null) { int w;
@Override public boolean isIdentifier() { return getType()==IDENTIFIER; }
fm = textArea.getFontMetricsForTokenType(token.getType()); if (fm == null) { return rect; // Don't return null as things'll error.
fm = textArea.getFontMetricsForTokenType(token.getType()); char[] text = token.text; int start = token.textOffset;
@Override public boolean isLeftCurly() { return getType()==SEPARATOR && isSingleChar('{'); }
@Override public boolean isRightCurly() { return getType()==SEPARATOR && isSingleChar('}'); }
@Override public boolean is(int type, String lexeme) { return this.getType()==type && textCount==lexeme.length() && lexeme.equals(getLexeme()); }
@Override public boolean isSingleChar(int type, char ch) { return this.getType()==type && isSingleChar(ch); }