Orchestration of refactoring operations

I am implmenting a program transformation by composing refactoring  operations of Intellij Idea programatically. All the refactoring  operations I have used programtically are sucessufully tested to my  program but only when I apply them one by one. When I like to use these  operations
sequentially in the same time, some operations are  runned without problem but not all the operations are runned when I  luanch the transformation which oblige me to run the operations one by  one (for example: run the first one then comment it and run the second  until the last operation).
What I like here is to run the  transformation until the end and in the same processus. Is there one who  knows what is wrong here? And thank you.

2 comments
Comment actions Permalink

I am implmenting a program  transformation by composing refactoring  operations of Intellij Idea  programatically. All the refactoring  operations I have used  programtically are sucessufully tested to my  program but only when I  apply them one by one. When I like to use these  operations
sequentially  in the same time, some operations are  runned without problem but not  all the operations are runned when I  luanch the transformation which  oblige me to run the operations one by  one (for example: run the first  one then comment it and run the second  until the last operation).

When I use the refactoring operations programatically, I usally instanciate the processors destinated to perform refactoring operations. For example, in the following I show for you how I try to orchestrate some operations and then I explain what is the problem dealing with them (I put some numbers to refer the operations in order to clarify where is the problem:

   ExtractMethodProcessor extractMethodProcessor  = new ExtractMethodProcessor(project, editor,elements,method.getReturnTypeNoResolve(),"Extract Method","accept",HelpID.EXTRACT_METHOD);
   runnableHelper.runWriteCommand(project, new Runnable() {
              void run() {
                       try{   extractMethodProcessor.prepare();




                            }catch(PrepareFailedException e) { System.out.print(e.getStackTrace());}

             1)  extractMethodProcessor.testRun();

              2) generaliseParameter(extractMethodProcessor.getExtractedMethod(),visitors[0].getSuperClass());

              3) invokeOnScope(project, extractMethodProcessor.getExtractedMethod(), new AnalysisScope(project));//}});

              InlineMethodProcessor inline = new InlineMethodProcessor(project,extractMethodProcessor.getExtractedMethod(), (PsiJavaCodeReferenceElement)((PsiMethodCallExpression)(((PsiExpressionStatement)method.getBody().getStatements()[0]).getExpression())).getMethodExpression().getReference(),editor,true);

              4) inline.run();

              5)  MethodDuplicatesHandler.invokeOnScope(project, method, new AnalysisScope(method.getContainingFile()));//}})

               memberInfo[0] = new MemberInfo(extractMethodProcessor.getExtractedMethod());

               PullUpHelper pullup = new PullUpHelper(composite, composite.getSuperClass(),memberInfo,new DocCommentPolicy<PsiComment>(DocCommentPolicy.ASIS));
             6) pullup.run();


-------------------------------------------------------------------------------------------------------Overview about the problem-----------------------------------------------------------------------------------------------------

When I execute the above refactoring operations one by one there is no problem, but when I try to execute them in the same time the operations 1, 2, 3, 4 are executed, then the operation 5 is not executed and finally the operation 6 is executed. So, I am asking if someone has an idea about this?

0
Comment actions Permalink

Just to precise:
                      - The operation number 2 is based on the instanciation of the class ChangeSignatureProcessor and it runs this instance.
                      - When the operation 5 is called after the operations 1, 2, 3 and 4 directly it seems like it is not aware about the changes done by these operations. On the other hand, when I execute the operations 1, 2, 3 and 4, then I stop the plugin and I recompile again and I execute the operation 5 it works without problem and it detects the method duplicates.

0

Please sign in to leave a comment.