private static NLSElement findElement(NLSLine line, int position) {
   NLSElement[] elements = line.getElements();
   for (int i = 0; i < elements.length; i++) {
     NLSElement element = elements[i];
     if (isPositionInElement(element, position)) return element;
   }
   return null;
 }
  private void deleteAccessor(NLSSubstitution substitution, TextChange change, ICompilationUnit cu)
      throws CoreException {
    AccessorClassReference accessorClassRef = substitution.getAccessorClassReference();
    if (accessorClassRef != null) {
      Region region = accessorClassRef.getRegion();
      String[] args = {
        substitution.getValueNonEmpty(),
        BasicElementLabels.getJavaElementName(substitution.getKey())
      };
      String label = Messages.format(NLSMessages.NLSSourceModifier_remove_accessor, args);
      String replaceString = '\"' + unwindEscapeChars(substitution.getValueNonEmpty()) + '\"';
      TextChangeCompatibility.addTextEdit(
          change, label, new ReplaceEdit(region.getOffset(), region.getLength(), replaceString));
      if (fIsEclipseNLS && substitution.getState() != NLSSubstitution.INTERNALIZED) {

        Region position = substitution.getNLSElement().getPosition();
        int lineStart = getLineStart(cu.getBuffer(), position.getOffset());
        int lineEnd = getLineEnd(cu.getBuffer(), position.getOffset());
        String cuLine = cu.getBuffer().getText(lineStart, lineEnd - lineStart);
        StringBuffer buf = new StringBuffer(cuLine);
        buf.replace(
            region.getOffset() - lineStart,
            region.getOffset() + region.getLength() - lineStart,
            replaceString);
        try {
          NLSLine[] allLines = NLSScanner.scan(buf.toString());

          NLSLine nlsLine = allLines[0];
          NLSElement element =
              findElement(
                  nlsLine,
                  position.getOffset() - lineStart - accessorClassRef.getName().length() - 1);
          if (element == null || element.hasTag()) return;

          NLSElement[] elements = nlsLine.getElements();
          int indexInElementList = Arrays.asList(elements).indexOf(element);
          String editText =
              ' ' + NLSElement.createTagText(indexInElementList + 1); // tags are 1-based
          TextChangeCompatibility.addTextEdit(change, label, new InsertEdit(lineEnd, editText));

        } catch (InvalidInputException e) {
        } catch (BadLocationException e) {
        }
      }
    }
  }