当前位置: 首页>>代码示例>>Java>>正文


Java ASTNode.getLastLineNumber方法代码示例

本文整理汇总了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()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:GroovyGradleDetector.java

示例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;
}
 
开发者ID:apache,项目名称:groovy,代码行数:37,代码来源:GeneralUtils.java

示例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);
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:SourceText.java

示例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()));
}
 
开发者ID:mParticle,项目名称:mparticle-android-sdk,代码行数:12,代码来源:GradleBuildDetector.java

示例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());
}
 
开发者ID:apache,项目名称:groovy,代码行数:5,代码来源:RuntimeParserException.java

示例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());
}
 
开发者ID:apache,项目名称:groovy,代码行数:4,代码来源:SyntaxException.java


注:本文中的org.codehaus.groovy.ast.ASTNode.getLastLineNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。