GlobalSearchScope (GrTypeDefinition typeDefinition) { GlobalSearchScope defaultScope = typeDefinition.getResolveScope(); PsiFile file = typeDefinition.getContainingFile(); if (file instanceof GroovyFile && ((GroovyFile)file).isScript()) { Module module = ModuleUtilCore.findModuleForPsiElement(file); if (module != null) { return defaultScope.intersectWith(module.getModuleScope()); } } return defaultScope; }