本文整理汇总了Java中jdk.nashorn.internal.runtime.JSErrorType类的典型用法代码示例。如果您正苦于以下问题:Java JSErrorType类的具体用法?Java JSErrorType怎么用?Java JSErrorType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JSErrorType类属于jdk.nashorn.internal.runtime包,在下文中一共展示了JSErrorType类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: error
import jdk.nashorn.internal.runtime.JSErrorType; //导入依赖的package包/类
/**
* Report an error.
*
* @param errorType The error type
* @param message Error message.
* @return ParserException upon failure. Caller should throw and not ignore
*/
protected final ParserException error(final JSErrorType errorType, final String message) {
// TODO - column needs to account for tabs.
final int position = Token.descPosition(token);
final int column = position - linePosition;
final String formatted = ErrorManager.format(message, source, line, column, token);
return new ParserException(errorType, formatted, source, line, column, token);
}
示例2: referenceError
import jdk.nashorn.internal.runtime.JSErrorType; //导入依赖的package包/类
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) {
if (earlyError) {
throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
}
final ArrayList<Expression> args = new ArrayList<>();
args.add(lhs);
if (rhs == null) {
args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish()));
} else {
args.add(rhs);
}
args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString()));
return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
}
示例3: throwParserException
import jdk.nashorn.internal.runtime.JSErrorType; //导入依赖的package包/类
private void throwParserException(final String message, final Node origin) {
if (origin == null) {
throw new ParserException(message);
}
final Source source = compiler.getSource();
final long token = origin.getToken();
final int line = source.getLine(origin.getStart());
final int column = source.getColumn(origin.getStart());
final String formatted = ErrorManager.format(message, source, line, column, token);
throw new ParserException(JSErrorType.SYNTAX_ERROR, formatted, source, line, column, token);
}
示例4: error
import jdk.nashorn.internal.runtime.JSErrorType; //导入依赖的package包/类
ParserException error(final String message, final int start, final int length) throws ParserException {
final long token = Token.toDesc(STRING, start, length);
final int pos = Token.descPosition(token);
final Source src = Source.sourceFor("<json>", source);
final int lineNum = src.getLine(pos);
final int columnNum = src.getColumn(pos);
final String formatted = ErrorManager.format(message, src, lineNum, columnNum, token);
return new ParserException(JSErrorType.SYNTAX_ERROR, formatted, src, lineNum, columnNum, token);
}
示例5: referenceError
import jdk.nashorn.internal.runtime.JSErrorType; //导入依赖的package包/类
private RuntimeNode referenceError(final Expression lhs, final Expression rhs, final boolean earlyError) {
if (env._parse_only || earlyError) {
throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
}
final ArrayList<Expression> args = new ArrayList<>();
args.add(lhs);
if (rhs == null) {
args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish()));
} else {
args.add(rhs);
}
args.add(LiteralNode.newInstance(lhs.getToken(), lhs.getFinish(), lhs.toString()));
return new RuntimeNode(lhs.getToken(), lhs.getFinish(), RuntimeNode.Request.REFERENCE_ERROR, args);
}
示例6: error
import jdk.nashorn.internal.runtime.JSErrorType; //导入依赖的package包/类
/**
* Generate a runtime exception
*
* @param message error message
* @param type token type
* @param start start position of lexed error
* @param length length of lexed error
* @throws ParserException unconditionally
*/
protected void error(final String message, final TokenType type, final int start, final int length) throws ParserException {
final long token = Token.toDesc(type, start, length);
final int pos = Token.descPosition(token);
final int lineNum = source.getLine(pos);
final int columnNum = source.getColumn(pos);
final String formatted = ErrorManager.format(message, source, lineNum, columnNum, token);
throw new ParserException(JSErrorType.SYNTAX_ERROR, formatted, source, lineNum, columnNum, token);
}