Bug 217904 - Add OnSaveTask SPI
Add OnSaveTask SPI
Status: RESOLVED FIXED
Product: editor
Classification: Unclassified
Component: Formatting & Indentation
7.3
PC Linux
: P1 (vote)
: 7.3
Assigned To: apireviews
issues@editor
: API, API_REVIEW_FAST
: 231224 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-09-05 14:10 UTC by Miloslav Metelka
Modified: 2013-06-14 09:42 UTC (History)
1 user (show)

See Also:
Issue Type: TASK
:


Attachments
Patch containing OnSaveTask (50.35 KB, patch)
2012-09-05 14:15 UTC, Miloslav Metelka
Details | Diff
Corrected API patch. (50.45 KB, patch)
2012-09-06 15:48 UTC, Jan Lahoda
Details | Diff
A possible java.hints implementation. (24.27 KB, patch)
2012-09-06 15:49 UTC, Jan Lahoda
Details | Diff
Corrected java.hints implementation. (27.41 KB, patch)
2012-09-06 15:56 UTC, Jan Lahoda
Details | Diff
Patch with JL01, 02, 03 implemented (56.25 KB, patch)
2012-09-06 22:26 UTC, Miloslav Metelka
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Miloslav Metelka 2012-09-05 14:10:55 UTC
Attached patch adds an SPI class OnSaveTask which allows modules to register (into MimeLookup) custom tasks that will be performed right before document saving.
Comment 1 Miloslav Metelka 2012-09-05 14:14:19 UTC
Requesting a fasttrack review. It's only one class OnSaveTask with two inner classes Factory and Context. A test is there and two implementations TrailingWhitespaceRemove and ReformatBeforeSave.
Comment 2 Miloslav Metelka 2012-09-05 14:15:02 UTC
Created attachment 123958 [details]
Patch containing OnSaveTask
Comment 3 Jan Lahoda 2012-09-06 15:48:24 UTC
Created attachment 123991 [details]
Corrected API patch.

A patch corrected to always call the given Runnable in runLocked.
Comment 4 Jan Lahoda 2012-09-06 15:49:19 UTC
Created attachment 123992 [details]
A possible java.hints implementation.

An implementation for Java that allows to select Remove Unused Imports or Organize Imports as the post-save actions.
Comment 5 Jan Lahoda 2012-09-06 15:56:05 UTC
A few comments:
JL01: would it be possible not to pass the UndoableEdit to the run method, but rather add something like "addEdit(UndoableEdit edit)" to the Context?
JL02: I would suggest to make the OnSaveTask Cancelable.
JL03: how about modified lines, could the Context be extended to return them. I know I can get them from the Document, but having them in the Context would be more convenient.
Comment 6 Jan Lahoda 2012-09-06 15:56:31 UTC
Created attachment 123993 [details]
Corrected java.hints implementation.
Comment 7 Miloslav Metelka 2012-09-06 22:26:03 UTC
Created attachment 124003 [details]
Patch with JL01, 02, 03 implemented
Comment 8 Miloslav Metelka 2012-09-06 22:26:28 UTC
Honzo, could you check the patch and possibly update java.hints as necessary? Thanks.
Comment 9 Jaroslav Tulach 2012-09-07 09:44:51 UTC
Y01 Right now the public javadoc advocates to register the task in layer - I'd rather stress that the proper registration is via @MimeRegistration annotation in include an example of such registration in the javadoc.
Comment 10 Miloslav Metelka 2012-09-17 11:30:35 UTC
Implemented Y01 and integrated:
http://hg.netbeans.org/jet-main/rev/4ba15f1c615e

Also integrated jlahoda's java related tasks and customizer:
http://hg.netbeans.org/jet-main/rev/3ca98f3ad60f
Comment 11 Quality Engineering 2012-09-18 02:11:17 UTC
Integrated into 'main-golden', will be available in build *201209180001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/4ba15f1c615e
User: Miloslav Metelka <mmetelka@netbeans.org>
Log: #217904 - Add OnSaveTask SPI.
Comment 12 Quality Engineering 2012-09-19 03:05:50 UTC
Integrated into 'main-golden', will be available in build *201209190001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/3ca98f3ad60f
User: Miloslav Metelka <mmetelka@netbeans.org>
Log: #217904 - Add OnSaveTask SPI - integrated jlahoda's java OnSave tasks and customizer.
Comment 13 Dusan Balek 2013-06-14 09:42:26 UTC
*** Bug 231224 has been marked as a duplicate of this bug. ***


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo