cp7781 commented on a change in pull request #361: my first refactoring session
URL: https://github.com/apache/incubator-netbeans/pull/361#discussion_r161112334
##########
File path:
refactoring.api/src/org/netbeans/modules/refactoring/api/RefactoringSession.java
##########
@@ -246,27 +223,20 @@ private Problem reallyUndoRefactoring(boolean
saveAfterDone) {
f.undoChange();
}
}
- for (Transaction commit : SPIAccessor.DEFAULT.getCommits(bag)) {
- SPIAccessor.DEFAULT.check(commit, true);
- }
- UndoableWrapper wrapper =
MimeLookup.getLookup("").lookup(UndoableWrapper.class);
+ SPIAccessor.DEFAULT.getCommits(bag).forEach(commit ->
SPIAccessor.DEFAULT.check(commit, true));
+ UndoableWrapper undoableWrapper =
MimeLookup.getLookup("").lookup(UndoableWrapper.class);
for (ListIterator<Transaction> commitIterator =
commits.listIterator(commits.size()); commitIterator.hasPrevious();) {
final Transaction commit = commitIterator.previous();
- setWrappers(commit, wrapper);
+ undoableWrapper.setActive(true, this);
commit.rollback();
- unsetWrappers(commit, wrapper);
- }
- wrapper.close();
- for (Transaction commit : SPIAccessor.DEFAULT.getCommits(bag)) {
- SPIAccessor.DEFAULT.sum(commit);
+ undoableWrapper.setActive(false, null);
}
-
- while (it.hasPrevious()) {
+ undoableWrapper.close();
Review comment:
Probably. Under the circumstance, that the code from within line 228 to 232
throws an unexpected exception. I'm not sure, if that is even possible. But it
is a potential pitfall. I like your approach.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists