private async Task SetRootModelAsync(REnvironment env) { _shell.AssertIsOnMainThread(); if (env.Kind != REnvironmentKind.Error) { try { var result = await EvaluateAndDescribeAsync(env); var wrapper = new VariableViewModel(result, _aggregator); _rootNode.Model = new VariableNode(_settings, wrapper); } catch (RException ex) { SetRootNode(VariableViewModel.Error(ex.Message)); } catch (RHostDisconnectedException ex) { SetRootNode(VariableViewModel.Error(ex.Message)); } } else { SetRootNode(VariableViewModel.Error(env.Name)); } // Some of the Variable Explorer tool bar buttons are depend on the R Environment (e.g., Delete all Variables button). // This will give those UI elements a chance to update state. _shell.UpdateCommandStatus(); }
private async Task SetRootModelAsync(REnvironment env) { await TaskUtilities.SwitchToBackgroundThread(); var debugSession = await GetDebugSessionAsync(); var frames = await debugSession.GetStackFramesAsync(); var frame = frames.FirstOrDefault(f => f.Index == 0); if (frame != null) { const DebugEvaluationResultFields fields = DebugEvaluationResultFields.Classes | DebugEvaluationResultFields.Expression | DebugEvaluationResultFields.TypeName | (DebugEvaluationResultFields.Repr | DebugEvaluationResultFields.ReprStr) | DebugEvaluationResultFields.Dim | DebugEvaluationResultFields.Length; DebugEvaluationResult result = await frame.EvaluateAsync( GetExpression(env), fields); var wrapper = new EvaluationWrapper(result); var rootNodeModel = new VariableNode(_settings, wrapper); VsAppShell.Current.DispatchOnUIThread( () => { _rootNode.Model = rootNodeModel; }); } }
private async Task <IRValueInfo> EvaluateAndDescribeAsync(REnvironment env) { await TaskUtilities.SwitchToBackgroundThread(); const REvaluationResultProperties properties = ClassesProperty | ExpressionProperty | TypeNameProperty | DimProperty | LengthProperty; return(await _session.EvaluateAndDescribeAsync(env.EnvironmentExpression, properties, null)); }
private string GetExpression(REnvironment env) { if (env.FrameIndex.HasValue) { return(Invariant($"sys.frame({env.FrameIndex.Value})")); } else { return(Invariant($"as.environment({env.Name.ToRStringLiteral()})")); } }
private async Task SetRootModelAsync(REnvironment env) { await TaskUtilities.SwitchToBackgroundThread(); const REvaluationResultProperties properties = ClassesProperty | ExpressionProperty | TypeNameProperty | DimProperty | LengthProperty; IRValueInfo result; try { result = await _session.EvaluateAndDescribeAsync(env.EnvironmentExpression, properties, null); } catch (RException ex) { VsAppShell.Current.DispatchOnUIThread(() => SetRootNode(VariableViewModel.Error(ex.Message))); return; } var wrapper = new VariableViewModel(result, _aggregator); var rootNodeModel = new VariableNode(_settings, wrapper); VsAppShell.Current.DispatchOnUIThread(() => _rootNode.Model = rootNodeModel); }
private async Task<IRValueInfo> EvaluateAndDescribeAsync(REnvironment env) { await TaskUtilities.SwitchToBackgroundThread(); const REvaluationResultProperties properties = ClassesProperty | ExpressionProperty | TypeNameProperty | DimProperty | LengthProperty; return await _session.EvaluateAndDescribeAsync(env.EnvironmentExpression, properties, null); }