/** * Creates and returns an NLS tag edit for a string that is at the specified position in * a compilation unit. Returns <code>null</code> if the string is already NLSed * or the edit could not be created for some other reason. * @throws CoreException */ public static TextEdit createNLSEdit(ICompilationUnit cu, int position) throws CoreException { NLSLine nlsLine= scanCurrentLine(cu, position); if (nlsLine == null) return null; NLSElement element= findElement(nlsLine, position); if (element.hasTag()) return null; NLSElement[] elements= nlsLine.getElements(); int indexInElementList= Arrays.asList(elements).indexOf(element); int editOffset= computeInsertOffset(elements, indexInElementList, cu); String editText= ' ' + NLSElement.createTagText(indexInElementList + 1); //tags are 1-based return new InsertEdit(editOffset, editText); }
/** * Creates and returns an NLS tag edit for a string that is at the specified position in a * compilation unit. * * @param cu the compilation unit * @param position position of the string * @return the edit, or <code>null</code> if the string is already NLSed or the edit could not * be created for some other reason. * @throws CoreException if scanning fails */ public static TextEdit createNLSEdit(ICompilationUnit cu, int position) throws CoreException { NLSLine nlsLine= scanCurrentLine(cu, position); if (nlsLine == null) return null; NLSElement element= findElement(nlsLine, position); if (element.hasTag()) return null; NLSElement[] elements= nlsLine.getElements(); int indexInElementList= Arrays.asList(elements).indexOf(element); int editOffset= computeInsertOffset(elements, indexInElementList, cu); String editText= ' ' + NLSElement.createTagText(indexInElementList + 1); //tags are 1-based return new InsertEdit(editOffset, editText); }
/** * Creates and returns an NLS tag edit for a string that is at the specified position in a * compilation unit. * * @param cu the compilation unit * @param position position of the string * @return the edit, or <code>null</code> if the string is already NLSed or the edit could not * be created for some other reason. * @throws CoreException if scanning fails */ public static TextEdit createNLSEdit(ICompilationUnit cu, int position) throws CoreException { NLSLine nlsLine= scanCurrentLine(cu, position); if (nlsLine == null) return null; NLSElement element= findElement(nlsLine, position); if (element.hasTag()) return null; NLSElement[] elements= nlsLine.getElements(); int indexInElementList= Arrays.asList(elements).indexOf(element); int editOffset= computeInsertOffset(elements, indexInElementList, cu); String editText= ' ' + NLSElement.createTagText(indexInElementList + 1); //tags are 1-based return new InsertEdit(editOffset, editText); }