Examples of GoConstDeclaration


Examples of ro.redeul.google.go.lang.psi.declarations.GoConstDeclaration

    private void appendConstToLastDeclaration(RangeMarker[] exprMarkers, String declaration,
                                              GoConstDeclarations declarations) {
        RangeMarker originalRange = document.createRangeMarker(declarations.getTextRange());
        GoConstDeclaration[] consts = declarations.getDeclarations();
        GoConstDeclaration lastConst = consts[consts.length - 1];
        if (consts.length == 1 && !isEnclosedByParenthesis(consts[0])) {
            SmartPsiElementPointer<GoConstDeclarations> declPointer = createSmartElementPointer(declarations);
            SmartPsiElementPointer<GoConstDeclaration> lastConstPointer = createSmartElementPointer(lastConst);
            addParentheses(declarations);
            lastConst = lastConstPointer.getElement();
            declarations = declPointer.getElement();
            if (lastConst == null || declarations == null) {
                return;
            }

            originalRange = document.createRangeMarker(declarations.getTextRange());
        }

        int offset = lastConst.getTextOffset() + lastConst.getTextLength();
        String stmt = "\n$" + VARIABLE + "$ = " + declaration;

        startRenaming(editor, exprMarkers, offset, stmt, originalRange);
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.declarations.GoConstDeclaration

        }

        PsiElement element = declaration;
        while ((element = element.getPrevSibling()) != null) {
            if (element instanceof GoConstDeclaration) {
                GoConstDeclaration preConst = (GoConstDeclaration) element;
                if (preConst.hasInitializers()) {
                    return declaration.getIdentifiers().length != preConst.getIdentifiers().length;
                }
            }
        }
        return false;
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.declarations.GoConstDeclaration

        PsiElement parent = resolve.getParent();
        if (!(parent instanceof GoConstDeclaration)) {
            return null;
        }

        GoConstDeclaration cd = ((GoConstDeclaration) parent);
        GoLiteralIdentifier[] ids = cd.getIdentifiers();
        GoExpr[] exprs = cd.getExpressions();
        if (ids == null || exprs == null || ids.length != exprs.length) {
            return null;
        }

        for (int i = 0; i < ids.length; i++) {
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.declarations.GoConstDeclaration

        PsiElement parent = id.getParent();
        if (parent instanceof GoVarDeclaration) {
            GoVarDeclaration gsvd = (GoVarDeclaration) parent;
            removeIdentifier(id, parent, gsvd.getIdentifiers(), gsvd.getExpressions());
        } else if (parent instanceof GoConstDeclaration) {
            GoConstDeclaration gcd = (GoConstDeclaration) parent;
            removeIdentifier(id, parent, gcd.getIdentifiers(), gcd.getExpressions());
        }
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.declarations.GoConstDeclaration

                GoVarDeclaration vd = (GoVarDeclaration) parent;
                type = vd.getIdentifiersType();
                identifiers = vd.getIdentifiers();
                expressions = vd.getExpressions();
            } else if (parent instanceof GoConstDeclaration) {
                GoConstDeclaration cd = (GoConstDeclaration) parent;
                type = cd.getIdentifiersType();
                identifiers = cd.getIdentifiers();
                expressions = cd.getExpressions();
            } else if (parent instanceof GoTypeStructField) {
                type = ((GoTypeStructField) parent).getType();
            }

            // return type name if type is explicitly defined in declaration.
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.declarations.GoConstDeclaration

            if (identifier.isIota())
                setData(Pair.create(GoLiteral.Type.Int, identifier.getIotaValue()));
            else {
                GoLiteralIdentifier definition = GoPsiUtils.resolveSafely(identifier, GoLiteralIdentifier.class);
                if (definition != null) {
                    GoConstDeclaration constDeclaration = getAs(GoConstDeclaration.class, definition.getParent());

                    GoExpr valueExpression = constDeclaration.getExpression(definition);
                    if (valueExpression != null)
                        valueExpression.accept(this);
                }
            }
        }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.declarations.GoConstDeclaration

        if (!(element instanceof GoConstDeclaration)) {
            return;
        }

        GoConstDeclaration cd = (GoConstDeclaration) element;
        GoLiteralIdentifier[] ids = cd.getIdentifiers();
        GoExpr[] expressions = cd.getExpressions();

        if (expressions.length == 0) {
            DeleteStmtFix.deleteStatement(cd);
            return;
        }

        if (ids.length <= expressions.length) {
            return;
        }

        cd.deleteChildRange(ids[expressions.length - 1].getNextSibling(), ids[ids.length - 1]);
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.declarations.GoConstDeclaration

        if (!(element instanceof GoConstDeclaration)) {
            return;
        }

        GoConstDeclaration cd = (GoConstDeclaration) element;
        GoLiteralIdentifier[] ids = cd.getIdentifiers();
        GoExpr[] expressions = cd.getExpressions();

        if (ids.length == 0) {
            DeleteStmtFix.deleteStatement(cd);
            return;
        }

        if (expressions.length <= ids.length) {
            return;
        }

        cd.deleteChildRange(expressions[ids.length - 1].getNextSibling(), expressions[expressions.length - 1]);
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.declarations.GoConstDeclaration

        if (!(element instanceof GoConstDeclaration)) {
            return;
        }

        GoConstDeclaration cd = (GoConstDeclaration) element;
        if (!cd.hasInitializers()) {
            addConstInitializer(project, editor, cd);
        } else {
            addMissingExpression(project, editor, cd);
        }
    }
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.