String (int offset, PsiFile file) { if (offset > 0) { offset--; } final String text = file.getText(); StringBuilder prefixBuilder = new StringBuilder(); while(offset > 0 && Character.isLetterOrDigit(text.charAt(offset))) { prefixBuilder.insert(0, text.charAt(offset)); offset--; } return prefixBuilder.toString(); }