void (Class<? extends YAMLScalar>... notPreserveEols) { final PsiFile file = myFixture.configureByFile("sampleDocument.yml"); Collection<YAMLScalar> scalars = PsiTreeUtil.collectElementsOfType(file, YAMLScalar.class); assertEquals(5, scalars.size()); final String text; try { text = FileUtil.loadFile(new File(getTestDataPath() + getTestName(true) + ".txt"), true); } catch (IOException e) { fail(e.toString()); return; } for (YAMLScalar scalar : scalars) { boolean matchTrimmed = ContainerUtil.exists(notPreserveEols, aClass -> aClass == scalar.getClass()); final ElementManipulator<YAMLScalar> manipulator = ElementManipulators.getManipulator(scalar); assertNotNull(manipulator); WriteCommandAction.runWriteCommandAction(getProject(), ()-> { final YAMLScalar newElement = manipulator.handleContentChange(scalar, text); assertEquals(newElement.getClass() + ";" + scalar.getClass(), newElement.getClass(), scalar.getClass()); StringBuilder stringBuilder = new StringBuilder(); assertTrue(newElement.createLiteralTextEscaper().decode(ElementManipulators.getValueTextRange(newElement), stringBuilder)); assertEquals("Failed at " + scalar.getClass() + " (became " + newElement.getClass() + "): ", matchTrimmed ? StringUtil.trim(text) : text, stringBuilder.toString()); }); } }