Package ro.redeul.google.go.inspection.fix

Examples of ro.redeul.google.go.inspection.fix.CastTypeFix


                    GoPsiType type = builtinTypes[index];
                    if (!checkParametersExp(type, goExpr)){
                        result.addProblem(
                                goExpr,
                                GoBundle.message("warning.functioncall.type.mismatch", type.getText()),
                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new CastTypeFix(goExpr, GoTypes.fromPsi(type)));
                        return;
                    }
                }
            }
            return;
        }

        for (GoFunctionParameter functionParameter : goFunctionDeclaration.getParameters()) {
            if (index >= goExprs.length)
                return;
            GoPsiType type = functionParameter.getType();
            String typeName = type != null ? type.getText() : "";
            if (functionParameter.isVariadic()) {
                if (call.isCallWithVariadicParameter()){
                    GoExpr goExpr = goExprs[index];
                    GoType[] types = goExpr.getType();
                    if (types.length!=1){
                        result.addProblem(
                                goExpr,
                                GoBundle.message("warning.functioncall.type.mismatch", "[]"+typeName),
                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
                        return;
                    }
                    GoType exprType = types[0].underlyingType();
                    if (!(exprType instanceof GoTypeSlice)){
                        result.addProblem(
                                goExpr,
                                GoBundle.message("warning.functioncall.type.mismatch", "[]"+typeName),
                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
                        return;
                    }

                    //TODO test with assignable
                    if (!((GoTypeSlice) exprType).getElementType().isIdentical(GoTypes.fromPsi(type)) ) {
                        result.addProblem(
                                goExpr,
                                GoBundle.message("warning.functioncall.type.mismatch", "[]"+typeName),
                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
                        return;
                    }
                }else {
                    for (; index < goExprs.length; index++) {
                        GoExpr goExpr = goExprs[index];
                        if (!checkParametersExp(functionParameter.getType(), goExpr)) {
                            result.addProblem(
                                    goExpr,
                                    GoBundle.message("warning.functioncall.type.mismatch", typeName),
                                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new CastTypeFix(goExpr, GoTypes.fromPsi(type)));
                            return;
                        }
                    }
                }
            } else {
                GoLiteralIdentifier[] identifiers = functionParameter.getIdentifiers();
                if (identifiers.length < 2) {
                    GoExpr goExpr = goExprs[index];
                    if (!checkParametersExp(functionParameter.getType(), goExpr)) {
                        result.addProblem(
                                goExpr,
                                GoBundle.message("warning.functioncall.type.mismatch", typeName),
                                ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new CastTypeFix(goExpr, GoTypes.fromPsi(type)));
                        return;
                    }
                    index++;
                } else {
                    for (GoLiteralIdentifier goLiteralIdentifier : identifiers) {
                        GoExpr goExpr = goExprs[index];
                        if (!checkParametersExp(functionParameter.getType(), goExpr)) {
                            result.addProblem(
                                    goExpr,
                                    GoBundle.message("warning.functioncall.type.mismatch", typeName),
                                    ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new CastTypeFix(goExpr, GoTypes.fromPsi(type)));
                            return;
                        }
                        index++;
                    }
                }
View Full Code Here


                            indexExpr,
                            GoBundle.message("warn.index.map.invalid.type",
                                    indexExpr.getText(),
                                    GoTypes.getRepresentation(indexType, goFile),
                                    GoTypes.getRepresentation(keyType, goFile)),
                            new CastTypeFix(indexExpr, keyType));
                }
            }
        }, result);
    }
View Full Code Here

TOP

Related Classes of ro.redeul.google.go.inspection.fix.CastTypeFix

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.