Bug 290049 - Reconciling a compilation unit does not return an AST with bindings when it should (probably)
Summary: Reconciling a compilation unit does not return an AST with bindings when it s...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-21 14:30 EDT by Michael Rennie CLA
Modified: 2009-10-27 07:33 EDT (History)
4 users (show)

See Also:


Attachments
Proposed fix (2.66 KB, patch)
2009-09-23 14:17 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Rennie CLA 2009-09-21 14:30:40 EDT
I20090917-0100

Investigating a fix for bug 223315, I was trying to reconcile a compilation unit using a call to:

unit.reconcile(AST.JLS3, true, true, unit.getOwner(), null);

and noticed that I was not getting any bindings in the AST.

Talking with Olivier, he felt that we should probably be getting back an AST with bindings.
Comment 1 Michael Rennie CLA 2009-09-21 14:31:57 EDT
The compilation unit in question was for the sample snippet given in bug 223315 comment # 3
Comment 2 Markus Keller CLA 2009-09-22 10:13:04 EDT
Looks like the point of the matter is whether the WorkingCopyOwner overrides getProblemRequestor(..). I only ever see bindings when the WorkingCopyOwner actually returns an IProblemRequestor.

When the returned IProblemRequestor is null or its isActive() method returns false, I don't get bindings. Although the Javadoc of the reconcile(..) methods says "Its bindings are computed only if the problem requestor is active, or if the problem detection is forced", it looks like it actually implements "*and* if the problem detection is forced" (maybe also if problem detection is not forced but the working copy is not consistent -- I didn't check that).

I made my observations by tweaking ASTView#createAST(ITypeRoot, int, int) from 
jdt-ui-home/plugins/org.eclipse.jdt.astview .
Comment 3 Olivier Thomann CLA 2009-09-22 10:20:24 EDT
This is exactly what we noticed yesterday and I believe this is inconsistent.
Would it be a problem for you to fix this or you have code that relies on this behavior ?
Comment 4 Markus Keller CLA 2009-09-23 10:49:16 EDT
> Would it be a problem for you to fix this or you have code that relies on this
> behavior ?

You mean you want to completely implement the Javadoc, i.e. return bindings also with an inactive or inexistent problem requestor if problem detection is being forced? I don't think we expect anywhere to get no bindings there, so that fix would be fine with me (it won't affect us).
Comment 5 Dani Megert CLA 2009-09-23 12:28:21 EDT
Right, the behavior will not be affected but it can have a performance hit as this will result in more work in certain scenarios. At this point please don't touch this and simply update the Javadoc, especially since it's not really needed that we fix this now.

Also note that the fix would not even fix any client issue if the owner is the default one as the editor reconciler only activates the problem requestor when he's running.
Comment 6 Olivier Thomann CLA 2009-09-23 12:35:07 EDT
That's fine for me. Much simpler to fix :-).
Comment 7 Olivier Thomann CLA 2009-09-23 14:17:54 EDT
Created attachment 147915 [details]
Proposed fix
Comment 8 Olivier Thomann CLA 2009-09-23 14:19:31 EDT
Bindings are only created if the problem reporter is active.

I removed the mention to ", or if the problem detection is forced" for all reconcile methods as this clearly doesn't match the current implementation. Changing that might have a bad side-effect for existing clients in term of performance.

Released for 3.6M3.
Comment 9 Ayushman Jain CLA 2009-10-27 06:42:39 EDT
Verified for 3.6M3