| /*=============================================================================# |
| # Copyright (c) 2010, 2021 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.core.model; |
| |
| import org.eclipse.debug.core.DebugException; |
| |
| import org.eclipse.statet.jcommons.lang.NonNullByDefault; |
| |
| import org.eclipse.statet.r.core.data.CombinedRElement; |
| import org.eclipse.statet.r.core.model.ArgsDefinition; |
| import org.eclipse.statet.r.core.model.ArgsDefinition.Arg; |
| import org.eclipse.statet.r.core.model.RLangMethod; |
| |
| |
| @NonNullByDefault |
| public class RFunctionValue extends RElementVariableValue<CombinedRElement> { |
| |
| |
| public RFunctionValue(final RElementVariable variable) { |
| super(variable); |
| } |
| |
| |
| @Override |
| public String getValueString() throws DebugException { |
| if (this.element instanceof RLangMethod) { |
| final RLangMethod lang= (RLangMethod)this.element; |
| final StringBuilder sb= new StringBuilder(); |
| final ArgsDefinition args= lang.getArgsDefinition(); |
| sb.append("function("); //$NON-NLS-1$ |
| if (args == null) { |
| sb.append("<unknown>"); //$NON-NLS-1$ |
| } |
| else if (args.size() > 0) { |
| { final Arg arg= args.get(0); |
| if (arg.name != null) { |
| sb.append(arg.name); |
| } |
| } |
| { for (int i= 1; i < args.size(); i++) { |
| sb.append(", "); //$NON-NLS-1$ |
| final Arg arg= args.get(i); |
| if (arg.name != null) { |
| sb.append(arg.name); |
| } |
| } |
| } |
| } |
| sb.append(")"); //$NON-NLS-1$ |
| return sb.toString(); |
| } |
| return super.getValueString(); |
| } |
| |
| } |