private static void writeWarning(Ruby runtime, ID id, String message) { RubyStackTraceElement[] stack = getRubyStackTrace(runtime); String file; int line; if (stack.length == 0) { file = "(unknown)"; line = -1; } else { file = stack[0].getFileName(); line = stack[0].getLineNumber(); } runtime.getWarnings().warning(id, file, line, message); }
private static void emptyImplementationWarning(Ruby runtime, ID id, String name) { runtime.getWarnings().warnOnce(id, name + " does nothing on JRuby"); } }
@Override public IRubyObject set(IRubyObject value) { runtime.getWarnings().warn(ID.INEFFECTIVE_GLOBAL, "warning: variable " + name + " is no longer effective; ignored"); return value; }
/** * Verbose mode warning methods, their contract is that consumer must explicitly check for runtime.isVerbose() * before calling them */ public void warning(String message) { if (!runtime.warningsEnabled()) return; warning(ID.MISCELLANEOUS, message); }
private void confirmCachedProxy(String message) { final RubyClass realClass = metaClass.getRealClass(); if ( ! realClass.getCacheProxy() ) { final Ruby runtime = getRuntime(); if (Java.OBJECT_PROXY_CACHE) { runtime.getWarnings().warnOnce(IRubyWarnings.ID.NON_PERSISTENT_JAVA_PROXY, MessageFormat.format(message, realClass)); } else { runtime.getWarnings().warn(MessageFormat.format(message, realClass)); realClass.setCacheProxy(true); runtime.getJavaSupport().getObjectProxyCache().put(getObject(), this); } } }
public void warn(ID id, String message) { if (!runtime.warningsEnabled()) return; RubyStackTraceElement[] stack = getRubyStackTrace(runtime); String file; int line; if (stack.length == 0) { file = "(unknown)"; line = -1; } else { file = stack[0].getFileName(); line = stack[0].getLineNumber(); } warn(id, file, line, message); }
public static void writeWarningDyncall(ThreadContext context, RubyString errorString) { RubyModule warning = context.runtime.getWarning(); sites(context).warn.call(context, warning, warning, errorString); }
/** * Prints a warning, unless $VERBOSE is nil. */ @Override public void warn(ID id, String fileName, int lineNumber, String message) { if (!runtime.warningsEnabled()) return; StringBuilder buffer = new StringBuilder(100); buffer.append(fileName).append(':').append(lineNumber + 1).append(": "); buffer.append("warning: ").append(message).append('\n'); RubyString errorString = runtime.newString(buffer.toString()); writeWarningDyncall(runtime.getCurrentContext(), errorString); }
@Override public void warning(ID id, String message) { if (!runtime.warningsEnabled() || !runtime.isVerbose()) return; writeWarning(runtime, id, message); }
@JRubyMethod public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObject arg) { Ruby runtime = context.runtime; if (!runtime.warningsEnabled()) return context.nil; TypeConverter.checkType(context, arg, runtime.getString()); RubyString str = (RubyString) arg; if (!str.getEncoding().isAsciiCompatible()) { throw runtime.newEncodingCompatibilityError("ASCII incompatible encoding: " + str.getEncoding()); } writeWarningToError(runtime.getCurrentContext(), str); return context.nil; }
RubyWarnings.createWarningModule(this);
public void warn(WARNING_ID id, String message, Object... data) { ID ourID; if (id == WARNING_ID.DUMMY_VALUE_USED) { ourID = ID.DUMMY_VALUE_USED; } else { ourID = ID.MISCELLANEOUS; } runtime.getWarnings().warn(ourID, message); }
/** * Prints a warning, only in verbose mode. */ @Override @Deprecated public void warning(ID id, ISourcePosition position, String message) { warning(id, position.getFile(), position.getLine(), message); }
private void confirmCachedProxy(String message) { final RubyClass realClass = metaClass.getRealClass(); if ( ! realClass.getCacheProxy() ) { final Ruby runtime = getRuntime(); if (Java.OBJECT_PROXY_CACHE) { runtime.getWarnings().warnOnce(IRubyWarnings.ID.NON_PERSISTENT_JAVA_PROXY, MessageFormat.format(message, realClass)); } else { runtime.getWarnings().warn(MessageFormat.format(message, realClass)); realClass.setCacheProxy(true); runtime.getJavaSupport().getObjectProxyCache().put(getObject(), this); } } }
@Override public void warn(ID id, String message) { if (!runtime.warningsEnabled()) return; RubyStackTraceElement[] stack = getRubyStackTrace(runtime); String file; int line; if (stack.length == 0) { file = "(unknown)"; line = -1; } else { file = stack[0].getFileName(); line = stack[0].getLineNumber(); } warn(id, file, line, message); }
public static void writeWarningDyncall(ThreadContext context, RubyString errorString) { RubyModule warning = context.runtime.getWarning(); sites(context).warn.call(context, warning, warning, errorString); }
/** * Prints a warning, unless $VERBOSE is nil. */ @Override public void warn(ID id, String fileName, int lineNumber, String message) { if (!runtime.warningsEnabled()) return; StringBuilder buffer = new StringBuilder(100); buffer.append(fileName).append(':').append(lineNumber + 1).append(": "); buffer.append("warning: ").append(message).append('\n'); RubyString errorString = runtime.newString(buffer.toString()); writeWarningDyncall(runtime.getCurrentContext(), errorString); }