Java Code Examples for jdk.nashorn.internal.runtime.Source#getColumn()

The following examples show how to use jdk.nashorn.internal.runtime.Source#getColumn() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JSONParser.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 2
Source File: AssignSymbols.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 3
Source File: JSONParser.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 4
Source File: AssignSymbols.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 5
Source File: JSONParser.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 6
Source File: AssignSymbols.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 7
Source File: JSONParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 8
Source File: AssignSymbols.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 9
Source File: JSONParser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 10
Source File: AssignSymbols.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 11
Source File: JSONParser.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 12
Source File: AssignSymbols.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 13
Source File: CodeGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterThrowNode(final ThrowNode throwNode) {
    lineNumber(throwNode);

    if (throwNode.isSyntheticRethrow()) {
        //do not wrap whatever this is in an ecma exception, just rethrow it
        load(throwNode.getExpression());
        method.athrow();
        return false;
    }

    method._new(ECMAException.class).dup();

    final Source source     = lc.getCurrentFunction().getSource();

    final Expression expression = throwNode.getExpression();
    final int        position   = throwNode.position();
    final int        line       = throwNode.getLineNumber();
    final int        column     = source.getColumn(position);

    load(expression, Type.OBJECT);

    method.load(source.getName());
    method.load(line);
    method.load(column);
    method.invoke(ECMAException.THROW_INIT);

    method.athrow();

    return false;
}
 
Example 14
Source File: CodeGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterThrowNode(final ThrowNode throwNode) {
    lineNumber(throwNode);

    if (throwNode.isSyntheticRethrow()) {
        //do not wrap whatever this is in an ecma exception, just rethrow it
        load(throwNode.getExpression());
        method.athrow();
        return false;
    }

    method._new(ECMAException.class).dup();

    final Source source     = lc.getCurrentFunction().getSource();

    final Expression expression = throwNode.getExpression();
    final int        position   = throwNode.position();
    final int        line       = throwNode.getLineNumber();
    final int        column     = source.getColumn(position);

    load(expression, Type.OBJECT);

    method.load(source.getName());
    method.load(line);
    method.load(column);
    method.invoke(ECMAException.THROW_INIT);

    method.athrow();

    return false;
}
 
Example 15
Source File: JSONParser.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 16
Source File: AssignSymbols.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
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);
}