Sequence of refactoring operations

Hello,
Actually I compose refactoring operations by call them ina form of a sequence from the API. I try to run the sequence of operations in one time but I can not : I can only perform them one by one. I would ask if somebody has an idea
how to run a sequence of refactoring operations with an atomic manner.

Best regards,,

6 comments

Not sure what you mean by "cannot" and what kind of atomicity you need. If you need the possibility to undo your operations in one step, you need to wrap your entire sequence of operations in a single CommandProcessor.executeCommand().

0

I mean that when I try to run a sequence of refactoring operations at ounce from a plugin integrated in th refactorer menu, the seqeunce does not continue to the end but it stop in the middle. I am asking so how to let
this sequence continuing to the end without interruption

0

This only depends on your code; there is no logic in the platform that would force the execution to stop. Maybe there is an exception thrown from your code?

0

Yes, there is the folowing exception :
[  39688]  ERROR - com.intellij.ide.IdeEventQueue - Error during dispatching of java.awt.event.MouseEvent[MOUSE_RELEASED,(409,162),absolute(409,189),button=1,modifiers=Button1,clickCount=1] on frame0
com.intellij.psi.PsiInvalidElementAccessException: Element: class com.intellij.psi.impl.source.tree.java.PsiNewExpressionImpl because: containing file is null

0

Some of the changes you're making are invalidating a PSI element, and you're trying to work with it after it has been invalidated. If you're using operations like add() or replace(), please make sure that you're correctly using the return values of those methods. Otherwise, it's not possible to say where the problem is without knowing exactly what you're doing.

0

I think that you are alright because the first operation will change the
state of the program then the next operation will may be not be executed, but how could I validate the state of the program beween operations when they are excecuted in a sequence ?

0

Please sign in to leave a comment.