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

Bug 473156

Summary: [preferences] Import formatter -> Not active
Product: [Eclipse Project] JDT Reporter: Marvin Fröhlich <eclipse>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert
Version: 3.8.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
INFOLOG Eclipse settings
none
strange.epf none

Description Marvin Fröhlich CLA 2015-07-21 05:44:49 EDT
If I import formatter rules through File->Import->Preferences, the formatter gets imported and selected. But it isn't active. I have to select another formatter, apply, select the correct formatter and apply again to make it effective.
Comment 1 Dani Megert CLA 2015-07-21 08:28:34 EDT
Works for me using http://download.eclipse.org/eclipse/downloads/drops4/R-4.5-201506032000/
Comment 2 Marvin Fröhlich CLA 2015-07-22 07:08:35 EDT
Created attachment 255348 [details]
INFOLOG Eclipse settings

I imported this into a fresh Mars workspace. And the formatter was selected, but not effective.
Comment 3 Marvin Fröhlich CLA 2015-07-22 07:09:08 EDT
Please try again using the attached preferences.
Comment 4 Dani Megert CLA 2015-07-22 07:37:08 EDT
(In reply to Marvin  Fröhlich from comment #2)
> Created attachment 255348 [details]
> INFOLOG Eclipse settings
> 
> I imported this into a fresh Mars workspace. And the formatter was selected,
> but not effective.

I can reproduce it with those preferences. Really stange! If I use a preference file where I only have the formatter profile 'Strange' and Tabs switched to Spaces, it works!

1. start new workspace
2. paste this into the 'Package Explorer'
public class C {
void bug() {

}
}
3. Format
==> default formatting prefs with Tabs are used
4. import the 'strange.epf'
5. Format
==> spaces are used


Is there something special in your preference file or in the formatter preferences? I suspect that during import an exception happens that gets swallowed. Even a restart doesn't fix the problem.
Comment 5 Dani Megert CLA 2015-07-22 07:37:30 EDT
Created attachment 255349 [details]
strange.epf
Comment 6 Dani Megert CLA 2015-07-22 08:04:25 EDT
(In reply to Dani Megert from comment #4)
> I suspect that during import an exception happens that gets
> swallowed.

Another reason for trouble could be the different profile version in the exported preferences.

Noopur, please take a look if you have some spare time. I would check whether/how the settings are stored into the JDT Core preference store.
Comment 7 Marvin Fröhlich CLA 2015-07-22 10:19:37 EDT
Well, I guess, you would consider a lot of these settings "strange" or "special". We use the logical next-line-brace style, spaces instead of tabs and spaced parentheses. Nothing too special, I think.

I set up this formatter using an Eclipse release some years back and never touched it again.

The preferences were exported using Mars though.
Comment 8 Noopur Gupta CLA 2015-08-03 07:28:14 EDT
(comment #2)
> Created attachment 255348 [details]
> INFOLOG Eclipse settings

This issue can be reproduced with Eclipse 3.8.1 also by using the attached profile.
Comment 9 Noopur Gupta CLA 2015-08-06 07:42:38 EDT
The difference between the two attached preference files which causes the bug is that the old file doesn't have any separate formatter entries like "/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.formatter...".

For Tab policy, the old file works properly if I add the following entry to it:
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.formatter.tabulation.char=space
Comment 10 Noopur Gupta CLA 2015-08-06 08:00:02 EDT
(In reply to Marvin  Fröhlich from comment #7)
> The preferences were exported using Mars though.

If I export the preferences from Mars via File > Export > Preferences, I get those separate formatter entries like "/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.formatter..." in the file, which are missing in your attached preferences file.

Can you please specify the steps of how exactly you exported the preferences.
Also, try to export the preferences again with plain Mars and check if you still don't get those entries in your file.
Comment 11 Noopur Gupta CLA 2015-08-06 08:48:22 EDT
I did some more testing and found that those extra entries are added in Mars only if you check "Export all" (which is checked by default) in the Export Preferences wizard page. If you check only "Java Code Style Preference" or check all preference types manually / using "Select All" button, then those entries are missing in the exported file and the bug can be reproduced on import.

The above behavior can be seen in Eclipse 3.8.1 also.

So looks like the bug is that those entries are not being added to exported file on checking only "Java Code Style Preference" or on checking all preference types manually / using "Select All" button.
Comment 12 Dani Megert CLA 2015-08-06 09:18:28 EDT
(In reply to Noopur Gupta from comment #11)
> I did some more testing and found that those extra entries are added in Mars
> only if you check "Export all" (which is checked by default) in the Export
> Preferences wizard page. If you check only "Java Code Style Preference" or
> check all preference types manually / using "Select All" button, then those
> entries are missing in the exported file and the bug can be reproduced on
> import.

Good catch!
Comment 13 Noopur Gupta CLA 2015-08-07 09:35:09 EDT

*** This bug has been marked as a duplicate of bug 189804 ***