String (Document document, int offset) { CharSequence chars = document.getCharsSequence(); int start = offset; while (true) { ProgressManager.checkCanceled(); if (start == 0) break; char c = chars.charAt(start - 1); if (!(Character.isJavaIdentifierPart(c))) break; start--; } return chars.subSequence(start, offset).toString(); }