Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Wahlbrink2018-10-16 09:50:32 +0000
committerStephan Wahlbrink2018-10-22 14:46:52 +0000
commitf4b8669f30395293639e0f0f83c737cd98e5f5e0 (patch)
tree347b56e5f0d77615f1f4dde31df8cb5476542852
parentad836558489834b5414b370df948c44075af8bb9 (diff)
downloadorg.eclipse.statet-r-f4b8669f30395293639e0f0f83c737cd98e5f5e0.tar.gz
org.eclipse.statet-r-f4b8669f30395293639e0f0f83c737cd98e5f5e0.tar.xz
org.eclipse.statet-r-f4b8669f30395293639e0f0f83c737cd98e5f5e0.zip
Bug 540176: [R-Debug] Add more detail for R promise and language objects
in Variables view - Add TmpUtils for easier handling of temporary R objects / adapt to changes in rj - Add support for detail (pane) of R debug variables/values Change-Id: Ic2f2435656f6e20a4ef5dcacd2a5501391c0ad72
-rw-r--r--r/org.eclipse.statet.nico.core/src/org/eclipse/statet/nico/core/runtime/ToolProcess.java6
-rw-r--r--r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RFunction2.java40
-rw-r--r--r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RLanguageVar.java8
-rw-r--r--r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RPromiseVar.java11
-rw-r--r--r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RReferenceVar.java10
-rw-r--r--r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RVectorVar.java9
-rw-r--r--r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/r/nico/ICombinedRDataAdapter.java41
-rw-r--r--r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/r/nico/impl/RjsController.java13
-rw-r--r--r/org.eclipse.statet.r.core/src/org/eclipse/statet/r/core/tool/TmpUtils.java140
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/RJTmp.java43
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/eval/EvalExpressionRunnable.java45
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/eval/ExpressionManager.java24
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/eval/REvaluationResult.java15
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RArrayDimVariable.java11
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RArrayIndexVariable.java16
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RArrayValue.java12
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementValue.java23
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementVariable.java27
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementVariableCompactStore.java64
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementVariableStore.java16
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/REnvValue.java26
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RLanguageValue.java128
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RListValue.java11
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RMainThread.java17
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RObjectAdapter.java103
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RPromiseValue.java216
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RStackFrame.java2
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RValueProxy.java11
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RVectorIndexVariable.java16
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RVectorValue.java30
-rw-r--r--r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/r/debug/core/IRValue.java2
-rw-r--r--r/org.eclipse.statet.r.debug.ui/src/org/eclipse/statet/internal/r/debug/ui/RDebugModelPresentation.java7
-rw-r--r--r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/AbstractRDataProvider.java82
-rw-r--r--r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/FindManager.java34
-rw-r--r--r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/RJTmp.java8
-rw-r--r--r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/ResolveCellIndexes.java5
36 files changed, 1030 insertions, 242 deletions
diff --git a/r/org.eclipse.statet.nico.core/src/org/eclipse/statet/nico/core/runtime/ToolProcess.java b/r/org.eclipse.statet.nico.core/src/org/eclipse/statet/nico/core/runtime/ToolProcess.java
index 74e3acc3..9bb13b39 100644
--- a/r/org.eclipse.statet.nico.core/src/org/eclipse/statet/nico/core/runtime/ToolProcess.java
+++ b/r/org.eclipse.statet.nico.core/src/org/eclipse/statet/nico/core/runtime/ToolProcess.java
@@ -132,7 +132,7 @@ public class ToolProcess extends AbstractProcess implements IProcess, Tool, IToo
fWorkspaceData.addPropertyListener(new Listener() {
@Override
public void propertyChanged(final ToolWorkspace workspace, final Map<String, Object> properties) {
- final Map<String, String> attributes= getAttributes(true);
+ final Map<String, String> attributes= getAttributes();
final DebugEvent nameEvent;
synchronized (attributes) {
fToolLabelTrimmedWD = null;
@@ -145,7 +145,7 @@ public class ToolProcess extends AbstractProcess implements IProcess, Tool, IToo
});
fToolLabelTrimmedWD = null;
- final Map<String, String> attributes= getAttributes(true);
+ final Map<String, String> attributes= getAttributes();
doSet(attributes, IProcess.ATTR_PROCESS_LABEL, computeConsoleLabel());
doSet(attributes, IProcess.ATTR_PROCESS_TYPE, (fMainType+PROCESS_TYPE_SUFFIX).intern());
@@ -315,7 +315,7 @@ public class ToolProcess extends AbstractProcess implements IProcess, Tool, IToo
eventCollection.add(new DebugEvent(ToolProcess.this, DebugEvent.TERMINATE));
}
- final Map<String, String> attributes= getAttributes(true);
+ final Map<String, String> attributes= getAttributes();
final DebugEvent nameEvent;
synchronized (attributes) {
fToolLabelStatus = newStatus.getMarkedLabel();
diff --git a/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RFunction2.java b/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RFunction2.java
index 5b6b0aa3..3708aca5 100644
--- a/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RFunction2.java
+++ b/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RFunction2.java
@@ -18,6 +18,7 @@ import java.io.IOException;
import java.util.Collections;
import java.util.List;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
import org.eclipse.statet.jcommons.lang.Nullable;
import org.eclipse.statet.ecommons.text.core.input.StringParserInput;
@@ -37,20 +38,45 @@ import org.eclipse.statet.rj.data.RObjectFactory;
import org.eclipse.statet.rj.data.RStore;
+@NonNullByDefault
public final class RFunction2 extends BasicCombinedRElement
implements IRMethod, RFunction {
- private ArgsDefinition fArgs;
+ private static @Nullable ArgsDefinition parseArgDef(final @Nullable String headerSource) {
+ if (headerSource != null && headerSource.length() > 0) {
+ final RScanner scanner= new RScanner(AstInfo.LEVEL_MODEL_DEFAULT);
+ final FDef fDef= scanner.scanFDef(new StringParserInput(headerSource).init());
+ if (fDef != null) {
+ return SourceAnalyzer.createMethodArgDef(fDef, null);
+ }
+ }
+ return null;
+ }
+
+
+ private final @Nullable ArgsDefinition args;
public RFunction2(final ArgsDefinition args,
final @Nullable BasicCombinedRElement parent, final @Nullable RElementName name) {
super(parent, name);
- this.fArgs= args;
+ this.args= args;
}
+ public RFunction2(final RFunction org,
+ final @Nullable BasicCombinedRElement parent, final @Nullable RElementName name) {
+ super(parent, name);
+
+ if (org instanceof RFunction2) {
+ this.args= ((RFunction2) org).args;
+ }
+ else {
+ final String headerSource= org.getHeaderSource();
+ this.args= parseArgDef(headerSource);
+ }
+ }
public RFunction2(final RJIO io, final RObjectFactory factory,
final @Nullable BasicCombinedRElement parent, final @Nullable RElementName name)
@@ -59,13 +85,7 @@ public final class RFunction2 extends BasicCombinedRElement
/*final int options =*/ io.readInt();
final String headerSource= io.readString();
- if (headerSource != null && headerSource.length() > 0) {
- final RScanner scanner= new RScanner(AstInfo.LEVEL_MODEL_DEFAULT);
- final FDef fDef= scanner.scanFDef(new StringParserInput(headerSource).init());
- if (fDef != null) {
- this.fArgs= SourceAnalyzer.createMethodArgDef(fDef, null);
- }
- }
+ this.args= parseArgDef(headerSource);
}
@Override
@@ -107,7 +127,7 @@ public final class RFunction2 extends BasicCombinedRElement
@Override
public @Nullable ArgsDefinition getArgsDefinition() {
- return this.fArgs;
+ return this.args;
}
diff --git a/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RLanguageVar.java b/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RLanguageVar.java
index 2c350047..8372bd53 100644
--- a/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RLanguageVar.java
+++ b/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RLanguageVar.java
@@ -41,6 +41,14 @@ public class RLanguageVar extends BasicCombinedRElement
private final String className1;
+ public RLanguageVar(final RLanguage org,
+ final @Nullable BasicCombinedRElement parent, final @Nullable RElementName name) {
+ super(parent, name);
+
+ this.type= org.getLanguageType();
+ this.className1= org.getRClassName();
+ }
+
public RLanguageVar(final RJIO io, final RObjectFactory factory,
final @Nullable BasicCombinedRElement parent, final @Nullable RElementName name)
throws IOException {
diff --git a/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RPromiseVar.java b/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RPromiseVar.java
index 6f14265e..1639299c 100644
--- a/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RPromiseVar.java
+++ b/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RPromiseVar.java
@@ -14,6 +14,7 @@
package org.eclipse.statet.internal.r.rdata;
+import java.io.IOException;
import java.util.Collections;
import java.util.List;
@@ -22,18 +23,26 @@ import org.eclipse.statet.jcommons.lang.Nullable;
import org.eclipse.statet.r.core.data.CombinedRElement;
import org.eclipse.statet.r.core.model.RElementName;
+import org.eclipse.statet.rj.data.RJIO;
import org.eclipse.statet.rj.data.RList;
+import org.eclipse.statet.rj.data.RObjectFactory;
import org.eclipse.statet.rj.data.RStore;
+import org.eclipse.statet.rj.data.impl.ExternalizableRObject;
@NonNullByDefault
-public final class RPromiseVar extends BasicCombinedRElement {
+public final class RPromiseVar extends BasicCombinedRElement
+ implements ExternalizableRObject {
public RPromiseVar(final @Nullable BasicCombinedRElement parent, final @Nullable RElementName name) {
super(parent, name);
}
+ @Override
+ public void writeExternal(final RJIO io, final RObjectFactory factory) throws IOException {
+ }
+
@Override
public byte getRObjectType() {
diff --git a/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RReferenceVar.java b/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RReferenceVar.java
index 2e04fa7d..ea744e45 100644
--- a/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RReferenceVar.java
+++ b/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RReferenceVar.java
@@ -28,6 +28,7 @@ import org.eclipse.statet.r.core.model.RElementName;
import org.eclipse.statet.rj.data.RJIO;
import org.eclipse.statet.rj.data.RObject;
import org.eclipse.statet.rj.data.RObjectFactory;
+import org.eclipse.statet.rj.data.RReference;
import org.eclipse.statet.rj.data.RStore;
import org.eclipse.statet.rj.data.impl.ExternalizableRObject;
@@ -53,6 +54,15 @@ public final class RReferenceVar extends BasicCombinedRElement
this.baseClassName= className;
}
+ public RReferenceVar(final RReference org,
+ final @Nullable BasicCombinedRElement parent, final @Nullable RElementName name) {
+ super(parent, name);
+
+ this.handle= org.getHandle();
+ this.type= org.getReferencedRObjectType();
+ this.baseClassName= org.getRClassName();
+ }
+
public RReferenceVar(final RJIO io, final RObjectFactory factory,
final @Nullable BasicCombinedRElement parent, final @Nullable RElementName name)
throws IOException {
diff --git a/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RVectorVar.java b/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RVectorVar.java
index 1b0f8e4a..32bcec78 100644
--- a/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RVectorVar.java
+++ b/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/internal/r/rdata/RVectorVar.java
@@ -50,6 +50,15 @@ public class RVectorVar<TData extends RStore> extends BasicCombinedRElement
this.className1= className1;
}
+ public RVectorVar(final RVector<TData> rObject,
+ final @Nullable BasicCombinedRElement parent, final @Nullable RElementName name) {
+ super(parent, name);
+
+ this.data= rObject.getData();
+ this.length= rObject.getLength();
+ this.className1= rObject.getRClassName();
+ }
+
public RVectorVar(final RJIO io, final RObjectFactory factory,
final @Nullable BasicCombinedRElement parent, final @Nullable RElementName name)
throws IOException {
diff --git a/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/r/nico/ICombinedRDataAdapter.java b/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/r/nico/ICombinedRDataAdapter.java
index 2dd64217..d02480c5 100644
--- a/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/r/nico/ICombinedRDataAdapter.java
+++ b/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/r/nico/ICombinedRDataAdapter.java
@@ -20,14 +20,25 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.statet.jcommons.lang.NonNullByDefault;
import org.eclipse.statet.jcommons.lang.Nullable;
+import org.eclipse.statet.internal.r.rdata.BasicCombinedRElement;
import org.eclipse.statet.internal.r.rdata.DirectReferenceVar;
+import org.eclipse.statet.internal.r.rdata.RFunction2;
+import org.eclipse.statet.internal.r.rdata.RLanguageVar;
+import org.eclipse.statet.internal.r.rdata.RMissingVar;
+import org.eclipse.statet.internal.r.rdata.RNullVar;
+import org.eclipse.statet.internal.r.rdata.ROtherVar;
+import org.eclipse.statet.internal.r.rdata.RPromiseVar;
import org.eclipse.statet.internal.r.rdata.RReferenceVar;
+import org.eclipse.statet.internal.r.rdata.RVectorVar;
import org.eclipse.statet.r.console.core.IRDataAdapter;
import org.eclipse.statet.r.core.data.CombinedRElement;
import org.eclipse.statet.r.core.data.CombinedRReference;
import org.eclipse.statet.r.core.model.RElementName;
+import org.eclipse.statet.rj.data.RFunction;
+import org.eclipse.statet.rj.data.RLanguage;
import org.eclipse.statet.rj.data.RObject;
import org.eclipse.statet.rj.data.RReference;
+import org.eclipse.statet.rj.data.RVector;
@NonNullByDefault
@@ -43,6 +54,36 @@ public interface ICombinedRDataAdapter extends IRDataAdapter {
return new DirectReferenceVar(element, null, name);
}
+ static CombinedRElement create(final RObject rObject,
+ final RElementName name) {
+ final BasicCombinedRElement parent= null;
+ switch (rObject.getRObjectType()) {
+ case RObject.TYPE_NULL:
+ return new RNullVar(parent, name);
+ case RObject.TYPE_VECTOR:
+ return new RVectorVar((RVector<?>) rObject, parent, name);
+// case RObject.TYPE_ARRAY:
+// case RObject.TYPE_DATAFRAME:
+// case RObject.TYPE_LIST:
+// case RObject.TYPE_ENVIRONMENT:
+// case RObject.TYPE_S4OBJECT:
+ case RObject.TYPE_LANGUAGE:
+ return new RLanguageVar((RLanguage) rObject, parent, name);
+ case RObject.TYPE_FUNCTION:
+ return new RFunction2((RFunction) rObject, parent, name);
+ case RObject.TYPE_REFERENCE:
+ return new RReferenceVar((RReference) rObject, parent, name);
+ case RObject.TYPE_OTHER:
+ return new ROtherVar(rObject.getRClassName(), parent, name);
+ case RObject.TYPE_MISSING:
+ return new RMissingVar(parent, name);
+ case RObject.TYPE_PROMISE:
+ return new RPromiseVar(parent, name);
+ default:
+ throw new UnsupportedOperationException();
+ }
+ }
+
CombinedRElement evalCombinedStruct(String command,
int options, int depth, @Nullable RElementName name,
diff --git a/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/r/nico/impl/RjsController.java b/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/r/nico/impl/RjsController.java
index b6c37809..b3f6f5de 100644
--- a/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/r/nico/impl/RjsController.java
+++ b/r/org.eclipse.statet.r.console.core/src/org/eclipse/statet/r/nico/impl/RjsController.java
@@ -830,10 +830,15 @@ public class RjsController extends AbstractRDbgController
@Override
protected void postCancelTask(final int options, final IProgressMonitor monitor) throws CoreException {
super.postCancelTask(options, monitor);
- this.fCurrentInput= ""; //$NON-NLS-1$
- doSubmitL(monitor);
- this.fCurrentInput= ""; //$NON-NLS-1$
- doSubmitL(monitor);
+ if (this.fRjs.isConsoleReady()) {
+ this.fCurrentInput= ""; //$NON-NLS-1$
+ doSubmitL(monitor);
+ this.fCurrentInput= ""; //$NON-NLS-1$
+ doSubmitL(monitor);
+ }
+ else {
+ // reschedule?
+ }
}
@Override
diff --git a/r/org.eclipse.statet.r.core/src/org/eclipse/statet/r/core/tool/TmpUtils.java b/r/org.eclipse.statet.r.core/src/org/eclipse/statet/r/core/tool/TmpUtils.java
new file mode 100644
index 00000000..05c425ea
--- /dev/null
+++ b/r/org.eclipse.statet.r.core/src/org/eclipse/statet/r/core/tool/TmpUtils.java
@@ -0,0 +1,140 @@
+/*=============================================================================#
+ # Copyright (c) 2012, 2018 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.core.tool;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.statet.jcommons.collections.ImCollections;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+
+import org.eclipse.statet.internal.r.core.RCorePlugin;
+import org.eclipse.statet.r.core.RCore;
+import org.eclipse.statet.r.core.model.RElementName;
+import org.eclipse.statet.rj.data.RDataUtils;
+import org.eclipse.statet.rj.data.RObject;
+import org.eclipse.statet.rj.data.UnexpectedRDataException;
+import org.eclipse.statet.rj.services.FunctionCall;
+import org.eclipse.statet.rj.services.RService;
+
+
+@NonNullByDefault
+public class TmpUtils {
+
+
+ private static final String CREATE_ITEM= "rj:::tmp.createItem"; //$NON-NLS-1$
+ private static final String REMOVE_ITEM= "rj:::tmp.removeItem"; //$NON-NLS-1$
+ private static final String SET= "rj:::tmp.set"; //$NON-NLS-1$
+ private static final String REMOVE= "rj:::tmp.remove"; //$NON-NLS-1$
+
+ private static final String PREFIX_PAR= "prefix"; //$NON-NLS-1$
+ private static final String ID_PAR= "id"; //$NON-NLS-1$
+ private static final String NAME_PAR= "name"; //$NON-NLS-1$
+ private static final String VALUE_PAR= "value"; //$NON-NLS-1$
+
+ private static final RElementName PKG_ELEMENT_NAME= RElementName.create(RElementName.SCOPE_NS, "rj");
+ private static final RElementName ENV_ELEMENT_NAME= RElementName.create(RElementName.MAIN_DEFAULT, ".rj.tmp");
+ public static final RElementName ENV_FQ_ELEMENT_NAME= RElementName.create(ImCollections.newList(
+ PKG_ELEMENT_NAME, ENV_ELEMENT_NAME ));
+ public static final String ENV_FQ_NAME= "rj::.rj.tmp"; //$NON-NLS-1$
+
+
+ public static boolean isTmp(final RElementName elementName) {
+ return (PKG_ELEMENT_NAME.equals(elementName.getScope())
+ && ENV_ELEMENT_NAME.getSegmentName().equals(elementName.getSegmentName()) );
+ }
+
+ public static RElementName createFQElementName(final RElementName name) {
+ return RElementName.create(ImCollections.newList(PKG_ELEMENT_NAME, ENV_ELEMENT_NAME, name));
+ }
+
+
+ public static class Item {
+
+
+ private final String id;
+
+ private final RService r;
+
+
+ Item(final String id, final RService r) {
+ this.id= id;
+ this.r= r;
+ }
+
+
+ public String getId() {
+ return this.id;
+ }
+
+ public void dispose(
+ final IProgressMonitor m) throws CoreException {
+ final FunctionCall call= this.r.createFunctionCall(REMOVE_ITEM);
+ call.addChar(ID_PAR, this.id);
+ call.evalVoid(m);
+ }
+
+ public void disposeChecked(final IProgressMonitor m) {
+ try {
+ dispose(m);
+ }
+ catch (final CoreException e) {
+ RCorePlugin.log(new Status(IStatus.ERROR, RCore.BUNDLE_ID, 0,
+ "An error occurred when cleaning up temporary objects.",
+ e ));
+ }
+ }
+
+ public String createSub(final String sub) {
+ return getId() + sub;
+ }
+
+ public void set(final String sub, final RObject value,
+ final IProgressMonitor m) throws CoreException {
+ final FunctionCall call= this.r.createFunctionCall(SET);
+ call.addChar(NAME_PAR, sub);
+ call.add(VALUE_PAR, value);
+ call.evalVoid(m);
+ }
+
+ public void set(final String sub, final String expression,
+ final IProgressMonitor m) throws CoreException {
+ final FunctionCall call= this.r.createFunctionCall(SET);
+ call.addChar(NAME_PAR, sub);
+ call.add(VALUE_PAR, expression);
+ call.evalVoid(m);
+ }
+
+ public void remove(final String sub,
+ final IProgressMonitor m) throws CoreException {
+ final FunctionCall call= this.r.createFunctionCall(REMOVE);
+ call.addChar(NAME_PAR, sub);
+ call.evalVoid(m);
+ }
+
+ }
+
+
+ public static Item newItem(final String prefix,
+ final RService r, final IProgressMonitor m) throws CoreException, UnexpectedRDataException {
+ final FunctionCall call= r.createFunctionCall(CREATE_ITEM);
+ call.addChar(PREFIX_PAR, prefix);
+ final String id= RDataUtils.checkSingleCharValue(call.evalData(m));
+ return new Item(id, r);
+ }
+
+}
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/RJTmp.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/RJTmp.java
deleted file mode 100644
index f15a70fb..00000000
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/RJTmp.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*=============================================================================#
- # Copyright (c) 2012, 2018 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;
-
-import org.eclipse.statet.jcommons.collections.ImCollections;
-import org.eclipse.statet.jcommons.lang.NonNullByDefault;
-
-import org.eclipse.statet.r.core.model.RElementName;
-
-
-@NonNullByDefault
-public class RJTmp {
-
-
- public static final String CREATE_ID= "rj:::tmp.createId"; //$NON-NLS-1$
- public static final String SET= "rj:::tmp.set"; //$NON-NLS-1$
- public static final String REMOVE= "rj:::tmp.remove"; //$NON-NLS-1$
- public static final String REMOVE_ALL= "rj:::tmp.removeAll"; //$NON-NLS-1$
-
- public static final String PREFIX_PAR= "prefix"; //$NON-NLS-1$
- public static final String ID_PAR= "id"; //$NON-NLS-1$
- public static final String NAME_PAR= "name"; //$NON-NLS-1$
- public static final String VALUE_PAR= "value"; //$NON-NLS-1$
-
- public static final String ENV= "rj::.rj.tmp"; //$NON-NLS-1$
-
- public static final RElementName PKG_NAME= RElementName.create(RElementName.SCOPE_NS, "rj");
- public static final RElementName ENV_NAME= RElementName.create(RElementName.MAIN_DEFAULT, ".rj.tmp");
- public static final RElementName ENV_FQNAME= RElementName.create(ImCollections.newList(PKG_NAME, ENV_NAME));
-
-}
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/eval/EvalExpressionRunnable.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/eval/EvalExpressionRunnable.java
index a1c5198c..9168b1c1 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/eval/EvalExpressionRunnable.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/eval/EvalExpressionRunnable.java
@@ -20,8 +20,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
-import org.eclipse.statet.jcommons.collections.ImCollections;
-import org.eclipse.statet.jcommons.lang.NonNull;
import org.eclipse.statet.jcommons.lang.NonNullByDefault;
import org.eclipse.statet.jcommons.lang.Nullable;
import org.eclipse.statet.jcommons.lang.ObjectUtils;
@@ -33,13 +31,13 @@ import org.eclipse.statet.ecommons.ts.core.Tool;
import org.eclipse.statet.internal.r.debug.core.Messages;
import org.eclipse.statet.internal.r.debug.core.RDebugCorePlugin;
-import org.eclipse.statet.internal.r.debug.core.RJTmp;
import org.eclipse.statet.internal.r.debug.core.model.RElementVariable;
import org.eclipse.statet.internal.r.debug.core.model.RMainThread;
import org.eclipse.statet.r.console.core.RWorkspace;
import org.eclipse.statet.r.core.data.CombinedRElement;
import org.eclipse.statet.r.core.model.RElementName;
import org.eclipse.statet.r.core.tool.AbstractStatetRRunnable;
+import org.eclipse.statet.r.core.tool.TmpUtils;
import org.eclipse.statet.r.nico.AbstractRDbgController;
import org.eclipse.statet.rj.data.RDataUtils;
import org.eclipse.statet.rj.data.RObject;
@@ -47,7 +45,6 @@ import org.eclipse.statet.rj.data.RReference;
import org.eclipse.statet.rj.data.UnexpectedRDataException;
import org.eclipse.statet.rj.data.impl.RReferenceImpl;
import org.eclipse.statet.rj.eclient.core.RToolService;
-import org.eclipse.statet.rj.services.FunctionCall;
import org.eclipse.statet.rj.services.RService;
@@ -123,24 +120,20 @@ public class EvalExpressionRunnable extends AbstractStatetRRunnable implements S
return;
}
- final @NonNull String id;
- { final FunctionCall call= r.createFunctionCall(RJTmp.CREATE_ID);
- call.addChar(RJTmp.PREFIX_PAR, "dbg_watch"); //$NON-NLS-1$
- id= RDataUtils.checkSingleCharValue(call.evalData(monitor));
- }
+ final TmpUtils.Item tmpItem= TmpUtils.newItem("dbg_watch", r, monitor);
try {
- evalExpression(id, r, monitor);
+ evalExpression(tmpItem, r, monitor);
}
finally {
if (this.state != FINISHING_OK) {
- thread.getExpressionManager().cleanEvalResult(id, r, monitor);
+ tmpItem.disposeChecked(monitor);
}
}
}
catch (final CoreException | UnexpectedRDataException e) {
this.state= FINISHING_ERROR;
final ToStringBuilder sb= new ObjectUtils.ToStringBuilder(
- "An error occurred when evaluating watch expression." );
+ "An error occurred when evaluating the watch expression." );
sb.addProp("expression", this.task.getRExpression()); //$NON-NLS-1$
sb.addProp("frame", this.task.getStackFrame()); //$NON-NLS-1$
RDebugCorePlugin.log(new Status(IStatus.ERROR, RDebugCorePlugin.BUNDLE_ID, 0,
@@ -148,26 +141,23 @@ public class EvalExpressionRunnable extends AbstractStatetRRunnable implements S
}
}
- private void evalExpression(final String id, final AbstractRDbgController r,
+ private void evalExpression(final TmpUtils.Item tmpItem, final AbstractRDbgController r,
final IProgressMonitor monitor) throws UnexpectedRDataException, CoreException, DebugException {
final RMainThread thread= this.task.getThread();
- final String valueName= id + ".value"; //$NON-NLS-1$
+ final String valueName= tmpItem.createSub("value"); //$NON-NLS-1$
final RElementName valueElementName= RElementName.create(RElementName.MAIN_DEFAULT,
valueName );
- final RElementName fqElementName= RElementName.create(ImCollections.newList(
- RJTmp.PKG_NAME, RJTmp.ENV_NAME, valueElementName ));
+ final RElementName fqElementName= TmpUtils.createFQElementName(valueElementName);
// System.out.println(this.task.getRExpression() + " in " + this.task.getStackFrame());
CombinedRElement element;
- final RReference ref;
try {
- element= r.evalCombinedStruct(
- this.task.getRExpression(),
- new RReferenceImpl(this.task.getStackFrame().getHandle(), RObject.TYPE_ENVIRONMENT, null),
+ element= r.evalCombinedStruct(this.task.getRExpression(),
+ new RReferenceImpl(this.task.getStackFrame().getHandle(),
+ RObject.TYPE_ENVIRONMENT, RObject.CLASSNAME_ENVIRONMENT ),
0, RService.DEPTH_REFERENCE, fqElementName, monitor );
- ref= RDataUtils.checkRReference(element);
}
catch (final CoreException e) {
synchronized (this) {
@@ -184,12 +174,9 @@ public class EvalExpressionRunnable extends AbstractStatetRRunnable implements S
return;
}
}
+ final RReference ref= RDataUtils.checkRReference(element);
- { final FunctionCall call= r.createFunctionCall(RJTmp.SET);
- call.addChar(RJTmp.NAME_PAR, valueName);
- call.add(RJTmp.VALUE_PAR, ref);
- call.evalVoid(monitor);
- }
+ tmpItem.set(valueName, ref, monitor);
if (ref.getReferencedRObjectType() == RObject.TYPE_ENVIRONMENT) {
thread.resolveReference((CombinedRElement) ref, this.stamp, monitor);
@@ -197,10 +184,10 @@ public class EvalExpressionRunnable extends AbstractStatetRRunnable implements S
else {
element= r.getWorkspaceData().resolve(ref, RWorkspace.RESOLVE_UPTODATE, 0, monitor);
if (element == null) {
- element= r.findCombinedStruct(valueElementName, RJTmp.ENV_FQNAME, false,
+ element= r.findCombinedStruct(valueElementName, TmpUtils.ENV_FQ_ELEMENT_NAME, false,
0, RService.DEPTH_INFINITE, monitor );
if (element == null) {
- throw new UnexpectedRDataException("null");
+ throw new UnexpectedRDataException("null"); //$NON-NLS-1$
}
}
}
@@ -209,7 +196,7 @@ public class EvalExpressionRunnable extends AbstractStatetRRunnable implements S
variable.getValue(monitor);
this.state= FINISHING_OK;
evalCompleted(new REvaluationResult(this.task.getRExpression(), thread,
- variable, id ));
+ variable, tmpItem ));
}
private void evalCompleted(final REvaluationResult evalResult) {
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/eval/ExpressionManager.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/eval/ExpressionManager.java
index ffb8d4b9..b77cecab 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/eval/ExpressionManager.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/eval/ExpressionManager.java
@@ -24,7 +24,6 @@ import java.util.Map.Entry;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IExpressionManager;
@@ -41,16 +40,14 @@ import org.eclipse.statet.ecommons.ts.core.Tool;
import org.eclipse.statet.ecommons.ts.core.ToolService;
import org.eclipse.statet.internal.r.debug.core.Messages;
-import org.eclipse.statet.internal.r.debug.core.RDebugCorePlugin;
-import org.eclipse.statet.internal.r.debug.core.RJTmp;
import org.eclipse.statet.internal.r.debug.core.eval.REvalExpressionTask.Key;
import org.eclipse.statet.internal.r.debug.core.model.RDebugTarget;
import org.eclipse.statet.internal.r.debug.core.model.RMainThread;
import org.eclipse.statet.internal.r.debug.core.model.RStackFrame;
import org.eclipse.statet.r.console.core.RProcess;
+import org.eclipse.statet.r.core.tool.TmpUtils;
import org.eclipse.statet.r.debug.core.IRStackFrame;
import org.eclipse.statet.r.nico.AbstractRDbgController;
-import org.eclipse.statet.rj.services.FunctionCall;
@NonNullByDefault
@@ -127,7 +124,7 @@ public class ExpressionManager {
public void clearCache(final int stamp, final @Nullable IProgressMonitor monitor) {
synchronized (this) {
if (!this.evalResults.isEmpty()) {
- for (final Iterator<Entry<Key, @Nullable REvaluationResult>> iter= evalResults.entrySet().iterator(); iter.hasNext();) {
+ for (final Iterator<Entry<Key, @Nullable REvaluationResult>> iter= this.evalResults.entrySet().iterator(); iter.hasNext();) {
final Entry<Key, @Nullable REvaluationResult> entry= iter.next();
final REvaluationResult result= entry.getValue();
if (result != null) {
@@ -255,26 +252,13 @@ public class ExpressionManager {
continue;
}
iter.remove();
- final @Nullable String tmpId= result.getTmpId();
+ final TmpUtils.Item tmpId= result.getTmpItem();
if (tmpId != null) {
- cleanEvalResult(tmpId, r, monitor);
+ tmpId.disposeChecked(monitor);
}
}
}
- public void cleanEvalResult(final String id,
- final AbstractRDbgController r, final IProgressMonitor monitor) {
- try {
- final FunctionCall call= r.createFunctionCall(RJTmp.REMOVE_ALL);
- call.addChar(RJTmp.ID_PAR, id);
- call.evalVoid(monitor);
- }
- catch (final CoreException e) {
- RDebugCorePlugin.log(new Status(IStatus.ERROR, RDebugCorePlugin.BUNDLE_ID,
- 0, "An error occurred when cleaning up temporary objects.", e ));
- }
- }
-
public void register(final REvaluationExpression expression) {
this.expressions.add(expression);
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/eval/REvaluationResult.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/eval/REvaluationResult.java
index 055ce723..27a7b257 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/eval/REvaluationResult.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/eval/REvaluationResult.java
@@ -28,6 +28,7 @@ import org.eclipse.statet.jcommons.lang.Nullable;
import org.eclipse.statet.internal.r.debug.core.RDebugCorePlugin;
import org.eclipse.statet.internal.r.debug.core.model.RElementVariable;
import org.eclipse.statet.internal.r.debug.core.model.RMainThread;
+import org.eclipse.statet.r.core.tool.TmpUtils;
import org.eclipse.statet.r.debug.core.IREvaluationResult;
import org.eclipse.statet.r.debug.core.IRValue;
import org.eclipse.statet.r.debug.core.IRVariable;
@@ -44,7 +45,7 @@ public final class REvaluationResult implements IREvaluationResult {
private final int status;
private final @Nullable RElementVariable variable;
- private final @Nullable String tmpId;
+ private final TmpUtils. @Nullable Item tmpItem;
private final @Nullable ImList<@NonNull String> errorMessages;
@@ -52,12 +53,12 @@ public final class REvaluationResult implements IREvaluationResult {
public REvaluationResult(final String expression, final RMainThread thread,
- final RElementVariable variable, final String tmpId) {
+ final RElementVariable variable, final TmpUtils.Item tmpItem) {
this.expression= expression;
this.thread= thread;
this.status= IStatus.OK;
this.variable= variable;
- this.tmpId= tmpId;
+ this.tmpItem= tmpItem;
this.errorMessages= null;
this.lockCounter= 1;
@@ -69,7 +70,7 @@ public final class REvaluationResult implements IREvaluationResult {
this.thread= thread;
this.status= status;
this.variable= null;
- this.tmpId= null;
+ this.tmpItem= null;
this.errorMessages= ImCollections.newList(errorMessage);
this.lockCounter= 1;
@@ -80,7 +81,7 @@ public final class REvaluationResult implements IREvaluationResult {
this.thread= thread;
this.status= SKIPPED;
this.variable= null;
- this.tmpId= null;
+ this.tmpItem= null;
this.errorMessages= null;
this.lockCounter= 1;
@@ -111,8 +112,8 @@ public final class REvaluationResult implements IREvaluationResult {
return (this.variable != null) ? this.variable.getCurrentValue() : null;
}
- public @Nullable String getTmpId() {
- return this.tmpId;
+ public TmpUtils. @Nullable Item getTmpItem() {
+ return this.tmpItem;
}
@Override
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RArrayDimVariable.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RArrayDimVariable.java
index ae7a22f6..d96906e8 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RArrayDimVariable.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RArrayDimVariable.java
@@ -32,7 +32,8 @@ import org.eclipse.statet.r.debug.core.IRVariable;
@NonNullByDefault
-public class RArrayDimVariable extends RVariable implements IVariableDim, IRIndexValueInternal {
+public class RArrayDimVariable extends RVariable
+ implements IRVariable, IVariableDim, IRIndexValueInternal { // IRVariable for adapters!
private final RArrayValue mainValue;
@@ -103,7 +104,7 @@ public class RArrayDimVariable extends RVariable implements IVariableDim, IRInde
}
@Override
- public String getValueString() throws DebugException {
+ public String getValueString() {
final StringBuilder sb= new StringBuilder();
final int m= this.mainValue.dimCount - this.dimIndex.length;
sb.append('[');
@@ -135,6 +136,12 @@ public class RArrayDimVariable extends RVariable implements IVariableDim, IRInde
}
@Override
+ public String getDetailString() {
+ return ""; //$NON-NLS-1$
+ }
+
+
+ @Override
public boolean hasVariables() throws DebugException {
return (this.mainValue.dim.getInt(this.mainValue.dimCount - this.dimIndex.length) > 0);
}
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RArrayIndexVariable.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RArrayIndexVariable.java
index 3b58d8bb..71136e44 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RArrayIndexVariable.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RArrayIndexVariable.java
@@ -105,7 +105,7 @@ public class RArrayIndexVariable extends RVariable implements IRIndexedVariableI
@Override
public String getValueString() throws DebugException {
- final String data= this.mainValue.getData(this.dimIndex);
+ final String data= this.mainValue.getDataExpr(this.dimIndex);
if (data == null) {
throw newRequestLoadDataFailed();
}
@@ -119,15 +119,25 @@ public class RArrayIndexVariable extends RVariable implements IRIndexedVariableI
@Override
public boolean verifyValue(final String expression) throws DebugException {
- return this.mainValue.validateDataValue(expression);
+ return this.mainValue.validateDataExpr(expression);
}
@Override
public void setValue(final String expression) throws DebugException {
- this.mainValue.setDataValue(this.dimIndex, expression);
+ this.mainValue.setDataExpr(this.dimIndex, expression);
}
@Override
+ public String getDetailString() {
+ final String data= this.mainValue.getDataExpr(this.dimIndex);
+ if (data == null) {
+ return "<error>"; //$NON-NLS-1$
+ }
+ return data;
+ }
+
+
+ @Override
public boolean hasVariables() throws DebugException {
return false;
}
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RArrayValue.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RArrayValue.java
index 9613a6e9..d100c66a 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RArrayValue.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RArrayValue.java
@@ -147,6 +147,12 @@ public class RArrayValue extends RElementVariableValue<CombinedRElement>
}
@Override
+ public String getDetailString() {
+ return ""; //$NON-NLS-1$
+ }
+
+
+ @Override
public boolean hasVariables() throws DebugException {
return (this.length > 0 && this.dim.getInt(this.dimCount - 1) > 0);
}
@@ -296,7 +302,7 @@ public class RArrayValue extends RElementVariableValue<CombinedRElement>
return data;
}
- protected @Nullable String getData(final int[] dimIndex) {
+ protected @Nullable String getDataExpr(final int[] dimIndex) {
synchronized (this.variable) {
if (this != this.variable.getCurrentValue()) {
return null;
@@ -319,7 +325,7 @@ public class RArrayValue extends RElementVariableValue<CombinedRElement>
}
}
- protected boolean validateDataValue(final String expression) {
+ protected boolean validateDataExpr(final String expression) {
synchronized (this.variable) {
if (this != this.variable.getCurrentValue()) {
return false;
@@ -333,7 +339,7 @@ public class RArrayValue extends RElementVariableValue<CombinedRElement>
}
}
- protected void setDataValue(final int[] dimIndex, final String expression) throws DebugException {
+ protected void setDataExpr(final int[] dimIndex, final String expression) throws DebugException {
synchronized (this.variable) {
if (this != this.variable.getCurrentValue()) {
throw newRequestSetDataFailed();
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementValue.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementValue.java
index f01a5e76..849f5d0a 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementValue.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementValue.java
@@ -74,6 +74,11 @@ public abstract class RElementValue<TRElement extends CombinedRElement> extends
return this;
}
+ @Override
+ public String getDetailString() {
+ return ""; //$NON-NLS-1$
+ }
+
}
protected final static VariablePartitionFactory<IRIndexElementValue> PARTITION_FACTORY= new VariablePartitionFactory<IRIndexElementValue>() {
@@ -107,13 +112,11 @@ public abstract class RElementValue<TRElement extends CombinedRElement> extends
@Override
public String getValueString() throws DebugException {
- switch (this.element.getElementType()) {
+ switch (this.element.getRObjectType()) {
case RObject.TYPE_NULL:
return "NULL"; //$NON-NLS-1$
// case RObject.TYPE_MISSING:
// return "<missing>";
-// case RObject.TYPE_PROMISE:
-// return "<not yet evaluated>";
}
return ""; //$NON-NLS-1$
}
@@ -124,6 +127,20 @@ public abstract class RElementValue<TRElement extends CombinedRElement> extends
}
@Override
+ public String getDetailString() {
+ switch (this.element.getRObjectType()) {
+ case RObject.TYPE_NULL:
+ return "NULL"; //$NON-NLS-1$
+// case RObject.TYPE_MISSING:
+// return "<missing>";
+ case RObject.TYPE_PROMISE:
+ return "<not yet evaluated>";
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+
+ @Override
public boolean isAllocated() throws DebugException {
return true;
}
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementVariable.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementVariable.java
index c4d74b56..e576786c 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementVariable.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementVariable.java
@@ -50,18 +50,22 @@ public final class RElementVariable extends RVariable implements IRElementVariab
public static @Nullable RElementName createFQElementName(IRVariable variable) {
final List<RElementName> segments= new ArrayList<>();
- byte lastType= 0;
+ byte lastRType= 0;
do {
if (variable instanceof IRElementVariable) {
final CombinedRElement element= ((IRElementVariable) variable).getElement();
- segments.add(element.getElementName());
- lastType= element.getRObjectType();
+ final RElementName elementName= element.getElementName();
+ if (elementName.getType() == RElementName.MAIN_OTHER) { // detail e.g. of promise
+ return null;
+ }
+ lastRType= element.getRObjectType();
+ segments.add(elementName);
}
variable= variable.getParent();
}
while (variable != null);
- if (lastType != RObject.TYPE_ENVIRONMENT) {
+ if (lastRType != RObject.TYPE_ENVIRONMENT) {
return null;
}
@@ -70,6 +74,10 @@ public final class RElementVariable extends RVariable implements IRElementVariab
return RElementName.create(segments);
}
+ private static boolean isEnv(final @Nullable RObject object) {
+ return (object != null && object.getRObjectType() == RObject.TYPE_ENVIRONMENT);
+ }
+
private final RMainThread thread;
@@ -270,7 +278,7 @@ public final class RElementVariable extends RVariable implements IRElementVariab
switch (element.getRObjectType()) {
case RObject.TYPE_VECTOR:
if (element.getLength() == 1) {
- return ((RVectorValue) getValue()).validateDataValue(expression);
+ return ((RVectorValue) getValue()).validateDataExpr(expression);
}
throw newNotSupported();
default:
@@ -287,7 +295,7 @@ public final class RElementVariable extends RVariable implements IRElementVariab
switch (element.getRObjectType()) {
case RObject.TYPE_VECTOR:
if (element.getLength() == 1) {
- ((RVectorValue) getValue()).setDataValue(0, expression);
+ ((RVectorValue) getValue()).setDataExpr(0, expression);
return;
}
throw newNotSupported();
@@ -310,8 +318,15 @@ public final class RElementVariable extends RVariable implements IRElementVariab
case RObject.TYPE_DATAFRAME:
case RObject.TYPE_S4OBJECT:
return new RListValue.ByName(this);
+ case RObject.TYPE_LANGUAGE:
+ return new RLanguageValue(this);
case RObject.TYPE_FUNCTION:
return new RFunctionValue(this);
+ case RObject.TYPE_PROMISE:
+ if (isEnv(element.getModelParent())) {
+ return new RPromiseValue(this);
+ }
+ //$FALL-THROUGH$
default:
return new RElementVariableValue<>(this);
}
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementVariableCompactStore.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementVariableCompactStore.java
new file mode 100644
index 00000000..6c6750e6
--- /dev/null
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementVariableCompactStore.java
@@ -0,0 +1,64 @@
+/*=============================================================================#
+ # Copyright (c) 2016, 2018 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 java.util.function.Consumer;
+
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
+
+import org.eclipse.statet.r.debug.core.IRVariable;
+
+
+@NonNullByDefault
+public class RElementVariableCompactStore {
+
+
+ private final @Nullable RElementVariable[] array;
+
+
+ public RElementVariableCompactStore(final int length) {
+ this.array= new @Nullable RElementVariable[length];
+ }
+
+
+ public void set(final int idx, final RElementVariable value) {
+ this.array[idx]= value;
+ }
+
+ public @Nullable RElementVariable get(final int idx) {
+ return this.array[idx];
+ }
+
+ public @Nullable RElementVariable clear(final int idx) {
+ final RElementVariable value= this.array[idx];
+ this.array[idx]= null;
+ return value;
+ }
+
+ public void forEachSet(final Consumer<RElementVariable> action) {
+ for (int idx= 0; idx < this.array.length; idx++) {
+ final RElementVariable value= this.array[idx];
+ if (value != null) {
+ action.accept(value);
+ }
+ }
+ }
+
+ public void toArray(final @Nullable IRVariable[] to, final int idx) {
+ System.arraycopy(this.array, 0, to, idx, this.array.length);
+ }
+
+}
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementVariableStore.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementVariableStore.java
index b9a745fb..1f4f128e 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementVariableStore.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RElementVariableStore.java
@@ -28,24 +28,24 @@ public class RElementVariableStore {
private final long length;
- private final RElementVariable[][] arrays;
+ private final @Nullable RElementVariable[] @Nullable [] arrays;
public RElementVariableStore(final long length) {
this.length= length;
- this.arrays= new RElementVariable[
+ this.arrays= new @Nullable RElementVariable[
(this.length > 0) ?
(int) ((this.length - 1) / SEGMENT_LENGTH) + 1 :
- 0 ][];
+ 0 ] @Nullable [];
}
public void set(final long idx, final RElementVariable value) {
final int idx0= (int) (idx / SEGMENT_LENGTH);
- RElementVariable[] segment= this.arrays[idx0];
+ @Nullable RElementVariable[] segment= this.arrays[idx0];
if (segment == null) {
- segment= this.arrays[idx0]= new RElementVariable[
+ segment= this.arrays[idx0]= new @Nullable RElementVariable[
(idx0 == this.arrays.length - 1) ?
(int) ((this.length - 1) % SEGMENT_LENGTH) + 1 :
SEGMENT_LENGTH];
@@ -56,13 +56,13 @@ public class RElementVariableStore {
public @Nullable RElementVariable get(final long idx) {
final int idx0= (int) (idx / SEGMENT_LENGTH);
- final RElementVariable[] segment= this.arrays[idx0];
+ final @Nullable RElementVariable[] segment= this.arrays[idx0];
return (segment != null) ? segment[(int) (idx % SEGMENT_LENGTH)] : null;
}
public @Nullable RElementVariable clear(final long idx) {
final int idx0= (int) (idx / SEGMENT_LENGTH);
- final RElementVariable[] segment= this.arrays[idx0];
+ final @Nullable RElementVariable[] segment= this.arrays[idx0];
if (segment == null) {
return null;
}
@@ -89,7 +89,7 @@ public class RElementVariableStore {
public void forEachSet(final Consumer<RElementVariable> action) {
for (int idx0= 0; idx0 < this.arrays.length; idx0++) {
- final RElementVariable[] segment= this.arrays[idx0];
+ final @Nullable RElementVariable[] segment= this.arrays[idx0];
if (segment != null) {
for (int idx1= 0; idx1 < segment.length; idx1++) {
final RElementVariable value= segment[idx1];
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/REnvValue.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/REnvValue.java
index c5d53283..98749a9f 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/REnvValue.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/REnvValue.java
@@ -96,7 +96,7 @@ public class REnvValue extends RElementValue<RProcessREnvironment> implements IR
return getValueString(this.variable);
}
- public String getValueString(final IRVariable variable) throws DebugException {
+ public String getValueString(final IRVariable variable) {
final StringBuilder sb= new StringBuilder();
sb.append('[');
sb.append(this.element.getLength());
@@ -129,6 +129,30 @@ public class REnvValue extends RElementValue<RProcessREnvironment> implements IR
}
@Override
+ public String getDetailString() {
+ return getDetailString(this.variable);
+ }
+
+ public String getDetailString(final IRVariable variable) {
+ String envName= null;
+ final RElementName elementName= this.element.getElementName();
+ if (elementName != null && elementName.getNextSegment() == null
+ && RElementName.isPackageFacetScopeType(elementName.getType()) ) {
+ envName= elementName.getDisplayName();
+ }
+ if (envName == null) {
+ envName= this.element.getEnvironmentName();
+ }
+ if (envName == null) {
+ if (this.element.getHandle() != 0) {
+ envName= Long.toString(this.element.getHandle());
+ }
+ }
+ return (envName != null) ? envName : ""; //$NON-NLS-1$
+ }
+
+
+ @Override
public boolean hasVariables() throws DebugException {
return this.element.hasModelChildren(null);
}
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RLanguageValue.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RLanguageValue.java
new file mode 100644
index 00000000..df06fba5
--- /dev/null
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RLanguageValue.java
@@ -0,0 +1,128 @@
+/*=============================================================================#
+ # Copyright (c) 2010, 2018 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.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.DebugException;
+
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
+
+import org.eclipse.statet.r.core.data.CombinedRElement;
+import org.eclipse.statet.r.core.data.RValueFormatter;
+import org.eclipse.statet.rj.data.RLanguage;
+import org.eclipse.statet.rj.data.RObject;
+import org.eclipse.statet.rj.data.UnexpectedRDataException;
+import org.eclipse.statet.rj.eclient.core.RToolService;
+import org.eclipse.statet.rj.services.FQRObjectRef;
+import org.eclipse.statet.rj.services.util.dataaccess.LazyRStore;
+import org.eclipse.statet.rj.services.util.dataaccess.LazyRStore.Fragment;
+
+
+@NonNullByDefault
+public class RLanguageValue extends RElementVariableValue<CombinedRElement> {
+
+
+ private static final RObjectAdapter<RLanguage> ADAPTER= new RObjectAdapter<>(RObject.TYPE_LANGUAGE);
+
+ static void appendValue(final RValueFormatter valueFormatter, final RLanguage rObject) {
+ if (rObject.getLanguageType() == RLanguage.NAME) {
+ valueFormatter.appendName(rObject.getSource(), false);
+ }
+ else {
+ valueFormatter.appendSourceLine(rObject.getSource(), 200);
+ }
+ }
+
+
+ private @Nullable LazyRStore<RLanguage> detailObjectStore;
+
+
+ public RLanguageValue(final RElementVariable variable) {
+ super(variable);
+ }
+
+
+ public final RLanguage getRObject() {
+ return (RLanguage) this.element;
+ }
+
+
+ @Override
+ public String getValueString() throws DebugException {
+ final LazyRStore.Fragment<RLanguage> fragment;
+ synchronized (this) {
+ fragment= getDetailObjectFragment();
+ if (fragment == null || fragment.getRObject() == null) {
+// throw newRequestLoadDataFailed();
+ return ""; //$NON-NLS-1$
+ }
+ }
+
+ final RLanguage rObject= fragment.getRObject();
+ if (rObject.getSource() != null) {
+ final RValueFormatter valueFormatter= getDebugTarget().getValueFormatter();
+ synchronized (valueFormatter) {
+ valueFormatter.clear();
+ appendValue(valueFormatter, rObject);
+ return valueFormatter.getString();
+ }
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ @Override
+ public String getDetailString() {
+ final LazyRStore.Fragment<RLanguage> fragment;
+ synchronized (this) {
+ fragment= getDetailObjectFragment();
+ if (fragment == null || fragment.getRObject() == null) {
+ return "<error>"; //$NON-NLS-1$
+ }
+ }
+
+ final RLanguage rObject= fragment.getRObject();
+ if (rObject.getSource() != null) {
+ return rObject.getSource();
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+
+ void setDataObject(final RLanguage rObject) {
+ ensureDetailObjectStore().setFragment(0, 0, rObject);
+ }
+
+ private LazyRStore<RLanguage> ensureDetailObjectStore() {
+ if (this.detailObjectStore == null) {
+ this.detailObjectStore= new LazyRStore<>(1, 1, 1,
+ new RDataLoader<RLanguage>() {
+ @Override
+ protected RLanguage doLoad(final FQRObjectRef ref,
+ final Fragment<RLanguage> fragment,
+ final RToolService r, final IProgressMonitor monitor) throws CoreException, UnexpectedRDataException {
+ return ADAPTER.loadObject(ref, getRObject(), fragment, r, monitor);
+ }
+ });
+ }
+ return this.detailObjectStore;
+ }
+
+ private @Nullable Fragment<RLanguage> getDetailObjectFragment() {
+ return ensureDetailObjectStore().getFragment(0, 0, 0, null);
+ }
+
+}
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RListValue.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RListValue.java
index aa4cfdd0..ded98c44 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RListValue.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RListValue.java
@@ -102,11 +102,6 @@ public class RListValue extends RElementVariableValue<CombinedRList> implements
}
@Override
- public boolean isAllocated() throws DebugException {
- return true;
- }
-
- @Override
public String getValueString() throws DebugException {
final StringBuilder sb= new StringBuilder();
sb.append('[');
@@ -116,6 +111,12 @@ public class RListValue extends RElementVariableValue<CombinedRList> implements
}
@Override
+ public String getDetailString() {
+ return ""; //$NON-NLS-1$
+ }
+
+
+ @Override
public boolean hasVariables() throws DebugException {
return this.element.hasModelChildren(null);
}
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RMainThread.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RMainThread.java
index d730a605..8382fd09 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RMainThread.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RMainThread.java
@@ -45,7 +45,6 @@ import org.eclipse.statet.ecommons.ts.core.ToolService;
import org.eclipse.statet.internal.r.debug.core.Messages;
import org.eclipse.statet.internal.r.debug.core.RDebugCorePlugin;
-import org.eclipse.statet.internal.r.debug.core.RJTmp;
import org.eclipse.statet.internal.r.debug.core.eval.ExpressionManager;
import org.eclipse.statet.nico.core.NicoCore;
import org.eclipse.statet.nico.core.runtime.ToolController.IToolStatusListener;
@@ -56,6 +55,7 @@ import org.eclipse.statet.r.console.core.RWorkspace;
import org.eclipse.statet.r.console.core.util.LoadReferenceRunnable;
import org.eclipse.statet.r.core.data.CombinedRElement;
import org.eclipse.statet.r.core.model.RElementName;
+import org.eclipse.statet.r.core.tool.TmpUtils;
import org.eclipse.statet.r.debug.core.IRStackFrame;
import org.eclipse.statet.r.debug.core.IRThread;
import org.eclipse.statet.r.debug.core.breakpoints.IRBreakpoint;
@@ -338,7 +338,7 @@ public class RMainThread extends RDebugElement implements IRThread,
protected void checkInit(final IProgressMonitor monitor) {
try {
if (this.rjTmpEnvRef == null) {
- { final RObject rObject= this.controller.evalData(RJTmp.ENV,
+ { final RObject rObject= this.controller.evalData(TmpUtils.ENV_FQ_NAME,
null, 0, RService.DEPTH_REFERENCE, monitor );
this.rjTmpEnvRef= RDataUtils.checkRReference(rObject, RObject.TYPE_ENVIRONMENT);
}
@@ -728,18 +728,17 @@ public class RMainThread extends RDebugElement implements IRThread,
Collections.reverse(segments);
final RElementName name= RElementName.create(segments);
return new ToolFQRObjectRef(this.controller.getTool(), envRef,
- new RLanguageImpl(RLanguage.CALL, name.getDisplayName(RElementName.DISPLAY_EXACT), null) );
+ createRefName(name) );
}
else {
final RElementName elementName= element.getElementName();
if (elementName.getNextSegment() != null) {
- if (RJTmp.PKG_NAME.equals(elementName.getScope())
- && RJTmp.ENV_NAME.getSegmentName().equals(elementName.getSegmentName()) ) {
+ if (TmpUtils.isTmp(elementName)) {
segments.add(elementName.getNextSegment());
Collections.reverse(segments);
final RElementName name= RElementName.create(segments);
return new ToolFQRObjectRef(this.controller.getTool(), this.rjTmpEnvRef,
- new RLanguageImpl(RLanguage.CALL, name.getDisplayName(RElementName.DISPLAY_EXACT), null) );
+ createRefName(name) );
}
break;
}
@@ -766,6 +765,12 @@ public class RMainThread extends RDebugElement implements IRThread,
throw new IllegalStateException("Unable to create name.");
}
+ private RLanguage createRefName(final RElementName name) {
+ return new RLanguageImpl((name.getNextSegment() == null) ? RLanguage.NAME : RLanguage.CALL,
+ name.getDisplayName(RElementName.DISPLAY_EXACT),
+ null );
+ }
+
private EnvItem getEnvItem(final Long handle) {
EnvItem item= this.envItems.get(handle);
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RObjectAdapter.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RObjectAdapter.java
new file mode 100644
index 00000000..aaa14bf4
--- /dev/null
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RObjectAdapter.java
@@ -0,0 +1,103 @@
+/*=============================================================================#
+ # Copyright (c) 2017, 2018 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.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
+
+import org.eclipse.statet.rj.data.RDataUtils;
+import org.eclipse.statet.rj.data.RLanguage;
+import org.eclipse.statet.rj.data.RObject;
+import org.eclipse.statet.rj.data.RObjectFactory;
+import org.eclipse.statet.rj.data.UnexpectedRDataException;
+import org.eclipse.statet.rj.data.impl.DefaultRObjectFactory;
+import org.eclipse.statet.rj.services.FQRObject;
+import org.eclipse.statet.rj.services.FQRObjectRef;
+import org.eclipse.statet.rj.services.FunctionCall;
+import org.eclipse.statet.rj.services.RService;
+import org.eclipse.statet.rj.services.util.dataaccess.LazyRStore;
+
+
+/**
+ * org.eclipse.statet.rj.services.util.dataaccess.AbstractRDataAdapter<TRObject, TFragmentObject>
+ * for simple objects
+ */
+@NonNullByDefault
+public class RObjectAdapter<TRObject extends RObject> {
+
+
+ // org.eclipse.statet.rj.services.util.dataaccess
+
+ protected static final String API_R_PREFIX= "rj:::sda002"; //$NON-NLS-1$
+
+
+ protected static void addXRef(final FunctionCall fcall, final FQRObjectRef ref) {
+ fcall.add("x.env", ref.getEnv()); //$NON-NLS-1$
+ fcall.add("x.expr", DefaultRObjectFactory.INSTANCE.createExpression( //$NON-NLS-1$
+ "x.env$" + ((RLanguage) ref.getName()).getSource() )); //$NON-NLS-1$
+ }
+
+ // ----
+
+
+ private final byte objectType;
+
+
+ public RObjectAdapter(final byte objectType) {
+ this.objectType= objectType;
+ }
+
+
+ public TRObject loadObject(final FQRObjectRef ref, final RObject referenceObject,
+ final LazyRStore.Fragment<TRObject> fragment,
+ final RService r,
+ final IProgressMonitor monitor) throws CoreException, UnexpectedRDataException {
+ final RObject object;
+ if (((RLanguage) ref.getName()).getLanguageType() == RLanguage.NAME) {
+ final FQRObject fqrObject= r.findData(((RLanguage) ref.getName()).getSource(),
+ ref.getEnv(), false,
+ null, getLoadOptions(), RService.DEPTH_INFINITE,
+ monitor );
+ object= (fqrObject != null) ? fqrObject.getObject() : null;
+ }
+ else {
+ final FunctionCall fcall= r.createFunctionCall(getLoadObjectFName());
+ addXRef(fcall, ref);
+
+ object= fcall.evalData(null, getLoadOptions(), RService.DEPTH_INFINITE,
+ monitor );
+ }
+
+ return validateObject(object, referenceObject, fragment);
+ }
+
+ protected String getLoadObjectFName() {
+ return API_R_PREFIX + ".getObject"; //$NON-NLS-1$
+ }
+
+ protected int getLoadOptions() {
+ return RObjectFactory.F_WITH_DBG;
+ }
+
+ protected TRObject validateObject(final @Nullable RObject rObject, final RObject referenceObject,
+ final LazyRStore.Fragment<TRObject> fragment)
+ throws UnexpectedRDataException {
+ return (TRObject) RDataUtils.checkType(rObject, this.objectType);
+ }
+
+}
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RPromiseValue.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RPromiseValue.java
new file mode 100644
index 00000000..92981f00
--- /dev/null
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RPromiseValue.java
@@ -0,0 +1,216 @@
+/*=============================================================================#
+ # Copyright (c) 2010, 2018 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 static org.eclipse.statet.jcommons.lang.ObjectUtils.nonNullAssert;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IVariable;
+
+import org.eclipse.statet.jcommons.lang.NonNull;
+import org.eclipse.statet.jcommons.lang.NonNullByDefault;
+import org.eclipse.statet.jcommons.lang.Nullable;
+import org.eclipse.statet.jcommons.lang.ObjectUtils;
+
+import org.eclipse.statet.r.core.data.CombinedRElement;
+import org.eclipse.statet.r.core.data.RValueFormatter;
+import org.eclipse.statet.r.core.model.RElementName;
+import org.eclipse.statet.r.debug.core.IRVariable;
+import org.eclipse.statet.r.nico.ICombinedRDataAdapter;
+import org.eclipse.statet.rj.data.RLanguage;
+import org.eclipse.statet.rj.data.RObject;
+import org.eclipse.statet.rj.data.UnexpectedRDataException;
+import org.eclipse.statet.rj.data.impl.RPromiseImpl;
+import org.eclipse.statet.rj.eclient.core.RToolService;
+import org.eclipse.statet.rj.services.FQRObject;
+import org.eclipse.statet.rj.services.FQRObjectRef;
+import org.eclipse.statet.rj.services.RService;
+import org.eclipse.statet.rj.services.util.dataaccess.LazyRStore;
+import org.eclipse.statet.rj.services.util.dataaccess.LazyRStore.Fragment;
+
+
+@NonNullByDefault
+public class RPromiseValue extends RElementVariableValue<CombinedRElement> {
+
+
+ private static final RObjectAdapter<RPromiseImpl> ADAPTER= new RObjectAdapter<RPromiseImpl>(RObject.TYPE_PROMISE) {
+ @Override
+ public RPromiseImpl loadObject(final FQRObjectRef ref, final RObject referenceObject,
+ final LazyRStore.Fragment<RPromiseImpl> fragment,
+ final RService r,
+ final IProgressMonitor monitor) throws CoreException, UnexpectedRDataException {
+ final RObject object;
+ { final FQRObject fqrObject= r.findData(((RLanguage) ref.getName()).getSource(),
+ ref.getEnv(), false,
+ null, getLoadOptions(), RService.DEPTH_INFINITE,
+ monitor );
+ object= (fqrObject != null) ? fqrObject.getObject() : null;
+ }
+
+ return validateObject(object, referenceObject, fragment);
+ }
+ };
+
+
+ private @Nullable LazyRStore<RPromiseImpl> detailObjectStore;
+
+ private final RElementVariableCompactStore detailVariables;
+
+
+ public RPromiseValue(final RElementVariable variable) {
+ super(variable);
+
+ this.detailVariables= new RElementVariableCompactStore(2);
+ }
+
+
+ public final RObject getRObject() {
+ return this.element;
+ }
+
+ public final @Nullable RPromiseValue getVariablePreviousValue() {
+ return (RPromiseValue) this.variable.getPreviousValue();
+ }
+
+
+ @Override
+ public String getValueString() throws DebugException {
+ final LazyRStore.Fragment<RPromiseImpl> fragment;
+ synchronized (this) {
+ fragment= getDetailObjectFragment();
+ if (fragment == null || fragment.getRObject() == null) {
+ return ""; //$NON-NLS-1$
+ }
+ }
+
+ final RPromiseImpl rObject= fragment.getRObject();
+ if (rObject.getExpression() instanceof RLanguage) {
+ final @NonNull RLanguage exprObject= (RLanguage) rObject.getExpression();
+ if (exprObject.getSource() != null) {
+ final RValueFormatter valueFormatter= getDebugTarget().getValueFormatter();
+ synchronized (valueFormatter) {
+ valueFormatter.clear();
+ valueFormatter.append("= "); //$NON-NLS-1$
+ RLanguageValue.appendValue(valueFormatter, exprObject);
+ return valueFormatter.getString();
+ }
+ }
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ @Override
+ public boolean hasVariables() throws DebugException {
+ return true;
+ }
+
+ @Override
+ public IVariable[] getVariables() throws DebugException {
+ final RPromiseValue previousValue;
+ synchronized (this.variable) {
+ if (this != this.variable.getCurrentValue()) {
+ return NO_VARIABLES;
+ }
+ previousValue= getVariablePreviousValue();
+ }
+
+ final @Nullable IRVariable[] variables= new @Nullable IRVariable[2];
+ synchronized (this.detailVariables) {
+ this.detailVariables.toArray(variables, 0);
+ if (!ObjectUtils.isAnyNull(variables)) {
+ return (IRVariable[]) variables;
+ }
+ }
+
+ final LazyRStore.Fragment<RPromiseImpl> fragment;
+ synchronized (this) {
+ fragment= getDetailObjectFragment();
+ if (fragment == null || fragment.getRObject() == null) {
+ throw newRequestLoadDataFailed();
+ }
+ }
+ synchronized (this.detailVariables) {
+ for (int idx= 0; idx < 2; idx++) {
+ RElementVariable childVariable= this.detailVariables.get(idx);
+ if (childVariable == null) {
+ final RObject dataObject;
+ final String label;
+ switch (idx) {
+ case 0:
+ dataObject= nonNullAssert(fragment.getRObject().getExpression());
+ label= "expression"; //$NON-NLS-1$
+ break;
+ case 1:
+ dataObject= nonNullAssert(fragment.getRObject().getEnvironment());
+ label= "environment"; //$NON-NLS-1$
+ break;
+ default:
+ throw new IllegalStateException();
+ }
+ final CombinedRElement childElement= ICombinedRDataAdapter.create(dataObject,
+ RElementName.create(RElementName.MAIN_OTHER, label) );
+ if (previousValue != null) {
+ childVariable= checkPreviousVariable(previousValue, idx, childElement);
+ }
+ if (childVariable == null) {
+ childVariable= new RElementVariable(childElement,
+ this.variable.getThread(), this.stamp, this.variable );
+ if (dataObject instanceof RLanguage) {
+ final RLanguageValue childValue= ((RLanguageValue) childVariable.getValue());
+ childValue.setDataObject((RLanguage) dataObject);
+ }
+ }
+ this.detailVariables.set(idx, childVariable);
+ }
+ variables[idx]= childVariable;
+ }
+ return (IRVariable[]) variables;
+ }
+ }
+
+ protected @Nullable RElementVariable checkPreviousVariable(final RPromiseValue previousValue,
+ final int idx, final CombinedRElement element) {
+ if (idx >= 0 && idx < previousValue.element.getLength()) {
+ final RElementVariable previousVariable;
+ synchronized (previousValue) {
+ previousVariable= previousValue.detailVariables.clear(idx);
+ }
+ if (previousVariable != null
+ && previousVariable.update(element, this.stamp) ) {
+ return previousVariable;
+ }
+ }
+ return null;
+ }
+
+
+ private @Nullable Fragment<RPromiseImpl> getDetailObjectFragment() {
+ if (this.detailObjectStore == null) {
+ this.detailObjectStore= new LazyRStore<>(1, 1, 1,
+ new RDataLoader<RPromiseImpl>() {
+ @Override
+ protected RPromiseImpl doLoad(final FQRObjectRef ref,
+ final Fragment<RPromiseImpl> fragment,
+ final RToolService r, final IProgressMonitor monitor) throws CoreException, UnexpectedRDataException {
+ return ADAPTER.loadObject(ref, getRObject(), fragment, r, monitor);
+ }
+ });
+ }
+ return this.detailObjectStore.getFragment(0, 0, 0, null);
+ }
+
+}
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RStackFrame.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RStackFrame.java
index 5e817bc8..e69c4676 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RStackFrame.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RStackFrame.java
@@ -513,7 +513,7 @@ public class RStackFrame extends RDebugElement implements IRStackFrame {
}
if (element != null) {
this.frameVariable= new RElementVariable(element, this.thread, this.stamp, null);
- this.variables= this.frameVariable.getValue();
+ this.variables= this.frameVariable.getValue(monitor);
}
}
}
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RValueProxy.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RValueProxy.java
index 34fb0479..714ba6fe 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RValueProxy.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RValueProxy.java
@@ -88,6 +88,15 @@ public class RValueProxy implements IRValue {
}
@Override
+ public String getDetailString() {
+ if (this.value instanceof REnvValue) {
+ return ((REnvValue) this.value).getDetailString(this.variable);
+ }
+ return this.value.getDetailString();
+ }
+
+
+ @Override
public final boolean isAllocated() throws DebugException {
return this.value.isAllocated();
}
@@ -103,7 +112,7 @@ public class RValueProxy implements IRValue {
if (orgVariables.length == 0) {
return RElementVariableValue.NO_VARIABLES;
}
- final @NonNull IVariable[] proxyVariables= new IVariable[orgVariables.length];
+ final @NonNull IVariable[] proxyVariables= new @NonNull IVariable[orgVariables.length];
for (int i= 0; i < orgVariables.length; i++) {
proxyVariables[i]= RVariableProxy.create((IRVariable) orgVariables[i], this.variable);
}
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RVectorIndexVariable.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RVectorIndexVariable.java
index f1def2de..508210bf 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RVectorIndexVariable.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RVectorIndexVariable.java
@@ -92,7 +92,7 @@ public class RVectorIndexVariable extends RVariable implements IRIndexedVariable
@Override
public String getValueString() throws DebugException {
- final String data= this.mainValue.getData(this.index);
+ final String data= this.mainValue.getDataExpr(this.index);
if (data == null) {
throw newRequestLoadDataFailed();
}
@@ -106,15 +106,25 @@ public class RVectorIndexVariable extends RVariable implements IRIndexedVariable
@Override
public boolean verifyValue(final String expression) throws DebugException {
- return this.mainValue.validateDataValue(expression);
+ return this.mainValue.validateDataExpr(expression);
}
@Override
public void setValue(final String expression) throws DebugException {
- this.mainValue.setDataValue(this.index, expression);
+ this.mainValue.setDataExpr(this.index, expression);
}
@Override
+ public String getDetailString() {
+ final String data= this.mainValue.getDataExpr(this.index);
+ if (data == null) {
+ return "<error>"; //$NON-NLS-1$
+ }
+ return data;
+ }
+
+
+ @Override
public boolean hasVariables() throws DebugException {
return false;
}
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RVectorValue.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RVectorValue.java
index 547c1e15..2447c863 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RVectorValue.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/internal/r/debug/core/model/RVectorValue.java
@@ -117,7 +117,7 @@ public class RVectorValue extends RElementVariableValue<CombinedRElement> implem
return ""; //$NON-NLS-1$
}
else if (this.length == 1) {
- final String data= getData(0);
+ final String data= getDataExpr(0);
if (data == null) {
throw newRequestLoadDataFailed();
}
@@ -129,12 +129,28 @@ public class RVectorValue extends RElementVariableValue<CombinedRElement> implem
}
@Override
+ public String getDetailString() {
+ if (this.length == 0) {
+ return ""; //$NON-NLS-1$
+ }
+ else if (this.length == 1) {
+ final String data= getDataExpr(0);
+ if (data == null) {
+ return "<error>"; //$NON-NLS-1$
+ }
+ return data;
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+
+ @Override
public boolean hasVariables() throws DebugException {
return (this.length > 1);
}
@Override
- public @NonNull IVariable[] getVariables() throws DebugException {
+ public IVariable[] getVariables() throws DebugException {
if (this.length <= 1) {
return NO_VARIABLES;
}
@@ -153,12 +169,12 @@ public class RVectorValue extends RElementVariableValue<CombinedRElement> implem
}
@Override
- public @NonNull IRVariable[] getVariables(final long offset, final int length) {
+ public IRVariable[] getVariables(final long offset, final int length) {
return getVariables(offset, length, this.variable);
}
@Override
- public @NonNull IRVariable[] getVariables(final long offset, final int length, final IRVariable parent) {
+ public IRVariable[] getVariables(final long offset, final int length, final IRVariable parent) {
if (this.length <= 1) {
throw new UnsupportedOperationException();
}
@@ -227,7 +243,7 @@ public class RVectorValue extends RElementVariableValue<CombinedRElement> implem
return data;
}
- protected @Nullable String getData(final long idx) {
+ protected @Nullable String getDataExpr(final long idx) {
synchronized (this.variable) {
if (this != this.variable.getCurrentValue()) {
return null;
@@ -249,7 +265,7 @@ public class RVectorValue extends RElementVariableValue<CombinedRElement> implem
}
}
- protected boolean validateDataValue(final String expression) {
+ protected boolean validateDataExpr(final String expression) {
synchronized (this.variable) {
if (this != this.variable.getCurrentValue()) {
return false;
@@ -263,7 +279,7 @@ public class RVectorValue extends RElementVariableValue<CombinedRElement> implem
}
}
- protected void setDataValue(final long idx, final String expression) throws DebugException {
+ protected void setDataExpr(final long idx, final String expression) throws DebugException {
synchronized (this.variable) {
if (this != this.variable.getCurrentValue()) {
throw newRequestSetDataFailed();
diff --git a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/r/debug/core/IRValue.java b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/r/debug/core/IRValue.java
index f2e6b7c0..58d7caf5 100644
--- a/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/r/debug/core/IRValue.java
+++ b/r/org.eclipse.statet.r.debug.core/src/org/eclipse/statet/r/debug/core/IRValue.java
@@ -32,4 +32,6 @@ public interface IRValue extends IValue {
@Override
String getValueString() throws DebugException;
+ String getDetailString();
+
}
diff --git a/r/org.eclipse.statet.r.debug.ui/src/org/eclipse/statet/internal/r/debug/ui/RDebugModelPresentation.java b/r/org.eclipse.statet.r.debug.ui/src/org/eclipse/statet/internal/r/debug/ui/RDebugModelPresentation.java
index 801c388a..ba670286 100644
--- a/r/org.eclipse.statet.r.debug.ui/src/org/eclipse/statet/internal/r/debug/ui/RDebugModelPresentation.java
+++ b/r/org.eclipse.statet.r.debug.ui/src/org/eclipse/statet/internal/r/debug/ui/RDebugModelPresentation.java
@@ -60,6 +60,7 @@ import org.eclipse.statet.r.debug.core.IRDebugTarget;
import org.eclipse.statet.r.debug.core.IRElementVariable;
import org.eclipse.statet.r.debug.core.IRStackFrame;
import org.eclipse.statet.r.debug.core.IRThread;
+import org.eclipse.statet.r.debug.core.IRValue;
import org.eclipse.statet.r.debug.core.IRVariable;
import org.eclipse.statet.r.debug.core.RDebugModel;
import org.eclipse.statet.r.debug.core.breakpoints.IRBreakpoint;
@@ -507,8 +508,14 @@ public class RDebugModelPresentation extends LabelProvider
return null;
}
+
@Override
public void computeDetail(final IValue value, final IValueDetailListener listener) {
+ if (value instanceof IRValue) {
+ listener.detailComputed(value, ((IRValue) value).getDetailString());
+ return;
+ }
+ listener.detailComputed(value, null);
}
}
diff --git a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/AbstractRDataProvider.java b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/AbstractRDataProvider.java
index 6a00ccb6..8af12f9e 100644
--- a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/AbstractRDataProvider.java
+++ b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/AbstractRDataProvider.java
@@ -45,6 +45,7 @@ import org.eclipse.statet.ecommons.waltable.sort.ISortModel;
import org.eclipse.statet.ecommons.waltable.sort.SortDirection;
import org.eclipse.statet.r.core.model.RElementName;
+import org.eclipse.statet.r.core.tool.TmpUtils;
import org.eclipse.statet.r.nico.ICombinedRDataAdapter;
import org.eclipse.statet.r.ui.RUI;
import org.eclipse.statet.r.ui.dataeditor.IRDataTableInput;
@@ -60,8 +61,8 @@ import org.eclipse.statet.rj.data.RObjectFactory;
import org.eclipse.statet.rj.data.RStore;
import org.eclipse.statet.rj.data.RVector;
import org.eclipse.statet.rj.data.UnexpectedRDataException;
-import org.eclipse.statet.rj.data.impl.RFactorStructStore;
import org.eclipse.statet.rj.data.impl.DefaultRObjectFactory;
+import org.eclipse.statet.rj.data.impl.RFactorStructStore;
import org.eclipse.statet.rj.eclient.core.RToolService;
import org.eclipse.statet.rj.eclient.core.ToolFQRObjectRef;
import org.eclipse.statet.rj.services.FQRObjectRef;
@@ -91,12 +92,6 @@ public abstract class AbstractRDataProvider<T extends RObject> implements IDataP
}
}
- static final void cleanTmp(final String name, final RToolService r, final IProgressMonitor monitor) throws CoreException {
- final FunctionCall call= r.createFunctionCall(RJTmp.REMOVE);
- call.addChar(RJTmp.NAME_PAR, name);
- call.evalVoid(monitor);
- }
-
public static final class SortColumn {
@@ -571,7 +566,7 @@ public abstract class AbstractRDataProvider<T extends RObject> implements IDataP
private boolean updateFiltering;
private final StringBuilder rStringBuilder= new StringBuilder(128);
- private String rCacheId; // only in R jobs
+ private TmpUtils.Item rTmpItem; // only in R jobs
private T rObjectStruct;
private final ISortModel sortModel;
@@ -681,11 +676,9 @@ public abstract class AbstractRDataProvider<T extends RObject> implements IDataP
}
try {
- if (this.rCacheId == null) {
+ if (this.rTmpItem == null) {
// r.evalVoid("require(\"rj\", quietly= TRUE)", monitor);
- final FunctionCall call= r.createFunctionCall(RJTmp.CREATE_ID);
- call.addChar(RJTmp.PREFIX_PAR, "viewer"); //$NON-NLS-1$
- this.rCacheId= RDataUtils.checkSingleCharValue(call.evalData(monitor));
+ this.rTmpItem= TmpUtils.newItem("viewer", r, monitor);
}
}
catch (final Exception e) {
@@ -776,8 +769,8 @@ public abstract class AbstractRDataProvider<T extends RObject> implements IDataP
});
}
- final String createTmp(final String key) {
- return this.rCacheId + key;
+ final TmpUtils.Item getTmpItem() {
+ return this.rTmpItem;
}
private void runUpdate(final RToolService r, final IProgressMonitor monitor) throws CoreException {
@@ -943,7 +936,7 @@ public abstract class AbstractRDataProvider<T extends RObject> implements IDataP
private void updateSorting(
final RToolService r, final IProgressMonitor monitor) throws UnexpectedRDataException, CoreException {
- cleanSorting(r, monitor);
+ cleanSorting(monitor);
final SortColumn sortColumn;
this.fragmentsLock.lock();
@@ -957,20 +950,17 @@ public abstract class AbstractRDataProvider<T extends RObject> implements IDataP
if (sortColumn != null) {
if (this.rCacheSort == null) {
- this.rCacheSort= this.rCacheId + ".order"; //$NON-NLS-1$
+ this.rCacheSort= this.rTmpItem.createSub("order"); //$NON-NLS-1$
}
- final FunctionCall call= r.createFunctionCall(RJTmp.SET);
- call.addChar(RJTmp.NAME_PAR, this.rCacheSort);
final StringBuilder cmd= getRCmdStringBuilder();
appendOrderCmd(cmd, sortColumn);
- call.add(RJTmp.VALUE_PAR, cmd.toString());
- call.evalVoid(monitor);
+ this.rTmpItem.set(this.rCacheSort, cmd.toString(), monitor);
}
}
private void updateFiltering(
final RToolService r, final IProgressMonitor monitor) throws UnexpectedRDataException, CoreException {
- cleanFiltering(r, monitor);
+ cleanFiltering(monitor);
String filter;
this.fragmentsLock.lock();
@@ -988,13 +978,9 @@ public abstract class AbstractRDataProvider<T extends RObject> implements IDataP
}
else {
if (this.rCacheFilter == null) {
- this.rCacheFilter= this.rCacheId + ".include"; //$NON-NLS-1$
- }
- { final FunctionCall call= r.createFunctionCall(RJTmp.SET);
- call.addChar(RJTmp.NAME_PAR, this.rCacheFilter);
- call.add(RJTmp.VALUE_PAR, filter);
- call.evalVoid(monitor);
+ this.rCacheFilter= this.rTmpItem.createSub("include"); //$NON-NLS-1$
}
+ this.rTmpItem.set(this.rCacheFilter, filter, monitor);
{ final FunctionCall call= r.createFunctionCall(RJTmp.GET_FILTERED_COUNT);
call.addChar(RJTmp.FILTER_PAR, this.rCacheFilter);
filteredRowCount= RDataUtils.checkSingleIntValue(call.evalData(monitor));
@@ -1013,16 +999,15 @@ public abstract class AbstractRDataProvider<T extends RObject> implements IDataP
private void updateIdx(
final RToolService r, final IProgressMonitor monitor) throws UnexpectedRDataException, CoreException {
- cleanIdx(r, monitor);
+ cleanIdx(monitor);
if (this.rCacheSort != null || this.rCacheFilter != null) {
if (this.rCacheIdx == null) {
- this.rCacheIdx= this.rCacheId + ".idx"; //$NON-NLS-1$
+ this.rCacheIdx= this.rTmpItem.createSub("idx"); //$NON-NLS-1$
}
if (this.rCacheFilter == null) { // fRCacheSort != null
- final FunctionCall call= r.createFunctionCall(RJTmp.SET);
- call.addChar(RJTmp.NAME_PAR, this.rCacheIdx);
- call.add(RJTmp.VALUE_PAR, RJTmp.ENV+'$'+ this.rCacheSort);
- call.evalVoid(monitor);
+ final StringBuilder cmd= getRCmdStringBuilder();
+ cmd.append(TmpUtils.ENV_FQ_NAME+'$').append(this.rCacheSort);
+ this.rTmpItem.set(this.rCacheIdx, cmd.toString(), monitor);
}
else if (this.rCacheSort == null) { // fRCacheFilter != null
final FunctionCall call= r.createFunctionCall(RJTmp.SET_WHICH_INDEX);
@@ -1049,7 +1034,7 @@ public abstract class AbstractRDataProvider<T extends RObject> implements IDataP
final RToolService r, final IProgressMonitor monitor) throws CoreException {
if (this.rCacheIdx != null) {
if (this.rCacheIdxR == null) {
- final String name= this.rCacheIdx + ".r"; //$NON-NLS-1$
+ final String name= this.rTmpItem.createSub("idx.r"); //$NON-NLS-1$
try {
final FunctionCall call= r.createFunctionCall(RJTmp.SET_REVERSE_INDEX);
call.addChar(RJTmp.NAME_PAR, name);
@@ -1060,7 +1045,7 @@ public abstract class AbstractRDataProvider<T extends RObject> implements IDataP
}
finally {
if (this.rCacheIdxR == null) {
- cleanTmp(name, r, monitor);
+ this.rTmpItem.remove(name, monitor);
}
}
}
@@ -1260,36 +1245,37 @@ public abstract class AbstractRDataProvider<T extends RObject> implements IDataP
private void runClean(final RToolService r, final IProgressMonitor monitor) throws CoreException {
clear(Lock.ERROR_STATE);
- cleanSorting(r, monitor);
- cleanFiltering(r, monitor);
- this.findManager.clean(r, monitor);
- cleanTmp(this.rCacheId, r, monitor);
+ cleanSorting(monitor);
+ cleanFiltering(monitor);
+ this.findManager.clean(monitor);
+ this.rTmpItem.dispose(monitor);
+ this.rTmpItem= null;
}
- private void cleanSorting(final RToolService r, final IProgressMonitor monitor) throws CoreException {
- cleanIdx(r, monitor);
+ private void cleanSorting(final IProgressMonitor monitor) throws CoreException {
+ cleanIdx(monitor);
if (this.rCacheSort != null) {
- cleanTmp(this.rCacheSort, r, monitor);
+ this.rTmpItem.remove(this.rCacheSort, monitor);
this.rCacheSort= null;
}
}
- private void cleanFiltering(final RToolService r, final IProgressMonitor monitor) throws CoreException {
- cleanIdx(r, monitor);
+ private void cleanFiltering(final IProgressMonitor monitor) throws CoreException {
+ cleanIdx(monitor);
if (this.rCacheFilter != null) {
- cleanTmp(this.rCacheFilter, r, monitor);
+ this.rTmpItem.remove(this.rCacheFilter, monitor);
this.rCacheFilter= null;
}
}
- private void cleanIdx(final RToolService r, final IProgressMonitor monitor) throws CoreException {
+ private void cleanIdx(final IProgressMonitor monitor) throws CoreException {
this.updateIdx= true;
if (this.rCacheIdx != null) {
- cleanTmp(this.rCacheIdx, r, monitor);
+ this.rTmpItem.remove(this.rCacheIdx, monitor);
this.rCacheIdx= null;
}
if (this.rCacheIdxR != null) {
- cleanTmp(this.rCacheIdxR, r, monitor);
+ this.rTmpItem.remove(this.rCacheIdxR, monitor);
this.rCacheIdxR= null;
}
}
diff --git a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/FindManager.java b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/FindManager.java
index aedfdda1..a276ec7a 100644
--- a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/FindManager.java
+++ b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/FindManager.java
@@ -32,6 +32,7 @@ import org.eclipse.statet.ecommons.ui.components.StatusInfo;
import org.eclipse.statet.ecommons.ui.util.UIAccess;
import org.eclipse.statet.internal.r.ui.dataeditor.IFindListener.FindEvent;
+import org.eclipse.statet.r.core.tool.TmpUtils;
import org.eclipse.statet.r.ui.RUI;
import org.eclipse.statet.rj.data.RDataUtils;
import org.eclipse.statet.rj.data.RObject;
@@ -152,9 +153,9 @@ class FindManager {
this.listeners.remove(listener);
}
- void clean(final RToolService r, final IProgressMonitor monitor) throws CoreException {
+ void clean(final IProgressMonitor monitor) throws CoreException {
if (this.rCacheFind != null) {
- AbstractRDataProvider.cleanTmp(this.rCacheFind, r, monitor);
+ this.dataProvider.getTmpItem().remove(this.rCacheFind, monitor);
this.rCacheFind= null;
}
}
@@ -288,7 +289,7 @@ class FindManager {
long filteredCount= 0;
try {
if (this.rCacheFind == null) {
- this.rCacheFind= this.dataProvider.createTmp(".find");
+ this.rCacheFind= this.dataProvider.getTmpItem().createSub("find");
}
final boolean runWhich;
{ final StringBuilder cmd= this.dataProvider.getRCmdStringBuilder();
@@ -296,7 +297,7 @@ class FindManager {
cmd.append("x <- ").append(this.dataProvider.getInput().getFullName()).append("; ");
cmd.append("x.find <- (").append(this.currentTask.expression).append("); ");
cmd.append("dimnames(").append("x.find").append(") <- NULL; ");
- cmd.append("assign('").append(this.rCacheFind).append("', envir= ").append(RJTmp.ENV).append(", value= x.find); ");
+ cmd.append("assign('").append(this.rCacheFind).append("', envir= ").append(TmpUtils.ENV_FQ_NAME).append(", value= x.find); ");
cmd.append("})");
final RObject logi= r.evalData(cmd.toString(), null, RObjectFactory.F_ONLY_STRUCT, RService.DEPTH_ONE, monitor);
if (logi.getRObjectType() == RObject.TYPE_ARRAY
@@ -321,28 +322,25 @@ class FindManager {
}
}
if (runWhich) {
- final FunctionCall call= r.createFunctionCall(RJTmp.SET);
- call.addChar(RJTmp.NAME_PAR, this.rCacheFind);
final StringBuilder cmd= this.dataProvider.getRCmdStringBuilder();
- cmd.append("which(").append(RJTmp.ENV+'$').append(this.rCacheFind).append(", arr.ind= TRUE)");
- call.add(RJTmp.VALUE_PAR, cmd.toString());
- call.evalVoid(monitor);
+ cmd.append("which(").append(TmpUtils.ENV_FQ_NAME+'$').append(this.rCacheFind).append(", arr.ind= TRUE)");
+ this.dataProvider.getTmpItem().set(this.rCacheFind, cmd.toString(), monitor);
}
{ final FunctionCall call= r.createFunctionCall("NROW");
- call.add(RJTmp.ENV+'$'+this.rCacheFind);
+ call.add(TmpUtils.ENV_FQ_NAME+'$'+this.rCacheFind);
count= RDataUtils.checkSingleIntValue(call.evalData(monitor));
}
filteredCount= getFilteredCount(count, r, monitor);
}
catch (final CoreException e) {
- clean(r, monitor);
+ clean(monitor);
AbstractRDataProvider.checkCancel(e);
mode= FIND_ERROR;
throw e;
}
catch (final UnexpectedRDataException e) {
- clean(r, monitor);
+ clean(monitor);
AbstractRDataProvider.checkCancel(e);
mode= FIND_ERROR;
throw e;
@@ -433,18 +431,18 @@ class FindManager {
cmd.append("local({");
if (revIndexName != null) {
if (this.activeMode == FIND_CELL) {
- cmd.append("x <- ").append(RJTmp.ENV+'$').append(revIndexName)
- .append("[").append(RJTmp.ENV+'$').append(this.rCacheFind).append("[,1L]").append("]\n");
- cmd.append("x <- cbind(x, ").append(RJTmp.ENV+'$').append(this.rCacheFind).append("[,2L]").append(")\n");
+ cmd.append("x <- ").append(TmpUtils.ENV_FQ_NAME+'$').append(revIndexName)
+ .append("[").append(TmpUtils.ENV_FQ_NAME+'$').append(this.rCacheFind).append("[,1L]").append("]\n");
+ cmd.append("x <- cbind(x, ").append(TmpUtils.ENV_FQ_NAME+'$').append(this.rCacheFind).append("[,2L]").append(")\n");
}
else {
- cmd.append("x <- ").append(RJTmp.ENV+'$').append(revIndexName)
- .append("[").append(RJTmp.ENV+'$').append(this.rCacheFind).append("]\n");
+ cmd.append("x <- ").append(TmpUtils.ENV_FQ_NAME+'$').append(revIndexName)
+ .append("[").append(TmpUtils.ENV_FQ_NAME+'$').append(this.rCacheFind).append("]\n");
}
cmd.append("x <- na.omit(x)\n");
}
else {
- cmd.append("x <- ").append(RJTmp.ENV+'$').append(this.rCacheFind).append("\n");
+ cmd.append("x <- ").append(TmpUtils.ENV_FQ_NAME+'$').append(this.rCacheFind).append("\n");
}
cmd.append("x <- x[order(");
if (this.activeMode == FIND_CELL) {
diff --git a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/RJTmp.java b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/RJTmp.java
index 4b1200c0..0b8628db 100644
--- a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/RJTmp.java
+++ b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/RJTmp.java
@@ -18,22 +18,14 @@ package org.eclipse.statet.internal.r.ui.dataeditor;
public class RJTmp {
- public static final String CREATE_ID= "rj:::tmp.createId"; //$NON-NLS-1$
- public static final String SET= "rj:::tmp.set"; //$NON-NLS-1$
- public static final String REMOVE= "rj:::tmp.remove"; //$NON-NLS-1$
-
public static final String SET_REVERSE_INDEX= "rj:::tmp.setReverseIndex"; //$NON-NLS-1$
public static final String SET_FILTERED_INDEX= "rj:::tmp.setFilteredIndex"; //$NON-NLS-1$
public static final String SET_WHICH_INDEX= "rj:::tmp.setWhichIndex"; //$NON-NLS-1$
public static final String GET_FILTERED_COUNT= "rj:::tmp.getFilteredCount"; //$NON-NLS-1$
- public static final String PREFIX_PAR= "prefix"; //$NON-NLS-1$
public static final String NAME_PAR= "name"; //$NON-NLS-1$
- public static final String VALUE_PAR= "value"; //$NON-NLS-1$
public static final String INDEX_PAR= "index"; //$NON-NLS-1$
public static final String FILTER_PAR= "filter"; //$NON-NLS-1$
public static final String LEN_PAR= "len"; //$NON-NLS-1$
- public static final String ENV= "rj::.rj.tmp"; //$NON-NLS-1$
-
}
diff --git a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/ResolveCellIndexes.java b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/ResolveCellIndexes.java
index b8554af5..394194b0 100644
--- a/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/ResolveCellIndexes.java
+++ b/r/org.eclipse.statet.r.ui/src/org/eclipse/statet/internal/r/ui/dataeditor/ResolveCellIndexes.java
@@ -24,6 +24,7 @@ import org.eclipse.statet.ecommons.ts.core.Tool;
import org.eclipse.statet.ecommons.ts.core.ToolRunnable;
import org.eclipse.statet.ecommons.ts.core.ToolService;
+import org.eclipse.statet.r.core.tool.TmpUtils;
import org.eclipse.statet.r.ui.RUI;
import org.eclipse.statet.rj.data.RDataUtils;
import org.eclipse.statet.rj.data.RStore;
@@ -131,8 +132,8 @@ public class ResolveCellIndexes {
final String revIndexName= this.dataProvider.checkRevIndex(r, monitor);
if (revIndexName != null) {
final StringBuilder cmd= this.dataProvider.getRCmdStringBuilder();
- cmd.append(RJTmp.ENV+'$').append(revIndexName)
- .append("[").append(rowIdx + 1).append("]");
+ cmd.append(TmpUtils.ENV_FQ_NAME+'$').append(revIndexName)
+ .append('[').append(rowIdx + 1).append(']');
final RVector<?> vector= RDataUtils.checkRVector(r.evalData(cmd.toString(), monitor));
final RStore<?> data= RDataUtils.checkLengthEqual(vector, 1).getData();
if (data.isNA(0)) {

Back to the top