GrTypeDefinition (Project project, GrNamedArgument[] namedArguments, String packageName, String className) { StringBuilder classText = new StringBuilder(); if (!packageName.isEmpty()) { classText.append("package ").append(packageName).append('\n'); } classText.append("class ").append(className).append(" {\n"); for (GrNamedArgument argument : namedArguments) { final String fieldName = argument.getLabelName(); final GrExpression expression = argument.getExpression(); LOG.assertTrue(expression != null); final PsiType type = TypesUtil.unboxPrimitiveTypeWrapper(expression.getType()); if (type != null) { classText.append(type.getCanonicalText()); } else { classText.append(GrModifier.DEF); } classText.append(' ').append(fieldName).append('\n'); } classText.append('}'); return GroovyPsiElementFactory.getInstance(project).createTypeDefinition(classText.toString()); }