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)) || text.charAt(offset) == ':')) { prefixBuilder.insert(0, text.charAt(offset)); if (text.charAt(offset) == ':') { break; } offset--; } return prefixBuilder.toString(); }