Package org.jruby.common

Examples of org.jruby.common.RubyWarnings


    RubyStepMeta meta = new RubyStepMeta();
    Ruby runtime = RubyStepFactory.createScriptingContainer(true,meta.getRubyVersion()).getProvider().getRuntime();
    ParserConfiguration parserConfig = new ParserConfiguration(runtime, 0, true, CompatVersion.BOTH);
    parserSupport.setConfiguration(parserConfig);
    parserSupport.setResult(new RubyParserResult());
    parserSupport.setWarnings(new RubyWarnings(null));
    parserSupport.initTopLocalVariables();

    lexer.setEncoding(RubyYaccLexer.UTF8_ENCODING);
    lexer.setParserSupport(parserSupport);
    lexer.setState(RubyYaccLexer.LexState.EXPR_BEG);
View Full Code Here


            }
        }
    }

    private static void cmpFailed(ThreadContext context) {
        RubyWarnings warnings = context.runtime.getWarnings();

        warnings.warn("Comparable#== will no more rescue exceptions of #<=> in the next release.");
        warnings.warn("Return nil in #<=> if the comparison is inappropriate or avoid such comparison.");
    }
View Full Code Here

        IRubyObject savedError = context.runtime.getGlobalVariables().get("$!");
        try {
            result = coerceBody(context, other);
        } catch (RaiseException e) {
            RubyWarnings warnings = context.runtime.getWarnings();
            warnings.warn("Numerical comparison operators will no more rescue exceptions of #coerce");
            warnings.warn("in the next release. Return nil in #coerce if the coercion is impossible.");
            if (err) {
                coerceFailed(context, other);
            } else {
                context.runtime.getGlobalVariables().set("$!", savedError);
            }
            return null;
        }
   
        if (!(result instanceof RubyArray) || ((RubyArray) result).getLength() != 2) {
            if (err) {
                throw context.runtime.newTypeError("coerce must return [x, y]");
            } else if (!result.isNil()) {
                RubyWarnings warnings = context.runtime.getWarnings();
                warnings.warn("Bad return value for #coerce, called by numerical comparison operators.");
                warnings.warn("#coerce must return [x, y]. The next release will raise an error for this.");
            }
            return null;
        }
        return (RubyArray) result;
    }
View Full Code Here

TOP

Related Classes of org.jruby.common.RubyWarnings

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.