int (char[] text, int offset, int endOffset) { boolean isId = Character.isJavaIdentifierPart(text[offset]); for (int i = offset + 1; i < endOffset; i++) { if (isId != Character.isJavaIdentifierPart(text[i])) { return i; } } return endOffset; }