Package ro.redeul.google.go.lang.psi.expressions.literals

Examples of ro.redeul.google.go.lang.psi.expressions.literals.GoLiteral


            @Override
            public void visitBuiltinCallExpression(GoBuiltinCallOrConversionExpression expression) {
                GoPrimaryExpression baseExpression = expression.getBaseExpression();
                if (baseExpression instanceof GoLiteralExpression) {
                    GoLiteral literal = ((GoLiteralExpression) baseExpression).getLiteral();
                    if (literal instanceof GoLiteralIdentifier && "panic".equals(literal.getText())) {
                        addOccurrence(expression);
                    }
                }
            }
        }.visitFunctionDeclaration(function);
View Full Code Here


        }
        if (element2 instanceof GoType) {
            if (goExpr instanceof GoParenthesisedExpression)
                goExpr = ((GoParenthesisedExpression) goExpr).getInnerExpression();
            if (goExpr instanceof GoLiteralExpression) {
                GoLiteral literal = ((GoLiteralExpression) goExpr).getLiteral();
                if (literal instanceof GoLiteralFunction) {
                    return ((GoLiteralFunction) literal).isIdentical(element);
                }
            }
View Full Code Here

        return psiElement instanceof GoLiteralIdentifier && ((GoLiteralIdentifier) psiElement).getName().equals("nil");
    }

    public static boolean checkValidLiteralFloatExpr(GoExpr expr) {
        if (expr instanceof GoLiteralExpression) {
            GoLiteral literal = ((GoLiteralExpression) expr).getLiteral();
            if (literal instanceof GoLiteralIdentifier) {
                //Never will be null
                PsiElement goPsiElement = GoUtil.ResolveReferece(literal).getParent();
                if (goPsiElement instanceof GoConstDeclaration) {
                    for (GoExpr goExpr : ((GoConstDeclaration) goPsiElement).getExpressions()) {
                        if (!checkValidLiteralFloatExpr(goExpr))
                            return false;
                    }
                }
                return true;
            }
            if (literal instanceof GoLiteralExpression)
                return checkValidLiteralIntExpr((GoExpr) literal);
            return literal instanceof GoLiteralFloat || literal instanceof GoLiteralInteger || literal.getNode().getElementType() == GoElementTypes.LITERAL_CHAR;
        }
        if (expr instanceof GoBinaryExpression) {
            if (!checkValidLiteralFloatExpr(((GoBinaryExpression) expr).getLeftOperand()))
                return false;
            return checkValidLiteralFloatExpr(((GoBinaryExpression) expr).getRightOperand());
View Full Code Here

        return false;
    }

    public static boolean checkValidLiteralIntExpr(GoExpr expr) {
        if (expr instanceof GoLiteralExpression) {
            GoLiteral literal = ((GoLiteralExpression) expr).getLiteral();
            if (literal instanceof GoLiteralIdentifier) {
                //Never will be null
                PsiElement goPsiElement = GoUtil.ResolveReferece(literal).getParent();
                if (goPsiElement instanceof GoConstDeclaration) {
                    for (GoExpr goExpr : ((GoConstDeclaration) goPsiElement).getExpressions()) {
                        if (!checkValidLiteralIntExpr(goExpr))
                            return false;
                    }
                }
                return true;
            }
            if (literal instanceof GoLiteralExpression)
                return checkValidLiteralIntExpr((GoExpr) literal);
            if (literal instanceof GoLiteralInteger || literal.getNode().getElementType() == GoElementTypes.LITERAL_CHAR)
                return true;
            return literal instanceof GoLiteralFloat && literal.getText().matches("^[0-9]*\\.0*$");
        }
        if (expr instanceof GoBinaryExpression) {
            if (!checkValidLiteralIntExpr(((GoBinaryExpression) expr).getLeftOperand()))
                return false;
            return checkValidLiteralIntExpr(((GoBinaryExpression) expr).getRightOperand());
View Full Code Here

    private void visitExpressionAsIdentifier(GoExpr expr, boolean declaration) {
        if (!(expr instanceof GoLiteralExpression)) {
            return;
        }

        GoLiteral literal = ((GoLiteralExpression) expr).getLiteral();
        if ( literal.getType() == GoLiteral.Type.Identifier )
        if (needToCollectUsage((GoLiteralIdentifier)literal)) {
            if (declaration) {
                ctx.addDefinition(literal);
            } else {
                ctx.addUsage(literal);
View Full Code Here

            return flip(be.getLeftOperand()) + " || " + flip(be.getRightOperand());
        }

        if (expr instanceof GoLiteralExpression) {
            GoLiteral literal = ((GoLiteralExpression) expr).getLiteral();
            if (literal instanceof GoLiteralIdentifier) {
                return "!" + expr.getText();
            }
        }
View Full Code Here

        GoLiteralExpression literalExpression = (GoLiteralExpression)fmtExpr;

        if (literalExpression.getLiteral() == null)
            return;

        GoLiteral literal = literalExpression.getLiteral();

        switch (literal.getType()) {
            case Identifier:
                literal = findConstDefinition((GoLiteralIdentifier)literal);
                if (literal == null ||
                    literal.getType() != InterpretedString &&
                    literal.getType() != RawString)
                   break;
            case InterpretedString:
            case RawString:
                GoLiteralString stringLiteral = (GoLiteralString) literal;
                Context ctx = new Context(stringLiteral,
View Full Code Here

    }

    @NotNull
    @Override
    protected GoType[] resolveTypes() {
        GoLiteral literal = getLiteral();
        if (literal == null)
            return GoType.EMPTY_ARRAY;

        final GoTypes types = getInstance(getProject());
        GoNamesCache namesCache = GoNamesCache.getInstance(getProject());

        switch (literal.getType()) {
            case Bool:
                return new GoType[]{GoTypes.constant(GoTypeConstant.Kind.Boolean, literal.getValue())};
            case Int:
                return new GoType[]{GoTypes.constant(GoTypeConstant.Kind.Integer, literal.getValue())};
            case Float:
                return new GoType[]{GoTypes.constant(GoTypeConstant.Kind.Float, literal.getValue())};
            case Char:
                return new GoType[]{GoTypes.constant(GoTypeConstant.Kind.Rune, literal.getValue())};
            case ImaginaryInt:
            case ImaginaryFloat:
                return new GoType[]{GoTypes.constant(GoTypeConstant.Kind.Complex, literal.getValue())};

            case RawString:
            case InterpretedString:
                return new GoType[]{GoTypes.constant(GoTypeConstant.Kind.String, literal.getValue())};

            case Function:
                return new GoType[]{GoTypes.fromPsi((GoLiteralFunction) literal)};

            case Identifier:
View Full Code Here

        GoExpr[] expressions = element.getExpressions();

        for (GoExpr expr : expressions) {

            if (expr instanceof GoLiteralExpression) {
                GoLiteral literal = ((GoLiteralExpression) expr).getLiteral();
                if (literal instanceof GoLiteralFunction) {
                    if (i != 0) {
                        stringBuilder.append(",");
                    }
                    stringBuilder.append(GoUtil.getFuncDecAsParam(((GoLiteralFunction) literal).getParameters(),
View Full Code Here

        this.imports = imports;
    }

    @Override
    public void visitLiteralExpression(GoLiteralExpression expression) {
        GoLiteral literal = expression.getLiteral();

        if (literal == null)
            return;

        switch (literal.getType()) {
            case Identifier:
                checkQualifiedIdentifier((GoLiteralIdentifier)literal);
                break;
            case Composite:
            case Function:
View Full Code Here

TOP

Related Classes of ro.redeul.google.go.lang.psi.expressions.literals.GoLiteral

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.