eclipse-jdt / eclipse-jdt/eclipse.jdt.core
Long parse and resolve time for class with many class expressions in annotations
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/1056 discusses the slowness -- 1 second-ish parse and resolve -- for junit suite classes. TL;DR is these are classes with `@Suite.SuiteClasses({ /*dozens of class expressions*/ })` annotation. In order for Run As > JUnit * to determine if it is applicable, the `JUnit4TestFinder` runs a typical parse and create bindings sequence:
```java
// excerpt from JUnit4TestFinder
ASTParser parser= ASTParser.newParser(AST.getJLSLatest());
parser.setSource(type.getCompilationUnit());
parser.setFocalPosition(0);
parser.setResolveBindings(true);
CompilationUnit root= (CompilationUnit) parser.createAST(monitor);
ASTNode node= root.findDeclaringNode(type.getKey());
if (node instanceof TypeDeclaration || node instanceof RecordDeclaration) {
ITypeBinding binding= ((AbstractTypeDeclaration) node).resolveBinding();
if (binding != null) {
return isTest(binding);
}
}
```
This takes quite a long time (noticeable UI pause) for such test suite classes. This is further noticeable if user has PDE tooling installed, in which case "JUnit Test" and "JUnit Plug-in Test" detection both parse the source independently (in series?) or if user has JUnt 4 and JUnit 5 types on the classpath.
Could someone please have a look at the parsing and binding resolution to see why such files take so long? In my specific case, I supply the classes as fully-qaulified names, so I am unsure why type resolution takes so long.
Contributor guide
Assessment
This issue has not been assessed yet.