eclipse-archived / ceylon-ide-eclipse

Eclipse Plugin for Ceylon
http://ceylon-lang.org/documentation/ide
Eclipse Public License 1.0
59 stars 28 forks source link

Configuration for formatter #987

Closed gavinking closed 10 years ago

gavinking commented 10 years ago

We need a way to configure the formatter.

So a properties file type thing would be a great start, though I suppose we will eventually want a GUI for it.

akberc commented 10 years ago

All tabs and fields done - I am in Git hell right now. I rebased from master and did not rebase your changes to the formatter-profiles branch. Will push it shortly.

@lucaswerkmeister : Will you be able to add the hook into the FormatAction to load the selected profile: There are static methods in CeylonStyle that can do that.

lucaswerkmeister commented 10 years ago

Sure.

lucaswerkmeister commented 10 years ago

Okay, I cherry-picked all commits on formatter-profiles that weren’t already in master onto master in the new branch formatter-profiles-rebase (with a small change to your latest commit because it used createPreviewHeader(), which I removed in e559615f9b0a0a8a6f87bd1ab41156223a3445e4).

akberc commented 10 years ago

Yes, I have removed that now :) Thanks. I have pushed everything I have.

I will rebuild IDE plugin and continue in about 4 hours.

lucaswerkmeister commented 10 years ago

I can’t build it right now because FormatterTabMisc is missing.

akberc commented 10 years ago

Ooops. Pushed now. I will continue comparing and fixing after build.

akberc commented 10 years ago

@lucaswerkmeister Updated FormatterPreferences as well - was left from merge. I believe merge complete now.

lucaswerkmeister commented 10 years ago

Okay, I updated formatter-profiles-rebase as well. I don’t think we should merge formatter-profiles as it is now because it contains loads of double commits…

I’ll build now and check it out.

lucaswerkmeister commented 10 years ago

I get an “Unhandled event loop exception” trying to edit profiles now…

java.lang.ClassCastException: ceylon.formatter.options.parseFormattingOption_$2 cannot be cast to [Ljava.lang.String; at com.redhat.ceylon.eclipse.code.style.FormatterPreferences.get(FormatterPreferences.java:240) at com.redhat.ceylon.eclipse.code.style.FormatterTabPage$StringPreference.updateWidget(FormatterTabPage.java:607) at com.redhat.ceylon.eclipse.code.style.FormatterTabPage$StringPreference.(FormatterTabPage.java:535) at com.redhat.ceylon.eclipse.code.style.FormatterTabPage.createStringPref(FormatterTabPage.java:976) at com.redhat.ceylon.eclipse.code.style.FormatterTabMisc.doCreatePreferences(FormatterTabMisc.java:54) at com.redhat.ceylon.eclipse.code.style.FormatterTabPage.createContents(FormatterTabPage.java:823) at com.redhat.ceylon.eclipse.code.style.FormatterModifyProfileDialog.addTabPage(FormatterModifyProfileDialog.java:252) at com.redhat.ceylon.eclipse.code.style.FormatterModifyProfileDialog.addPages(FormatterModifyProfileDialog.java:82) at com.redhat.ceylon.eclipse.code.style.FormatterModifyProfileDialog.createDialogArea(FormatterModifyProfileDialog.java:130) at org.eclipse.jface.dialogs.Dialog.createContents(Dialog.java:768) ...

akberc commented 10 years ago

This is the last field on the misc tab probably, see issue above. If you want to release today, please take out the inline annotations from the misc tab. Then we can close this issue and open that as another issue to add that field.

Yes. Please merge your new branch with master. I had to skip rebase and merge and re commit on the foematter-profiles branch to get your changea

lucaswerkmeister commented 10 years ago

I fixed the inline annotations joining (5bae6883acfdbcc354614b2efc4854bea1c9fe2d), but now I get another error:

java.lang.NullPointerException at com.redhat.ceylon.eclipse.code.style.FormatterTabPage.doUpdatePreview(FormatterTabPage.java:96) at com.redhat.ceylon.eclipse.code.style.FormatterTabMisc.doUpdatePreview(FormatterTabMisc.java:103) at com.redhat.ceylon.eclipse.code.style.FormatterTabPage$1.update(FormatterTabPage.java:102)

akberc commented 10 years ago

Take it out :) Default value is good until 1.2. I will only have time tonight (Eastern Time Zone)

