int (PsiStatement @NotNull [] statements, @Nullable Ref<? super PsiField> outAnchor, @Nullable AtomicBoolean outBefore, @NotNull PsiClass targetClass, @NotNull PsiParameter myParameter) { int i = 0; for (; i < statements.length; i++) { PsiStatement psiStatement = statements[i]; if (psiStatement instanceof PsiExpressionStatement expressionStatement) { PsiExpression expression = expressionStatement.getExpression(); if (expression instanceof PsiMethodCallExpression methodCallExpression) { String text = methodCallExpression.getMethodExpression().getText(); if (text.equals("super") || text.equals("this")) { continue; } } else if (expression instanceof PsiAssignmentExpression assignmentExpression) { PsiExpression lExpression = assignmentExpression.getLExpression(); if (!(lExpression instanceof PsiReferenceExpression)) break; PsiElement lElement = ((PsiReferenceExpression)lExpression).resolve(); if (!(lElement instanceof PsiField) || ((PsiField)lElement).getContainingClass() != targetClass) break; Set<PsiParameter> parameters = new HashSet<>(); SyntaxTraverser.psiTraverser().withRoot(assignmentExpression.getRExpression()) .filter(PsiReferenceExpression.class) .forEach(expr -> { PsiElement resolve = expr.resolve(); if (resolve instanceof PsiParameter && ((PsiParameter)resolve).getDeclarationScope() == myParameter.getDeclarationScope()) { parameters.add((PsiParameter)resolve); } }); if (parameters.size() != 1) break; PsiElement rElement = parameters.iterator().next(); if (myParameter.getTextRange().getStartOffset() < rElement.getTextRange().getStartOffset()) { if (outAnchor != null) { outAnchor.set((PsiField)lElement); } if (outBefore != null) { outBefore.set(true); } break; } if (outAnchor != null) { outAnchor.set((PsiField)lElement); } if (outBefore != null) { outBefore.set(false); } continue; } } break; } return i; }