Inheritance: IREnvironment
Exemple #1
0
        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();
        }
Exemple #2
0
        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;
                });
            }
        }
Exemple #3
0
        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));
        }
Exemple #4
0
 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);
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        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();
        }