Community
Participate
Working Groups
Build Identifier: I20110613-1736 We have the following example: package one.two; public class one { } We use the ASTParser to get the AST of the code. The binding of the PackageDeclaration 'package one.two;' is null, but the binding of the QualifiedName 'one.two' is the correct package binding. Furthermore, if we have this case, then in any other compilation unit contained in the same package, the binding of the PackageDeclaration is null. Reproducible: Always Steps to Reproduce: 1. Create a Java class 'one' in the package 'one.two'. 2. Use the ASTView to get the AST of this class. 3. Look at the binding of the PackageDeclaration. It is null. 4. Look at the binding of the QualifiedName 'one.two'. It is the expected package binding.
I'll take a look.
Created attachment 203277 [details] Patch v1
Could you please give it a try ?
The patch works perfectly. The bindings of the PackageDeclarations can now be resolved.
Since the call to org.eclipse.jdt.internal.compiler.lookup.Scope.getPackage(char[][]) with "one.two" as the name doesn't work when resolved in the context of the package "one.two" (it considers that one is the type inside the package instead of the package 'one' itself), I suggest to add a method that retrieves packages only. Srikanth, please let me know what you think. I found quite weird that getPackage(..) doesn't do the job, but trying to change it is causing more trouble.
Released for 3.8M3.
Fix verified by reporter via comment#4. (In reply to comment #5) > Srikanth, please let me know what you think. I found quite weird that > getPackage(..) doesn't do the job, but trying to change it is causing more > trouble. Agree with the approach. VERIFIED for 3.8 M3.