void (final int offset, final Document document) { final CharSequence sequence = document.getCharsSequence(); int i = offset; while (i < sequence.length() && Character.isJavaIdentifierPart(sequence.charAt(i))) i++; document.deleteString(offset, i); }