IntentionAction (final GrNewExpression expression) { return new CreateClassActionBase(GrCreateClassKind.CLASS, expression.getReferenceElement()) { @Override protected void processIntention(@NotNull PsiElement element, @NotNull Project project, Editor editor) throws IncorrectOperationException { final PsiFile file = element.getContainingFile(); if (!(file instanceof GroovyFileBase groovyFile)) return; final PsiManager manager = myRefElement.getManager(); final String qualifier = ReadAction.compute(() -> groovyFile instanceof GroovyFile ? groovyFile.getPackageName() : ""); final String name = ReadAction.compute(() -> myRefElement.getReferenceName()); assert name != null; final Module module = ReadAction.compute(() -> ModuleUtilCore.findModuleForPsiElement(file)); PsiDirectory targetDirectory = getTargetDirectory(project, qualifier, name, module, getText()); if (targetDirectory == null) return; final GrTypeDefinition targetClass = createClassByType(targetDirectory, name, manager, myRefElement, GroovyTemplates.GROOVY_CLASS, true); if (targetClass == null) return; PsiType[] argTypes = getArgTypes(myRefElement); if (argTypes != null && argTypes.length > 0) { generateConstructor(myRefElement, name, argTypes, targetClass, project); bindRef(targetClass, myRefElement); } else { bindRef(targetClass, myRefElement); IntentionUtils.positionCursor(project, targetClass.getContainingFile(), targetClass); } } }; }