PsiClassType (@NotNull GroovyFile scriptFile) { if (!scriptFile.isScript()) return null; final VirtualFile virtualFile = scriptFile.getOriginalFile().getVirtualFile(); if (virtualFile == null) return null; final String filePath = virtualFile.getPath(); List<Trinity<String, String, GroovyDslScript>> supers = new ArrayList<>(); final Project project = scriptFile.getProject(); for (GroovyDslScript script : getDslScripts(project)) { final MultiMap staticInfo = script.getStaticInfo(); //noinspection unchecked final Collection infos = staticInfo.get("scriptSuperClass"); for (Object info : infos) { if (info instanceof @NonNls Map map) { final Object _pattern = map.get("pattern"); final Object _superClass = map.get("superClass"); if (_pattern instanceof String pattern && _superClass instanceof String superClass) { try { if (Pattern.matches(".*" + pattern, filePath)) { supers.add(Trinity.create(superClass, pattern, script)); } } catch (RuntimeException e) { script.handleDslError(e); } } } } } if (!supers.isEmpty()) { final String className = supers.get(0).first; final GroovyDslScript script = supers.get(0).third; try { return TypesUtil.createTypeByFQClassName(className, scriptFile); } catch (ProcessCanceledException e) { throw e; } catch (RuntimeException e) { script.handleDslError(e); return null; } } /*else if (supers.size() > 1) { StringBuilder buffer = new StringBuilder("Several script super class patterns match file ").append(filePath).append(". <p> "); for (Trinity<String, String, GroovyDslScript> aSuper : supers) { buffer.append(aSuper.third.getFilePath()).append(" ").append(aSuper.second).append('\n'); } NOTIFICATION_GROUP.createNotification("DSL script execution error", buffer.toString(), NotificationType.ERROR, null).notify(project); return null; }*/ else { return null; } }