public IRegion getDamageRegion(  
        ITypedRegion partition,  
        DocumentEvent event,  
        boolean documentPartitioningChanged) {  
        if (!documentPartitioningChanged) {  
            try {  
  
                IRegion info =  
                    fDocument.getLineInformationOfOffset(event.getOffset());  
                int start = Math.max(partition.getOffset(), info.getOffset());  
  
                int end =  
                    event.getOffset()  
                        + (event.getText() == null  
                            ? event.getLength()  
                            : event.getText().length());  
  
                if (info.getOffset() <= end  
                    && end <= info.getOffset() + info.getLength()) {  
                    // optimize the case of the same line  
                    end = info.getOffset() + info.getLength();  
                } else  
                    end = endOfLineOf(end);  
  
                end =  
                    Math.min(  
                        partition.getOffset() + partition.getLength(),  
                        end);  
                return new Region(start, end - start);  
  
            } catch (BadLocationException x) {  
            }  
        }  
  
        return partition;  
    }