PsiField (Project project, Document document, int offset) { PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document); if (file == null) return null; offset = CharArrayUtil.shiftForward(document.getCharsSequence(), offset, " \t"); PsiElement element = file.findElementAt(offset); if (element == null) return null; PsiField field = PsiTreeUtil.getParentOfType(element, PsiField.class, false); int line = document.getLineNumber(offset); if (field == null) { final PsiField[] fld = {null}; XDebuggerUtil.getInstance().iterateLine(project, document, line, element1 -> { PsiField field1 = PsiTreeUtil.getParentOfType(element1, PsiField.class, false); if (field1 != null) { fld[0] = field1; return false; } return true; }); field = fld[0]; } return field; }