lucaswerkmeister commented 10 years ago

Take what out? Default value for what? I don’t think this is related to the inline annotations.

lucaswerkmeister commented 10 years ago

Apparently, for FormatterTabMisc, doCreatePreviewPane() isn’t called, so in doUpdatePreview() fPreview is still null.

lucaswerkmeister commented 10 years ago

Ah, no, it is actually related to inline annotations – because the preference is updated after creation, when a listener is registered, which then wants to update the preview, which doesn’t exist yet because we’re still initializing.

lucaswerkmeister commented 10 years ago

Okay, fixed as well. There’s still a small problem – if you check “all” (annotations) and reopen the config, it’s unchecked and the annotations string pref now contains [Ljava.lang.String;@abcdef, but at least it can be opened :)

lucaswerkmeister commented 10 years ago

Whew, that was a hairy fix, including a runtime subtyping check bug :( but now it works!

akberc commented 10 years ago

Yes, I was stuck on this last night.

Great stuff!! You take the lead and let me know what you want me to add or change. Update the sample code?

Unrelated to formatter, but I will add hooks to the new module wizard for author name and version number (variables just to fill in the Style tab that makes room for formatter tab under it..

lucaswerkmeister commented 10 years ago

Okay, I think I’m done for now! The only two remaining problems I have:

akberc commented 10 years ago

How about we take out the main Style tab (with the author version) and the .ceylon/style file out. It was just a placeholder for a project properties page, and when we have some real style options, we can bring that back in if needed.

@lucaswerkmeister , @quintesse What should the nesting structure for project properties?

- Ceylon Formatter
- Ceylon Compiler
-- Build Paths
-- Module Repositories

-- OR --

- Ceylon
-- Compiler Build Paths
-- Module Repositories
-- Formatter Profiles
lucaswerkmeister commented 10 years ago

How about we take out the main Style tab

Yeah, that might be better for now.

What should the nesting structure for project properties?

Java / JDT has four toplevel property “pages”(?), but I don’t see why that would be an advantage… toplevel Ceylon seems more natural to me.

quintesse commented 10 years ago

I think @gavinking might have a stronger opinion on that than I do. Personally I'd probably copy Java's example, but I have no strong feelings about it.

akberc commented 10 years ago

I took the liberty of calling the top-level 'Ceylon Configuration' for that is literally what the four tabs do - update the Ceylon configuration for the project. Please change text in plugin.xml if needed.

I think we are ready to merge with master.

akberc commented 10 years ago

Bug: does not switch config value for profile back to default. Looking into it. But go ahead with merge.

lucaswerkmeister commented 10 years ago

@akberc I think I’ve found the bug:

public boolean performApply() {
    try {
        if (fFormatterProfileManager.getSelected() != null
                && fFormatterProfileManager.getSelected().getName() != "default"
                && fFormatterProfileManager.getSelected().getName() != "unnamed") {
            CeylonStyle.writeProfileToFile(fFormatterProfileManager
                    .getSelected(), project.getLocation().toFile());
            CeylonStyle.setFormatterProfile(project,
                    fFormatterProfileManager.getSelected().getName());
        }

You still need to set the formatter profile even if it’s the default. (But it’s probably correct that you don’t have to write it.) FormatterConfigurationBlock.java, around line 570.

gavinking commented 10 years ago

How about we take out the main Style tab

Yeah, that might be better for now.

Yes, please get rid of it. We don't want a page with one text field on it.

akberc commented 10 years ago

@lucaswerkmeister Bug fixed - and made the values constants for safety

lucaswerkmeister commented 10 years ago

Works great now, thanks a lot @akberc!

lucaswerkmeister commented 10 years ago

Done!! Thanks a lot @akberc for all your work here!

akberc commented 10 years ago

No worries. Thank you for testing, input and making the options variable! Sorry for being a bit late on this.

On another note, Github Windows client seem to have clobbered the plugin.xml git history on push, showing the whole file as replaced.

I will delete branch formatter-profiles - the original branch I was committing to.

gavinking commented 10 years ago

Alright, so thanks so much, @akberc and @lucaswerkmeister, this is overall actually really well done. I've cleaned the presentation of some of the options a little, but those were really very small changes.

Great work!