本文整理汇总了Java中org.codehaus.groovy.ast.ASTNode.getText方法的典型用法代码示例。如果您正苦于以下问题:Java ASTNode.getText方法的具体用法?Java ASTNode.getText怎么用?Java ASTNode.getText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.ast.ASTNode
的用法示例。
在下文中一共展示了ASTNode.getText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.codehaus.groovy.ast.ASTNode; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
String pathToGradle = System.getProperty("user.home")
+ "/.gradle/wrapper/dists/gradle-3.1-bin/37qejo6a26ua35lyn7h1u9v2n/gradle-3.1";
StringBuilder buildScript = new StringBuilder();
buildScript.append("subProjects{\n");
buildScript.append(" apply from: \"${rootProject.projectDir}/subX.gradle\"\n");
buildScript.append("}");
buildScript.append("allProjects{\n");
buildScript.append(" apply from: \"${rootProject.projectDir}/allX.gradle\"\n");
buildScript.append("}");
Future<EGradleBuildscriptResult> futureStatement = new GradleBuildScriptResultBuilder()
.build(buildScript.toString(), pathToGradle);
EGradleBuildscriptResult buildscriptResult = futureStatement.get();
ASTNode statement = buildscriptResult.getNode();
if (buildscriptResult.getException()!=null){
buildscriptResult.getException().printStackTrace(System.err);
return;
}
String text = statement != null ? statement.getText() : "error:";
System.out.println("script:" + text);
GradleBuildScriptResultInspector inspector = new GradleBuildScriptResultInspector();
inspector.inspect(statement);
}
示例2: getRefDescriptor
import org.codehaus.groovy.ast.ASTNode; //导入方法依赖的package包/类
private static String getRefDescriptor(ASTNode ref) {
if (ref instanceof FieldNode) {
FieldNode f = (FieldNode) ref;
return "the field "+f.getName()+" ";
} else if (ref instanceof PropertyNode) {
PropertyNode p = (PropertyNode) ref;
return "the property "+p.getName()+" ";
} else if (ref instanceof ConstructorNode) {
return "the constructor "+ref.getText()+" ";
} else if (ref instanceof MethodNode) {
return "the method "+ref.getText()+" ";
} else if (ref instanceof ClassNode) {
return "the super class "+ref+" ";
}
return "<unknown with class "+ref.getClass()+"> ";
}
示例3: getName
import org.codehaus.groovy.ast.ASTNode; //导入方法依赖的package包/类
private static String getName(ASTNode node) {
if (node instanceof FieldNode) return ((FieldNode) node).getName();
if (node instanceof PropertyNode) return ((PropertyNode) node).getName();
return node.getText();
}