本文整理汇总了Java中org.codehaus.groovy.ast.ClassNode.getName方法的典型用法代码示例。如果您正苦于以下问题:Java ClassNode.getName方法的具体用法?Java ClassNode.getName怎么用?Java ClassNode.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.ast.ClassNode
的用法示例。
在下文中一共展示了ClassNode.getName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import org.codehaus.groovy.ast.ClassNode; //导入方法依赖的package包/类
/**
* @see org.codehaus.groovy.control.CompilationUnit.ClassgenCallback#call(
* groovyjarjarasm.asm.ClassVisitor,
* org.codehaus.groovy.ast.ClassNode)
*/
@Override
public void call(ClassVisitor writer, ClassNode node) throws CompilationFailedException
{
classCount++;
String name = node.getName();
if (!classes.containsKey(name))
{
byte[] bytes = ((ClassWriter) writer).toByteArray();
classes.put(name, bytes);
}
}
示例2: getCompiledFiles
import org.codehaus.groovy.ast.ClassNode; //导入方法依赖的package包/类
private List<OutputItem> getCompiledFiles(CompilationUnit compilationUnit) throws IOException {
File targetDirectory = compilationUnit.getConfiguration().getTargetDirectory();
if (forStubs) {
return getStubOutputItems(compilationUnit, targetDirectory);
}
final SortedSet<String> allClasses = new TreeSet<String>();
//noinspection unchecked
List<GroovyClass> listOfClasses = compilationUnit.getClasses();
for (GroovyClass listOfClass : listOfClasses) {
allClasses.add(listOfClass.getName());
}
List<OutputItem> compiledFiles = new ArrayList<OutputItem>();
for (Iterator iterator = compilationUnit.iterator(); iterator.hasNext();) {
SourceUnit sourceUnit = (SourceUnit) iterator.next();
String fileName = sourceUnit.getName();
//for debug purposes
//System.out.println("source: " + fileName);
//System.out.print("classes:");
final ModuleNode ast = sourceUnit.getAST();
final List<ClassNode> topLevelClasses = ast.getClasses();
for (ClassNode classNode : topLevelClasses) {
final String topLevel = classNode.getName();
final String nested = topLevel + "$";
final SortedSet<String> tail = allClasses.tailSet(topLevel);
for (Iterator<String> tailItr = tail.iterator(); tailItr.hasNext(); ) {
String className = tailItr.next();
if (className.equals(topLevel) || className.startsWith(nested)) {
tailItr.remove();
compiledFiles.add(new OutputItem(targetDirectory, className.replace('.', '/') + ".class", fileName));
}
else {
break;
}
}
}
}
return compiledFiles;
}