Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 345417

Summary: ASTParser cannot resolve bindings for newly added secondary types
Product: [Eclipse Project] JDT Reporter: Missing name <noth>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann, satyam.kandula
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug
Attachments:
Description Flags
Plugin Project mentioned in the desription
none
Testcode which should be added to the runtime workspace none

Description Missing name CLA 2011-05-11 09:24:52 EDT
Build Identifier: 20110218-0911

We created a plugin project (using the "Plugin with an incremental project builder" template). In each build we look at all new or modified java files and create the AST of them using the ASTParser. Afterwards our AST visitor (SampleASTVisitor) walks over the AST and checks the bindings of constructor invocations.

When we copy files with constructor calls to non-public classes which are definied in another compilationunit (see the attached example code) the bindings for these constructor invocations is null, although the code does not contain syntax errors.

If we force a full build (for example by a clean), these bindings are resolved and not null. This would be the expected result in the step before.

Reproducible: Always

Steps to Reproduce:
1. load attached project "SampleProject" to your workspace
2. Run project as eclipse application
3. create empty java project in the runtime workspace
4. add Sample nature to the project
5. copy attached test code to the java project
6. now a message appears in the console, which says, that the binding is null
Comment 1 Missing name CLA 2011-05-11 09:27:18 EDT
Created attachment 195344 [details]
Plugin Project mentioned in the desription
Comment 2 Missing name CLA 2011-05-11 09:27:50 EDT
Created attachment 195345 [details]
Testcode which should be added to the runtime workspace
Comment 3 Satyam Kandula CLA 2011-05-13 11:17:43 EDT
If I attach the test code in a source folder, I don't see any problem.
Comment 4 Olivier Thomann CLA 2011-05-13 13:19:55 EDT
Satyam, please follow up.
Comment 5 Missing name CLA 2011-05-25 08:01:07 EDT
Maybe our description was not clear, steph 5 should be:
5. drag and drop the test code from windows explorer to the java project in eclipse

the message, saying that the binding is null should always appear if you do it like this
Comment 6 Satyam Kandula CLA 2011-05-25 08:15:30 EDT
(In reply to comment #5)
> Maybe our description was not clear, steph 5 should be:
> 5. drag and drop the test code from windows explorer to the java project in
> eclipse
> 
> the message, saying that the binding is null should always appear if you do it
> like this
Are you having the problem even if you drag and drop to a source folder of the java project?
Comment 7 Missing name CLA 2011-05-25 09:10:13 EDT
yes, i tested it with a source folder. can you try to delete the files from your project and then copy them again? then the message should appear.
Comment 8 Missing name CLA 2011-07-04 06:10:57 EDT
any news? can you reproduce the problem?
Comment 9 Satyam Kandula CLA 2011-07-04 07:46:40 EDT
(In reply to comment #8)
> any news? can you reproduce the problem?
Sorry for the delay. Yes, I am able to reproduce the problem when copying from the windows explorer. If used by importing the file system, it works good. 
This is a timing issues. Compiler gets the list of the secondary types from the search module and the indexing runs in another thread and if that isn't ready, we seem to end up in this problem. I will investigate further.
Comment 10 Satyam Kandula CLA 2011-07-04 10:06:50 EDT
AST creation doesn't wait for indexing to complete causing this problem. One way to fix is by waiting for the indexing to complete, which will cause considerable performance degradation. I will see if I can find a fix, but that looks to be hard :(.

A workaround is to call a dummy search.
Comment 11 Satyam Kandula CLA 2011-07-04 11:48:46 EDT
(In reply to comment #10)
> AST creation doesn't wait for indexing to complete causing this problem. One
> way to fix is by waiting for the indexing to complete, which will cause
> considerable performance degradation. I will see if I can find a fix, but that
> looks to be hard :(.
> 
> A workaround is to call a dummy search.

or even wait for a while!
Comment 12 Missing name CLA 2011-07-04 12:57:49 EDT
thx for your effort, we will try the workaround
Comment 13 Eclipse Genie CLA 2019-06-20 17:35:31 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.