private static void checkNewCall(GoBuiltinCallExpression expression, InspectionResult result) { GoExpr[] arguments = expression.getArguments(); GoPsiType type = expression.getTypeArgument(); if (type == null) { if (arguments.length == 0) { result.addProblem(expression, GoBundle.message("error.missing.argument", "type", "new")); } else { result.addProblem( expression, GoBundle.message("error.expression.is.not.a.type", arguments[0].getText())); } return; } if (arguments.length != 0) { result.addProblem(expression, GoBundle.message("error.too.many.arguments.in.call", "new")); } }
private static void checkMakeCall(GoBuiltinCallExpression expression, InspectionResult result) { GoExpr[] arguments = expression.getArguments(); GoPsiType type = expression.getTypeArgument(); if (type == null) { result.addProblem(expression, GoBundle.message("error.incorrect.make.type")); return; } GoPsiType finalType = resolveToFinalType(type); if (finalType instanceof GoPsiTypeSlice) { checkMakeSliceCall(expression, arguments, result); } else if (finalType instanceof GoPsiTypeChannel) { checkMakeChannelCall(arguments, result); } else if (finalType instanceof GoPsiTypeMap) { checkMakeMapCall(arguments, result); } else { result.addProblem(expression, GoBundle.message("error.cannot.make.type", type.getText())); } }
private static void checkMakeSliceCall( GoBuiltinCallExpression expression, GoExpr[] arguments, InspectionResult result) { if (arguments.length > 2) { result.addProblem( arguments[2], arguments[arguments.length - 1], GoBundle.message("error.too.many.arguments.in.call", "make")); return; } else if (arguments.length == 0) { String method = "make(" + expression.getTypeArgument().getText() + ")"; result.addProblem(expression, GoBundle.message("error.missing.argument", "len", method)); return; } // TODO: check len GoExpr len = arguments[0]; if (arguments.length != 2) { return; } // TODO: check capacity GoExpr capacity = arguments[1]; }