This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 24441 - [completion] Synchronization problem between java parser and completion
Summary: [completion] Synchronization problem between java parser and completion
Status: VERIFIED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 3.x
Hardware: PC Windows ME/2000
: P4 blocker (vote)
Assignee: issues@editor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-06-05 15:00 UTC by Jan Kovar
Modified: 2007-11-05 13:44 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Thread dump while invoking code completion (IDE freezed). (37.27 KB, text/plain)
2002-06-11 13:45 UTC, Jan Lahoda
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kovar 2002-06-05 15:00:05 UTC
1. Get some class with constructor with at least one 
parameter
2. In explorer open the list of constructor of that class 
3. prepare the string for using code completetion
4. save all and wait few sec to be sure parsing is ok.
5. check code completetion
6. change the parameter name or type
7. use arrow keys to get to place where you are checking 
code completetion
8. check code completetion
9. The code completetion should show old values.

If you repeat the same, but you will wait few seconds 
before step 8. all will work ok.
It looks like that if you use code completetion before the
parser manages to reparse the source code the old values 
will be remembered also after the parser will reparse the 
source.
Comment 1 Jan Kovar 2002-06-10 10:17:13 UTC
I think I found what is causing the problem.

In NBJavaSyntaxSupport within refreshClassInfo method the 
check for jcValid property is causing that the classInfo 
is not refreshed.

So, now it works in following way:
1. When the Code Completition is called for the first 
time, the classInfo is refreshed and jcValid is set to 
true. However in some cases the parser still did not 
finish the parsing and therefore old information is 
displayed (so far ok)
2. Now the problem is that when parser finished the 
parsing the jcValid property is not set back to false. So 
when CC is called again without any source modification it 
does not refresh the classInfo.

Possible solutions:
1. Remove jcValid check - probably easiest but probably 
not good 
2. Set up jcValid to false when the java parser is 
finished with parsing...
Comment 2 Martin Roskanin 2002-06-10 15:32:46 UTC
fixed in [maintrunk]

it was neccessary to reparse source element during refreshClassInfo()
operation ...

/cvs/editor/src/org/netbeans/modules/editor/java/NbJavaSyntaxSupport.java,v
 <--  NbJavaSyntaxSupport.java
new revision: 1.37; previous revision: 1.36
Comment 3 Martin Roskanin 2002-06-10 15:34:09 UTC
Honza, thank you for your help with the fixing.
Comment 4 Jan Lahoda 2002-06-11 13:42:51 UTC
This fix probably introduces huge performance regression:
1. Open a file.
2. Into some method try to write "Toolk".
3. Invoke Code completion.
4. Change text ("Toolk" to something similar ["Tool"]).
5. Repeat 3&4. Sometimes happens that Code completion block AWT for a
while (10-15 seconds). I will attach thread dump from such a situation.
Comment 5 Jan Lahoda 2002-06-11 13:45:15 UTC
Created attachment 6203 [details]
Thread dump while invoking code completion (IDE freezed).
Comment 6 Martin Roskanin 2002-06-11 14:08:27 UTC
fixed in [maintrunk]

Now AWT thread is not blocking by waiting for parsing finish. 

/cvs/editor/src/org/netbeans/modules/editor/java/NbJavaSyntaxSupport.java,v
 <--  NbJavaSyntaxSupport.java
new revision: 1.38; previous revision: 1.37


Comment 7 Martin Roskanin 2003-05-16 14:08:56 UTC
This problem also affects the retrieving the members of some private
variable.

private String s;
void foo(){
   s.|
}

Invoke the completion after "s.". It should show members of String.
Then delete or comment s. (make source compilable) and save the
document. Try to invoke the completion in the same place after "s."
again. Completion is not shown even after several invocations.
Document has to be modified to workaround this.
Comment 8 Martin Roskanin 2003-05-16 14:09:59 UTC
Sorry, the last comment belongs to the issue #33509
Comment 9 Quality Engineering 2003-06-30 18:01:02 UTC
Resolved for 3.3.x or earlier, no new info since then -> closing.
Comment 10 Quality Engineering 2003-06-30 18:13:06 UTC
Resolved for 3.3.x or earlier, no new info since then -> closing.
Comment 11 Martin Roskanin 2003-11-18 13:16:28 UTC
Reopened due to performance reasons (issue #34732). The fix was
rollbacked.
Comment 12 Martin Roskanin 2004-02-13 13:47:56 UTC
fixed in [maintrunk]

/cvs/editor/src/org/netbeans/modules/editor/java/NbJavaSyntaxSupport.java,v
 <--  NbJavaSyntaxSupport.java
new revision: 1.48; previous revision: 1.47

How to easy reproduce and test the fixed problem:

1.create class that contains only one variable 
int i;
2.save the source
3. create second variable 
int j; and immediately invoke completion by CTRL+SPACE
variable j is missing in completion and if you reopen completion
window it will not be display again. As a workaround the source needs
to be modified and reparse again.

The fix attached a listener to java parser, so the completion DB is
updated immediately after java source hierarchy is updated. (After 2
seconds of idle time by default)
Comment 13 Roman Strobl 2005-02-04 15:45:10 UTC
Verified in 200502031900.