PsiType () { if (getTreeParent() instanceof PsiNewExpression){ if (getTreeParent().getChildRole(this) == ChildRole.ARRAY_INITIALIZER){ return ((PsiNewExpression)getTreeParent()).getType(); } } else if (getTreeParent() instanceof PsiVariable){ return ((PsiVariable)getTreeParent()).getType(); } else if (getTreeParent() instanceof PsiArrayInitializerExpression){ PsiType parentType = ((PsiArrayInitializerExpression)getTreeParent()).getType(); if (!(parentType instanceof PsiArrayType)) return null; final PsiType componentType = ((PsiArrayType)parentType).getComponentType(); return componentType instanceof PsiArrayType ? componentType : null; } else if (getTreeParent() instanceof FieldElement){ return ((PsiField)getParent()).getType(); } return null; }