void (@NotNull PsiMethodCallExpression call) { if (!HighlightingFeature.PATTERN_GUARDS_AND_RECORD_PATTERNS.isAvailable(holder.getFile())) return; PsiTypeCastExpression qualifier = getQualifierReferenceExpression(call); if(qualifier==null) return; PsiInstanceOfExpression candidate = InstanceOfUtils.findPatternCandidate(qualifier); if (candidate == null) return; PsiPrimaryPattern pattern = candidate.getPattern(); if (pattern instanceof PsiDeconstructionPattern deconstruction) { PsiPatternVariable existingPatternVariable = findExistingPatternVariable(qualifier, deconstruction, call); if (existingPatternVariable == null) return; if (!isFinalOrEffectivelyFinal(existingPatternVariable)) return; String patternName = existingPatternVariable.getName(); if (PsiUtil.skipParenthesizedExprUp(call.getParent()) instanceof PsiLocalVariable localVariable && canReplaceLocalVariableWithPatternVariable(localVariable, existingPatternVariable)) { String name = localVariable.getName(); LocalQuickFix fix = new ExistingPatternVariableCanBeUsedFix(name, existingPatternVariable); holder.registerProblem(call, InspectionGadgetsBundle.message("inspection.pattern.variable.can.be.used.existing.message", patternName, name), fix); } else { String callText = call.getText(); LocalQuickFix fix = new ExistingPatternVariableCanBeUsedFix(callText, existingPatternVariable); holder.registerProblem(call, InspectionGadgetsBundle.message("inspection.pattern.variable.can.be.used.existing.message", patternName, callText), fix); } } }