for (int i= 0; i != positions.length; i++) { TypedPosition position= (TypedPosition) positions[i]; int offset= position.getOffset();  if (offset >= event.getOffset()) position.setOffset(offset + deltaLength);
Position position= positions[i];  if (position.isDeleted()) continue;  int offset= position.getOffset(); int length= position.getLength(); int end= offset + length;  if (offset > eventOffset + eventOldLength) position.setOffset(offset + deltaLength); else if (end < eventOffset) ; else if (offset <= eventOffset && end >= eventOffset + eventOldLength) {  position.setLength(length + deltaLength); } else if (offset < eventOffset) {  int newEnd= eventOffset + eventNewLength; position.setLength(newEnd - offset); } else if (end > eventOffset + eventOldLength) {    int newOffset = eventOffset + eventNewLength; position.setOffset(newOffset); position.setLength(length + deltaLength); } else {  position.delete(); JavaPlugin.log(new Status(IStatus.INFO, JavaPlugin.getPluginId(), IStatus.OK, "linked position deleted -> must leave: "+fPositionCategoryName, null)); fMustLeave= true;
	public void update(DocumentEvent event) {		int deltaLength= (event.getText() == null ? 0 : event.getText().length()) - event.getLength();		Position[] positions= getPositions(event.getDocument());		TypedPosition currentPosition= (TypedPosition) findCurrentPosition(positions, event.getOffset());		// document change outside positions		if (currentPosition == null) {						for (int i= 0; i != positions.length; i++) {				TypedPosition position= (TypedPosition) positions[i];				int offset= position.getOffset();								if (offset >= event.getOffset())					position.setOffset(offset + deltaLength);			}					// document change within a position		} else {			int length= currentPosition.getLength();				for (int i= 0; i != positions.length; i++) {				TypedPosition position= (TypedPosition) positions[i];				int offset= position.getOffset();								if (position.equals(currentPosition)) {					// see bug 41849					if (length + deltaLength < 0) {						fMustLeave= true;						return;					}					position.setLength(length + deltaLength);									} else if (offset > currentPosition.getOffset()) {					position.setOffset(offset + deltaLength);				}			}				}	}