blob: df04592911d30ca7788aea5e0d07bcaf98249e3d [file] [log] [blame]
/*=============================================================================#
# Copyright (c) 2012, 2019 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.r.ui.sourceediting;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.statet.ltk.model.core.elements.IModelElement;
import org.eclipse.statet.ltk.model.core.elements.ISourceElement;
import org.eclipse.statet.ltk.model.core.elements.ISourceUnit;
import org.eclipse.statet.ltk.model.core.elements.IWorkspaceSourceUnit;
import org.eclipse.statet.ltk.ui.sourceediting.actions.OpenDeclaration;
import org.eclipse.statet.r.ui.RLabelProvider;
public class ROpenDeclaration extends OpenDeclaration {
public ROpenDeclaration() {
}
@Override
public ILabelProvider createLabelProvider() {
return new RLabelProvider() {
@Override
public StyledString getStyledText(final IModelElement element) {
final StyledString styledText = super.getStyledText(element);
if (element instanceof ISourceElement) {
final ISourceUnit su = ((ISourceElement) element).getSourceUnit();
if (su instanceof IWorkspaceSourceUnit) {
styledText.append(" ∙ "); //$NON-NLS-1$
styledText.append(((IResource) su.getResource()).getFullPath().toString(),
StyledString.QUALIFIER_STYLER );
}
}
return styledText;
}
};
}
}