Module () { final GroovyScriptRunner scriptRunner = getScriptRunner(); Module[] modules = ModuleManager.getInstance(getProject()).getModules(); if (scriptRunner == null) { return modules[0]; } for (Module module : modules) { if (scriptRunner.isValidModule(module)) { return module; } } return null; }