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

Bug 153449

Summary: [preferences] Code folding has completely disappeared
Product: [Eclipse Project] JDT Reporter: Mark Melvin <mark.melvin>
Component: TextAssignee: Dani Megert <daniel_megert>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: david_williams, mik.kersten
Version: 3.2   
Target Milestone: 3.2.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
A bunch of screenshots
none
My eclipse configuration none

Description Mark Melvin CLA 2006-08-10 11:31:23 EDT
I do not know how I got my platform into this state but it has been like this for awhile and I cna't figure it out.  I have completely lost all ability to use and even see code folding, even though the actions and preference settings all seem to think it is still there and working/available.  

I can enable and disable folding, and I see my editor margin increase/decrease in size providing a gutter for the code folding markers to appear in, but they simply aren't there.  Also, all of the menu options to expand all and collapse all are there and enabled but they do nothing.

I'll attach a bunch of screenshots and my platform configuration info.

Things of note:

I am running Eclipse 3.2 on Windows XP, and my workspace is set up for feature-based self-hosting.
Comment 1 Mark Melvin CLA 2006-08-10 11:31:59 EDT
Created attachment 47700 [details]
A bunch of screenshots
Comment 2 Mark Melvin CLA 2006-08-10 11:32:22 EDT
Created attachment 47701 [details]
My eclipse configuration
Comment 3 Mark Melvin CLA 2006-08-10 11:37:25 EDT
Actually, I just saw this in my exported preferences:

/instance/org.eclipse.jdt.ui/editor_folding_provider=org.eclipse.mylar.java.ui.editor.foldingprovider

And I don't have Mylar installed.  I'm betting this is the problem.  I'll try to get rid of it and see what happens.
Comment 4 Mark Melvin CLA 2006-08-10 11:40:58 EDT
Nevermind!  That was it.  I'll set this to INVALID.  Sorry for the noise.
Comment 5 David Williams CLA 2006-08-10 13:28:09 EDT
Mark .. I'm not sure this was noise. 

I assume you had mylar installed at some point, it (or you) set some preference data, and then you uninstalled mylar. 

Seems a normal scenerio ... and seems there ought to be some way to (easily) filter out preferences of things no longer installed. ... easier than asking users to had edit their preference files :) 

Any suggestions? Based on how you, presumably, got into this state? 
Comment 6 Mark Melvin CLA 2006-08-10 13:46:36 EDT
Well, I think the actual sequence of events here was:

1) Installed Mylar because it was cool.
2) Exported my preferences at some point to keep my comment templates, etc.
3) Found Mylar was locking up my Eclipse occasionally so I removed it.
4) Some point down the road, I upgraded my Eclipse to 3.2, then re-imported my *old* exported settings to get my comment templates back.

So, basically I think I imported a set of preferences that was both from an older platform (maybe an earlier milestone build of 3.2 - or even 3.1?), and contained preference settings from non-existent plugins.
I assume the persisted plugin version ensures that only compatible preferences are imported, although I am unsure what algorithm it uses.
But there is another dimension.  Normally, I just upgrade my Eclipse when a new version comes out, then open it up on my old workspace.  So, what happens in this case?

There are two ways you can get version conflicts here.  Through importing preference directly, or through opening an old workspace with old preferences persisted.  Is this handled differently or the same?  I'm not sure.

I guess the problem here was not so much that the preference *key* was from a non-existing plugin (I assume that wouldn't have caused a problem), but rather the preference *value* pointed to a non-existing class.  I guess it could be a JDT bug then.
Comment 7 Dani Megert CLA 2006-08-10 17:57:37 EDT
Hi Mik. Is this another (like code assist) where Mylar hijacks JDT Text features and leaves them in a bad state once Mylar isn't present?
Comment 8 Dani Megert CLA 2006-08-10 18:08:04 EDT
>Seems a normal scenerio ...
Well, no. We are not supposed to expect that people replace stuff (e.g. JDT code assist or folding) with their own unless we provide clean extension points. Ways to prevent this in the future are
- we make more code private
- we throw exceptions when we detect that we are hijacked and things aren't as they should be

Of course we don't do this and are friendly but expect others to be as well but as a reward we get blamed - not a normal scenario if you ask me.

>Any suggestions? Based on how you, presumably, got into this state? 
Now that we know we can force our folding provider to be installed again once we detect that the current one doesn't even exist. Mik, can you confirm this?
Comment 9 Dani Megert CLA 2006-08-11 02:13:02 EDT
Just to clarify the 'hijacks': in this case I think Mylar didn't do anything bad i.e. I assume it correctly adds a folding provider via extension point and uses preference API to set this one to be the default. The problem is that this is done via special Mylar customization UI/wizard which is later no longer available and the user is not aware that he changed preferences that he could as well change in the preference UI itself.

We will have to add code that reverts to the default folding provider in case the current one is not present.

NOTE: this trick does not work for normal int, boolean or String preferences that get changed by a plug-in and that is later deleted from an install.
Comment 10 Dani Megert CLA 2006-08-16 12:19:45 EDT
Fixed in HEAD and R3_2_maintenance.
Comment 11 David Williams CLA 2006-08-16 14:16:39 EDT
I just wanted to say "thanks Dani". While we can't all cases of "bad preferences", as you point out, fixing the cases we can is a much appreciated attention to detail. 

And who ever comes up with a general automatic solution will undoubtedly be nominated for the Nobel Prize. :) 
Comment 12 Mik Kersten CLA 2006-08-24 20:33:15 EDT
Just catching up on this now (was away on vacation).  

Mylar for Eclipse 3.1 had a custom folding provider (via org.eclipse.mylar.java.ui.editor.foldingprovider).  Mylar for 3.2 uses the standard Java folding provider.  So yes, it looks like a preference value for a non-existing provider was imported.  This case was handled gracefully if the user updated from the 3.1 to the 3.2 version of Mylar, but not if they imported old preferences.  But the reverting to the default value of the provider is not defined definitely seems like a good idea since another plug-in could do this.

Dani: the only place that it was possible for Mylar's strategy of extening JDT to leave a preference value like this undefined was the content assist computer, which was resolved by bug 140416 as you indicate.

Mark: if you try an up-to-date version of Mylar and see any of the lock-ups that you refer to please file a bug report.
Comment 13 Martin Aeschlimann CLA 2006-08-31 06:31:36 EDT
verified in M20060830-0800