public int[] getSelectionStartAndEnd(ICompilationUnit iunit) { int[] offsets = new int[2]; CompilationUnit parsedUnit = ASTreeManipulationMethods.parseICompilationUnit(iunit); ASTNode nodeOne = ASTreeManipulationMethods.getASTNodeByIndex(parsedUnit, firstCutNodeIndex); ASTNode nodeTwo = ASTreeManipulationMethods.getASTNodeByIndex(parsedUnit, lastCutNodeIndex); offsets[0] = nodeOne.getStartPosition(); offsets[1] = nodeTwo.getStartPosition() + nodeTwo.getLength() - 1; return offsets; }
public int getRefactoringMarkerLine(ICompilationUnit unit) throws Exception { CompilationUnit tree = ASTreeManipulationMethods.parseICompilationUnit(unit); ASTNode node = ASTreeManipulationMethods.getASTNodeByIndex(tree, insertPlaceNodeIndex); int lineNo = tree.getLineNumber(node.getStartPosition()); return lineNo + 1; }