void () { @SuppressWarnings("ALL") @Language("JAVA") String text = """ class Foo { void method() {} Foo foo = new Foo() { void method() { System.out.println(); } }; }"""; configure(text); assertTopLevelFoldRegionsState("[FoldRegion +(44:82), placeholder='method() → { ', FoldRegion +(103:113), placeholder=' }']"); // emulate rename refactoring ('method' to 'otherMethod') Document document = myFixture.getEditor().getDocument(); WriteCommandAction.runWriteCommandAction(myFixture.getProject(), () -> { int pos; while ((pos = document.getText().indexOf("method")) >= 0) { document.replaceString(pos, pos + "method".length(), "otherMethod"); } }); myFixture.doHighlighting(); assertTopLevelFoldRegionsState("[FoldRegion +(49:92), placeholder='otherMethod() → { ', FoldRegion +(113:123), placeholder=' }']"); }