Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 369992 - "Fix Copyrights" should be able to automatically run on file save
Summary: "Fix Copyrights" should be able to automatically run on file save
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Releng (show other bugs)
Version: 4.2   Edit
Hardware: PC Windows XP
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Platform-Releng-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-27 13:59 EST by Ben Fritz CLA
Modified: 2022-02-03 14:49 EST (History)
3 users (show)

See Also:


Attachments
started save-action (169.83 KB, application/gzip)
2014-08-27 11:16 EDT, Leo Ufimtsev CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Fritz CLA 2012-01-27 13:59:51 EST
Build Identifier: Version: 3.6.2 Build id: M20110210-1200

Possibly related to the more general Bug 210780, which asks for scripting of the fix copyrights tool. I'd just like to be able to set up the Eclipse editor to automatically run the "Fix Copyrights" tool on any file every time I save it, just before writing to disk, so that I never need to worry about manually running the tool as long as I do my editing in Eclipse.

I've set up something similar in UltraEdit, which allows you to run a generic macro on file save, and Vim, which gives the BufWritePre autocmd event.

Reproducible: Always

Steps to Reproduce:
N/A: feature request
Comment 1 Leo Ufimtsev CLA 2014-07-15 14:45:28 EDT
I was thinking the same. 

I'll see if I can do this.
Comment 2 Leo Ufimtsev CLA 2014-08-27 11:16:10 EDT
Hey ya, 

I spent a couple of days looking into this. 

I got it working as far as having a 'Copyright fix' listed under Eclipse's save action. (see screenshots in zip).
(based on tutorial: http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Fguide%2Fjdt_api_contributing_a_cleanup.htm)
 
However, then I noticed that Eclipse's Save-Actions work with the source code AST (Abstract Syntax Tree) where as Copyright_tool works on files directly. 

I.e, the architectures aren't quite compatible with one another. 

This generates issues, e.g one loses git-integration because you no longer work with files. 
But even if the git issue is ignored, implementing this feature would require one to duplicate the copyright-tool logic and work separately on the AST instead of files. (i.e, one can't pass the file to the existing code easily). 
This is quite a big task and would require a big alteration in copyright tool. 

Unfortunately I won't have time to work on this anymore. But if someone wishes to pursue this, I"m attaching a test project with what I got so far. 

An alternative direction would be to intercept the save-command itself, and run the tool on the file after the save is complete. (and add a checkbox in the Copyright tool options. ) 
(as in: http://stackoverflow.com/questions/5899738/override-eclipse-file-save-action)
Comment 3 Leo Ufimtsev CLA 2014-08-27 11:16:36 EDT
Created attachment 246439 [details]
started save-action
Comment 4 Alexander Kurtakov CLA 2022-02-03 14:49:13 EST
Copyright tool is no longer developed.