Java Code Examples for jdk.nashorn.internal.parser.Token#descPosition()
The following examples show how to use
jdk.nashorn.internal.parser.Token#descPosition() .
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: RecompilableScriptFunctionData.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
private static long tokenFor(final FunctionNode fn) { final int position = Token.descPosition(fn.getFirstToken()); final long lastToken = Token.withDelimiter(fn.getLastToken()); // EOL uses length field to store the line number final int length = Token.descPosition(lastToken) - position + (Token.descType(lastToken) == TokenType.EOL ? 0 : Token.descLength(lastToken)); return Token.toDesc(TokenType.FUNCTION, position, length); }
Example 2
Source File: ErrorManager.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * Format an error message to include source and line information. * @param message Error message string. * @param source Source file information. * @param line Source line number. * @param column Source column number. * @param token Offending token descriptor. * @return formatted string */ public static String format(final String message, final Source source, final int line, final int column, final long token) { final String eoln = System.lineSeparator(); final int position = Token.descPosition(token); final StringBuilder sb = new StringBuilder(); // Source description and message. sb.append(source.getName()). append(':'). append(line). append(':'). append(column). append(' '). append(message). append(eoln); // Source content. final String sourceLine = source.getSourceLine(position); sb.append(sourceLine).append(eoln); // Pointer to column. for (int i = 0; i < column; i++) { if (sourceLine.charAt(i) == '\t') { sb.append('\t'); } else { sb.append(' '); } } sb.append('^'); // Use will append eoln. // buffer.append(eoln); return sb.toString(); }
Example 3
Source File: ErrorManager.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Format an error message to include source and line information. * @param message Error message string. * @param source Source file information. * @param line Source line number. * @param column Source column number. * @param token Offending token descriptor. * @return formatted string */ public static String format(final String message, final Source source, final int line, final int column, final long token) { final String eoln = System.lineSeparator(); final int position = Token.descPosition(token); final StringBuilder sb = new StringBuilder(); // Source description and message. sb.append(source.getName()). append(':'). append(line). append(':'). append(column). append(' '). append(message). append(eoln); // Source content. final String sourceLine = source.getSourceLine(position); sb.append(sourceLine).append(eoln); // Pointer to column. for (int i = 0; i < column; i++) { if (i < sourceLine.length() && sourceLine.charAt(i) == '\t') { sb.append('\t'); } else { sb.append(' '); } } sb.append('^'); // Use will append eoln. // buffer.append(eoln); return sb.toString(); }
Example 4
Source File: RecompilableScriptFunctionData.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static long tokenFor(final FunctionNode fn) { final int position = Token.descPosition(fn.getFirstToken()); final long lastToken = Token.withDelimiter(fn.getLastToken()); // EOL uses length field to store the line number final int length = Token.descPosition(lastToken) - position + (Token.descType(lastToken) == TokenType.EOL ? 0 : Token.descLength(lastToken)); return Token.toDesc(TokenType.FUNCTION, position, length); }
Example 5
Source File: RecompilableScriptFunctionData.java From hottub with GNU General Public License v2.0 | 5 votes |
private static long tokenFor(final FunctionNode fn) { final int position = Token.descPosition(fn.getFirstToken()); final long lastToken = Token.withDelimiter(fn.getLastToken()); // EOL uses length field to store the line number final int length = Token.descPosition(lastToken) - position + (Token.descType(lastToken) == TokenType.EOL ? 0 : Token.descLength(lastToken)); return Token.toDesc(TokenType.FUNCTION, position, length); }
Example 6
Source File: RecompilableScriptFunctionData.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static long tokenFor(final FunctionNode fn) { final int position = Token.descPosition(fn.getFirstToken()); final long lastToken = Token.withDelimiter(fn.getLastToken()); // EOL uses length field to store the line number final int length = Token.descPosition(lastToken) - position + (Token.descType(lastToken) == TokenType.EOL ? 0 : Token.descLength(lastToken)); return Token.toDesc(TokenType.FUNCTION, position, length); }
Example 7
Source File: RecompilableScriptFunctionData.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static long tokenFor(final FunctionNode fn) { final int position = Token.descPosition(fn.getFirstToken()); final long lastToken = Token.withDelimiter(fn.getLastToken()); // EOL uses length field to store the line number final int length = Token.descPosition(lastToken) - position + (Token.descType(lastToken) == TokenType.EOL ? 0 : Token.descLength(lastToken)); return Token.toDesc(TokenType.FUNCTION, position, length); }
Example 8
Source File: RecompilableScriptFunctionData.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static long tokenFor(final FunctionNode fn) { final int position = Token.descPosition(fn.getFirstToken()); final long lastToken = Token.withDelimiter(fn.getLastToken()); // EOL uses length field to store the line number final int length = Token.descPosition(lastToken) - position + (Token.descType(lastToken) == TokenType.EOL ? 0 : Token.descLength(lastToken)); return Token.toDesc(TokenType.FUNCTION, position, length); }
Example 9
Source File: RecompilableScriptFunctionData.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private static long tokenFor(final FunctionNode fn) { final int position = Token.descPosition(fn.getFirstToken()); final int length = Token.descPosition(fn.getLastToken()) - position + Token.descLength(fn.getLastToken()); return Token.toDesc(TokenType.FUNCTION, position, length); }
Example 10
Source File: Source.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Fetch a portion of source content associated with a token. * @param token Token descriptor. * @return Source content portion. */ public String getString(final long token) { final int start = Token.descPosition(token); final int len = Token.descLength(token); return new String(data(), start, len); }
Example 11
Source File: RecompilableScriptFunctionData.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private static long tokenFor(final FunctionNode fn) { final int position = Token.descPosition(fn.getFirstToken()); final int length = Token.descPosition(fn.getLastToken()) - position + Token.descLength(fn.getLastToken()); return Token.toDesc(TokenType.FUNCTION, position, length); }
Example 12
Source File: Source.java From jdk8u_nashorn with GNU General Public License v2.0 | 4 votes |
/** * Fetch a portion of source content associated with a token. * @param token Token descriptor. * @return Source content portion. */ public String getString(final long token) { final int start = Token.descPosition(token); final int len = Token.descLength(token); return new String(data(), start, len); }
Example 13
Source File: Node.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * Return token position from a token descriptor. * * @return Start position of the token in the source. */ public int position() { return Token.descPosition(token); }
Example 14
Source File: Node.java From TencentKona-8 with GNU General Public License v2.0 | 2 votes |
/** * Return token position from a token descriptor. * * @return Start position of the token in the source. */ public int position() { return Token.descPosition(token); }
Example 15
Source File: ParserException.java From jdk8u_nashorn with GNU General Public License v2.0 | 2 votes |
/** * Get token position within source where the error originated. * @return token position if available, else -1 */ public int getPosition() { return Token.descPosition(token); }
Example 16
Source File: Node.java From jdk8u60 with GNU General Public License v2.0 | 2 votes |
/** * Constructor * * @param token token * @param finish finish */ public Node(final long token, final int finish) { this.token = token; this.start = Token.descPosition(token); this.finish = finish; }
Example 17
Source File: Node.java From TencentKona-8 with GNU General Public License v2.0 | 2 votes |
/** * Constructor * * @param token token * @param finish finish */ public Node(final long token, final int finish) { this.token = token; this.start = Token.descPosition(token); this.finish = finish; }
Example 18
Source File: Node.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 2 votes |
/** * Return token position from a token descriptor. * * @return Start position of the token in the source. */ public int position() { return Token.descPosition(token); }
Example 19
Source File: Node.java From hottub with GNU General Public License v2.0 | 2 votes |
/** * Constructor * * @param token token * @param finish finish */ public Node(final long token, final int finish) { this.token = token; this.start = Token.descPosition(token); this.finish = finish; }
Example 20
Source File: Node.java From openjdk-jdk8u with GNU General Public License v2.0 | 2 votes |
/** * Return token position from a token descriptor. * * @return Start position of the token in the source. */ public int position() { return Token.descPosition(token); }