PsiType (VariableInfo[] outputInfos, GrStatement[] statements, ArrayList<GrStatement> returnStatements, boolean hasReturnValue, StringPartInfo stringPartInfo) { if (stringPartInfo != null) { return stringPartInfo.getLiteral().getType(); } PsiType outputType = PsiTypes.voidType(); if (outputInfos.length > 0) { if (outputInfos.length == 1) { outputType = outputInfos[0].getType(); } else { outputType = JavaPsiFacade.getElementFactory(myProject).createTypeFromText(CommonClassNames.JAVA_UTIL_LIST, getContext()); } } else if (ExtractUtil.isSingleExpression(statements)) { outputType = ((GrExpression)statements[0]).getType(); } else if (hasReturnValue) { assert !returnStatements.isEmpty(); List<PsiType> types = new ArrayList<>(returnStatements.size()); for (GrStatement statement : returnStatements) { if (statement instanceof GrReturnStatement) { GrExpression returnValue = ((GrReturnStatement)statement).getReturnValue(); if (returnValue != null) { types.add(returnValue.getType()); } } else if (statement instanceof GrExpression) { types.add(((GrExpression)statement).getType()); } } outputType = TypesUtil.getLeastUpperBoundNullable(types, getContext().getManager()); } return outputType; }