How to find CtCompilationUnit with spoon?
- Dominant language
- Java
- Stars
- 2k
- Forks
- 392
- Avg merge
- 11h 24m
- Merged PRs (30d)
- 36
Description
As I known, each java file can be parsed as a single CompilationUnit in eclipse jdt. I find that spoon has **CtCompilationUnit**
but It doesn't work. I don't know where is the problem.Here is my test code.
```
public class Demo {
public static void main(String[] args) {
Node node = new Node();
node.run();
}
public void run() {
System.out.println("Demo run");
}
}
class Node {
public void run() {
System.out.println("run");
}
}
```
I can use spoon to get each CtMethod info like this.
``` CtModel model = launcher.getModel();
CtPackage rootPackage = model.getRootPackage();
model.getElements(new AbstractFilter() { //CtCompilationUnit will get nothing?
@Override public boolean matches(CtMethod element) {
System.out.println(element.getPosition());
return true;
}
});
```
However, If i use filter to collect CtCompilationUnit, I get nothing. Anyone can tell me if I miss something?
Contributor guide
Assessment
This issue has not been assessed yet.