Package org.codehaus.groovy.syntax

Examples of org.codehaus.groovy.syntax.SyntaxException


    /**
     * Convenience routine to return the specified error's
     * underlying SyntaxException, or null if it isn't one.
     */
    public SyntaxException getSyntaxError(int index) {
        SyntaxException exception = null;

        Message message = getError(index);
        if (message != null && message instanceof SyntaxErrorMessage) {
            exception = ((SyntaxErrorMessage) message).getCause();
        }
View Full Code Here


                }
            } else {
                txt += "The sources " + nodeSource.getName() + " and " + storedSource.getName() + " are containing both a class of the name " + node.getName() + ".\n";
            }
            nodeSource.getErrorCollector().addErrorAndContinue(
                    new SyntaxErrorMessage(new SyntaxException(txt, node.getLineNumber(), node.getColumnNumber()), nodeSource)
            );
        }
        classes.put(name, node);

        if (classesToCompile.containsKey(name)) {
View Full Code Here

    private void addError(String msg, ASTNode expr, SourceUnit source) {
        int line = expr.getLineNumber();
        int col = expr.getColumnNumber();
        source.getErrorCollector().addErrorAndContinue(
                new SyntaxErrorMessage(new SyntaxException(msg + '\n', line, col), source)
        );
    }
View Full Code Here

                    }
                }

                if (failMessage != null) {
                    sourceUnit.getErrorCollector().addError(
                            new SyntaxException(failMessage, statement.getLineNumber(), statement.getColumnNumber()),
                            sourceUnit
                    );
                }

                return returnStatement;
            } else {
                if (seenPluginsBlock) {
                    String message = String.format(
                            pluginBlockTransformer.formatErrorMessage("all %s {} blocks must appear before any %s {} blocks in the script"),
                            classpathBlockName, PLUGINS
                    );
                    sourceUnit.getErrorCollector().addError(
                            new SyntaxException(message, statement.getLineNumber(), statement.getColumnNumber()),
                            sourceUnit
                    );
                }
                return statement; // don't transform classpathBlockName
            }
View Full Code Here

                    throw UncheckedException.throwAsUncheckedException(failure);
                }
            }
        }

        SyntaxException syntaxError = e.getErrorCollector().getSyntaxError(0);
        Integer lineNumber = syntaxError == null ? null : syntaxError.getLine();
        throw new ScriptCompilationException(String.format("Could not compile %s.", source.getDisplayName()), e, source,
                lineNumber);
    }
View Full Code Here

            call.setMethod(new ConstantExpression(INPUT));
        }
    }

    private void error(ASTNode call, String message) {
        SyntaxException syntaxException = new SyntaxException(message, call.getLineNumber(), call.getColumnNumber());
        sourceUnit.getErrorCollector().addError(syntaxException, sourceUnit);
    }
View Full Code Here

                    continue;
                }

                if (methodName.equals(MODEL)) {
                    source.getErrorCollector().addError(
                            new SyntaxException(NON_LITERAL_CLOSURE_TO_TOP_LEVEL_MODEL_MESSAGE, statement.getLineNumber(), statement.getColumnNumber()),
                            source
                    );
                }
            } else {
                RuleVisitor ruleVisitor = new RuleVisitor(source);
View Full Code Here

        restrict(astNode, message);
    }

    protected void restrict(ASTNode astNode, String message) {
        sourceUnit.getErrorCollector().addError(
                new SyntaxException(message, astNode.getLineNumber(), astNode.getColumnNumber()),
                sourceUnit
        );
    }
View Full Code Here

    return names.toArray(new String[names.size()]);
  }

  protected void reportError(final String message, final SourceUnit sourceUnit, final ASTNode node) {
    SyntaxException se = new SyntaxException(message, node.getLineNumber(), node.getColumnNumber());
    sourceUnit.getErrorCollector().addErrorAndContinue(new SyntaxErrorMessage(se, sourceUnit));
  }
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.syntax.SyntaxException

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.