ModCommand (@NotNull ActionContext context, @NotNull PsiVariable var, PsiReferenceExpression refExpr, @NotNull InlineMode mode) { PsiElement block = PsiUtil.getVariableCodeBlock(var, null); List<PsiReferenceExpression> allRefs = mode == InlineMode.INLINE_ONE || block == null ? List.of(refExpr) : VariableAccessUtils.getVariableReferences(var, block); if (allRefs.isEmpty()) { return ModCommand.error(RefactoringBundle.message("variable.is.never.used", var.getName())); } if (var instanceof PsiLocalVariable local) { return inlineLocal(context, local, refExpr, allRefs, mode); } return inlinePattern(context, (PsiPatternVariable)var, refExpr, allRefs, mode); }