void () { @SuppressWarnings("ALL") @Language("JAVA") String text = """ class Test { void test() { new Runnable() { static final long serialVersionUID = 42L; public void run() { System.out.println(); } }; } } """; configure(text); FoldingModelImpl foldingModel = (FoldingModelImpl)myFixture.getEditor().getFoldingModel(); FoldRegion closureStartFold = foldingModel.getCollapsedRegionAtOffset(text.indexOf("Runnable")); assertNotNull(closureStartFold); assertFalse(closureStartFold.isExpanded()); assertTrue(text.substring(closureStartFold.getEndOffset()).startsWith("System"));//one line closure myFixture.getEditor().getCaretModel().moveToOffset(myFixture.getEditor().getDocument().getText().indexOf("();") + 1); myFixture.type("2"); myFixture.doHighlighting(); closureStartFold = foldingModel.getCollapsedRegionAtOffset(text.indexOf("Runnable")); assertNotNull(closureStartFold); }