PsiType (PsiElement place) { if (!GroovyConfigUtils.getInstance().isVersionAtLeast(place, GroovyConfigUtils.GROOVY1_8)) { return null; } final PsiElement parent = place.getParent().getParent(); if (!(parent instanceof GrNewExpression)) return null; final PsiElement pparent = parent.getParent(); if (pparent instanceof GrVariable) { return ((GrVariable)pparent).getDeclaredType(); } else if (pparent instanceof GrAssignmentExpression) { GrAssignmentExpression assignment = (GrAssignmentExpression)pparent; GrExpression lvalue = assignment.getLValue(); GrExpression rvalue = assignment.getRValue(); if (parent == rvalue && !assignment.isOperatorAssignment()) { return lvalue.getNominalType(); } } else if (pparent instanceof GrApplicationStatement) { PsiElement ppparent = pparent.getParent(); if (ppparent instanceof GrAssignmentExpression assignment) { GrExpression lvalue = assignment.getLValue(); GrExpression rvalue = assignment.getRValue(); if (pparent == rvalue && !assignment.isOperatorAssignment()) { return lvalue.getNominalType(); } } } return null; }