PsiType (GrExpression diamondNew) { PsiElement skipped = PsiUtil.skipParentheses(diamondNew, true); assert skipped != null; PsiElement pParent = skipped.getParent(); if (pParent instanceof GrAssignmentExpression && PsiTreeUtil.isAncestor(((GrAssignmentExpression)pParent).getRValue(), diamondNew, false)) { GrExpression lValue = ((GrAssignmentExpression)pParent).getLValue(); if (PsiUtil.mightBeLValue(lValue)) { return lValue.getNominalType(); } } else if (pParent instanceof GrVariable && ((GrVariable)pParent).getInitializerGroovy() == diamondNew) { return ((GrVariable)pParent).getDeclaredType(); } else if (pParent instanceof GrListOrMap) { PsiElement ppParent = PsiUtil.skipParentheses(pParent.getParent(), true); if (ppParent instanceof GrTupleAssignmentExpression && PsiTreeUtil.isAncestor(((GrTupleAssignmentExpression)ppParent).getRValue(), pParent, false)) { GrTuple lValue = ((GrTupleAssignmentExpression)ppParent).getLValue(); GrExpression[] initializers = ((GrListOrMap)pParent).getInitializers(); int index = ArrayUtil.find(initializers, diamondNew); GrExpression[] expressions = lValue.getExpressions(); if (index < expressions.length) { return expressions[index].getNominalType(); } } } return null; }