Examples of GoPsiType


Examples of ro.redeul.google.go.lang.psi.types.GoPsiType

                        }
                    }

                    @Override
                    public void visitFunctionParameter(GoFunctionParameter parameter) {
                        GoPsiType typeForBody = parameter.getTypeForBody();
                        if (typeForBody != null)
                            setData(new GoType[]{GoTypes.fromPsi(typeForBody)});
                    }

                    @Override
                    public void visitMethodReceiver(GoMethodReceiver receiver) {
                        GoPsiType type = receiver.getType();
                        if (type != null)
                            setData(new GoType[]{GoTypes.fromPsi(type)});
                    }


                    @Override
                    public void visitSwitchTypeGuard(GoSwitchTypeGuard typeGuard) {
                        GoSwitchTypeStatement switchStatement = (GoSwitchTypeStatement) typeGuard.getParent();

                        TextRange litRange = identifier.getTextRange();
                        for (GoSwitchTypeClause clause : switchStatement.getClauses()) {
                            TextRange clauseTextRange = clause.getTextRange();
                            if (clauseTextRange.contains(litRange)) {
                                setData(GoTypes.fromPsiType(clause.getTypes()));
                            }
                        }
                    }

                    @Override
                    public void visitForWithRangeAndVars(GoForWithRangeAndVarsStatement statement) {
                        if (resolvedIdent != null) {
                            if (statement.getKey() == resolvedIdent) {
                                setData(statement.getKeyType());
                            } else if (statement.getValue() == resolvedIdent) {
                                setData(statement.getValueType());
                            }
                        }
                    }
                });

            case Composite:
                GoLiteralComposite composite = (GoLiteralComposite) literal;
                GoPsiType literalType = composite.getLiteralType();
                if (literalType == null) {
                    return GoType.EMPTY_ARRAY;
                }
                return new GoType[]{
                        GoTypes.fromPsi(literalType)
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.types.GoPsiType

            if ( !(underlyingType instanceof GoTypeStruct) )
                continue;

            GoTypeStruct typeStruct = (GoTypeStruct) underlyingType;
            for (GoTypeStructAnonymousField field : typeStruct.getPsiType().getAnonymousFields()) {
                GoPsiType psiType = field.getType();
                if ( psiType == null)
                    continue;
                if ( psiType instanceof GoPsiTypePointer) {
                    psiType = ((GoPsiTypePointer) psiType).getTargetType();
                }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.types.GoPsiType

        return (GoPsiElementBase) child;
    }

    @Override
    public String getFieldName() {
        GoPsiType type = getType();
        if ( type instanceof GoPsiTypeName) {
            return type.getName();
        }

        if (type instanceof GoPsiTypePointer) {
            return ((GoPsiTypePointer)type).getTargetType().getName();
        }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.types.GoPsiType

        return processor.execute(this, state);
    }

    @Override
    public GoType getIdentifierType(GoLiteralIdentifier identifier) {
        GoPsiType identifiersType = getIdentifiersType();
        if (identifiersType != null) {
            return GoTypes.fromPsi(identifiersType);
        }

        GoLiteralIdentifier[] identifiers = getIdentifiers();
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.types.GoPsiType

        return findChildByClass(GoPsiType.class);
    }

    @Override
    public GoPsiType getIdentifiersType() {
        GoPsiType type = findChildByClass(GoPsiType.class);

        if ( type != null )
            return type;

        PsiElement declaration = this.getPrevSibling();
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.types.GoPsiType

    private GoType[] resolveVarTypes(GoVarDeclaration parent, GoLiteralIdentifier identifier, int i) {

        GoType identifierType = parent.getIdentifierType(identifier);
        if (identifierType != null && identifierType instanceof GoTypePsiBacked) {
            GoPsiType goPsiType = GoTypeUtils.resolveToFinalType(((GoTypePsiBacked) identifierType).getPsiType());
            if (goPsiType instanceof GoPsiTypeFunction) {
                return GoUtil.getFuncCallTypes((GoPsiTypeFunction) goPsiType);
            }
        }

        GoExpr[] expressions = parent.getExpressions();
        if (expressions.length == 1 && expressions[0] instanceof GoCallOrConvExpression) {
            GoType[] types = expressions[0].getType();
            if (i < types.length) {
                GoType type = types[i];
                if (type instanceof GoTypePsiBacked) {
                    GoPsiType goPsiType = GoTypeUtils.resolveToFinalType(((GoTypePsiBacked) type).getPsiType());
                    if (goPsiType instanceof GoPsiTypeFunction) {
                        return GoUtil.getFuncCallTypes((GoPsiTypeFunction) goPsiType);
                    }
                }
            }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.types.GoPsiType

        if (name == null)
            return null;

        LookupElementBuilder builder = LookupElementBuilder.create(id, name);

        GoPsiType ownerType = null;
        if (id.getParent() != null && id.getParent() instanceof GoTypeStructField) {
            GoTypeStructField structField = (GoTypeStructField) id.getParent();
            ownerType = (GoPsiType) structField.getParent();
        }

        if (ownerType == null) {
            return builder;
        }

        return builder
                .bold()
                .withTailText(String.format(" (defined by: %s)",
                        ownerType.getName()))
                .withTypeText("<field>", ownerType != type);
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.types.GoPsiType

        }.visitFile(file);
    }

    private static void checkNewCall(GoBuiltinCallOrConversionExpression 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()));
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.types.GoPsiType

        }
    }

    private static void checkMakeCall(GoBuiltinCallOrConversionExpression 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) {
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.types.GoPsiType

        return findChildByClass(GoTypeNameDeclaration.class);
    }

    @Nullable
    public GoPsiType getType() {
        GoPsiType types[] = findChildrenByClass(GoPsiType.class);
        for (GoPsiType type : types) {
            if ( type instanceof GoTypeNameDeclaration )
                continue;

            return type;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.