本文整理汇总了Java中jdk.nashorn.internal.parser.Token.descLength方法的典型用法代码示例。如果您正苦于以下问题:Java Token.descLength方法的具体用法?Java Token.descLength怎么用?Java Token.descLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.parser.Token
的用法示例。
在下文中一共展示了Token.descLength方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeComments
import jdk.nashorn.internal.parser.Token; //导入方法依赖的package包/类
/**
* Removes all commentaries from some JavaScript code.
*
* @param text a source
* @return comments-free JavaScript code
*/
public static String removeComments(String text) {
StringBuilder sb = new StringBuilder();
int i = 0;
for (Long t : getCommentsTokens(text)) {
int offset = Token.descPosition(t);
int lenght = Token.descLength(t);
sb.append(text.substring(i, offset));
for (int j = 0; j < lenght; j++) {
sb.append(" ");//NOI18N
}
i = offset + lenght;
}
sb.append(text.substring(i));
return sb.toString();
}
示例2: tokenFor
import jdk.nashorn.internal.parser.Token; //导入方法依赖的package包/类
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);
}
示例3: getString
import jdk.nashorn.internal.parser.Token; //导入方法依赖的package包/类
/**
* 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);
}
示例4: getString
import jdk.nashorn.internal.parser.Token; //导入方法依赖的package包/类
/**
* 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(content, start, len);
}
示例5: tokenFor
import jdk.nashorn.internal.parser.Token; //导入方法依赖的package包/类
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);
}
示例6: length
import jdk.nashorn.internal.parser.Token; //导入方法依赖的package包/类
/**
* Return token length from a token descriptor.
*
* @return Length of the token.
*/
public int length() {
return Token.descLength(token);
}