GrField (@NotNull PsiClass targetClass, @NotNull PsiField field, @Nullable PsiElement place) { if (targetClass instanceof GroovyScriptClass) { PsiElement added = targetClass.getContainingFile().add(field.getParent()); return (GrField)((GrVariableDeclaration)added).getVariables()[0]; } else { return (GrField)targetClass.add(field); } }