Program: 12056
Project: 12056
Buggy source:
private void extractClone(){
  this.cloneInfo=new CloneInformation();
  Set<ITypeBinding> requiredImportTypeBindings=new LinkedHashSet<ITypeBinding>();
  ITypeBinding commonSuperTypeOfSourceTypeDeclarations=null;
  if (sourceTypeDeclarations.get(0).resolveBinding().isEqualTo(sourceTypeDeclarations.get(1).resolveBinding()) && sourceTypeDeclarations.get(0).resolveBinding().getQualifiedName().equals(sourceTypeDeclarations.get(1).resolveBinding().getQualifiedName())) {
    cloneInfo.sourceCompilationUnit=sourceCompilationUnits.get(0);
    cloneInfo.sourceICompilationUnit=(ICompilationUnit)cloneInfo.sourceCompilationUnit.getJavaElement();
    cloneInfo.sourceTypeDeclaration=sourceTypeDeclarations.get(0);
    cloneInfo.sourceRewriter=ASTRewrite.create(cloneInfo.sourceTypeDeclaration.getAST());
    cloneInfo.ast=cloneInfo.sourceTypeDeclaration.getAST();
  }
 else {
    ITypeBinding typeBinding1=sourceTypeDeclarations.get(0).resolveBinding();
    ITypeBinding typeBinding2=sourceTypeDeclarations.get(1).resolveBinding();
    commonSuperTypeOfSourceTypeDeclarations=ASTNodeMatcher.commonSuperType(typeBinding1,typeBinding2);
    if (commonSuperTypeOfSourceTypeDeclarations != null) {
      if (pullUpToCommonSuperclass(commonSuperTypeOfSourceTypeDeclarations,typeBinding1,typeBinding2)) {
        IJavaElement javaElement=commonSuperTypeOfSourceTypeDeclarations.getJavaElement();
        javaElementsToOpenInEditor.add(javaElement);
        ICompilationUnit iCompilationUnit=(ICompilationUnit)javaElement.getParent();
        ASTParser parser=ASTParser.newParser(AST.JLS4);
        parser.setKind(ASTParser.K_COMPILATION_UNIT);
        parser.setSource(iCompilationUnit);
        parser.setResolveBindings(true);
        CompilationUnit compilationUnit=(CompilationUnit)parser.createAST(null);
        List<AbstractTypeDeclaration> typeDeclarations=compilationUnit.types();
        for (        AbstractTypeDeclaration abstractTypeDeclaration : typeDeclarations) {
          if (abstractTypeDeclaration instanceof TypeDeclaration) {
            TypeDeclaration typeDeclaration=(TypeDeclaration)abstractTypeDeclaration;
            if (typeDeclaration.resolveBinding().isEqualTo(commonSuperTypeOfSourceTypeDeclarations)) {
              cloneInfo.sourceCompilationUnit=compilationUnit;
              cloneInfo.sourceICompilationUnit=iCompilationUnit;
              cloneInfo.sourceTypeDeclaration=typeDeclaration;
              cloneInfo.sourceRewriter=ASTRewrite.create(cloneInfo.sourceTypeDeclaration.getAST());
              cloneInfo.ast=cloneInfo.sourceTypeDeclaration.getAST();
              cloneInfo.superclassNotDirectlyInheritedFromRefactoredSubclasses=!superclassDirectlyInheritedFromRefactoredSubclasses(commonSuperTypeOfSourceTypeDeclarations,typeBinding1,typeBinding2);
              break;
            }
          }
        }
        MultiTextEdit multiTextEdit=new MultiTextEdit();
        CompilationUnitChange compilationUnitChange=new CompilationUnitChange("String_Node_Str",iCompilationUnit);
        compilationUnitChange.setEdit(multiTextEdit);
        compilationUnitChanges.put(iCompilationUnit,compilationUnitChange);
      }
 else {
        if (extractToUtilityClass(commonSuperTypeOfSourceTypeDeclarations)) {
          cloneInfo.extractUtilityClass=true;
        }
        if (cloneInfo.extractUtilityClass) {
          cloneInfo.intermediateClassName="String_Node_Str";
        }
 else {
          cloneInfo.intermediateClassName="String_Node_Str" + commonSuperTypeOfSourceTypeDeclarations.getName();
        }
        ClassObject commonSuperType=ASTReader.getSystemObject().getClassObject(commonSuperTypeOfSourceTypeDeclarations.getQualifiedName());
        CompilationUnit compilationUnit=null;
        if (commonSuperType != null) {
          compilationUnit=findCompilationUnit(commonSuperType.getAbstractTypeDeclaration());
        }
 else {
          compilationUnit=sourceCompilationUnits.get(0);
        }
        if (compilationUnit.getPackage() != null) {
          cloneInfo.intermediateClassPackageBinding=compilationUnit.getPackage().resolveBinding();
        }
        ICompilationUnit iCompilationUnit=(ICompilationUnit)compilationUnit.getJavaElement();
        IContainer container=(IContainer)iCompilationUnit.getResource().getParent();
        if (container instanceof IProject) {
          IProject contextProject=(IProject)container;
          cloneInfo.file=contextProject.getFile(cloneInfo.intermediateClassName + "String_Node_Str");
        }
 else         if (container instanceof IFolder) {
          IFolder contextFolder=(IFolder)container;
          cloneInfo.file=contextFolder.getFile(cloneInfo.intermediateClassName + "String_Node_Str");
        }
        boolean intermediateAlreadyExists=false;
        ICompilationUnit intermediateICompilationUnit=JavaCore.createCompilationUnitFrom(cloneInfo.file);
        javaElementsToOpenInEditor.add(intermediateICompilationUnit);
        ASTParser intermediateParser=ASTParser.newParser(AST.JLS4);
        intermediateParser.setKind(ASTParser.K_COMPILATION_UNIT);
        if (cloneInfo.file.exists()) {
          intermediateAlreadyExists=true;
          intermediateParser.setSource(intermediateICompilationUnit);
          intermediateParser.setResolveBindings(true);
        }
 else {
          cloneInfo.document=new Document();
          intermediateParser.setSource(cloneInfo.document.get().toCharArray());
        }
        CompilationUnit intermediateCompilationUnit=(CompilationUnit)intermediateParser.createAST(null);
        AST intermediateAST=intermediateCompilationUnit.getAST();
        ASTRewrite intermediateRewriter=ASTRewrite.create(intermediateAST);
        ListRewrite intermediateTypesRewrite=intermediateRewriter.getListRewrite(intermediateCompilationUnit,CompilationUnit.TYPES_PROPERTY);
        TypeDeclaration intermediateTypeDeclaration=null;
        if (intermediateAlreadyExists) {
          List<AbstractTypeDeclaration> abstractTypeDeclarations=intermediateCompilationUnit.types();
          for (          AbstractTypeDeclaration abstractTypeDeclaration : abstractTypeDeclarations) {
            if (abstractTypeDeclaration instanceof TypeDeclaration) {
              TypeDeclaration typeDeclaration=(TypeDeclaration)abstractTypeDeclaration;
              if (typeDeclaration.getName().getIdentifier().equals(cloneInfo.intermediateClassName)) {
                intermediateTypeDeclaration=typeDeclaration;
                int intermediateModifiers=intermediateTypeDeclaration.getModifiers();
                if ((intermediateModifiers & Modifier.ABSTRACT) == 0 && !cloneInfo.extractUtilityClass) {
                  ListRewrite intermediateModifiersRewrite=intermediateRewriter.getListRewrite(intermediateTypeDeclaration,TypeDeclaration.MODIFIERS2_PROPERTY);
                  intermediateModifiersRewrite.insertLast(intermediateAST.newModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD),null);
                }
                break;
              }
            }
          }
          MultiTextEdit intermediateMultiTextEdit=new MultiTextEdit();
          CompilationUnitChange intermediateCompilationUnitChange=new CompilationUnitChange("String_Node_Str",intermediateICompilationUnit);
          intermediateCompilationUnitChange.setEdit(intermediateMultiTextEdit);
          compilationUnitChanges.put(intermediateICompilationUnit,intermediateCompilationUnitChange);
        }
 else {
          if (compilationUnit.getPackage() != null) {
            intermediateRewriter.set(intermediateCompilationUnit,CompilationUnit.PACKAGE_PROPERTY,compilationUnit.getPackage(),null);
          }
          intermediateTypeDeclaration=intermediateAST.newTypeDeclaration();
          SimpleName intermediateName=intermediateAST.newSimpleName(cloneInfo.intermediateClassName);
          intermediateRewriter.set(intermediateTypeDeclaration,TypeDeclaration.NAME_PROPERTY,intermediateName,null);
          ListRewrite intermediateModifiersRewrite=intermediateRewriter.getListRewrite(intermediateTypeDeclaration,TypeDeclaration.MODIFIERS2_PROPERTY);
          intermediateModifiersRewrite.insertLast(intermediateAST.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD),null);
          if (!cloneInfo.extractUtilityClass) {
            intermediateModifiersRewrite.insertLast(intermediateAST.newModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD),null);
            intermediateRewriter.set(intermediateTypeDeclaration,TypeDeclaration.SUPERCLASS_TYPE_PROPERTY,intermediateAST.newSimpleType(intermediateAST.newSimpleName(commonSuperTypeOfSourceTypeDeclarations.getName())),null);
            ListRewrite interfaceRewrite=intermediateRewriter.getListRewrite(intermediateTypeDeclaration,TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY);
            List<Type> superInterfaceTypes1=sourceTypeDeclarations.get(0).superInterfaceTypes();
            List<Type> superInterfaceTypes2=sourceTypeDeclarations.get(1).superInterfaceTypes();
            for (            Type interfaceType1 : superInterfaceTypes1) {
              for (              Type interfaceType2 : superInterfaceTypes2) {
                if (interfaceType1.resolveBinding().isEqualTo(interfaceType2.resolveBinding())) {
                  interfaceRewrite.insertLast(interfaceType1,null);
                  Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
                  typeBindings.add(interfaceType1.resolveBinding());
                  getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
                  break;
                }
              }
            }
            ListRewrite bodyDeclarationsRewrite=intermediateRewriter.getListRewrite(intermediateTypeDeclaration,TypeDeclaration.BODY_DECLARATIONS_PROPERTY);
            for (            MethodDeclaration methodDeclaration1 : sourceTypeDeclarations.get(0).getMethods()) {
              List<SingleVariableDeclaration> parameters1=methodDeclaration1.parameters();
              if (methodDeclaration1.isConstructor()) {
                for (                MethodDeclaration methodDeclaration2 : sourceTypeDeclarations.get(1).getMethods()) {
                  List<SingleVariableDeclaration> parameters2=methodDeclaration2.parameters();
                  if (methodDeclaration2.isConstructor()) {
                    if (matchingParameterTypes(parameters1,parameters2)) {
                      SuperConstructorInvocation superConstructorInvocation1=firstStatementIsSuperConstructorInvocation(methodDeclaration1);
                      SuperConstructorInvocation superConstructorInvocation2=firstStatementIsSuperConstructorInvocation(methodDeclaration2);
                      if (superConstructorInvocation1 != null && superConstructorInvocation2 != null) {
                        if (compareStatements(sourceCompilationUnits.get(0).getTypeRoot(),sourceCompilationUnits.get(1).getTypeRoot(),superConstructorInvocation1,superConstructorInvocation2)) {
                          MethodDeclaration constructor=intermediateAST.newMethodDeclaration();
                          intermediateRewriter.set(constructor,MethodDeclaration.NAME_PROPERTY,intermediateName,null);
                          intermediateRewriter.set(constructor,MethodDeclaration.CONSTRUCTOR_PROPERTY,true,null);
                          ListRewrite constructorModifierRewriter=intermediateRewriter.getListRewrite(constructor,MethodDeclaration.MODIFIERS2_PROPERTY);
                          List<IExtendedModifier> modifiers=methodDeclaration1.modifiers();
                          for (                          IExtendedModifier modifier : modifiers) {
                            if (modifier instanceof Modifier) {
                              constructorModifierRewriter.insertLast((Modifier)modifier,null);
                            }
                          }
                          ListRewrite parameterRewriter=intermediateRewriter.getListRewrite(constructor,MethodDeclaration.PARAMETERS_PROPERTY);
                          for (                          SingleVariableDeclaration parameter : parameters1) {
                            Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
                            typeBindings.add(parameter.getType().resolveBinding());
                            getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
                            parameterRewriter.insertLast(parameter,null);
                          }
                          Block constructorBody=intermediateAST.newBlock();
                          ListRewrite constructorBodyRewriter=intermediateRewriter.getListRewrite(constructorBody,Block.STATEMENTS_PROPERTY);
                          constructorBodyRewriter.insertLast(superConstructorInvocation1,null);
                          intermediateRewriter.set(constructor,MethodDeclaration.BODY_PROPERTY,constructorBody,null);
                          bodyDeclarationsRewrite.insertLast(constructor,null);
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          intermediateTypesRewrite.insertLast(intermediateTypeDeclaration,null);
        }
        cloneInfo.sourceCompilationUnit=intermediateCompilationUnit;
        cloneInfo.sourceICompilationUnit=intermediateICompilationUnit;
        cloneInfo.sourceTypeDeclaration=intermediateTypeDeclaration;
        cloneInfo.sourceRewriter=intermediateRewriter;
        cloneInfo.ast=intermediateAST;
      }
    }
  }
  ASTRewrite sourceRewriter=cloneInfo.sourceRewriter;
  AST ast=cloneInfo.ast;
  TypeDeclaration sourceTypeDeclaration=cloneInfo.sourceTypeDeclaration;
  MethodDeclaration sourceMethodDeclaration=sourceMethodDeclarations.get(0);
  ListRewrite bodyDeclarationsRewrite=sourceRewriter.getListRewrite(sourceTypeDeclaration,TypeDeclaration.BODY_DECLARATIONS_PROPERTY);
  if (commonSuperTypeOfSourceTypeDeclarations != null) {
    Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
    typeBindings.add(commonSuperTypeOfSourceTypeDeclarations);
    getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
  }
  Set<VariableDeclaration> accessedLocalFieldsG1=getLocallyAccessedFields(mapper.getDirectlyAccessedLocalFieldsG1(),sourceTypeDeclarations.get(0));
  Set<VariableDeclaration> accessedLocalFieldsG2=getLocallyAccessedFields(mapper.getDirectlyAccessedLocalFieldsG2(),sourceTypeDeclarations.get(1));
  if (!sourceTypeDeclarations.get(0).resolveBinding().isEqualTo(sourceTypeDeclarations.get(1).resolveBinding()) || !sourceTypeDeclarations.get(0).resolveBinding().getQualifiedName().equals(sourceTypeDeclarations.get(1).resolveBinding().getQualifiedName())) {
    pullUpLocallyAccessedFields(accessedLocalFieldsG1,accessedLocalFieldsG2,bodyDeclarationsRewrite,requiredImportTypeBindings);
    Set<VariableDeclaration> indirectlyAccessedLocalFieldsG1=getLocallyAccessedFields(mapper.getIndirectlyAccessedLocalFieldsG1(),sourceTypeDeclarations.get(0));
    Set<VariableDeclaration> indirectlyAccessedLocalFieldsG2=getLocallyAccessedFields(mapper.getIndirectlyAccessedLocalFieldsG2(),sourceTypeDeclarations.get(1));
    Set<MethodObject> accessedLocalMethodsG1=mapper.getAccessedLocalMethodsG1();
    Set<MethodObject> accessedLocalMethodsG2=mapper.getAccessedLocalMethodsG2();
    for (    MethodObject localMethodG1 : accessedLocalMethodsG1) {
      for (      MethodObject localMethodG2 : accessedLocalMethodsG2) {
        ITypeBinding returnTypesCommonSuperType=ASTNodeMatcher.commonSuperType(localMethodG1.getMethodDeclaration().getReturnType2().resolveBinding(),localMethodG2.getMethodDeclaration().getReturnType2().resolveBinding());
        if (localMethodG1.getName().equals(localMethodG2.getName()) && (localMethodG1.getReturnType().equals(localMethodG2.getReturnType()) || (returnTypesCommonSuperType != null && !ASTNodeMatcher.isTaggingInterface(returnTypesCommonSuperType))) && localMethodG1.getParameterTypeList().equals(localMethodG2.getParameterTypeList())) {
          MethodDeclaration methodDeclaration1=localMethodG1.getMethodDeclaration();
          MethodDeclaration methodDeclaration2=localMethodG2.getMethodDeclaration();
          Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
          boolean clones=type2Clones(methodDeclaration1,methodDeclaration2);
          Type returnType=methodDeclaration1.getReturnType2();
          TypeDeclaration typeDeclaration1=findTypeDeclaration(methodDeclaration1);
          TypeDeclaration typeDeclaration2=findTypeDeclaration(methodDeclaration2);
          Set<VariableDeclaration> fieldsAccessedInMethod1=getFieldsAccessedInMethod(indirectlyAccessedLocalFieldsG1,methodDeclaration1);
          Set<VariableDeclaration> fieldsAccessedInMethod2=getFieldsAccessedInMethod(indirectlyAccessedLocalFieldsG2,methodDeclaration2);
          boolean avoidPullUpDueToSerialization1=avoidPullUpMethodDueToSerialization(sourceTypeDeclarations.get(0),fieldsAccessedInMethod1);
          boolean avoidPullUpDueToSerialization2=avoidPullUpMethodDueToSerialization(sourceTypeDeclarations.get(1),fieldsAccessedInMethod2);
          if (clones && !avoidPullUpDueToSerialization1 && !avoidPullUpDueToSerialization2) {
            if (!typeDeclaration1.resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding()) && !typeDeclaration2.resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding())) {
              MethodDeclaration copiedMethodDeclaration=(MethodDeclaration)ASTNode.copySubtree(ast,methodDeclaration1);
              ListRewrite modifiersRewrite=sourceRewriter.getListRewrite(copiedMethodDeclaration,MethodDeclaration.MODIFIERS2_PROPERTY);
              List<IExtendedModifier> originalModifiers=copiedMethodDeclaration.modifiers();
              for (              IExtendedModifier extendedModifier : originalModifiers) {
                if (extendedModifier.isModifier()) {
                  Modifier modifier=(Modifier)extendedModifier;
                  if (modifier.isPrivate()) {
                    modifiersRewrite.replace(modifier,ast.newModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD),null);
                  }
                }
              }
              if (!localMethodG1.getReturnType().equals(localMethodG2.getReturnType()) && returnTypesCommonSuperType != null && !ASTNodeMatcher.isTaggingInterface(returnTypesCommonSuperType)) {
                Type newReturnType=generateTypeFromTypeBinding(returnTypesCommonSuperType,ast,sourceRewriter);
                sourceRewriter.set(copiedMethodDeclaration,MethodDeclaration.RETURN_TYPE2_PROPERTY,newReturnType,null);
                typeBindings.add(returnTypesCommonSuperType);
              }
              if (!localMethodG1.isStatic() && localMethodG2.isStatic()) {
                modifiersRewrite.insertLast(ast.newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD),null);
              }
              bodyDeclarationsRewrite.insertLast(copiedMethodDeclaration,null);
              TypeVisitor typeVisitor=new TypeVisitor();
              methodDeclaration1.accept(typeVisitor);
              typeBindings.addAll(typeVisitor.getTypeBindings());
              fieldsAccessedInMethod1.removeAll(accessedLocalFieldsG1);
              fieldsAccessedInMethod2.removeAll(accessedLocalFieldsG2);
              pullUpLocallyAccessedFields(fieldsAccessedInMethod1,fieldsAccessedInMethod2,bodyDeclarationsRewrite,requiredImportTypeBindings);
            }
            if (!typeDeclaration1.resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding())) {
              methodDeclarationsToBePulledUp.get(0).add(methodDeclaration1);
            }
            if (!typeDeclaration2.resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding())) {
              methodDeclarationsToBePulledUp.get(1).add(methodDeclaration2);
            }
          }
 else {
            if (!typeDeclaration1.resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding()) && !typeDeclaration2.resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding())) {
              MethodDeclaration newMethodDeclaration=ast.newMethodDeclaration();
              sourceRewriter.set(newMethodDeclaration,MethodDeclaration.NAME_PROPERTY,ast.newSimpleName(methodDeclaration1.getName().getIdentifier()),null);
              if (localMethodG1.getReturnType().equals(localMethodG2.getReturnType())) {
                sourceRewriter.set(newMethodDeclaration,MethodDeclaration.RETURN_TYPE2_PROPERTY,returnType,null);
                typeBindings.add(returnType.resolveBinding());
              }
 else               if (returnTypesCommonSuperType != null && !ASTNodeMatcher.isTaggingInterface(returnTypesCommonSuperType)) {
                Type newReturnType=generateTypeFromTypeBinding(returnTypesCommonSuperType,ast,sourceRewriter);
                sourceRewriter.set(newMethodDeclaration,MethodDeclaration.RETURN_TYPE2_PROPERTY,newReturnType,null);
                typeBindings.add(returnTypesCommonSuperType);
              }
              ListRewrite modifiersRewrite=sourceRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.MODIFIERS2_PROPERTY);
              List<IExtendedModifier> originalModifiers=methodDeclaration1.modifiers();
              for (              IExtendedModifier extendedModifier : originalModifiers) {
                if (extendedModifier.isModifier()) {
                  Modifier modifier=(Modifier)extendedModifier;
                  if (modifier.isProtected()) {
                    modifiersRewrite.insertLast(ast.newModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD),null);
                    if ((methodDeclaration2.getModifiers() & Modifier.PROTECTED) == 0) {
                      updateAccessModifier(methodDeclaration2,Modifier.ModifierKeyword.PROTECTED_KEYWORD);
                    }
                  }
 else                   if (modifier.isPublic()) {
                    modifiersRewrite.insertLast(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD),null);
                    if ((methodDeclaration2.getModifiers() & Modifier.PUBLIC) == 0) {
                      updateAccessModifier(methodDeclaration2,Modifier.ModifierKeyword.PUBLIC_KEYWORD);
                    }
                  }
 else                   if (modifier.isPrivate()) {
                    modifiersRewrite.insertLast(ast.newModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD),null);
                    updateAccessModifier(methodDeclaration1,Modifier.ModifierKeyword.PROTECTED_KEYWORD);
                    if ((methodDeclaration2.getModifiers() & Modifier.PROTECTED) == 0) {
                      updateAccessModifier(methodDeclaration2,Modifier.ModifierKeyword.PROTECTED_KEYWORD);
                    }
                  }
                }
              }
              if (cloneInfo.superclassNotDirectlyInheritedFromRefactoredSubclasses) {
                Block methodBody=ast.newBlock();
                sourceRewriter.set(newMethodDeclaration,MethodDeclaration.BODY_PROPERTY,methodBody,null);
                Expression returnedExpression=generateDefaultValue(sourceRewriter,ast,returnType);
                if (returnedExpression != null) {
                  ReturnStatement returnStatement=ast.newReturnStatement();
                  sourceRewriter.set(returnStatement,ReturnStatement.EXPRESSION_PROPERTY,returnedExpression,null);
                  ListRewrite statementsRewrite=sourceRewriter.getListRewrite(methodBody,Block.STATEMENTS_PROPERTY);
                  statementsRewrite.insertLast(returnStatement,null);
                }
              }
 else {
                modifiersRewrite.insertLast(ast.newModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD),null);
              }
              ListRewrite parametersRewrite=sourceRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.PARAMETERS_PROPERTY);
              List<SingleVariableDeclaration> parameters=methodDeclaration1.parameters();
              for (              SingleVariableDeclaration parameter : parameters) {
                parametersRewrite.insertLast(parameter,null);
                typeBindings.add(parameter.getType().resolveBinding());
              }
              ListRewrite thrownExceptionsRewrite=sourceRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY);
              List<Name> thrownExceptions=methodDeclaration1.thrownExceptions();
              for (              Name thrownException : thrownExceptions) {
                thrownExceptionsRewrite.insertLast(thrownException,null);
                typeBindings.add(thrownException.resolveTypeBinding());
              }
              bodyDeclarationsRewrite.insertLast(newMethodDeclaration,null);
            }
          }
          getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
          break;
        }
      }
    }
  }
  MethodDeclaration newMethodDeclaration=ast.newMethodDeclaration();
  sourceRewriter.set(newMethodDeclaration,MethodDeclaration.NAME_PROPERTY,ast.newSimpleName(extractedMethodName),null);
  List<VariableDeclaration> returnedVariables1=this.returnedVariables.get(0);
  List<VariableDeclaration> returnedVariables2=this.returnedVariables.get(1);
  ITypeBinding returnTypeBinding=null;
  if (returnedVariables1.size() == 1 && returnedVariables2.size() == 1) {
    Type returnType1=extractType(returnedVariables1.get(0));
    Type returnType2=extractType(returnedVariables2.get(0));
    if (returnType1.resolveBinding().isEqualTo(returnType2.resolveBinding()))     returnTypeBinding=returnType1.resolveBinding();
 else     returnTypeBinding=ASTNodeMatcher.commonSuperType(returnType1.resolveBinding(),returnType2.resolveBinding());
  }
 else {
    returnTypeBinding=findReturnTypeBinding();
  }
  if (returnTypeBinding != null) {
    Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
    typeBindings.add(returnTypeBinding);
    getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
    Type returnType=generateTypeFromTypeBinding(returnTypeBinding,ast,sourceRewriter);
    sourceRewriter.set(newMethodDeclaration,MethodDeclaration.RETURN_TYPE2_PROPERTY,returnType,null);
  }
 else {
    sourceRewriter.set(newMethodDeclaration,MethodDeclaration.RETURN_TYPE2_PROPERTY,ast.newPrimitiveType(PrimitiveType.VOID),null);
  }
  ListRewrite modifierRewrite=sourceRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.MODIFIERS2_PROPERTY);
  if (sourceTypeDeclarations.get(0).resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding()) && sourceTypeDeclarations.get(1).resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding())) {
    Modifier accessModifier=newMethodDeclaration.getAST().newModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD);
    modifierRewrite.insertLast(accessModifier,null);
  }
 else   if (cloneInfo.extractUtilityClass) {
    Modifier accessModifier=newMethodDeclaration.getAST().newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
    modifierRewrite.insertLast(accessModifier,null);
  }
 else {
    Modifier accessModifier=newMethodDeclaration.getAST().newModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD);
    modifierRewrite.insertLast(accessModifier,null);
  }
  if (((sourceMethodDeclarations.get(0).getModifiers() & Modifier.STATIC) != 0 && (sourceMethodDeclarations.get(1).getModifiers() & Modifier.STATIC) != 0) || cloneInfo.extractUtilityClass) {
    Modifier staticModifier=newMethodDeclaration.getAST().newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD);
    modifierRewrite.insertLast(staticModifier,null);
  }
  ListRewrite parameterRewrite=sourceRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.PARAMETERS_PROPERTY);
  Map<VariableBindingKeyPair,ArrayList<VariableDeclaration>> commonPassedParameters=mapper.getCommonPassedParameters();
  for (  VariableBindingKeyPair parameterName : commonPassedParameters.keySet()) {
    ArrayList<VariableDeclaration> variableDeclarations=commonPassedParameters.get(parameterName);
    VariableDeclaration variableDeclaration1=variableDeclarations.get(0);
    VariableDeclaration variableDeclaration2=variableDeclarations.get(1);
    if (parameterIsUsedByNodesWithoutDifferences(variableDeclaration1,variableDeclaration2)) {
      if (!variableDeclaration1.resolveBinding().isField() && !variableDeclaration2.resolveBinding().isField()) {
        ITypeBinding typeBinding1=extractType(variableDeclaration1).resolveBinding();
        ITypeBinding typeBinding2=extractType(variableDeclaration2).resolveBinding();
        ITypeBinding typeBinding=null;
        if (!typeBinding1.isEqualTo(typeBinding2)) {
          ITypeBinding commonSuperTypeBinding=ASTNodeMatcher.commonSuperType(typeBinding1,typeBinding2);
          if (commonSuperTypeBinding != null) {
            typeBinding=commonSuperTypeBinding;
          }
        }
 else {
          typeBinding=typeBinding1;
        }
        Type variableType=generateTypeFromTypeBinding(typeBinding,ast,sourceRewriter);
        Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
        typeBindings.add(typeBinding);
        getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
        SingleVariableDeclaration parameter=ast.newSingleVariableDeclaration();
        sourceRewriter.set(parameter,SingleVariableDeclaration.NAME_PROPERTY,variableDeclaration1.getName(),null);
        sourceRewriter.set(parameter,SingleVariableDeclaration.TYPE_PROPERTY,variableType,null);
        parameterRewrite.insertLast(parameter,null);
        originalPassedParameters.put(parameterName,variableDeclarations);
      }
    }
  }
  Block newMethodBody=newMethodDeclaration.getAST().newBlock();
  ListRewrite methodBodyRewrite=sourceRewriter.getListRewrite(newMethodBody,Block.STATEMENTS_PROPERTY);
  Set<ITypeBinding> thrownExceptionTypeBindings=new LinkedHashSet<ITypeBinding>();
  for (  PDGNodeMapping pdgNodeMapping : sortedNodeMappings) {
    PDGNode pdgNode1=pdgNodeMapping.getNodeG1();
    AbstractStatement statement1=pdgNode1.getStatement();
    PDGBlockNode blockNode1=mapper.getPDG1().isNestedWithinBlockNode(pdgNode1);
    if (blockNode1 != null && blockNode1 instanceof PDGTryNode && mapper.getRemovableNodesG1().contains(blockNode1)) {
    }
 else {
      ThrownExceptionVisitor thrownExceptionVisitor=new ThrownExceptionVisitor();
      statement1.getStatement().accept(thrownExceptionVisitor);
      thrownExceptionTypeBindings.addAll(thrownExceptionVisitor.getTypeBindings());
    }
    getSimpleTypeBindings(extractTypeBindings(statement1),requiredImportTypeBindings);
    PDGNode pdgNode2=pdgNodeMapping.getNodeG2();
    AbstractStatement statement2=pdgNode2.getStatement();
    PDGBlockNode blockNode2=mapper.getPDG2().isNestedWithinBlockNode(pdgNode2);
    if (blockNode2 != null && blockNode2 instanceof PDGTryNode && mapper.getRemovableNodesG2().contains(blockNode2)) {
    }
 else {
      ThrownExceptionVisitor thrownExceptionVisitor=new ThrownExceptionVisitor();
      statement2.getStatement().accept(thrownExceptionVisitor);
      thrownExceptionTypeBindings.addAll(thrownExceptionVisitor.getTypeBindings());
    }
    getSimpleTypeBindings(extractTypeBindings(statement2),requiredImportTypeBindings);
  }
  ListRewrite thrownExceptionRewrite=sourceRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY);
  List<Name> thrownExceptions1=sourceMethodDeclarations.get(0).thrownExceptions();
  List<Name> thrownExceptions2=sourceMethodDeclarations.get(1).thrownExceptions();
  for (  Name thrownException1 : thrownExceptions1) {
    for (    Name thrownException2 : thrownExceptions2) {
      if (thrownException1.resolveTypeBinding().isEqualTo(thrownException2.resolveTypeBinding()) && thrownExceptionTypeBindings.contains(thrownException1.resolveTypeBinding())) {
        thrownExceptionRewrite.insertLast(thrownException1,null);
        Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
        typeBindings.add(thrownException1.resolveTypeBinding());
        getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
        thrownExceptionTypeBindings.remove(thrownException1.resolveTypeBinding());
        break;
      }
    }
  }
  for (  ITypeBinding thrownExceptionTypeBinding : thrownExceptionTypeBindings) {
    thrownExceptionRewrite.insertLast(ast.newSimpleName(thrownExceptionTypeBinding.getName()),null);
    Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
    typeBindings.add(thrownExceptionTypeBinding);
    getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
  }
  CloneStructureNode root=mapper.getCloneStructureRoot();
  for (  CloneStructureNode child : root.getChildren()) {
    if (processableNode(child)) {
      Statement statement=processCloneStructureNode(child,ast,sourceRewriter);
      methodBodyRewrite.insertLast(statement,null);
    }
  }
  if (returnedVariables1.size() == 1 && returnedVariables2.size() == 1 && !mappedNodesContainStatementReturningVariable(returnedVariables1.get(0),returnedVariables2.get(0))) {
    ReturnStatement returnStatement=ast.newReturnStatement();
    sourceRewriter.set(returnStatement,ReturnStatement.EXPRESSION_PROPERTY,returnedVariables1.get(0).getName(),null);
    methodBodyRewrite.insertLast(returnStatement,null);
    if (!mappedNodesContainStatementDeclaringVariable(returnedVariables1.get(0),returnedVariables2.get(0)) && !variableIsPassedAsCommonParameter(returnedVariables1.get(0),returnedVariables2.get(0))) {
      Type returnedType=extractType(returnedVariables1.get(0));
      Expression initializer=generateDefaultValue(sourceRewriter,ast,returnedType);
      VariableDeclarationFragment fragment=ast.newVariableDeclarationFragment();
      sourceRewriter.set(fragment,VariableDeclarationFragment.NAME_PROPERTY,returnedVariables1.get(0).getName(),null);
      sourceRewriter.set(fragment,VariableDeclarationFragment.INITIALIZER_PROPERTY,initializer,null);
      VariableDeclarationStatement declarationStatement=ast.newVariableDeclarationStatement(fragment);
      sourceRewriter.set(declarationStatement,VariableDeclarationStatement.TYPE_PROPERTY,returnedType,null);
      methodBodyRewrite.insertFirst(declarationStatement,null);
    }
  }
  int existingArgValue=findExistingParametersWithArgName();
  int i=0;
  if (existingArgValue > 0) {
    i=existingArgValue + 1;
  }
  for (  ASTNodeDifference difference : parameterizedDifferenceMap.values()) {
    AbstractExpression expression1=difference.getExpression1();
    AbstractExpression expression2=difference.getExpression2();
    boolean isReturnedVariable=false;
    if (expression1 != null) {
      isReturnedVariable=isReturnedVariable(expression1.getExpression(),this.returnedVariables.get(0));
    }
 else     if (expression2 != null) {
      isReturnedVariable=isReturnedVariable(expression2.getExpression(),this.returnedVariables.get(1));
    }
    ITypeBinding typeBinding1=expression1 != null ? expression1.getExpression().resolveTypeBinding() : expression2.getExpression().resolveTypeBinding();
    ITypeBinding typeBinding2=expression2 != null ? expression2.getExpression().resolveTypeBinding() : expression1.getExpression().resolveTypeBinding();
    if (!isReturnedVariable) {
      ITypeBinding typeBinding=null;
      if (difference.containsDifferenceType(DifferenceType.SUBCLASS_TYPE_MISMATCH) || differenceContainsSubDifferenceWithSubclassTypeMismatch(difference)) {
        if (!typeBinding1.isEqualTo(typeBinding2)) {
          ITypeBinding commonSuperTypeBinding=ASTNodeMatcher.commonSuperType(typeBinding1,typeBinding2);
          if (commonSuperTypeBinding != null) {
            typeBinding=commonSuperTypeBinding;
          }
        }
 else {
          typeBinding=typeBinding1;
        }
      }
 else {
        if (expression1 != null && !typeBinding1.getQualifiedName().equals("String_Node_Str")) {
          typeBinding=typeBinding1;
        }
 else {
          typeBinding=typeBinding2;
        }
      }
      Type type=generateTypeFromTypeBinding(typeBinding,ast,sourceRewriter);
      Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
      typeBindings.add(typeBinding);
      getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
      SingleVariableDeclaration parameter=ast.newSingleVariableDeclaration();
      sourceRewriter.set(parameter,SingleVariableDeclaration.NAME_PROPERTY,ast.newSimpleName("String_Node_Str" + i),null);
      i++;
      sourceRewriter.set(parameter,SingleVariableDeclaration.TYPE_PROPERTY,type,null);
      parameterRewrite.insertLast(parameter,null);
    }
  }
  for (  VariableDeclaration variableDeclaration : fieldDeclarationsToBeParameterized.get(0)) {
    if (accessedLocalFieldsG1.contains(variableDeclaration)) {
      SingleVariableDeclaration parameter=ast.newSingleVariableDeclaration();
      Type type=generateTypeFromTypeBinding(variableDeclaration.resolveBinding().getType(),ast,sourceRewriter);
      sourceRewriter.set(parameter,SingleVariableDeclaration.TYPE_PROPERTY,type,null);
      sourceRewriter.set(parameter,SingleVariableDeclaration.NAME_PROPERTY,variableDeclaration.getName(),null);
      parameterRewrite.insertLast(parameter,null);
    }
  }
  sourceRewriter.set(newMethodDeclaration,MethodDeclaration.BODY_PROPERTY,newMethodBody,null);
  bodyDeclarationsRewrite.insertLast(newMethodDeclaration,null);
  cloneInfo.requiredImportTypeBindings=requiredImportTypeBindings;
  cloneInfo.methodBodyRewrite=methodBodyRewrite;
  cloneInfo.parameterRewrite=parameterRewrite;
}

