void () { CodeStyleSettings temp = CodeStyle.createTestSettings(); NamedScopeDescriptor descriptor = new NamedScopeDescriptor("Test"); descriptor.setPattern("file:*.java"); temp.getExcludedFiles().addDescriptor(descriptor); CodeStyle.doWithTemporarySettings(getProject(), temp, () -> doTest(new ReformatCodeRunOptions(WHOLE_FILE).setOptimizeImports(true))); }