本文整理汇总了Java中org.codehaus.groovy.ast.ASTNode.getLastLineNumber方法的典型用法代码示例。如果您正苦于以下问题:Java ASTNode.getLastLineNumber方法的具体用法?Java ASTNode.getLastLineNumber怎么用?Java ASTNode.getLastLineNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.ast.ASTNode
的用法示例。
在下文中一共展示了ASTNode.getLastLineNumber方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLocation
import org.codehaus.groovy.ast.ASTNode; //导入方法依赖的package包/类
@Override
protected Location createLocation(@NonNull Context context, @NonNull Object cookie) {
ASTNode node = (ASTNode) cookie;
Pair<Integer, Integer> offsets = getOffsets(node, context);
int fromLine = node.getLineNumber() - 1;
int fromColumn = node.getColumnNumber() - 1;
int toLine = node.getLastLineNumber() - 1;
int toColumn = node.getLastColumnNumber() - 1;
return Location.create(context.file,
new DefaultPosition(fromLine, fromColumn, offsets.getFirst()),
new DefaultPosition(toLine, toColumn, offsets.getSecond()));
}
示例2: convertASTToSource
import org.codehaus.groovy.ast.ASTNode; //导入方法依赖的package包/类
/**
* Converts an expression into the String source. Only some specific expressions like closure expression
* support this.
*
* @param readerSource a source
* @param expression an expression. Can't be null
* @return the source the closure was created from
* @throws java.lang.IllegalArgumentException when expression is null
* @throws java.lang.Exception when closure can't be read from source
*/
public static String convertASTToSource(ReaderSource readerSource, ASTNode expression) throws Exception {
if (expression == null) throw new IllegalArgumentException("Null: expression");
StringBuilder result = new StringBuilder();
for (int x = expression.getLineNumber(); x <= expression.getLastLineNumber(); x++) {
String line = readerSource.getLine(x, null);
if (line == null) {
throw new Exception(
"Error calculating source code for expression. Trying to read line " + x + " from " + readerSource.getClass()
);
}
if (x == expression.getLastLineNumber()) {
line = line.substring(0, expression.getLastColumnNumber() - 1);
}
if (x == expression.getLineNumber()) {
line = line.substring(expression.getColumnNumber() - 1);
}
//restoring line breaks is important b/c of lack of semicolons
result.append(line).append('\n');
}
String source = result.toString().trim();
return source;
}
示例3: hasPlausibleSourcePosition
import org.codehaus.groovy.ast.ASTNode; //导入方法依赖的package包/类
private static boolean hasPlausibleSourcePosition(ASTNode node) {
return node.getLineNumber() > 0
&& node.getColumnNumber() > 0
&& node.getLastLineNumber() >= node.getLineNumber()
&& node.getLastColumnNumber() >
(node.getLineNumber() == node.getLastLineNumber() ? node.getColumnNumber() : 0);
}
示例4: createLocation
import org.codehaus.groovy.ast.ASTNode; //导入方法依赖的package包/类
private Location createLocation(@NonNull Context context, @NonNull Object cookie) {
ASTNode node = (ASTNode) cookie;
Pair<Integer, Integer> offsets = getOffsets(node, context);
int fromLine = node.getLineNumber() - 1;
int fromColumn = node.getColumnNumber() - 1;
int toLine = node.getLastLineNumber() - 1;
int toColumn = node.getLastColumnNumber() - 1;
return Location.create(context.file,
new DefaultPosition(fromLine, fromColumn, offsets.getFirst()),
new DefaultPosition(toLine, toColumn, offsets.getSecond()));
}
示例5: createSyntaxErrorMessage
import org.codehaus.groovy.ast.ASTNode; //导入方法依赖的package包/类
private Message createSyntaxErrorMessage(String message, ASTNode node) {
return new SyntaxErrorMessage(
new SyntaxException(message, node.getLineNumber(), node.getColumnNumber(),
node.getLastLineNumber(), node.getLastColumnNumber()),
getSourceUnit());
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:DependencyManagementBomTransformation.java
示例6: throwParserException
import org.codehaus.groovy.ast.ASTNode; //导入方法依赖的package包/类
public void throwParserException() throws SyntaxException {
final ASTNode node = getNode();
throw new SyntaxException(getMessage(), node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber());
}
示例7: SyntaxException
import org.codehaus.groovy.ast.ASTNode; //导入方法依赖的package包/类
public SyntaxException(String message, ASTNode node) {
this(message, node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber());
}