TokenInfo (PsiToken t1, PsiToken t2) { if (t1.kind != TokenKind.text && t2.kind != TokenKind.text) { return t1.kind.compareTo(t2.kind) > 0 ? t1 : t2; } if (t1.kind == TokenKind.text && t2.kind == TokenKind.text) { if (t1.length() == 0) return t2; if (t2.length() == 0) return t1; if (t1.psi == t2.psi && t1.rangeInPsi.getStartOffset() + t1.length() == t2.rangeInPsi.getStartOffset()) { return new PsiToken(t1.text + t2.text, t1.psi, t1.rangeInPsi.union(t2.rangeInPsi), TokenKind.text); } } return null; }