Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.IRegion


        if (document == null) {
            return null;
        }

        IRegion lineInfo;
        String line;
        try {
            lineInfo = document.getLineInformationOfOffset(offset);
            line = document.get(lineInfo.getOffset(), lineInfo.getLength());
        } catch (final BadLocationException ex) {
            return null;
        }
        final int offsetInLine = offset - lineInfo.getOffset();

        IRegion r = getLink(line, offsetInLine);
        if (r != null) {
            final String text = line.substring(r.getOffset(),
                    r.getOffset() + r.getLength());
            r = new Region(lineInfo.getOffset() + r.getOffset(), r.getLength());

            return new IHyperlink[] { new TraceHyperlink(r, text) };
        }
        return null;
    }
View Full Code Here


        boolean hasChanged = false;
        final int offset = selection.getOffset();
        if (document instanceof IDocumentExtension4) {
            final long currentModificationStamp = ((IDocumentExtension4) document)
                    .getModificationStamp();
            final IRegion markOccurrenceTargetRegion = fMarkOccurrenceTargetRegion;
            hasChanged = currentModificationStamp != fMarkOccurrenceModificationStamp;
            if (markOccurrenceTargetRegion != null && !hasChanged) {
                if (markOccurrenceTargetRegion.getOffset() <= offset
                        && offset <= markOccurrenceTargetRegion.getOffset()
                                + markOccurrenceTargetRegion.getLength()) {
                    return;
                }
            }
            fMarkOccurrenceTargetRegion = ErlangWordFinder.findWord(module, editor,
                    offset);
View Full Code Here

        final IDocument document = sourceViewer.getDocument();
        if (document == null) {
            return;
        }

        final IRegion selection = getSignedSelection(sourceViewer);

        final int selectionLength = Math.abs(selection.getLength());
        if (selectionLength > 1) {
            setStatusLineErrorMessage(ErlangEditorMessages.GotoMatchingBracket_error_invalidSelection);
            sourceViewer.getTextWidget().getDisplay().beep();
            return;
        }

        // #26314
        final int sourceCaretOffset = selection.getOffset() + selection.getLength();
        // TODO fix me!
        // if (isSurroundedByBrackets(document, sourceCaretOffset))
        // sourceCaretOffset -= selection.getLength();

        final IRegion region = getBracketMatcher().match(document, sourceCaretOffset);
        if (region == null) {
            setStatusLineErrorMessage(ErlangEditorMessages.GotoMatchingBracket_error_noMatchingBracket);
            sourceViewer.getTextWidget().getDisplay().beep();
            return;
        }

        final int offset = region.getOffset();
        final int length = region.getLength();

        if (length < 1) {
            return;
        }

        final int anchor = getBracketMatcher().getAnchor();
        // http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
        int targetOffset = ICharacterPairMatcher.RIGHT == anchor ? offset + 1 : offset
                + length;

        boolean visible = false;
        if (sourceViewer instanceof ITextViewerExtension5) {
            final ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
            visible = extension.modelOffset2WidgetOffset(targetOffset) > -1;
        } else {
            final IRegion visibleRegion = sourceViewer.getVisibleRegion();
            // http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
            visible = targetOffset >= visibleRegion.getOffset()
                    && targetOffset <= visibleRegion.getOffset()
                            + visibleRegion.getLength();
        }

        if (!visible) {
            setStatusLineErrorMessage(ErlangEditorMessages.GotoMatchingBracket_error_bracketOutsideSelectedElement);
            sourceViewer.getTextWidget().getDisplay().beep();
View Full Code Here

        level.fUI.setExitPosition(sourceViewer, offset + 2 + selLength, 0,
                Integer.MAX_VALUE);
        level.fUI.setCyclingMode(LinkedModeUI.CYCLE_NEVER);
        level.fUI.enter();

        final IRegion newSelection = level.fUI.getSelectedRegion();
        sourceViewer.setSelectedRange(newSelection.getOffset(), newSelection.getLength());
    }
View Full Code Here

        updateDocumentSelection(document, offset, selStr.length(), closingCharacter);
    }

    private int getKindOfBracket(final IDocument document, final int offset,
            final int length) throws BadLocationException {
        final IRegion endLine = document.getLineInformationOfOffset(offset + length);

        List<ErlToken> tokens = null;
        final int getOffset = offset + length, getLength = endLine.getOffset()
                + endLine.getLength() - getOffset;
        final String str = document.get(getOffset, getLength);
        try {
            tokens = ErlangEngine.getInstance().getSimpleScannerService()
                    .lightScanString(str, 0);
        } catch (final ScannerException e) {
View Full Code Here

            // get the text hover content
            final String contentType = TextUtilities.getContentType(
                    sourceViewer.getDocument(), IErlangPartitions.ERLANG_PARTITIONING,
                    offset, true);

            final IRegion hoverRegion = textHover.getHoverRegion(sourceViewer, offset);
            if (hoverRegion == null) {
                return;
            }

            final String hoverInfo = "";
View Full Code Here

            final int widgetLocation = styledText.getOffsetAtLocation(new Point(x, y));
            if (textViewer instanceof ITextViewerExtension5) {
                final ITextViewerExtension5 extension = (ITextViewerExtension5) textViewer;
                return extension.widgetOffset2ModelOffset(widgetLocation);
            }
            final IRegion visibleRegion = textViewer.getVisibleRegion();
            return widgetLocation + visibleRegion.getOffset();
        } catch (final IllegalArgumentException e) {
            return -1;
        }

    }
View Full Code Here

        log.info("mark line " + lr.getLineNum());

        try {

            final IRegion reg = doc.getLineInformation(lr.getLineNum() - 1);
            final int length = reg.getLength();
            final int offset = reg.getOffset();
            final Position pos = new Position(offset, length);

            Annotation annotation;
            if (lr.called()) {
                annotation = CoverageAnnotationFactory
View Full Code Here

        }

        final IDocument document = part.getDocument();
        fText = part;

        final IRegion region = fPairMatcher.match(document, offset);
        if (region != null && region.getLength() >= 2) {
            part.setSelectedRange(region.getOffset(), region.getLength());
        } else {
            if (!selectComment(offset)) {
                selectWord(offset);
            }
        }
View Full Code Here

        private int length;
        private int offset;

        public MarkCallLocation(final IDocument doc, final int line) {
            try {
                final IRegion info = doc.getLineInformation(line);
                final String lineStr = doc.get(info.getOffset(), info.getLength());

                try {
                    final String cmd = lineStr.substring(26, 32);
                    if ("return".equals(cmd)) {
                        String ref = lineStr.substring(34, lineStr.indexOf(" ->"));
                        ref = ref.substring(0, ref.length() - 2);
                        // find call before it
                        for (int ln = line - 1; ln > 0; ln--) {
                            final IRegion li = doc.getLineInformation(ln);
                            final String ls = doc.get(li.getOffset(), li.getLength());
                            if (ls.contains(ref)) {
                                offset = li.getOffset();
                                length = li.getLength();
                                description = ref;
                                break;
                            }
                        }
                    } else if ("  call".equals(cmd)) {
                        final String ref = lineStr.substring(34, lineStr.indexOf('('));
                        // find return after it
                        for (int ln = line + 1; ln < doc.getNumberOfLines(); ln++) {
                            final IRegion li = doc.getLineInformation(ln);
                            final String ls = doc.get(li.getOffset(), li.getLength());
                            if (ls.contains(ref)) {
                                offset = li.getOffset();
                                length = li.getLength();
                                description = ref;
                                break;
                            }
                        }
                    } else {
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.IRegion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.