use of org.codehaus.groovy.ast.ModuleNode in project spring-boot by spring-projects.
the class AnnotatedNodeASTTransformation method visit.
@Override
public void visit(ASTNode[] nodes, SourceUnit source) {
this.sourceUnit = source;
List<AnnotationNode> annotationNodes = new ArrayList<>();
ClassVisitor classVisitor = new ClassVisitor(source, annotationNodes);
for (ASTNode node : nodes) {
if (node instanceof ModuleNode) {
ModuleNode module = (ModuleNode) node;
visitAnnotatedNode(module.getPackage(), annotationNodes);
for (ImportNode importNode : module.getImports()) {
visitAnnotatedNode(importNode, annotationNodes);
}
for (ImportNode importNode : module.getStarImports()) {
visitAnnotatedNode(importNode, annotationNodes);
}
for (Map.Entry<String, ImportNode> entry : module.getStaticImports().entrySet()) {
visitAnnotatedNode(entry.getValue(), annotationNodes);
}
for (Map.Entry<String, ImportNode> entry : module.getStaticStarImports().entrySet()) {
visitAnnotatedNode(entry.getValue(), annotationNodes);
}
for (ClassNode classNode : module.getClasses()) {
visitAnnotatedNode(classNode, annotationNodes);
classNode.visitContents(classVisitor);
}
}
}
processAnnotationNodes(annotationNodes);
}
use of org.codehaus.groovy.ast.ModuleNode in project intellij-community by JetBrains.
the class GroovyCompilerWrapper method getCompiledFiles.
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;
}
Aggregations