Collection<Module> () { Module[] modules = ModuleManager.getInstance(getProject()).getModules(); final GroovyScriptRunner scriptRunner = getScriptRunner(); if (scriptRunner == null) { return Arrays.asList(modules); } ArrayList<Module> res = new ArrayList<>(); for (Module module : modules) { if (scriptRunner.isValidModule(module)) { res.add(module); } } return res; }