blob: 96b4b20b95c42d2798bdd00630cb8e44c5347da3 [file] [log] [blame]
/*=============================================================================#
# Copyright (c) 2011, 2020 Stephan Wahlbrink and others.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
# which is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
#
# Contributors:
# Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation
#=============================================================================*/
package org.eclipse.statet.internal.r.debug.ui.actions;
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.statet.internal.r.debug.ui.RDebugUIUtils;
import org.eclipse.statet.ltk.ui.sourceediting.ISourceEditor;
import org.eclipse.statet.nico.core.runtime.ToolStatus;
import org.eclipse.statet.r.core.model.RElementAccess;
import org.eclipse.statet.r.nico.AbstractRDbgController;
public class StepIntoSelectionHyperlinkDetector extends AbstractHyperlinkDetector {
public StepIntoSelectionHyperlinkDetector() {
}
@Override
public IHyperlink[] detectHyperlinks(final ITextViewer textViewer,
final IRegion region, final boolean canShowMultipleHyperlinks) {
final ISourceEditor editor = getAdapter(ISourceEditor.class);
if (editor == null) {
return null;
}
final AbstractRDbgController controller = RDebugUIUtils.getRDbgController(editor);
if (controller == null || controller.getStatus() != ToolStatus.STARTED_SUSPENDED) {
return null;
}
final RElementAccess access = StepIntoSelectionHandler.searchAccess(editor, region);
if (access != null) {
return new IHyperlink[] {
new StepIntoSelectionHyperlink(editor, access, controller) };
}
return null;
}
}