Community
Participate
Working Groups
Created attachment 120547 [details] patch for requested enhancement We are building control flow graphs from Java sources using the Eclipse AST. In the case of assert statement we have to simulate an AssertionError exception. Unfortunately there is no binding information available about the AssertionError class in the AST if the class was not explicitly referenced. The patch I'm attached to this enhancement proposal contains the solution of this problem. It is a two-line modification of DefaultBindingResolver.resolveWellKnownType method.
Will consider for 3.7M2. AssertionError are linked to the assert statement and as is it mihgt be interesting to expose it as a well known type binding. Of course javadoc also needs to be updated.
Created attachment 177882 [details] Proposed fix
Released for 3.7M2. Added regression test in: org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2#test0719
I noticed two issues with the patch: 1. TESTS_NUMBERS stands uncommented. 2. In the chunk of code below: + // none of the well known bindings resolve in a plain AST + for (int i = 0; i<wkbs.length; i++) { + assertNotNull("No binding for " + wkbs[i], currentAst.resolveWellKnownType(wkbs[i])); + } + + // none of the no so well known bindings resolve either + for (int i = 0; i<nwkbs.length; i++) { + assertNull("Binding for " + nwkbs[i], currentAst.resolveWellKnownType(nwkbs[i])); + } I think the first comment is wrong. Verified for 3.7 M2 by code inspection.
(In reply to comment #4) > I noticed two issues with the patch: > 1. TESTS_NUMBERS stands uncommented > 2. In the chunk of code below: > I think the first comment is wrong. I'll fix both problems.
Done. We will contribute again to fix this issue.