void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PsiElement initialElement = descriptor.getPsiElement(); PsiElement element = myQuickFixAdapter.adjustValue(initialElement); FileEditor fileEditor = FileEditorManager.getInstance(project).getSelectedEditor(element.getContainingFile().getVirtualFile()); boolean whitespaceBefore = false; PsiElement prevPrev = null; PsiElement prev = element.getPrevSibling(); if (prev instanceof PsiWhiteSpace) { whitespaceBefore = true; prevPrev = prev.getPrevSibling(); } boolean shouldAddWhitespace = myQuickFixAdapter.fixWhitespaceBefore(initialElement, element); PsiElement parent = element.getParent(); boolean isJsonPropName = parent instanceof JsonProperty && ((JsonProperty)parent).getNameElement() == element; if (isJsonPropName) { WriteAction.run(() -> element.replace(new JsonElementGenerator(project).createStringLiteral(""))); } else { WriteAction.run(() -> element.delete()); } EditorEx editor = EditorUtil.getEditorEx(fileEditor); assert editor != null; // this is a workaround for buggy formatters such as in YAML - it removes the whitespace after ':' when deleting the value shouldAddWhitespace |= prevPrev != null && PsiUtilCore.getElementType(prevPrev.getNextSibling()) != TokenType.WHITE_SPACE; if (shouldAddWhitespace && whitespaceBefore) { WriteAction.run(() -> { int offset = editor.getCaretModel().getOffset(); editor.getDocument().insertString(offset, " "); editor.getCaretModel().moveToOffset(offset + 1); }); } if (isJsonPropName) { editor.getCaretModel().moveToOffset(((JsonProperty)parent).getNameElement().getTextOffset() + 1); } CodeCompletionHandlerBase.createHandler(CompletionType.BASIC).invokeCompletion(project, editor); }