Search in sources :

Example 1 with LinkGeneratorResult

use of org.fife.ui.rsyntaxtextarea.LinkGeneratorResult in project jadx by skylot.

the class CodeLinkGenerator method isLinkAtOffset.

@Override
public LinkGeneratorResult isLinkAtOffset(RSyntaxTextArea textArea, int offset) {
    try {
        if (jNode.getCodeInfo() == null) {
            return null;
        }
        int sourceOffset = getLinkSourceOffset(textArea, offset);
        if (sourceOffset == -1) {
            return null;
        }
        JumpPosition defPos = getJumpBySourceOffset(textArea, sourceOffset);
        if (defPos == null) {
            return null;
        }
        return new LinkGeneratorResult() {

            @Override
            public HyperlinkEvent execute() {
                return new HyperlinkEvent(defPos, HyperlinkEvent.EventType.ACTIVATED, null, defPos.getNode().makeLongString());
            }

            @Override
            public int getSourceOffset() {
                return sourceOffset;
            }
        };
    } catch (Exception e) {
        LOG.error("isLinkAtOffset error", e);
        return null;
    }
}
Also used : LinkGeneratorResult(org.fife.ui.rsyntaxtextarea.LinkGeneratorResult) HyperlinkEvent(javax.swing.event.HyperlinkEvent) JumpPosition(jadx.gui.utils.JumpPosition) BadLocationException(javax.swing.text.BadLocationException)

Aggregations

JumpPosition (jadx.gui.utils.JumpPosition)1 HyperlinkEvent (javax.swing.event.HyperlinkEvent)1 BadLocationException (javax.swing.text.BadLocationException)1 LinkGeneratorResult (org.fife.ui.rsyntaxtextarea.LinkGeneratorResult)1