int (PsiBuilder builder, String tokenText, boolean caseSensitive) { CharSequence sequence = builder.getOriginalText(); int offset = builder.getCurrentOffset(); int endOffset = offset + tokenText.length(); CharSequence subSequence = sequence.subSequence(offset, Math.min(endOffset, sequence.length())); if (!Comparing.equal(subSequence, tokenText, caseSensitive)) return 0; int count = 0; while (true) { int nextOffset = builder.rawTokenTypeStart(++count); if (nextOffset > endOffset) { return -count; } else if (nextOffset == endOffset) { break; } } return count; }