Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1c830b3cfcb88460020608bc22849a6d7c989186 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*******************************************************************************
 * Copyright (c) 2015 QNX Software Systems and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *******************************************************************************/
package org.eclipse.cdt.internal.qt.ui.editor;

import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.ui.texteditor.ITextEditor;

public class QMLHyperlinkDetector extends AbstractHyperlinkDetector {

	@Override
	public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
		// TODO is length of region ever > 0?
		IRegion wordRegion = QMLEditor.findWord(textViewer.getDocument(), region.getOffset());
		if (wordRegion != null) {
			ITextEditor editor = (ITextEditor) getAdapter(ITextEditor.class);
			return new IHyperlink[] { new QMLHyperlink(wordRegion, textViewer, editor) };
		}
		return null;
	}

}

Back to the top