Problem with CDI Builder creating new 'A' type
by Xavier Coulon
Hello Daniel,
As I'm trying to fix https://issues.jboss.org/browse/JBIDE-12095, I found something a bit strange in the CDIBuilderDelegate when editing a 'package-info.java' file (just adding a space char):
At line 90, the CDIBuilderDelegate#build() method calls the PackageDelegate#setPackage() method below which creates a 'class A {}' as shown below.
public void setPackage(IPackageDeclaration pkg, IRootDefinitionContext context) {
qualifiedName = pkg.getElementName();
IType contextType = null;
ICompilationUnit u = null;
if(pkg.getParent() instanceof ICompilationUnit) {
try {
u = ((ICompilationUnit)pkg.getParent()).getWorkingCopy(new NullProgressMonitor());
contextType = u.createType("class A {}", null, false, new NullProgressMonitor());
} catch (JavaModelException e) {
}
}
super.setAnnotatable(pkg, contextType, context, 0);
if (u != null) {
try {
u.discardWorkingCopy();
} catch (JavaModelException e) {
}
}
}
The JAX-RS plugin catches an event for this type creation but fails later. I can add some tests to verify that the type really exist, but still, is this necessary (just asking, don't take is bad) ?
Thanks.
Best regards,
/Xavier
12 years, 5 months