Examples of GoLiteralIdentifier


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

                if (typeContainsStruct(type, struct)) {
                    result.addProblem(field, GoBundle.message(
                        "error.invalid.recursive.type", struct.getName()));
                }

                GoLiteralIdentifier identifier = typeName.getIdentifier();
                String name = identifier.getName();
                if (fields.contains(name)) {
                    result.addProblem(identifier, GoBundle.message(
                        "error.duplicate.field", name));
                } else {
                    fields.add(name);
View Full Code Here

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

            if (info.getSeverity() != HighlightSeverity.ERROR ||
                !info.getDescription().contains("Unresolved symbol")) {
                continue;
            }

            GoLiteralIdentifier id = findElementOfClassAtRange(file, start, end, GoLiteralIdentifier.class);
            if (!isPackageUsage(id)) {
                continue;
            }

            if (id == null) {
                continue;
            }

            // packages exist
            String expectedPackage = id.getText();
            List<String> sdkPackages = getPackagesByName(
                    namesCache.getSdkPackages(), expectedPackage);
            List<String> projectPackages = getPackagesByName(
                    namesCache.getProjectPackages(), expectedPackage);
            if (imported.contains(expectedPackage) || sdkPackages.size() == 0 && projectPackages.size() == 0) {
                continue;
            }

            toImport = new Data(id, sdkPackages, projectPackages);
            if (id.getTextRange().getEndOffset() > caretOffset) {
                return toImport;
            }
        }
        return toImport;
    }
View Full Code Here

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

                allPackages.addAll(data.sdkPackages);
                String importMessage = getPromptMessage(allPackages);
                AddImportFix fix = new AddImportFix(data.sdkPackages,
                                                    data.projectPackages, file,
                                                    editor);
                GoLiteralIdentifier identifier = data.identifier;
                int start = identifier.getTextOffset();
                int end = identifier.getTextRange().getEndOffset();

                HintManager.getInstance()
                           .showQuestionHint(editor, importMessage, start, end,
                                             fix);
            }
View Full Code Here

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

    private void getFunctionParameters(GoFunctionDeclaration fd) {
        Map<String, VariableUsage> variables = createFunctionParametersMap(fd.getParameters(), fd.getResults());

        if (fd instanceof GoMethodDeclaration) {
            // Add method receiver to parameter list
            GoLiteralIdentifier receiver = getMethodReceiverIdentifier((GoMethodDeclaration) fd);
            if (receiver != null) {
                variables.put(receiver.getName(), new VariableUsage(receiver));
            }
        }
    }
View Full Code Here

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

        final Map<String, GoLiteralIdentifier> labelDeclarations = new HashMap<String, GoLiteralIdentifier>();
        final List<GoLiteralIdentifier> labelUsages = new ArrayList<GoLiteralIdentifier>();
        new GoRecursiveElementVisitor() {
            @Override
            public void visitLabeledStatement(GoLabeledStatement statement) {
                GoLiteralIdentifier label = statement.getLabel();
                String name = label.getName();
                if (labelDeclarations.containsKey(name)) {
                    result.addProblem(label, GoBundle.message("error.label.already.defined", name));
                } else {
                    labelDeclarations.put(name, label);
                }

                super.visitLabeledStatement(statement);
            }

            @Override
            public void visitBreakStatement(GoBreakStatement statement) {
                checkLabelUsage(statement.getLabel());
            }

            @Override
            public void visitContinueStatement(GoContinueStatement statement) {
                checkLabelUsage(statement.getLabel());
            }

            @Override
            public void visitGotoStatement(GoGotoStatement statement) {
                checkLabelUsage(statement.getLabel());
            }

            private void checkLabelUsage(GoLiteralIdentifier label) {
                if (label == null) {
                    return;
                }

                String name = label.getName();
                if (name == null || name.isEmpty()) {
                    return;
                }

                labelUsages.add(label);
            }

            @Override
            public void visitFunctionLiteral(GoLiteralFunction literal) {
                checkFunction(result, literal);
            }
        }.visitElement(function);

        Set<String> usedLabels = new HashSet<String>();
        for (GoLiteralIdentifier label : labelUsages) {
            String name = label.getName();
            if (labelDeclarations.containsKey(name)) {
                usedLabels.add(name);
            }
        }

        for (Map.Entry<String, GoLiteralIdentifier> e : labelDeclarations.entrySet()) {
            String name = e.getKey();
            if (!usedLabels.contains(name)) {
                result.addProblem(e.getValue(), GoBundle.message("error.label.defined.and.not.used", name));
            }
        }

        for (GoLiteralIdentifier label : labelUsages) {
            String name = label.getName();
            if (name == null || !labelDeclarations.containsKey(name)) {
                continue;
            }
            checkUsage(label, labelDeclarations.get(name), result);
        }
View Full Code Here

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

        PsiElement parent = findCommonParent(gotoStatement, labeledStatement);
        if (parent == null || !labeledStatement.getParent().equals(parent)) {
            return;
        }

        GoLiteralIdentifier label = gotoStatement.getLabel();
        PsiElement gotoParent = gotoStatement;
        while (gotoParent != null && !parent.equals(gotoParent.getParent())) {
            gotoParent = gotoParent.getParent();
        }
        if (gotoParent == null) {
View Full Code Here

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

        }
    }

    private static void addJumpOverProblem(GoLiteralIdentifier label, GoLiteralIdentifier[] identifiers,
                                           InspectionResult result) {
        GoLiteralIdentifier identifier = findFirstIdentifier(identifiers);
        if (identifier == null) {
            return;
        }

        result.addProblem(label,
                GoBundle.message("error.goto.jumps.over.declaration", label.getName(), identifier.getName()));
    }
View Full Code Here

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

    }

    private static void checkJumpInsideBlock(GoGotoStatement gotoStatement, GoLabeledStatement labeledStatement,
                                             InspectionResult result) {
        PsiElement parent = findCommonParent(gotoStatement, labeledStatement);
        GoLiteralIdentifier label = gotoStatement.getLabel();
        String name = label.getName();
        if (!labeledStatement.getParent().equals(parent) &&
            !labeledStatement.equals(parent)) {
            result.addProblem(label, GoBundle.message("error.goto.jumps.into.block", name));
        }
    }
View Full Code Here

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

    }

    @Override
    @NotNull
    public String getName() {
        GoLiteralIdentifier identifiers[] =
                findChildrenByClass(GoLiteralIdentifier.class);

        String name = null;
        if ( identifiers.length > 0)
            name = identifiers[identifiers.length - 1].getName();
View Full Code Here

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

    }

    @NotNull
    @Override
    public PsiElement getNavigationElement() {
        GoLiteralIdentifier identifiers[] =
                findChildrenByClass(GoLiteralIdentifier.class);

        GoLiteralIdentifier identifier = null;
        if (identifiers.length > 0)
            identifier = identifiers[identifiers.length - 1];

        return identifier == null ? this : identifier;
    }
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.