Community
Participate
Working Groups
It is useful to be able to control the auto edit strategies via user preferences. I made such an implementation in the Geppetto development environment for Puppet and would like to contribute it to Xtext. Before doing so, I have some questions regarding the approach. My current implementation makes use of the DefaultEditStrategyProvider (and naturally its superclass AbstractEditStrategyProvider). The result would have been cleaner if I had replaced both of these with my own implementation (but i did not know this when I started). In my implementation, I have delegated some of the preference responsibilities to a preference helper class. This is not needed - it could just as well go directly to the preference store. I have attached the classes for review, and like some feedback / discussion. (Or just take what I did and change it...). (Attachments to follow).
Created attachment 202467 [details] preference page
Created attachment 202468 [details] constants
Created attachment 202469 [details] helper
Created attachment 202470 [details] overriding edit strategy provider The PPEditStrategyProvider is the "messy" part, that wraps strategies in a wrapper that is aware of preferences. The complexity is because I wanted to reuse the default implementation. Taking over all the responsibility would be much cleaner.
Cleanest API compatible implementation is probably to: - use separate preference keys for the different strategies - use a wrapper that knows about the preference key per strategy - make the abstract edit strategy aware that strategies may be wrapped (like in the overriding implementation that is attached). Or (breaking API) Add an Supplier<Boolean> enabler parameter to the edit strategies themselves (then there is no need for a wrapper). The strategies simply need to call get() on the Supplier to know if they are enabled or not.
Since some auto edit strategies depend on others I'd expect surprising behavior if I disable some of them. Didn't you face such situations?
(In reply to comment #6) > Since some auto edit strategies depend on others I'd expect surprising behavior > if I disable some of them. Didn't you face such situations? No, seems to work just fine - I disable all strategies for a particular character pair. Anything in particular you think should be tested to verify that there is no negative effect?
Unfortunately we didn't find the time to review the attached implemetation for 2.1. Is that a worthy addition for 2.1.1?
I think so. We should at least review it.
*** Bug 391639 has been marked as a duplicate of this bug. ***