It would be useful to allow ModificationResult to write changes into guarded sections of a document in case the API
client is aware of what he does.
My usecase is the BeanInfo refactoring. When I implement GuardedBlockHandler I can decide according to
ModificationResult.Difference if proposed changes are valid and in such case I could permit to write them to the document.
So what I propose is to add 2 methods to ModificationResult.Difference
public boolean isGuarded();
public void guards(boolean b);
The default behavior would remain the same. Modifications of guarded sections are forbidden by default.
Created attachment 58267 [details]
I would like to ask for review of this simple change. TM will be 6.1
Missing @since and increase module version otherwise OK.
Consider using of more descriptive method names - otherwise it is OK for me.
-the method names seem not very intuitive to me - would be nice if we could improve them (maybe forceWrite/isForceWrite?).
-implementation note: I would prefer use of NbDocument.runAtomic(AsUser) instead of BaseDocument.runAtomic(AsUser)
-please make sure that module(s) that will use these new methods depend on the new version of java.source (in order to
prevent problems with AU).
TZ: sure, @since has lost while I was hg queuing. apichanges.xml is already there.
DB, JL01: I wanted names to be short. In case of making names really descriptive I would propose
JL02: There already was casting to BaseDocument. But I am fine to use NbDocument.
Thanks for comments.
setCommitToGuards(boolean allow) is good.
Created attachment 58381 [details]
proposed changes ver. 2
I have updated the patch. If no more objections occur I will push this tomorrow.
I am going to integrate.
integrated as http://hg.netbeans.org/main/rev/8274af13b6ae