void (PsiParameterListOwner owner, PsiParameter[] parameters, PsiElement body) { DfaValueFactory factory = new DfaValueFactory(owner.getProject()); ControlFlow flow = ControlFlowAnalyzer.buildFlow(body, factory, true); if (flow == null) return; DfaMemoryState state = new JvmDfaMemoryStateImpl(factory); DfaVariableValue var1 = PlainDescriptor.createVariableValue(factory, parameters[0]); DfaVariableValue var2; if (parameters.length == 2) { // compare() var2 = PlainDescriptor.createVariableValue(factory, parameters[1]); } else { // compareTo() assert owner instanceof PsiMethod; var2 = ThisDescriptor.createThisValue(factory, ((PsiMethod)owner).getContainingClass()); } state.applyCondition(var1.eq(var2)); var interceptor = new ComparatorListener(owner); if (new StandardDataFlowInterpreter(flow, interceptor).interpret(state) != RunnerResult.OK) return; if (interceptor.myRange.contains(0) || interceptor.myContexts.isEmpty()) return; PsiElement context = null; if (interceptor.myContexts.size() == 1) { context = interceptor.myContexts.iterator().next(); } else { PsiElement commonParent = PsiTreeUtil.findCommonParent(interceptor.myContexts.toArray(PsiElement.EMPTY_ARRAY)); if (commonParent instanceof PsiExpression) { context = commonParent; } else { PsiParameterListOwner parent = PsiTreeUtil.getParentOfType(body, PsiMethod.class, PsiLambdaExpression.class); if (parent instanceof PsiMethod) { context = ((PsiMethod)parent).getNameIdentifier(); } else if (parent instanceof PsiLambdaExpression) { context = parent.getParameterList(); } } } registerError(context != null ? context : body, InspectionGadgetsBundle.message("suspicious.comparator.compare.descriptor.non.reflexive")); }