public void test_ExtractMethodFromClosure() throws Exception { this.addNodeById("5161277940733600914"); this.addNodeById("5161277940733600960"); ExtractMethodRefactoringParameters params = ExtractMethodFactory.createParameters( ListSequence.fromListAndArray( new ArrayList<SNode>(), SNodeOperations.cast( this.getNodeById("5161277940733600941"), "jetbrains.mps.baseLanguage.structure.LocalVariableDeclarationStatement"), SNodeOperations.cast( this.getNodeById("5161277940733600950"), "jetbrains.mps.baseLanguage.structure.ExpressionStatement"))); params.setName("foo"); MethodParameter p0 = ListSequence.fromList(params.getParameters()).getElement(0); MethodParameter p1 = ListSequence.fromList(params.getParameters()).getElement(1); if (SNodeOperations.isInstanceOf( p0.getDeclaration(), "jetbrains.mps.baseLanguage.structure.LocalVariableDeclaration")) { ListSequence.fromList(params.getParameters()).setElement(0, p1); ListSequence.fromList(params.getParameters()).setElement(1, p0); } ExtractMethodRefactoring ref = ExtractMethodFactory.createRefactoring(params); ref.doRefactor(); Assert.assertEquals( null, NodesMatcher.matchNodes( ListSequence.fromListAndArray( new ArrayList<SNode>(), SNodeOperations.cast( this.getNodeById("5161277940733600919"), "jetbrains.mps.baseLanguage.structure.ClassConcept")), ListSequence.fromListAndArray( new ArrayList<SNode>(), SNodeOperations.cast( this.getNodeById("5161277940733600997"), "jetbrains.mps.baseLanguage.structure.ClassConcept")))); }