public static void doEdit(@NotNull Editor editor) {
    if (!(editor instanceof EditorImpl) || editor.getProject() == null) {
      return;
    }
    FoldRegion region = editor.getFoldingModel().getCollapsedRegionAtOffset(editor.getCaretModel().getOffset());
    if (region == null) return;
    PsiElement psiElement = getEditableElement(region);
    PropertyFoldingEditHandler handler = new PropertyFoldingEditHandler(psiElement);
    if (!handler.isValid()) return;
    VisualPosition regionPosition = editor.offsetToVisualPosition(region.getStartOffset());
    VisualPosition caretPosition = editor.getCaretModel().getVisualPosition();
    int placeholderOffset =
      ((EditorImpl)editor).visualColumnToOffsetInFoldRegion(region, caretPosition.column - regionPosition.column, false);
    int valueOffset = handler.placeholderToValueOffset(placeholderOffset);
    String value = StringUtil.notNullize(handler.getValue());
    Pair<String, Integer> unescaped = unescape(value, valueOffset);

    Ref<Boolean> manuallyResized = new Ref<>();
    Ref<JBPopup> popupRef = new Ref<>();
    EditorTextField textField = new EditorTextField(unescaped.first, editor.getProject(), FileTypes.PLAIN_TEXT) {
      @Override
      protected @NotNull EditorEx createEditor() {
        EditorEx e = super.createEditor();
        e.getCaretModel().moveToOffset(Math.max(0, Math.min(e.getDocument().getTextLength(), unescaped.second)));
        e.setHorizontalScrollbarVisible(true);
        e.getDocument().addDocumentListener(new DocumentListener() {
          @Override
          public void documentChanged(@NotNull DocumentEvent event) {
            if (manuallyResized.isNull()) {
              popupRef.get().pack(true, true);
            }
          }
        });
        return e;
      }

      @Override
      protected boolean shouldHaveBorder() {
        return false;
      }
    };
    textField.setOneLineMode(false);
    textField.setFontInheritedFromLAF(false);

    MyShiftEnterAction shiftEnterAction = new MyShiftEnterAction();

    JPanel panel = new JPanel(new GridBagLayout()) {
      @Override
      public Dimension getPreferredSize() {
        int MIN_WIDTH = JBUI.scale(350);
        int MAX_WIDTH = JBUI.scale(550);
        Dimension size = super.getPreferredSize();
        int width = size.width;
        int height = size.height;
        if (width > MAX_WIDTH) {
          setSize(MAX_WIDTH, height);
          validate();
          size = super.getPreferredSize();
          width = size.width;
          height = size.height;
        }
        return new Dimension(Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, width)), Math.min(MAX_WIDTH, height));
      }
    };
    panel.setBackground(textField.getBackground());
    int topBottomGap = 2;
    int sideGap = 4;
    int betweenGap = 1;
    GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
                                                  new JBInsets(topBottomGap, sideGap, topBottomGap, betweenGap), 0, 0);
    panel.add(textField, c);
    JComponent button = createNewLineButton(textField, editor.getLineHeight(), shiftEnterAction);
    c.gridx = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.insets = new JBInsets(topBottomGap, betweenGap, topBottomGap, sideGap);
    panel.add(button, c);

    JBPopup popup = JBPopupFactory.getInstance()
      .createComponentPopupBuilder(panel, textField)
      .setRequestFocus(true)
      .setResizable(true)
      .setLocateByContent(true)
      .setCancelOnWindowDeactivation(false)
      .createPopup();
    popupRef.set(popup);
    ((AbstractPopup)popup).addResizeListener(() -> manuallyResized.set(Boolean.TRUE), popup);

    new MyEnterAction(textField, region, popup, handler)
      .registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)), textField);
    shiftEnterAction
      .registerCustomShortcutSet(new CustomShortcutSet(SHIFT_ENTER), textField);

    Point location = editor.visualPositionToXY(new VisualPosition(regionPosition.line, regionPosition.column + 1));
    location.translate(-JBUI.scale(sideGap), -JBUI.scale(topBottomGap));
    popup.show(new RelativePoint(editor.getContentComponent(), location));
    LightweightHint hint = showTooltip(editor, handler.getFile(), handler.getKey());
    if (hint != null) {
      popup.addListener(new JBPopupListener() {
        @Override
        public void onClosed(@NotNull LightweightWindowEvent event) {
          hint.hide();
        }
      });
    }
  }
public static void doEdit(@NotNull Editor editor)