eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
866 stars 781 forks source link

IDE (Eclipse Photon) formatter config broken #6424

Open htreu opened 6 years ago

htreu commented 6 years ago

taken from the ESH Forum: https://www.eclipse.org/forums/index.php/t/1095926/

Original text:

I've installed the latest version of Eclipse Smart Home and it formats the JavaDoc wrong on save. For example it changes:

     * @param channelUID the {@link ChannelUID} of the channel to which the command was sent
     * @param command the {@link Command}

into:

     * @param channelUID the {@link ChannelUID} of the channel to which the command was sent
     * @param command    the {@link Command}

When I try to open the Java -> Code Style -> Formatter and want to edit a template Eclipse hangs temporary and in the log file the following exception is thrown:

!ENTRY org.eclipse.ui 4 0 2018-10-30 10:14:33.533
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.IllegalArgumentException: Alignment value is not an integer: null
    at org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants.getWrappingStyle(DefaultCodeFormatterConstants.java:4554)
    at org.eclipse.jdt.internal.ui.preferences.formatter.FormatterModifyDialog$LineWrapPreference.updateWidget(FormatterModifyDialog.java:211)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog$Preference.init(ModifyDialog.java:280)
    at org.eclipse.jdt.internal.ui.preferences.formatter.FormatterModifyDialog$LineWrapPreference.init(FormatterModifyDialog.java:205)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog$ProfilePreferenceTree.addChild(ModifyDialog.java:907)
    at org.eclipse.jdt.internal.ui.preferences.formatter.FormatterModifyDialog.lambda$20(FormatterModifyDialog.java:1225)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog$ProfilePreferenceTree$PrefBuilder.build(ModifyDialog.java:839)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog$ProfilePreferenceTree$PrefBuilder.build(ModifyDialog.java:1)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog$ProfilePreferenceTree$SectionBuilder.build(ModifyDialog.java:822)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog$ProfilePreferenceTree$SectionBuilder.build(ModifyDialog.java:1)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog$ProfilePreferenceTree$SectionBuilder.build(ModifyDialog.java:822)
    at org.eclipse.jdt.internal.ui.preferences.formatter.FormatterModifyDialog.createLineWrapTree(FormatterModifyDialog.java:1207)
    at org.eclipse.jdt.internal.ui.preferences.formatter.FormatterModifyDialog.createPreferenceTree(FormatterModifyDialog.java:575)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog.createMainArea(ModifyDialog.java:1262)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialog.createDialogArea(ModifyDialog.java:1246)
    at org.eclipse.jface.dialogs.Dialog.createContents(Dialog.java:771)
    at org.eclipse.jface.window.Window.create(Window.java:429)
    at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1099)
    at org.eclipse.jface.dialogs.StatusDialog.create(StatusDialog.java:203)
    at org.eclipse.jface.window.Window.open(Window.java:786)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ProfileConfigurationBlock$ButtonController.modifyButtonPressed(ProfileConfigurationBlock.java:231)
    at org.eclipse.jdt.internal.ui.preferences.formatter.ProfileConfigurationBlock$ButtonController.widgetSelected(ProfileConfigurationBlock.java:175)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5797)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1374)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:5051)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4583)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:821)
    at org.eclipse.jface.window.Window.open(Window.java:797)
    at org.eclipse.ui.internal.dialogs.WorkbenchPreferenceDialog.open(WorkbenchPreferenceDialog.java:214)
    at org.eclipse.ui.internal.OpenPreferencesAction.run(OpenPreferencesAction.java:66)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:476)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:568)
    at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:400)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5797)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1374)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:5051)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4583)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1173)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1062)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:628)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:339)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:563)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:151)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:155)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:199)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:391)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:246)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:595)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1501)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1474)
Caused by: java.lang.NumberFormatException: null
    at java.lang.Integer.parseInt(Integer.java:542)
    at java.lang.Integer.parseInt(Integer.java:615)
    at org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants.getWrappingStyle(DefaultCodeFormatterConstants.java:4538)
    ... 61 more

Eclipse IDE for Java Developers

Version: 2018-09 (4.9.0) Build id: 20180917-1800

htreu commented 6 years ago

@Hilbrand I just realised you entered the original issue. Let's continue here.

