Bug 520340 - enable CLI to CDT's code formatter
Summary: enable CLI to CDT's code formatter
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: Next   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 9.4.0   Edit
Assignee: Mustafa Yücel CLA
QA Contact: Doug Schaefer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 527137
  Show dependency tree
 
Reported: 2017-07-30 19:32 EDT by Mustafa Yücel CLA
Modified: 2019-11-12 14:30 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mustafa Yücel CLA 2017-07-30 19:32:37 EDT
formatting source code from the command line

example usage:
eclipse -nosplash -application org.eclipse.cdt.core.CodeFormatter -consoleLog \
        -verbose -config .settings/org.eclipse.cdt.core.prefs src/
Comment 3 Jonah Graham CLA 2017-11-02 07:07:13 EDT
Mustafa, Thanks for your persistence on getting this through. Can you check it works as expected in the nightly build http://download.eclipse.org/tools/cdt/builds/master/nightly/ and update the N&N for 9.4 and then I will close this bug off. https://wiki.eclipse.org/CDT/User/NewIn94

Thanks again!
Jonah
Comment 4 Jonah Graham CLA 2017-11-08 07:45:07 EST
This commit has some bad @since tags. I think this happened because the initial review I did was against an earlier baseline. We need to fix the @since tags, and possibly increment version numbers of bundles.
Comment 5 Eclipse Genie CLA 2017-11-08 09:12:25 EST
New Gerrit change created: https://git.eclipse.org/r/111226
Comment 6 Mustafa Yücel CLA 2017-11-08 11:07:24 EST
strangewise I didnt get emails for your comments on bugzilla on 2/11 and today. Luckily I was clicking on the link on my gerrit review today ;)

I will do the test and the wiki update before the feature freeze this weekend.

The older since tags is because I was implementing the plugin against oxygen and not against oxygen.1 or oxygen.1a
Comment 7 Mustafa Yücel CLA 2017-11-08 11:09:17 EST
I added myself to the CC list, hope this works
Comment 8 Mustafa Yücel CLA 2017-11-08 11:24:14 EST
where should I add a code formatter feature? build/parser is not really fitting...
Comment 9 Mustafa Yücel CLA 2017-11-08 11:28:11 EST
my suggestions: put under editor chapter or create formatter chapter?
Comment 11 Mustafa Yücel CLA 2017-11-08 15:05:49 EST
I edited the N&N page and awaits a moderation.

