1
/*******************************************************************************
2
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Anton Leherbauer (Wind River Systems) - initial API and implementation
10
*******************************************************************************/
12
package org.eclipse.cdt.internal.ui.text;
14
import org.eclipse.jface.text.BadLocationException;
15
import org.eclipse.jface.text.DocumentEvent;
16
import org.eclipse.jface.text.IDocument;
17
import org.eclipse.jface.text.IRegion;
18
import org.eclipse.jface.text.ITypedRegion;
19
import org.eclipse.jface.text.Region;
20
import org.eclipse.jface.text.presentation.IPresentationDamager;
23
* A simple presentation damager always damaging the whole partition.
24
* This is necessary if the partition contains multiline highlight regions.
28
public class PartitionDamager implements IPresentationDamager {
31
* @see org.eclipse.jface.text.presentation.IPresentationDamager#getDamageRegion(org.eclipse.jface.text.ITypedRegion, org.eclipse.jface.text.DocumentEvent, boolean)
33
public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event,
34
boolean documentPartitioningChanged) {
35
if (!documentPartitioningChanged && event.getOffset() == partition.getOffset() + partition.getLength()) {
38
lineRegion = event.fDocument.getLineInformationOfOffset(event.getOffset());
39
int start= partition.getOffset();
40
int end= lineRegion.getOffset() + lineRegion.getLength();
41
return new Region(start, end - start);
42
} catch (BadLocationException exc) {
50
* @see org.eclipse.jface.text.presentation.IPresentationDamager#setDocument(org.eclipse.jface.text.IDocument)
52
public void setDocument(IDocument document) {