void (@NotNull ImperativeCommand.Environment env) { Project project = getProject(); PsiDocumentManager.getInstance(getProject()).commitDocument(getDocument()); int offset = env.generateValue(Generator.integers(0, getDocument().getTextLength()).noShrink(), null); Editor editor = FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, getVirtualFile(), offset), true); assert editor != null; PsiElement element = getFile().findElementAt(offset); if (element == null) return; List<PsiExpression> expressions = PsiTreeUtil.collectParents(element, PsiExpression.class, true, e -> false); expressions = ContainerUtil.filter(expressions, ex -> { TextRange exRange = ex.getTextRange(); return CodeInsightUtil.findExpressionInRange(getFile(), exRange.getStartOffset(), exRange.getEndOffset()) == ex; }); if (expressions.isEmpty()) return; PsiExpression expression = env.generateValue(Generator.sampledFrom(expressions), null); TextRange range = expression.getTextRange(); editor.getSelectionModel().setSelection(range.getStartOffset(), range.getEndOffset()); if (env.generateValue(Generator.booleans(), null)) { introduceVariableInline(env, project, editor, expression); } else { Disposable disposable = Disposer.newDisposable(); try { UiInterceptors.register(new RandomActivityInterceptor(env, disposable)); introduceVariableNoInline(env, project, editor, expression); } finally { Disposer.dispose(disposable); } } }