PsiClass (Project project, VirtualFile stubFile) { final String[] components = StringUtil.trimEnd(stubFile.getPath(), ".java").split("[\\\\/]"); final int stubs = Arrays.asList(components).indexOf(GROOVY_STUBS); if (stubs < 0 || stubs >= components.length - 3) { return null; } final String moduleName = components[stubs + 1]; final Module module = ModuleManager.getInstance(project).findModuleByName(moduleName); if (module == null) { return null; } final String fqn = StringUtil.join(Arrays.asList(components).subList(stubs + 3, components.length), "."); return JavaPsiFacade.getInstance(project).findClass(fqn, GlobalSearchScope.moduleScope(module)); }