FormattingService (@NotNull PsiFile file) { FormattingService importsOptimizer = ContainerUtil.find( FormattingService.EP_NAME.getExtensionList(), s -> s.getFeatures().contains(FormattingService.Feature.OPTIMIZE_IMPORTS) && s.canFormat(file) ); LOG.assertTrue(importsOptimizer != null, "At least 1 formatting service which can optimize imports in PsiFile " + file.getName() + " should be registered."); return importsOptimizer; }