void (@NotNull ReplacementInfo info, @NotNull ReplaceOptions options) { final PsiElement elementToReplace = StructuralSearchUtil.getPresentableElement(info.getMatch(0)); assert elementToReplace != null; final String replacementToMake = info.getReplacement(); final PsiElement elementParent = elementToReplace.getParent(); final boolean listContext = elementParent instanceof XmlTag; if (listContext) { doReplaceInContext(info, elementToReplace, replacementToMake, elementParent); } else { final LanguageFileType fileType = myReplaceOptions.getMatchOptions().getFileType(); assert fileType != null; final PsiElement[] replacements = MatcherImplUtil.createTreeFromText(replacementToMake, PatternTreeContext.Block, fileType, myProject); if (replacements.length > 0) { final PsiElement replacement = ReplacerUtil.copySpacesAndCommentsBefore(elementToReplace, replacements, replacementToMake, elementParent); // preserve comments Replacer.handleComments(elementToReplace, replacement, info); elementToReplace.replace(replacement); } else { elementToReplace.delete(); } } }