Fixed version (ground truth):
private void extractClone(){
  this.cloneInfo=new CloneInformation();
  Set<ITypeBinding> requiredImportTypeBindings=new LinkedHashSet<ITypeBinding>();
  ITypeBinding commonSuperTypeOfSourceTypeDeclarations=null;
  if (sourceTypeDeclarations.get(0).resolveBinding().isEqualTo(sourceTypeDeclarations.get(1).resolveBinding()) && sourceTypeDeclarations.get(0).resolveBinding().getQualifiedName().equals(sourceTypeDeclarations.get(1).resolveBinding().getQualifiedName())) {
    cloneInfo.sourceCompilationUnit=sourceCompilationUnits.get(0);
    cloneInfo.sourceICompilationUnit=(ICompilationUnit)cloneInfo.sourceCompilationUnit.getJavaElement();
    cloneInfo.sourceTypeDeclaration=sourceTypeDeclarations.get(0);
    cloneInfo.sourceRewriter=ASTRewrite.create(cloneInfo.sourceTypeDeclaration.getAST());
    cloneInfo.ast=cloneInfo.sourceTypeDeclaration.getAST();
  }
 else {
    ITypeBinding typeBinding1=sourceTypeDeclarations.get(0).resolveBinding();
    ITypeBinding typeBinding2=sourceTypeDeclarations.get(1).resolveBinding();
    commonSuperTypeOfSourceTypeDeclarations=ASTNodeMatcher.commonSuperType(typeBinding1,typeBinding2);
    if (commonSuperTypeOfSourceTypeDeclarations != null) {
      if (pullUpToCommonSuperclass(commonSuperTypeOfSourceTypeDeclarations,typeBinding1,typeBinding2)) {
        IJavaElement javaElement=commonSuperTypeOfSourceTypeDeclarations.getJavaElement();
        javaElementsToOpenInEditor.add(javaElement);
        ICompilationUnit iCompilationUnit=(ICompilationUnit)javaElement.getParent();
        ASTParser parser=ASTParser.newParser(AST.JLS4);
        parser.setKind(ASTParser.K_COMPILATION_UNIT);
        parser.setSource(iCompilationUnit);
        parser.setResolveBindings(true);
        CompilationUnit compilationUnit=(CompilationUnit)parser.createAST(null);
        List<AbstractTypeDeclaration> typeDeclarations=compilationUnit.types();
        for (        AbstractTypeDeclaration abstractTypeDeclaration : typeDeclarations) {
          if (abstractTypeDeclaration instanceof TypeDeclaration) {
            TypeDeclaration typeDeclaration=(TypeDeclaration)abstractTypeDeclaration;
            if (typeDeclaration.resolveBinding().isEqualTo(commonSuperTypeOfSourceTypeDeclarations)) {
              cloneInfo.sourceCompilationUnit=compilationUnit;
              cloneInfo.sourceICompilationUnit=iCompilationUnit;
              cloneInfo.sourceTypeDeclaration=typeDeclaration;
              cloneInfo.sourceRewriter=ASTRewrite.create(cloneInfo.sourceTypeDeclaration.getAST());
              cloneInfo.ast=cloneInfo.sourceTypeDeclaration.getAST();
              cloneInfo.superclassNotDirectlyInheritedFromRefactoredSubclasses=!superclassDirectlyInheritedFromRefactoredSubclasses(commonSuperTypeOfSourceTypeDeclarations,typeBinding1,typeBinding2);
              break;
            }
          }
        }
        MultiTextEdit multiTextEdit=new MultiTextEdit();
        CompilationUnitChange compilationUnitChange=new CompilationUnitChange("String_Node_Str",iCompilationUnit);
        compilationUnitChange.setEdit(multiTextEdit);
        compilationUnitChanges.put(iCompilationUnit,compilationUnitChange);
      }
 else {
        if (extractToUtilityClass(commonSuperTypeOfSourceTypeDeclarations)) {
          cloneInfo.extractUtilityClass=true;
        }
        if (cloneInfo.extractUtilityClass) {
          cloneInfo.intermediateClassName="String_Node_Str";
        }
 else {
          cloneInfo.intermediateClassName="String_Node_Str" + commonSuperTypeOfSourceTypeDeclarations.getName();
        }
        ClassObject commonSuperType=ASTReader.getSystemObject().getClassObject(commonSuperTypeOfSourceTypeDeclarations.getQualifiedName());
        CompilationUnit compilationUnit=null;
        if (commonSuperType != null) {
          compilationUnit=findCompilationUnit(commonSuperType.getAbstractTypeDeclaration());
        }
 else {
          compilationUnit=sourceCompilationUnits.get(0);
        }
        if (compilationUnit.getPackage() != null) {
          cloneInfo.intermediateClassPackageBinding=compilationUnit.getPackage().resolveBinding();
        }
        ICompilationUnit iCompilationUnit=(ICompilationUnit)compilationUnit.getJavaElement();
        IContainer container=(IContainer)iCompilationUnit.getResource().getParent();
        if (container instanceof IProject) {
          IProject contextProject=(IProject)container;
          cloneInfo.file=contextProject.getFile(cloneInfo.intermediateClassName + "String_Node_Str");
        }
 else         if (container instanceof IFolder) {
          IFolder contextFolder=(IFolder)container;
          cloneInfo.file=contextFolder.getFile(cloneInfo.intermediateClassName + "String_Node_Str");
        }
        boolean intermediateAlreadyExists=false;
        ICompilationUnit intermediateICompilationUnit=JavaCore.createCompilationUnitFrom(cloneInfo.file);
        javaElementsToOpenInEditor.add(intermediateICompilationUnit);
        ASTParser intermediateParser=ASTParser.newParser(AST.JLS4);
        intermediateParser.setKind(ASTParser.K_COMPILATION_UNIT);
        if (cloneInfo.file.exists()) {
          intermediateAlreadyExists=true;
          intermediateParser.setSource(intermediateICompilationUnit);
          intermediateParser.setResolveBindings(true);
        }
 else {
          cloneInfo.document=new Document();
          intermediateParser.setSource(cloneInfo.document.get().toCharArray());
        }
        CompilationUnit intermediateCompilationUnit=(CompilationUnit)intermediateParser.createAST(null);
        AST intermediateAST=intermediateCompilationUnit.getAST();
        ASTRewrite intermediateRewriter=ASTRewrite.create(intermediateAST);
        ListRewrite intermediateTypesRewrite=intermediateRewriter.getListRewrite(intermediateCompilationUnit,CompilationUnit.TYPES_PROPERTY);
        TypeDeclaration intermediateTypeDeclaration=null;
        if (intermediateAlreadyExists) {
          List<AbstractTypeDeclaration> abstractTypeDeclarations=intermediateCompilationUnit.types();
          for (          AbstractTypeDeclaration abstractTypeDeclaration : abstractTypeDeclarations) {
            if (abstractTypeDeclaration instanceof TypeDeclaration) {
              TypeDeclaration typeDeclaration=(TypeDeclaration)abstractTypeDeclaration;
              if (typeDeclaration.getName().getIdentifier().equals(cloneInfo.intermediateClassName)) {
                intermediateTypeDeclaration=typeDeclaration;
                int intermediateModifiers=intermediateTypeDeclaration.getModifiers();
                if ((intermediateModifiers & Modifier.ABSTRACT) == 0 && !cloneInfo.extractUtilityClass) {
                  ListRewrite intermediateModifiersRewrite=intermediateRewriter.getListRewrite(intermediateTypeDeclaration,TypeDeclaration.MODIFIERS2_PROPERTY);
                  intermediateModifiersRewrite.insertLast(intermediateAST.newModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD),null);
                }
                break;
              }
            }
          }
          MultiTextEdit intermediateMultiTextEdit=new MultiTextEdit();
          CompilationUnitChange intermediateCompilationUnitChange=new CompilationUnitChange("String_Node_Str",intermediateICompilationUnit);
          intermediateCompilationUnitChange.setEdit(intermediateMultiTextEdit);
          compilationUnitChanges.put(intermediateICompilationUnit,intermediateCompilationUnitChange);
        }
 else {
          if (compilationUnit.getPackage() != null) {
            intermediateRewriter.set(intermediateCompilationUnit,CompilationUnit.PACKAGE_PROPERTY,compilationUnit.getPackage(),null);
          }
          intermediateTypeDeclaration=intermediateAST.newTypeDeclaration();
          SimpleName intermediateName=intermediateAST.newSimpleName(cloneInfo.intermediateClassName);
          intermediateRewriter.set(intermediateTypeDeclaration,TypeDeclaration.NAME_PROPERTY,intermediateName,null);
          ListRewrite intermediateModifiersRewrite=intermediateRewriter.getListRewrite(intermediateTypeDeclaration,TypeDeclaration.MODIFIERS2_PROPERTY);
          intermediateModifiersRewrite.insertLast(intermediateAST.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD),null);
          if (!cloneInfo.extractUtilityClass) {
            intermediateModifiersRewrite.insertLast(intermediateAST.newModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD),null);
            intermediateRewriter.set(intermediateTypeDeclaration,TypeDeclaration.SUPERCLASS_TYPE_PROPERTY,intermediateAST.newSimpleType(intermediateAST.newSimpleName(commonSuperTypeOfSourceTypeDeclarations.getName())),null);
            ListRewrite interfaceRewrite=intermediateRewriter.getListRewrite(intermediateTypeDeclaration,TypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY);
            List<Type> superInterfaceTypes1=sourceTypeDeclarations.get(0).superInterfaceTypes();
            List<Type> superInterfaceTypes2=sourceTypeDeclarations.get(1).superInterfaceTypes();
            for (            Type interfaceType1 : superInterfaceTypes1) {
              for (              Type interfaceType2 : superInterfaceTypes2) {
                if (interfaceType1.resolveBinding().isEqualTo(interfaceType2.resolveBinding())) {
                  interfaceRewrite.insertLast(interfaceType1,null);
                  Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
                  typeBindings.add(interfaceType1.resolveBinding());
                  getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
                  break;
                }
              }
            }
            ListRewrite bodyDeclarationsRewrite=intermediateRewriter.getListRewrite(intermediateTypeDeclaration,TypeDeclaration.BODY_DECLARATIONS_PROPERTY);
            for (            MethodDeclaration methodDeclaration1 : sourceTypeDeclarations.get(0).getMethods()) {
              List<SingleVariableDeclaration> parameters1=methodDeclaration1.parameters();
              if (methodDeclaration1.isConstructor()) {
                for (                MethodDeclaration methodDeclaration2 : sourceTypeDeclarations.get(1).getMethods()) {
                  List<SingleVariableDeclaration> parameters2=methodDeclaration2.parameters();
                  if (methodDeclaration2.isConstructor()) {
                    if (matchingParameterTypes(parameters1,parameters2)) {
                      SuperConstructorInvocation superConstructorInvocation1=firstStatementIsSuperConstructorInvocation(methodDeclaration1);
                      SuperConstructorInvocation superConstructorInvocation2=firstStatementIsSuperConstructorInvocation(methodDeclaration2);
                      if (superConstructorInvocation1 != null && superConstructorInvocation2 != null) {
                        if (compareStatements(sourceCompilationUnits.get(0).getTypeRoot(),sourceCompilationUnits.get(1).getTypeRoot(),superConstructorInvocation1,superConstructorInvocation2)) {
                          MethodDeclaration constructor=intermediateAST.newMethodDeclaration();
                          intermediateRewriter.set(constructor,MethodDeclaration.NAME_PROPERTY,intermediateName,null);
                          intermediateRewriter.set(constructor,MethodDeclaration.CONSTRUCTOR_PROPERTY,true,null);
                          ListRewrite constructorModifierRewriter=intermediateRewriter.getListRewrite(constructor,MethodDeclaration.MODIFIERS2_PROPERTY);
                          List<IExtendedModifier> modifiers=methodDeclaration1.modifiers();
                          for (                          IExtendedModifier modifier : modifiers) {
                            if (modifier instanceof Modifier) {
                              constructorModifierRewriter.insertLast((Modifier)modifier,null);
                            }
                          }
                          ListRewrite parameterRewriter=intermediateRewriter.getListRewrite(constructor,MethodDeclaration.PARAMETERS_PROPERTY);
                          for (                          SingleVariableDeclaration parameter : parameters1) {
                            Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
                            typeBindings.add(parameter.getType().resolveBinding());
                            getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
                            parameterRewriter.insertLast(parameter,null);
                          }
                          Block constructorBody=intermediateAST.newBlock();
                          ListRewrite constructorBodyRewriter=intermediateRewriter.getListRewrite(constructorBody,Block.STATEMENTS_PROPERTY);
                          constructorBodyRewriter.insertLast(superConstructorInvocation1,null);
                          intermediateRewriter.set(constructor,MethodDeclaration.BODY_PROPERTY,constructorBody,null);
                          bodyDeclarationsRewrite.insertLast(constructor,null);
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          intermediateTypesRewrite.insertLast(intermediateTypeDeclaration,null);
        }
        cloneInfo.sourceCompilationUnit=intermediateCompilationUnit;
        cloneInfo.sourceICompilationUnit=intermediateICompilationUnit;
        cloneInfo.sourceTypeDeclaration=intermediateTypeDeclaration;
        cloneInfo.sourceRewriter=intermediateRewriter;
        cloneInfo.ast=intermediateAST;
      }
    }
  }
  ASTRewrite sourceRewriter=cloneInfo.sourceRewriter;
  AST ast=cloneInfo.ast;
  TypeDeclaration sourceTypeDeclaration=cloneInfo.sourceTypeDeclaration;
  MethodDeclaration sourceMethodDeclaration=sourceMethodDeclarations.get(0);
  ListRewrite bodyDeclarationsRewrite=sourceRewriter.getListRewrite(sourceTypeDeclaration,TypeDeclaration.BODY_DECLARATIONS_PROPERTY);
  if (commonSuperTypeOfSourceTypeDeclarations != null) {
    Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
    typeBindings.add(commonSuperTypeOfSourceTypeDeclarations);
    getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
  }
  Set<VariableDeclaration> accessedLocalFieldsG1=getLocallyAccessedFields(mapper.getDirectlyAccessedLocalFieldsG1(),sourceTypeDeclarations.get(0));
  Set<VariableDeclaration> accessedLocalFieldsG2=getLocallyAccessedFields(mapper.getDirectlyAccessedLocalFieldsG2(),sourceTypeDeclarations.get(1));
  if (!sourceTypeDeclarations.get(0).resolveBinding().isEqualTo(sourceTypeDeclarations.get(1).resolveBinding()) || !sourceTypeDeclarations.get(0).resolveBinding().getQualifiedName().equals(sourceTypeDeclarations.get(1).resolveBinding().getQualifiedName())) {
    pullUpLocallyAccessedFields(accessedLocalFieldsG1,accessedLocalFieldsG2,bodyDeclarationsRewrite,requiredImportTypeBindings);
    Set<VariableDeclaration> indirectlyAccessedLocalFieldsG1=getLocallyAccessedFields(mapper.getIndirectlyAccessedLocalFieldsG1(),sourceTypeDeclarations.get(0));
    Set<VariableDeclaration> indirectlyAccessedLocalFieldsG2=getLocallyAccessedFields(mapper.getIndirectlyAccessedLocalFieldsG2(),sourceTypeDeclarations.get(1));
    Set<MethodObject> accessedLocalMethodsG1=mapper.getAccessedLocalMethodsG1();
    Set<MethodObject> accessedLocalMethodsG2=mapper.getAccessedLocalMethodsG2();
    for (    MethodObject localMethodG1 : accessedLocalMethodsG1) {
      for (      MethodObject localMethodG2 : accessedLocalMethodsG2) {
        ITypeBinding returnTypesCommonSuperType=ASTNodeMatcher.commonSuperType(localMethodG1.getMethodDeclaration().getReturnType2().resolveBinding(),localMethodG2.getMethodDeclaration().getReturnType2().resolveBinding());
        if (localMethodG1.getName().equals(localMethodG2.getName()) && (localMethodG1.getReturnType().equals(localMethodG2.getReturnType()) || (returnTypesCommonSuperType != null && !ASTNodeMatcher.isTaggingInterface(returnTypesCommonSuperType))) && localMethodG1.getParameterTypeList().equals(localMethodG2.getParameterTypeList())) {
          MethodDeclaration methodDeclaration1=localMethodG1.getMethodDeclaration();
          MethodDeclaration methodDeclaration2=localMethodG2.getMethodDeclaration();
          Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
          boolean clones=type2Clones(methodDeclaration1,methodDeclaration2);
          Type returnType=methodDeclaration1.getReturnType2();
          TypeDeclaration typeDeclaration1=findTypeDeclaration(methodDeclaration1);
          TypeDeclaration typeDeclaration2=findTypeDeclaration(methodDeclaration2);
          Set<VariableDeclaration> fieldsAccessedInMethod1=getFieldsAccessedInMethod(indirectlyAccessedLocalFieldsG1,methodDeclaration1);
          Set<VariableDeclaration> fieldsAccessedInMethod2=getFieldsAccessedInMethod(indirectlyAccessedLocalFieldsG2,methodDeclaration2);
          boolean avoidPullUpDueToSerialization1=avoidPullUpMethodDueToSerialization(sourceTypeDeclarations.get(0),fieldsAccessedInMethod1);
          boolean avoidPullUpDueToSerialization2=avoidPullUpMethodDueToSerialization(sourceTypeDeclarations.get(1),fieldsAccessedInMethod2);
          if (clones && !avoidPullUpDueToSerialization1 && !avoidPullUpDueToSerialization2) {
            if (!typeDeclaration1.resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding()) && !typeDeclaration2.resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding())) {
              MethodDeclaration copiedMethodDeclaration=(MethodDeclaration)ASTNode.copySubtree(ast,methodDeclaration1);
              ListRewrite modifiersRewrite=sourceRewriter.getListRewrite(copiedMethodDeclaration,MethodDeclaration.MODIFIERS2_PROPERTY);
              List<IExtendedModifier> originalModifiers=copiedMethodDeclaration.modifiers();
              for (              IExtendedModifier extendedModifier : originalModifiers) {
                if (extendedModifier.isModifier()) {
                  Modifier modifier=(Modifier)extendedModifier;
                  if (modifier.isPrivate()) {
                    modifiersRewrite.replace(modifier,ast.newModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD),null);
                  }
                }
              }
              if (!localMethodG1.getReturnType().equals(localMethodG2.getReturnType()) && returnTypesCommonSuperType != null && !ASTNodeMatcher.isTaggingInterface(returnTypesCommonSuperType)) {
                Type newReturnType=generateTypeFromTypeBinding(returnTypesCommonSuperType,ast,sourceRewriter);
                sourceRewriter.set(copiedMethodDeclaration,MethodDeclaration.RETURN_TYPE2_PROPERTY,newReturnType,null);
                typeBindings.add(returnTypesCommonSuperType);
              }
              if (!localMethodG1.isStatic() && localMethodG2.isStatic()) {
                modifiersRewrite.insertLast(ast.newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD),null);
              }
              bodyDeclarationsRewrite.insertLast(copiedMethodDeclaration,null);
              TypeVisitor typeVisitor=new TypeVisitor();
              methodDeclaration1.accept(typeVisitor);
              typeBindings.addAll(typeVisitor.getTypeBindings());
              fieldsAccessedInMethod1.removeAll(accessedLocalFieldsG1);
              fieldsAccessedInMethod2.removeAll(accessedLocalFieldsG2);
              pullUpLocallyAccessedFields(fieldsAccessedInMethod1,fieldsAccessedInMethod2,bodyDeclarationsRewrite,requiredImportTypeBindings);
            }
            if (!typeDeclaration1.resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding())) {
              methodDeclarationsToBePulledUp.get(0).add(methodDeclaration1);
            }
            if (!typeDeclaration2.resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding())) {
              methodDeclarationsToBePulledUp.get(1).add(methodDeclaration2);
            }
          }
 else {
            if (!typeDeclaration1.resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding()) && !typeDeclaration2.resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding())) {
              MethodDeclaration newMethodDeclaration=ast.newMethodDeclaration();
              sourceRewriter.set(newMethodDeclaration,MethodDeclaration.NAME_PROPERTY,ast.newSimpleName(methodDeclaration1.getName().getIdentifier()),null);
              if (localMethodG1.getReturnType().equals(localMethodG2.getReturnType())) {
                sourceRewriter.set(newMethodDeclaration,MethodDeclaration.RETURN_TYPE2_PROPERTY,returnType,null);
                typeBindings.add(returnType.resolveBinding());
              }
 else               if (returnTypesCommonSuperType != null && !ASTNodeMatcher.isTaggingInterface(returnTypesCommonSuperType)) {
                Type newReturnType=generateTypeFromTypeBinding(returnTypesCommonSuperType,ast,sourceRewriter);
                sourceRewriter.set(newMethodDeclaration,MethodDeclaration.RETURN_TYPE2_PROPERTY,newReturnType,null);
                typeBindings.add(returnTypesCommonSuperType);
              }
              ListRewrite modifiersRewrite=sourceRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.MODIFIERS2_PROPERTY);
              List<IExtendedModifier> originalModifiers=methodDeclaration1.modifiers();
              for (              IExtendedModifier extendedModifier : originalModifiers) {
                if (extendedModifier.isModifier()) {
                  Modifier modifier=(Modifier)extendedModifier;
                  if (modifier.isProtected()) {
                    modifiersRewrite.insertLast(ast.newModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD),null);
                    if ((methodDeclaration2.getModifiers() & Modifier.PROTECTED) == 0) {
                      updateAccessModifier(methodDeclaration2,Modifier.ModifierKeyword.PROTECTED_KEYWORD);
                    }
                  }
 else                   if (modifier.isPublic()) {
                    modifiersRewrite.insertLast(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD),null);
                    if ((methodDeclaration2.getModifiers() & Modifier.PUBLIC) == 0) {
                      updateAccessModifier(methodDeclaration2,Modifier.ModifierKeyword.PUBLIC_KEYWORD);
                    }
                  }
 else                   if (modifier.isPrivate()) {
                    modifiersRewrite.insertLast(ast.newModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD),null);
                    updateAccessModifier(methodDeclaration1,Modifier.ModifierKeyword.PROTECTED_KEYWORD);
                    if ((methodDeclaration2.getModifiers() & Modifier.PROTECTED) == 0) {
                      updateAccessModifier(methodDeclaration2,Modifier.ModifierKeyword.PROTECTED_KEYWORD);
                    }
                  }
                }
              }
              if (cloneInfo.superclassNotDirectlyInheritedFromRefactoredSubclasses) {
                Block methodBody=ast.newBlock();
                sourceRewriter.set(newMethodDeclaration,MethodDeclaration.BODY_PROPERTY,methodBody,null);
                Expression returnedExpression=generateDefaultValue(sourceRewriter,ast,returnType);
                if (returnedExpression != null) {
                  ReturnStatement returnStatement=ast.newReturnStatement();
                  sourceRewriter.set(returnStatement,ReturnStatement.EXPRESSION_PROPERTY,returnedExpression,null);
                  ListRewrite statementsRewrite=sourceRewriter.getListRewrite(methodBody,Block.STATEMENTS_PROPERTY);
                  statementsRewrite.insertLast(returnStatement,null);
                }
              }
 else {
                modifiersRewrite.insertLast(ast.newModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD),null);
              }
              ListRewrite parametersRewrite=sourceRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.PARAMETERS_PROPERTY);
              List<SingleVariableDeclaration> parameters=methodDeclaration1.parameters();
              for (              SingleVariableDeclaration parameter : parameters) {
                parametersRewrite.insertLast(parameter,null);
                typeBindings.add(parameter.getType().resolveBinding());
              }
              ListRewrite thrownExceptionsRewrite=sourceRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY);
              List<Name> thrownExceptions=methodDeclaration1.thrownExceptions();
              for (              Name thrownException : thrownExceptions) {
                thrownExceptionsRewrite.insertLast(thrownException,null);
                typeBindings.add(thrownException.resolveTypeBinding());
              }
              bodyDeclarationsRewrite.insertLast(newMethodDeclaration,null);
            }
          }
          getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
          break;
        }
      }
    }
  }
  MethodDeclaration newMethodDeclaration=ast.newMethodDeclaration();
  sourceRewriter.set(newMethodDeclaration,MethodDeclaration.NAME_PROPERTY,ast.newSimpleName(extractedMethodName),null);
  List<VariableDeclaration> returnedVariables1=this.returnedVariables.get(0);
  List<VariableDeclaration> returnedVariables2=this.returnedVariables.get(1);
  ITypeBinding returnTypeBinding=null;
  if (returnedVariables1.size() == 1 && returnedVariables2.size() == 1) {
    Type returnType1=extractType(returnedVariables1.get(0));
    Type returnType2=extractType(returnedVariables2.get(0));
    if (returnType1.resolveBinding().isEqualTo(returnType2.resolveBinding()))     returnTypeBinding=returnType1.resolveBinding();
 else     returnTypeBinding=ASTNodeMatcher.commonSuperType(returnType1.resolveBinding(),returnType2.resolveBinding());
  }
 else {
    returnTypeBinding=findReturnTypeBinding();
  }
  if (returnTypeBinding != null) {
    Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
    typeBindings.add(returnTypeBinding);
    getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
    Type returnType=generateTypeFromTypeBinding(returnTypeBinding,ast,sourceRewriter);
    sourceRewriter.set(newMethodDeclaration,MethodDeclaration.RETURN_TYPE2_PROPERTY,returnType,null);
  }
 else {
    sourceRewriter.set(newMethodDeclaration,MethodDeclaration.RETURN_TYPE2_PROPERTY,ast.newPrimitiveType(PrimitiveType.VOID),null);
  }
  ListRewrite modifierRewrite=sourceRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.MODIFIERS2_PROPERTY);
  if (sourceTypeDeclarations.get(0).resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding()) && sourceTypeDeclarations.get(1).resolveBinding().isEqualTo(sourceTypeDeclaration.resolveBinding())) {
    Modifier accessModifier=newMethodDeclaration.getAST().newModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD);
    modifierRewrite.insertLast(accessModifier,null);
  }
 else   if (cloneInfo.extractUtilityClass) {
    Modifier accessModifier=newMethodDeclaration.getAST().newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD);
    modifierRewrite.insertLast(accessModifier,null);
  }
 else {
    Modifier accessModifier=newMethodDeclaration.getAST().newModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD);
    modifierRewrite.insertLast(accessModifier,null);
  }
  if (((sourceMethodDeclarations.get(0).getModifiers() & Modifier.STATIC) != 0 && (sourceMethodDeclarations.get(1).getModifiers() & Modifier.STATIC) != 0) || cloneInfo.extractUtilityClass) {
    Modifier staticModifier=newMethodDeclaration.getAST().newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD);
    modifierRewrite.insertLast(staticModifier,null);
  }
  ListRewrite parameterRewrite=sourceRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.PARAMETERS_PROPERTY);
  Map<VariableBindingKeyPair,ArrayList<VariableDeclaration>> commonPassedParameters=mapper.getCommonPassedParameters();
  for (  VariableBindingKeyPair parameterName : commonPassedParameters.keySet()) {
    ArrayList<VariableDeclaration> variableDeclarations=commonPassedParameters.get(parameterName);
    VariableDeclaration variableDeclaration1=variableDeclarations.get(0);
    VariableDeclaration variableDeclaration2=variableDeclarations.get(1);
    if (parameterIsUsedByNodesWithoutDifferences(variableDeclaration1,variableDeclaration2)) {
      if (!variableDeclaration1.resolveBinding().isField() && !variableDeclaration2.resolveBinding().isField()) {
        ITypeBinding typeBinding1=extractType(variableDeclaration1).resolveBinding();
        ITypeBinding typeBinding2=extractType(variableDeclaration2).resolveBinding();
        ITypeBinding typeBinding=null;
        if (!typeBinding1.isEqualTo(typeBinding2)) {
          ITypeBinding commonSuperTypeBinding=ASTNodeMatcher.commonSuperType(typeBinding1,typeBinding2);
          if (commonSuperTypeBinding != null) {
            typeBinding=commonSuperTypeBinding;
          }
        }
 else {
          typeBinding=typeBinding1;
        }
        Type variableType=generateTypeFromTypeBinding(typeBinding,ast,sourceRewriter);
        Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
        typeBindings.add(typeBinding);
        getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
        SingleVariableDeclaration parameter=ast.newSingleVariableDeclaration();
        sourceRewriter.set(parameter,SingleVariableDeclaration.NAME_PROPERTY,variableDeclaration1.getName(),null);
        sourceRewriter.set(parameter,SingleVariableDeclaration.TYPE_PROPERTY,variableType,null);
        parameterRewrite.insertLast(parameter,null);
        originalPassedParameters.put(parameterName,variableDeclarations);
      }
    }
  }
  Block newMethodBody=newMethodDeclaration.getAST().newBlock();
  ListRewrite methodBodyRewrite=sourceRewriter.getListRewrite(newMethodBody,Block.STATEMENTS_PROPERTY);
  Set<ITypeBinding> thrownExceptionTypeBindings=new LinkedHashSet<ITypeBinding>();
  for (  PDGNodeMapping pdgNodeMapping : sortedNodeMappings) {
    PDGNode pdgNode1=pdgNodeMapping.getNodeG1();
    AbstractStatement statement1=pdgNode1.getStatement();
    PDGBlockNode blockNode1=mapper.getPDG1().isNestedWithinBlockNode(pdgNode1);
    if (blockNode1 != null && blockNode1 instanceof PDGTryNode && mapper.getRemovableNodesG1().contains(blockNode1)) {
    }
 else {
      ThrownExceptionVisitor thrownExceptionVisitor=new ThrownExceptionVisitor();
      statement1.getStatement().accept(thrownExceptionVisitor);
      for (      ITypeBinding thrownException : thrownExceptionVisitor.getTypeBindings()) {
        if (pdgNode1.getThrownExceptionTypes().contains(thrownException.getQualifiedName())) {
          thrownExceptionTypeBindings.add(thrownException);
        }
      }
    }
    getSimpleTypeBindings(extractTypeBindings(statement1),requiredImportTypeBindings);
    PDGNode pdgNode2=pdgNodeMapping.getNodeG2();
    AbstractStatement statement2=pdgNode2.getStatement();
    PDGBlockNode blockNode2=mapper.getPDG2().isNestedWithinBlockNode(pdgNode2);
    if (blockNode2 != null && blockNode2 instanceof PDGTryNode && mapper.getRemovableNodesG2().contains(blockNode2)) {
    }
 else {
      ThrownExceptionVisitor thrownExceptionVisitor=new ThrownExceptionVisitor();
      statement2.getStatement().accept(thrownExceptionVisitor);
      for (      ITypeBinding thrownException : thrownExceptionVisitor.getTypeBindings()) {
        if (pdgNode2.getThrownExceptionTypes().contains(thrownException.getQualifiedName())) {
          thrownExceptionTypeBindings.add(thrownException);
        }
      }
    }
    getSimpleTypeBindings(extractTypeBindings(statement2),requiredImportTypeBindings);
  }
  ListRewrite thrownExceptionRewrite=sourceRewriter.getListRewrite(newMethodDeclaration,MethodDeclaration.THROWN_EXCEPTIONS_PROPERTY);
  List<Name> thrownExceptions1=sourceMethodDeclarations.get(0).thrownExceptions();
  List<Name> thrownExceptions2=sourceMethodDeclarations.get(1).thrownExceptions();
  for (  Name thrownException1 : thrownExceptions1) {
    for (    Name thrownException2 : thrownExceptions2) {
      if (thrownException1.resolveTypeBinding().isEqualTo(thrownException2.resolveTypeBinding()) && thrownExceptionTypeBindings.contains(thrownException1.resolveTypeBinding())) {
        thrownExceptionRewrite.insertLast(thrownException1,null);
        Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
        typeBindings.add(thrownException1.resolveTypeBinding());
        getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
        thrownExceptionTypeBindings.remove(thrownException1.resolveTypeBinding());
        break;
      }
    }
  }
  for (  ITypeBinding thrownExceptionTypeBinding : thrownExceptionTypeBindings) {
    thrownExceptionRewrite.insertLast(ast.newSimpleName(thrownExceptionTypeBinding.getName()),null);
    Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
    typeBindings.add(thrownExceptionTypeBinding);
    getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
  }
  CloneStructureNode root=mapper.getCloneStructureRoot();
  for (  CloneStructureNode child : root.getChildren()) {
    if (processableNode(child)) {
      Statement statement=processCloneStructureNode(child,ast,sourceRewriter);
      methodBodyRewrite.insertLast(statement,null);
    }
  }
  if (returnedVariables1.size() == 1 && returnedVariables2.size() == 1 && !mappedNodesContainStatementReturningVariable(returnedVariables1.get(0),returnedVariables2.get(0))) {
    ReturnStatement returnStatement=ast.newReturnStatement();
    sourceRewriter.set(returnStatement,ReturnStatement.EXPRESSION_PROPERTY,returnedVariables1.get(0).getName(),null);
    methodBodyRewrite.insertLast(returnStatement,null);
    if (!mappedNodesContainStatementDeclaringVariable(returnedVariables1.get(0),returnedVariables2.get(0)) && !variableIsPassedAsCommonParameter(returnedVariables1.get(0),returnedVariables2.get(0))) {
      Type returnedType=extractType(returnedVariables1.get(0));
      Expression initializer=generateDefaultValue(sourceRewriter,ast,returnedType);
      VariableDeclarationFragment fragment=ast.newVariableDeclarationFragment();
      sourceRewriter.set(fragment,VariableDeclarationFragment.NAME_PROPERTY,returnedVariables1.get(0).getName(),null);
      sourceRewriter.set(fragment,VariableDeclarationFragment.INITIALIZER_PROPERTY,initializer,null);
      VariableDeclarationStatement declarationStatement=ast.newVariableDeclarationStatement(fragment);
      sourceRewriter.set(declarationStatement,VariableDeclarationStatement.TYPE_PROPERTY,returnedType,null);
      methodBodyRewrite.insertFirst(declarationStatement,null);
    }
  }
  int existingArgValue=findExistingParametersWithArgName();
  int i=0;
  if (existingArgValue > 0) {
    i=existingArgValue + 1;
  }
  for (  ASTNodeDifference difference : parameterizedDifferenceMap.values()) {
    AbstractExpression expression1=difference.getExpression1();
    AbstractExpression expression2=difference.getExpression2();
    boolean isReturnedVariable=false;
    if (expression1 != null) {
      isReturnedVariable=isReturnedVariable(expression1.getExpression(),this.returnedVariables.get(0));
    }
 else     if (expression2 != null) {
      isReturnedVariable=isReturnedVariable(expression2.getExpression(),this.returnedVariables.get(1));
    }
    ITypeBinding typeBinding1=expression1 != null ? expression1.getExpression().resolveTypeBinding() : expression2.getExpression().resolveTypeBinding();
    ITypeBinding typeBinding2=expression2 != null ? expression2.getExpression().resolveTypeBinding() : expression1.getExpression().resolveTypeBinding();
    if (!isReturnedVariable) {
      ITypeBinding typeBinding=null;
      if (difference.containsDifferenceType(DifferenceType.SUBCLASS_TYPE_MISMATCH) || differenceContainsSubDifferenceWithSubclassTypeMismatch(difference)) {
        if (!typeBinding1.isEqualTo(typeBinding2)) {
          ITypeBinding commonSuperTypeBinding=ASTNodeMatcher.commonSuperType(typeBinding1,typeBinding2);
          if (commonSuperTypeBinding != null) {
            typeBinding=commonSuperTypeBinding;
          }
        }
 else {
          typeBinding=typeBinding1;
        }
      }
 else {
        if (expression1 != null && !typeBinding1.getQualifiedName().equals("String_Node_Str")) {
          typeBinding=typeBinding1;
        }
 else {
          typeBinding=typeBinding2;
        }
      }
      Type type=generateTypeFromTypeBinding(typeBinding,ast,sourceRewriter);
      Set<ITypeBinding> typeBindings=new LinkedHashSet<ITypeBinding>();
      typeBindings.add(typeBinding);
      getSimpleTypeBindings(typeBindings,requiredImportTypeBindings);
      SingleVariableDeclaration parameter=ast.newSingleVariableDeclaration();
      sourceRewriter.set(parameter,SingleVariableDeclaration.NAME_PROPERTY,ast.newSimpleName("String_Node_Str" + i),null);
      i++;
      sourceRewriter.set(parameter,SingleVariableDeclaration.TYPE_PROPERTY,type,null);
      parameterRewrite.insertLast(parameter,null);
    }
  }
  for (  VariableDeclaration variableDeclaration : fieldDeclarationsToBeParameterized.get(0)) {
    if (accessedLocalFieldsG1.contains(variableDeclaration)) {
      SingleVariableDeclaration parameter=ast.newSingleVariableDeclaration();
      Type type=generateTypeFromTypeBinding(variableDeclaration.resolveBinding().getType(),ast,sourceRewriter);
      sourceRewriter.set(parameter,SingleVariableDeclaration.TYPE_PROPERTY,type,null);
      sourceRewriter.set(parameter,SingleVariableDeclaration.NAME_PROPERTY,variableDeclaration.getName(),null);
      parameterRewrite.insertLast(parameter,null);
    }
  }
  sourceRewriter.set(newMethodDeclaration,MethodDeclaration.BODY_PROPERTY,newMethodBody,null);
  bodyDeclarationsRewrite.insertLast(newMethodDeclaration,null);
  cloneInfo.requiredImportTypeBindings=requiredImportTypeBindings;
  cloneInfo.methodBodyRewrite=methodBodyRewrite;
  cloneInfo.parameterRewrite=parameterRewrite;
}