the link is currently pointing to the JDT help page. I would like to point it to the fitting CDT help page as soon its available.
Comment 12 Jonah Graham CLA 2017-11-09 08:36:06 EST
(In reply to Mustafa Yücel from comment #6)
> strangewise I didnt get emails for your comments on bugzilla on 2/11 and
> today. Luckily I was clicking on the link on my gerrit review today ;)
:-(

> The older since tags is because I was implementing the plugin against oxygen
> and not against oxygen.1 or oxygen.1a
Not a problem. I should have caught it too. API additions are pretty easy to manage. It is API changes that are really important and normally in the weeks before the release someone (used to be Marc K) checks all API stuff, but of course it is best to get it right in the first place.

(In reply to Mustafa Yücel from comment #9)
> my suggestions: put under editor chapter or create formatter chapter?
Create a new chapter is fine. Those are placeholders, not hard and fast categories.

(In reply to Mustafa Yücel from comment #11)
> I edited the N&N page and awaits a moderation.
OK, I can't see the change yet.

> the link is currently pointing to the JDT help page. I would like to point
> it to the fitting CDT help page as soon its available.
That is fine.

---

Once the N&N is fully updated with CDT help page link we can close this bug off. AFAICT everything else is in hand.
Comment 13 Mustafa Yücel CLA 2017-11-09 12:35:31 EST
(In reply to Jonah Graham from comment #12)
> (In reply to Mustafa Yücel from comment #6)
> > strangewise I didnt get emails for your comments on bugzilla on 2/11 and
> > today. Luckily I was clicking on the link on my gerrit review today ;)
> :-(
> 
> > The older since tags is because I was implementing the plugin against oxygen
> > and not against oxygen.1 or oxygen.1a
> Not a problem. I should have caught it too. API additions are pretty easy to
> manage. It is API changes that are really important and normally in the
> weeks before the release someone (used to be Marc K) checks all API stuff,
> but of course it is best to get it right in the first place.
> 
> (In reply to Mustafa Yücel from comment #9)
> > my suggestions: put under editor chapter or create formatter chapter?
> Create a new chapter is fine. Those are placeholders, not hard and fast
> categories.
> 
> (In reply to Mustafa Yücel from comment #11)
> > I edited the N&N page and awaits a moderation.
> OK, I can't see the change yet.

strange, its still showing 'Success: your edit has been sent to moderation.'. Who is doing the moderation? I thought you could do it too...

> > the link is currently pointing to the JDT help page. I would like to point
> > it to the fitting CDT help page as soon its available.
> That is fine.
> 
> ---
> 
> Once the N&N is fully updated with CDT help page link we can close this bug
> off. AFAICT everything else is in hand.
Comment 14 Mustafa Yücel CLA 2017-11-09 13:05:41 EST
I made a test run with eclipse-platform-I20171107-2000-linux-gtk-x86_64.tar.gz and installing CDT with your updatesite. I was surprised first it was showing photon instead of oxygen.2 in splash

The other surprise was that it seems no more working without specifying the workspace with -data (java.lang.IllegalStateException: The instance data location has not been specified yet). But the good news is that the following command is working:

eclipse -nosplash -application org.eclipse.cdt.core.CodeFormatter -consoleLog \
        -verbose -data workspace -config workspace/project/.settings/org.eclipse.cdt.core.prefs workspace/project/src/

This would mean we may have to adapt the help (core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/Messages.properties and doc/org.eclipse.cdt.doc.user/tasks/cdt_t_format_app_run.htm) again, including my N&N change...
Comment 15 Jonah Graham CLA 2017-11-09 13:10:29 EST
(In reply to Mustafa Yücel from comment #13)
> > (In reply to Mustafa Yücel from comment #11)
> > > I edited the N&N page and awaits a moderation.
> > OK, I can't see the change yet.
> 
> strange, its still showing 'Success: your edit has been sent to
> moderation.'. Who is doing the moderation? I thought you could do it too...
Not me, the Eclipse webmaster. Once you have been moderated, later edits can go right through.
Comment 16 Jonah Graham CLA 2017-11-09 13:14:09 EST
(In reply to Mustafa Yücel from comment #14)
> I made a test run with
> eclipse-platform-I20171107-2000-linux-gtk-x86_64.tar.gz and installing CDT
> with your updatesite. I was surprised first it was showing photon instead of
> oxygen.2 in splash
eclipse-platform-I20171107 is photon, we are releasing oxygen.2, so you want 
"4.7 Maintenance Builds" from http://download.eclipse.org/eclipse/downloads/ -- e.g. M20171108-1700.


> The other surprise was that it seems no more working without specifying the
> workspace with -data (java.lang.IllegalStateException: The instance data
> location has not been specified yet). 
That is a pain. You may have found a photon bug. Does it work with the oxygen maintenance build?

> But the good news is that the
> following command is working:
> 
> eclipse -nosplash -application org.eclipse.cdt.core.CodeFormatter
> -consoleLog \
>         -verbose -data workspace -config
> workspace/project/.settings/org.eclipse.cdt.core.prefs workspace/project/src/
> 
> This would mean we may have to adapt the help
> (core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/Messages.
> properties and doc/org.eclipse.cdt.doc.user/tasks/cdt_t_format_app_run.htm)
> again, including my N&N change...
Hopefully it is just a photon bug that can be fixed -- what does the JDT formatter do in Photon?
Comment 17 Mustafa Yücel CLA 2017-11-09 13:30:07 EST
what is also working:

config and source outside workspace:
eclipse -nosplash -application org.eclipse.cdt.core.CodeFormatter -consoleLog \
        -verbose -data workspace -config project/.settings/org.eclipse.cdt.core.prefs project/src/

source outside workspace (takes default config from eclipse or workspace):
eclipse -nosplash -application org.eclipse.cdt.core.CodeFormatter -consoleLog \
        -verbose -data workspace project/src/
Comment 18 Mustafa Yücel CLA 2017-11-09 13:42:15 EST
(In reply to Jonah Graham from comment #16)
> (In reply to Mustafa Yücel from comment #14)
> > I made a test run with
> > eclipse-platform-I20171107-2000-linux-gtk-x86_64.tar.gz and installing CDT
> > with your updatesite. I was surprised first it was showing photon instead of
> > oxygen.2 in splash
> eclipse-platform-I20171107 is photon, we are releasing oxygen.2, so you want 
> "4.7 Maintenance Builds" from http://download.eclipse.org/eclipse/downloads/
> -- e.g. M20171108-1700.

ok good to know, will try it afterwards
 
> > The other surprise was that it seems no more working without specifying the
> > workspace with -data (java.lang.IllegalStateException: The instance data
> > location has not been specified yet). 
> That is a pain. You may have found a photon bug. Does it work with the
> oxygen maintenance build?

or -data is mandatory and no more optional?

> > But the good news is that the
> > following command is working:
> > 
> > eclipse -nosplash -application org.eclipse.cdt.core.CodeFormatter
> > -consoleLog \
> >         -verbose -data workspace -config
> > workspace/project/.settings/org.eclipse.cdt.core.prefs workspace/project/src/
> > 
> > This would mean we may have to adapt the help
> > (core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/formatter/Messages.
> > properties and doc/org.eclipse.cdt.doc.user/tasks/cdt_t_format_app_run.htm)
> > again, including my N&N change...
> Hopefully it is just a photon bug that can be fixed -- what does the JDT
> formatter do in Photon?

same exception, it only works with -data
Comment 19 Mustafa Yücel CLA 2017-11-09 14:01:04 EST
Good news, tried a test run with oxygen.2, it is working there with and without -data

Shall we remove the warning about -data in commands line help? Can you still reproduce your exceptions with using -data?
Comment 20 Mustafa Yücel CLA 2017-11-10 12:57:45 EST
my N&N changes are now visible on https://wiki.eclipse.org/CDT/User/NewIn94
Comment 21 Jonah Graham CLA 2017-11-10 15:28:52 EST
(In reply to Mustafa Yücel from comment #18)
> > Hopefully it is just a photon bug that can be fixed -- what does the JDT
> > formatter do in Photon?
> 
> same exception, it only works with -data
In that case, please file a bug against Platform (if you haven't already).


(In reply to Mustafa Yücel from comment #20)
> my N&N changes are now visible on https://wiki.eclipse.org/CDT/User/NewIn94
Great. I have reviewed them and made a minor change -- added link back to this bug.
Comment 22 Jonah Graham CLA 2017-11-10 15:32:18 EST
Thanks Mustafa for this improvement!

I have marked this bug as resolved now and created a new one, Bug 527137, to ensure the N&N gets updated. With the significant conversation in here it was difficult to see what was left to do, so easier to manage as a split out bug.
Comment 23 Jonah Graham CLA 2019-11-12 14:30:42 EST
(In reply to Jonah Graham from comment #21)
> In that case, please file a bug against Platform (if you haven't already).

I don't know if there is another bug on this, but the issue came up again so it is filed, See Bug 552973