private int getCuttedASTNodeIndexInNodeTwo(ASTNode nodeOne, ASTNode nodeTwo) { int start = ExtractMethod.getLengthOfCommonnSubnodesFromStart(nodeOne, nodeTwo); ArrayList<ASTNode> childrenTwo = ASTreeManipulationMethods.getChildNodes(nodeTwo); ASTNode node; if (start != 0) node = childrenTwo.get(start - 1); else node = nodeTwo; int index = ASTreeManipulationMethods.getASTNodeIndexInCompilationUnit(node); return index; }
private int[] getCutASTNodeIndex(ASTNode nodeOne, ASTNode nodeTwo) { int[] index = new int[2]; ArrayList<ASTNode> childrenOne = ASTreeManipulationMethods.getChildNodes(nodeOne); ArrayList<ASTNode> childrenTwo = ASTreeManipulationMethods.getChildNodes(nodeTwo); int childrenOneSize = childrenOne.size(); int childrenTwoSize = childrenTwo.size(); int start = ExtractMethod.getLengthOfCommonnSubnodesFromStart(nodeOne, nodeTwo); int end = Math.min( ExtractMethod.getLengthOfCommonnSubnodesFromEnd(nodeOne, nodeTwo), childrenTwoSize - start); ASTNode firstDiffNode = childrenOne.get(start); ASTNode lastDiffNode = childrenOne.get(childrenOneSize - end - 1); index[0] = ASTreeManipulationMethods.getASTNodeIndexInCompilationUnit(firstDiffNode); index[1] = ASTreeManipulationMethods.getASTNodeIndexInCompilationUnit(lastDiffNode); return index; }