Bug 508677 - [Generic Editor] Extension point for auto edit strategies
Summary: [Generic Editor] Extension point for auto edit strategies
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.6   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: 4.8 M1   Edit
Assignee: Michal Niewrzal CLA
QA Contact:
URL:
Whiteboard:
Keywords: Documentation, noteworthy
Depends on:
Blocks:
 
Reported: 2016-12-05 09:42 EST by Michal Niewrzal CLA
Modified: 2017-07-18 11:58 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Niewrzal CLA 2016-12-05 09:42:34 EST
Such extension point will provide array of IAutoEditStrategy for ExtensionBasedTextViewerConfiguration.getAutoEditStrategies. This will also help LSP4E to provide advanced editor operations. Current default implementation only adds indentation in new line.
Comment 1 Michal Niewrzal CLA 2016-12-16 04:15:03 EST
Maybe it would be nice to support something similar to https://code.visualstudio.com/docs/extensionAPI/extension-points#_contributeslanguages (language-configuration.json)
Comment 2 Eclipse Genie CLA 2016-12-16 07:52:17 EST
New Gerrit change created: https://git.eclipse.org/r/87308
Comment 3 Mickael Istria CLA 2017-03-16 15:25:37 EDT
Actually, I'm not sure whether this actually belong to:
* the editor (as suggested)
* the document (as documentListener) so it can apply on any keystroke
* the DocumentBuffer/Resource so it can apply on save.

The more I work with the generic editor, the more I have the impression that a document listener can be a better fit. However, there are can easily issue if you change a document as part of the documentListener (for example if you have multiple edits pending and introduce a new one before them).
Comment 4 Mickael Istria CLA 2017-06-28 08:00:16 EDT
@Michal: what's your opinion regarding my last comment? What do you think about relying on Document Listener for those?
Comment 5 Michal Niewrzal CLA 2017-06-28 08:26:05 EDT
(In reply to Mickael Istria from comment #4)
> @Michal: what's your opinion regarding my last comment? What do you think
> about relying on Document Listener for those?

I'm not sure how it will look without any initial implementation. You want to reuse somehow IAutoEditStrategy or just have new interface. I'm also not sure what's the problem with current mechanism. Are there any major disadvanteges?
Comment 6 Mickael Istria CLA 2017-06-28 08:48:52 EDT
(In reply to Michal Niewrzal from comment #5)
> I'm not sure how it will look without any initial implementation.

Actually, there would be no initial implementation. It would just be a recommendation for poeple who want auto-edit to use the documentSetup extension point and add a listener/an IAutoEditorStrategy on the document directly.

> You want to reuse somehow IAutoEditStrategy or just have new interface.

Reuse, reuse, reuse! No new public APIs for Generic editor!

> I'm also not
> sure what's the problem with current mechanism. Are there any major
> disadvanteges?

The only disadvantage I see is that it's more code for a feature that *might* already be possible to provide without new code.

[2 seconds later]
So I did look at the code and it's not possible to plug an IAutoEditStrategy directly on an IDocument (too bad), so your proposal may be the best way to do things. I'll have a closer look very soon (ping me otherwise).
Comment 7 Michal Niewrzal CLA 2017-06-28 08:59:58 EDT
(In reply to Mickael Istria from comment #6)
> So I did look at the code and it's not possible to plug an IAutoEditStrategy
> directly on an IDocument (too bad), so your proposal may be the best way to
> do things. I'll have a closer look very soon (ping me otherwise).

Take your time. I have no pressure with this but I just miss default auto edit strategy (indentation, brackets closing) in generic editor :)
Comment 9 Mickael Istria CLA 2017-06-29 11:16:52 EDT
Thanks a lot for this great contribution Michal.
Before closing this bug we need to:
* add an entry in Platform's N&N
* add this extension point to the automated documentation, and a note about it in the "human" documentation
* add the extension from the example to the PDE template for Generic Editor.

Unless you prefer otherwise, I suggest we keep this bug open to track those tasks,
Comment 10 Dani Megert CLA 2017-06-29 12:17:17 EDT
(In reply to Mickael Istria from comment #9)
> Thanks a lot for this great contribution Michal.

Mickael, you are on the project for some time now. I would expect that you have read  https://wiki.eclipse.org/Version_Numbering. Maybe you have read it and you have forgotten the details again. So, please do again.

What's worse is that you do not seem to have set up your 4.8 workspace correctly as expected by a committer. To set up API Tools is a requirement for active committers. You seem to have failed on that, because it would have told you that the version is wrong. Please improve on this. I have better use to spend my time than cleaning up such issues.

I've fixed the version number with http://git.eclipse.org/c/platform/eclipse.platform.text.git/commit/?id=422ac20e0c3cc4109fac9eb0fa60d4f387ba4227
Comment 11 Dani Megert CLA 2017-06-29 13:09:31 EDT
(In reply to Dani Megert from comment #10)

Sorry, the version change was justified because a new extension point was added. This is not handled by PDE Tools and version guidelines. Nevertheless code was committed that resulted in an error in the IDE, which should not happen by an experienced committer. A problem filter should have been added.

I've fixed the wiki, the version and the problem filter.

The API Tools issue is bug 518988.
Comment 12 Eclipse Genie CLA 2017-06-30 04:27:49 EDT
New Gerrit change created: https://git.eclipse.org/r/100435
Comment 13 Eclipse Genie CLA 2017-07-03 07:16:50 EDT
New Gerrit change created: https://git.eclipse.org/r/100547
Comment 17 Mickael Istria CLA 2017-07-18 11:58:05 EDT
Feature and related patches merged.
Thanks a lot for this good contribution Michal!