PsiVariable () { if (myFieldRangeStart == null) return null; PsiClass parentClass = getParentClass(); if (parentClass == null || !parentClass.isValid()) return null; PsiElement element = parentClass.getContainingFile().findElementAt(myFieldRangeStart.getStartOffset()); if (element instanceof PsiWhiteSpace) { element = PsiTreeUtil.skipWhitespacesForward(element); } if (element instanceof PsiField) return (PsiVariable)element; final PsiField field = PsiTreeUtil.getParentOfType(element, PsiField.class, false); if (field != null) return field; element = PsiTreeUtil.skipWhitespacesBackward(element); return PsiTreeUtil.getParentOfType(element, PsiField.class, false); }