if (token == 1003) { ---> selection int offset= member.getSourceRange().getOffset(); int length= scanner.getCurrentTokenEndPosition(); // find the indent String comment= source.substring(0, length + 1); if (comment.indexOf(lineDelimiter) != -1) { int lineStart= comment.lastIndexOf(lineDelimiter) + lineDelimiter.length(); int commentStart= comment.lastIndexOf("*/"); String blanks= source.substring(lineStart, commentStart); // construct the String to write into the comment String text= blanks + "* " + string + lineDelimiter; tbe.add(SimpleTextEdit.createReplace(offset + lineStart, 0, text)); } else { String sourceCU= member.getCompilationUnit().getSource().substring(0, offset); int lineStart= sourceCU.lastIndexOf(lineDelimiter) + lineDelimiter.length(); String blanks= sourceCU.substring(lineStart); // construct the String to write into the comment String text= lineDelimiter+ blanks + " * " + string + lineDelimiter + blanks; tbe.add(SimpleTextEdit.createReplace(offset + length -2, 0, text)); } <------ selection break; } else if (token == 1002)