@Override
  public JavaCodeFragment createCodeFragment(TextWithImports item, PsiElement context, final Project project) {
    final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(project);
    final String text = item.getText();

    JavaCodeFragment fragment = null;
    if (CodeFragmentKind.EXPRESSION == item.getKind()) {
      try {
        String expressionText = StringUtil.trimTrailing(text, ';');
        if (!expressionText.isEmpty()) {
          JavaPsiFacade.getElementFactory(project).createExpressionFromText(expressionText, context); // to test that expression is ok
        }
        fragment = factory.createExpressionCodeFragment(expressionText, context, null, true);
      }
      catch (IncorrectOperationException ignored) {
      }
    }

    if (fragment == null) {
      fragment = factory.createCodeBlockCodeFragment(text, context, true);
    }

    if (!item.getImports().isEmpty()) {
      fragment.addImportsFromString(item.getImports());
    }
    fragment.setVisibilityChecker(JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE);
    fragment.putUserData(KEY, "DebuggerComboBoxEditor.IS_DEBUGGER_EDITOR");
    fragment.putCopyableUserData(JavaCompletionUtil.DYNAMIC_TYPE_EVALUATOR, (expression, parameters) -> {
      if (!RuntimeTypeEvaluator.isSubtypeable(expression)) {
        return null;
      }

      if (parameters.getInvocationCount() <= 1 && JavaCompletionUtil.mayHaveSideEffects(expression)) {
        CompletionService.getCompletionService().setAdvertisementText(JavaDebuggerBundle.message("invoke.completion.once.more"));
        return null;
      }

      final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(project).getContext();
      DebuggerSession debuggerSession = debuggerContext.getDebuggerSession();
      if (debuggerSession != null && debuggerContext.getSuspendContext() != null) {
        final Semaphore semaphore = new Semaphore();
        semaphore.down();
        final AtomicReference<PsiType> nameRef = new AtomicReference<>();
        final RuntimeTypeEvaluator worker =
          new RuntimeTypeEvaluator(null, expression, debuggerContext, ProgressManager.getInstance().getProgressIndicator()) {
            @Override
            protected void typeCalculationFinished(@Nullable PsiType type) {
              nameRef.set(type);
              semaphore.up();
            }
          };
        debuggerSession.getProcess().getManagerThread().invoke(worker);
        for (int i = 0; i < 50; i++) {
          ProgressManager.checkCanceled();
          if (semaphore.waitFor(20)) break;
        }
        return nameRef.get();
      }
      return null;
    });

    return fragment;
  }
@Override
  public JavaCodeFragment createCodeFragment(TextWithImports item, PsiElement context, final Project project)