maggu2810 commented 6 years ago

It seems the documentation is outdated. The IDE setup instructions has been changed from Oxygen to Photon one month ago. I assume it would be not possible to use different formatter rules in one setup file. So, we should define the version we support officially. We decided not to update the documentation to 2018-09 (IIRC) because a change every 6 month could be hard to maintain.

@kaikreuzer WRT to the formatter rules and other settings, what do you think about the official IDE version?

maggu2810 commented 6 years ago

@htreu You use "Eclipse Oxygen" in the title of that issue but

Eclipse IDE for Java Developers

Version: 2018-09 (4.9.0)
Build id: 20180917-1800

in your comment.

I don't understand which IDE version is affected, Oxygen or 2018-09 or both?

Hilbrand commented 6 years ago

Oh sorry. Releases are so quick I'm still used to the other version. But the problem is with eclipse Photon.

htreu commented 6 years ago

I can confirm the problem also exists with Eclipse 2018-09.

Hilbrand commented 6 years ago

The version @htreu mentions is the version I also have this problem with: SimRel 2018‑09. I was under the assumption Photon was still the latest. Sorry for the confusion. So i maybe it's also a problem with Photon, but I haven't tested that version.

maggu2810 commented 6 years ago

I will inspect and try to fix the problem.

@kaikreuzer WRT to the formatter rules and other settings, what do you think about the official IDE version?

@kaikreuzer Can you answer the question above?

The formatter rules that are embedded to the Oomph setup file should reflect the settings of a given IDE version. If e.g. 2018-09 adds more options that should not be added to the formatter rules at least not as long as we don't know that old IDEs could handle more recent formatter rules.

kaikreuzer commented 6 years ago

@kaikreuzer Can you answer the question above?

Difficult, because I do not really understand it 😊 . But in general: We should make sure that OUR formatter is applied and working and no new fancy stuff interferes with it. Does that answer the question?

maggu2810 commented 6 years ago

Not really :wink:

Assume some of us start using Eclipse 2018-09 but the official IDE documentation still states Photon. If there is a new formatter option in the new Eclipse IDE that is not set by the Oomph setup (because it does not exist in the old IDE) the default option is used. The default option could reformat the code. Now we could set the option that way that it result into the same look & feel as before. If we commit the new formatter rules to get applied for everyone we need to check if Photon is still working as expected. This check adds another overhead as we need to check against 2018-09 and Photon...

maggu2810 commented 6 years ago

As Photon is the official IDE I will add formatting rules that works for Photon and don't care about (upward) compatibility to 2018-09. This way OUR formatter is applied and working with the official IDE version.

maggu2810 commented 6 years ago

I can confirm the problem also exists with Eclipse 2018-09.

That's interesting at all because it works for me on 2018-09.

maggu2810 commented 6 years ago

I tried (will try) different revisions of the setup file (targetplatform/EclipseSmartHome.setup) and checked if I can open the formatter settings (Preferences, Java, Code Style, Formatter).

revision Photon
7176f8961a4caba501fe38bab52a44c8705011c3 success
4610e3b9c7f3cadef0dc15e3b45142434963de6c success

@htreu Can you give it a try, too?

maggu2810 commented 6 years ago

@J-N-K As you comment that you are affected of that problem, can you try to execute the ESH Eclipse IDE setup instructions using Photon and a newly created user profile on your machine? The new user should be used because there are some other folders used by the IDE or the setup (e.g. ${HOME}/.eclipse).

J-N-K commented 6 years ago

I don't see that problem with a new Photon-IDE on a fresh profile (Windows 10, 64bit).

maggu2810 commented 6 years ago

@J-N-K Thanks a lot. So I would assume it is not a problem of the setup file but on the local machine setup.

@htreu Please comment

J-N-K commented 6 years ago

I did another test: The OpenHAB IDE (fresh install on a fresh profile) uses the wrong formatting. So you can ignore my comment as I was not using the ESH IDE.

J-N-K commented 5 years ago

The easy fix is: Go to preferences, select java formatter. ESH is selected, but not active. Select something else, apply, reselect ESH, apply. Now it is working again.

wborn commented 5 years ago

I tested the easy fix and it works. :+1: That was easy! :smile: