String (@NotNull PsiMethodCallExpression call) { PsiElement parent = PsiTreeUtil.getParentOfType(call, PsiVariable.class, PsiAssignmentExpression.class); if (parent == null) return null; if (parent instanceof PsiVariable) { PsiExpression initializer = PsiUtil.skipParenthesizedExprDown(((PsiVariable)parent).getInitializer()); return initializer == call ? ((PsiVariable)parent).getName() : null; } PsiAssignmentExpression assignment = (PsiAssignmentExpression)parent; PsiExpression rhs = PsiUtil.skipParenthesizedExprDown(assignment.getRExpression()); if (rhs != call) return null; PsiExpression lhs = PsiUtil.skipParenthesizedExprDown(assignment.getLExpression()); PsiReferenceExpression ref = ObjectUtils.tryCast(lhs, PsiReferenceExpression.class); if (ref == null) return null; PsiExpression qualifier = ref.getQualifierExpression(); if (qualifier != null && SideEffectChecker.mayHaveSideEffects(qualifier)) return null; PsiVariable variable = ObjectUtils.tryCast(ref.resolve(), PsiVariable.class); if (variable == null || variable instanceof PsiField && variable.hasModifierProperty(PsiModifier.VOLATILE)) return null; return ref.getText(); }