Bug 522090 - Expose API for code cleanup on Core rather than UI
Summary: Expose API for code cleanup on Core rather than UI
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.8   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-09 13:25 EDT by Archimedes Trajano CLA
Modified: 2022-06-26 17:17 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Archimedes Trajano CLA 2017-09-09 13:25:36 EDT
The code formatting is already provided by core, can the API for code cleanup or at least save actions be put in core as well so it can be used by external formatters such as https://site.trajano.net/m2e-codestyle-maven-plugin/
Comment 2 Stephan Herrmann CLA 2017-09-10 05:00:04 EDT
Currently we have no time to look into this, due to priority on Java 9 work.

Still a few remarks:

I can see that most of the API package itself has no dependencies into other parts of JDT/UI, but at least ICleanUpConfigurationUI has a dependency on SWT which is a no-go for JDT/Core.

Would this be just about moving the interfaces and leaving all implementation in JDT/UI. In particular, what about classes like 
  org.eclipse.jdt.internal.corext.fix.CleanUpRegistry
  org.eclipse.jdt.internal.corext.fix.CleanUpRefactoring
where clean-ups a managed and invoked? These parts are more intertwined with UI code than the interfaces themselves. What is helped if only the interfaces are moved, but no code in JDT/Core uses them?
What about the individual implementations, subtypes of ICleanUp? Isn't that actually what you want to invoke in a headless setting?

=> I'm not convinced that copying a few interfaces into JDT/Core alone provides any benefit.

=> If, OTOH, implementations should be moved, too, we'd be speaking about a complex refactoring. Are you potentially interested in contributing such a refactoring? If so, let's wait until after Java 9 GA to discuss this in a bit more detail. Also the JDT/LS project might have a say in that discussion ...

@Olivier, are you still reading JDT/Core bugs? :)
Comment 3 Archimedes Trajano CLA 2017-12-22 12:41:51 EST
Ideally I would like to have an API that would allow me to do the following:

(this has M2E impact too)

m2e.generateProjectConfiguration("project path"): IJavaProject 

 (to generate the .classpath and .project) this will need to generate the classpath and project files either directly or in-memory (ideal) and returns an IJavaProject (I'm just guessing that's what JDT projects are called)

IJavaProject or other projects extend something like "ICleanupCapable"

Then ICleanupCapable looks like

interface ICleanupCapable {
  CleanupSteps generateCleanupSteps(ICleanupConfiguration);
}

that would generate the steps for cleanup.  Then have a method that I can call to actually apply the cleanup steps.

Unlike the formatter this is more complex because you would need the project context to have the classpath etc.  Formatter is only limited to a single file.
Comment 4 Eclipse Genie CLA 2020-06-22 09:53:24 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 5 Eclipse Genie CLA 2022-06-26 17:17:43 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.