Search in sources :

Example 66 with IRegion

use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.

the class ProjectionMapping method getCoverage.

@Override
public IRegion getCoverage() {
    Position[] fragments = getFragments();
    if (fragments != null && fragments.length > 0) {
        Position first = fragments[0];
        Position last = fragments[fragments.length - 1];
        return new Region(first.offset, exclusiveEnd(last) - first.offset);
    }
    return new Region(0, 0);
}
Also used : Position(org.eclipse.jface.text.Position) Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion)

Example 67 with IRegion

use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.

the class ProjectionMapping method toOriginLines.

@Override
public IRegion toOriginLines(int imageLine) throws BadLocationException {
    IRegion imageRegion = fSlaveDocument.getLineInformation(imageLine);
    IRegion originRegion = toOriginRegion(imageRegion);
    int originStartLine = fMasterDocument.getLineOfOffset(originRegion.getOffset());
    if (originRegion.getLength() == 0)
        return new Region(originStartLine, 1);
    int originEndLine = fMasterDocument.getLineOfOffset(inclusiveEnd(originRegion));
    return new Region(originStartLine, (originEndLine + 1) - originStartLine);
}
Also used : Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IRegion(org.eclipse.jface.text.IRegion)

Example 68 with IRegion

use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.

the class ProjectionTextStore method get.

@Override
public String get(int offset, int length) {
    try {
        IRegion[] fragments = fMapping.toExactOriginRegions(new Region(offset, length));
        StringBuilder buffer = new StringBuilder();
        for (int i = 0; i < fragments.length; i++) {
            IRegion fragment = fragments[i];
            buffer.append(fMasterDocument.get(fragment.getOffset(), fragment.getLength()));
        }
        return buffer.toString();
    } catch (BadLocationException e) {
        internalError();
    }
    // unreachable
    return null;
}
Also used : Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IRegion(org.eclipse.jface.text.IRegion) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 69 with IRegion

use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.

the class ProjectionDocumentTest method test29_20.

@Test
public void test29_20() {
    // test computation of unprojected  master regions
    // spanning multiple fragments
    // starting touching left fragment border
    // ending touching right fragment border
    IRegion[] expected = { new Region(80, 20), new Region(120, 20) };
    assertUnprojectedMasterRegions(expected, 60, 100);
}
Also used : Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IRegion(org.eclipse.jface.text.IRegion) Test(org.junit.Test)

Example 70 with IRegion

use of org.eclipse.jface.text.IRegion in project eclipse.platform.text by eclipse.

the class ProjectionDocumentTest method test29_22.

@Test
public void test29_22() {
    // test computation of unprojected  master regions
    // spanning multiple fragments
    // starting inside fragment
    // ending left of fragment
    IRegion[] expected = { new Region(80, 20), new Region(120, 10) };
    assertUnprojectedMasterRegions(expected, 70, 60);
}
Also used : Region(org.eclipse.jface.text.Region) IRegion(org.eclipse.jface.text.IRegion) IRegion(org.eclipse.jface.text.IRegion) Test(org.junit.Test)

Aggregations

IRegion (org.eclipse.jface.text.IRegion)341 BadLocationException (org.eclipse.jface.text.BadLocationException)158 Region (org.eclipse.jface.text.Region)151 Test (org.junit.Test)94 IDocument (org.eclipse.jface.text.IDocument)68 Point (org.eclipse.swt.graphics.Point)49 Position (org.eclipse.jface.text.Position)38 ITextViewerExtension5 (org.eclipse.jface.text.ITextViewerExtension5)20 ITypedRegion (org.eclipse.jface.text.ITypedRegion)20 FindReplaceDocumentAdapter (org.eclipse.jface.text.FindReplaceDocumentAdapter)18 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)17 IEditorPart (org.eclipse.ui.IEditorPart)13 ArrayList (java.util.ArrayList)11 Document (org.eclipse.jface.text.Document)11 StyledText (org.eclipse.swt.custom.StyledText)10 ITextSelection (org.eclipse.jface.text.ITextSelection)9 IFile (org.eclipse.core.resources.IFile)8 Annotation (org.eclipse.jface.text.source.Annotation)7 HashMap (java.util.HashMap)6 CoreException (org.eclipse.core.runtime.CoreException)6