Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 311100 - [project explorer] Once I expand the Source Node under JavaScript Resources it never refreshes
Summary: [project explorer] Once I expand the Source Node under JavaScript Resources i...
Status: RESOLVED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 RC2   Edit
Assignee: Nitin Dahyabhai CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard: PMC_approved
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-29 15:26 EDT by Chris Jaun CLA
Modified: 2010-05-19 23:56 EDT (History)
1 user (show)

See Also:
david_williams: pmc_approved+
thatnitind: pmc_approved? (raghunathan.srinivasan)
thatnitind: pmc_approved? (naci.dai)
thatnitind: pmc_approved? (deboer)
thatnitind: pmc_approved? (neil.hauge)
thatnitind: pmc_approved? (kaloyan)
cmjaun: review+


Attachments
proposed patch (1.91 KB, patch)
2010-05-19 01:00 EDT, Nitin Dahyabhai CLA
no flags Details | Diff
updated patch - only updates from resource changes (1.99 KB, patch)
2010-05-19 07:50 EDT, Nitin Dahyabhai CLA
no flags Details | Diff
updated patch - includes other files (3.82 KB, patch)
2010-05-19 13:50 EDT, Nitin Dahyabhai CLA
no flags Details | Diff
Add #hashCode() to ProjectLibraryRoot and NamespaceGroup (4.23 KB, patch)
2010-05-19 20:44 EDT, Nitin Dahyabhai CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Jaun CLA 2010-04-29 15:26:44 EDT
I crated a JS file with some functions.
I expanded the source folder node under JavaScript Resources.

My functions were displayed.

I added new functions(while the node remained expanded). It never updated.

I closed and re-expanded the node. Still no update.

It only updated if I right-clicked and did a Refresh.
Comment 1 Nitin Dahyabhai CLA 2010-05-03 18:30:04 EDT
What about when you save the file?
Comment 2 Chris Jaun CLA 2010-05-04 09:38:02 EDT
Nope.
Comment 3 Nitin Dahyabhai CLA 2010-05-19 01:00:54 EDT
Created attachment 169048 [details]
proposed patch
Comment 4 Nitin Dahyabhai CLA 2010-05-19 07:50:45 EDT
Created attachment 169092 [details]
updated patch - only updates from resource changes
Comment 5 Chris Jaun CLA 2010-05-19 10:42:54 EDT
I get an error when applying your patch.

The method getParent() is undefined for the type NamespaceGroup	PackageExplorerContentProvider.java	/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/packageview	line 657
Comment 6 Nitin Dahyabhai CLA 2010-05-19 13:50:10 EDT
Created attachment 169163 [details]
updated patch - includes other files
Comment 7 Chris Jaun CLA 2010-05-19 15:13:19 EDT
Applied new patch.

No more error.

I have verified the fix works.
Comment 8 Nitin Dahyabhai CLA 2010-05-19 17:45:48 EDT
* Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such. 

For 3.2 we've made the types, functions, and variables in the user's source folders visible under the JavaScript Resources node along with the libraries and containers from previous releases.  Previously there was no way of getting an overall picture of the types in the user's sources.  Without this fix, the contents of the node representing the user's source folder won't update automatically, rendering the feature pretty much useless.

* Is there a work-around? If so, why do you believe the work-around is insufficient? 

The workaround is to manually refreshing the JavaScript Resources node for the source folder every time a JavaScript file is written to disk.  It's not obvious that this would be needed, and while it's the only place where it would be needed, the user's own sources are where these kinds of changes are most expected.

* How has the fix been tested? Is there a test case attached to the Bugzilla record? Has a JUnit Test been added? 

Tested by Chris and I, no JUnit.

* Give a brief technical overview. Who has reviewed this fix? 

Reviewed by Chris.  The JSDT content provider method for handling IJavaScriptElementDeltas will request a refresh of the parent node if a compilation unit's contents change and the delta was caused by a file modification.  The parent has to be refreshed because, by design, we don't show a node for the file itself in this part of the tree.

* What is the risk associated with this fix? 
Low as it only affects what's visible in the common navigator.  Only queuing a refresh when the file is also modified on-disk prevents it from being a performance problem while the contents are being updated in the editor without saving, but it still takes non-zero time to refresh that part of the tree.
Comment 9 David Williams CLA 2010-05-19 20:14:00 EDT
if you implement 'equals' shouldn't you implement 'hashcode' too?
Comment 10 Nitin Dahyabhai CLA 2010-05-19 20:44:50 EDT
Created attachment 169254 [details]
Add #hashCode() to ProjectLibraryRoot and NamespaceGroup

(In reply to comment #9)
> if you implement 'equals' shouldn't you implement 'hashCode' too?

Yes.
Comment 11 Nitin Dahyabhai CLA 2010-05-19 21:48:39 EDT
Committing.