GetChildrenAsync() public method

public GetChildrenAsync ( ) : Task>
return Task>
Beispiel #1
0
        private async Task UpdateList()
        {
            if (_updating)
            {
                return;
            }

            try {
                _updating = true;
                // May be null in tests
                var session = Workflow.RSession;
                if (session.IsHostRunning)
                {
                    var stackFrames = await session.TracebackAsync();

                    var globalStackFrame = stackFrames.FirstOrDefault(s => s.IsGlobal);
                    if (globalStackFrame != null)
                    {
                        const REvaluationResultProperties properties =
                            ExpressionProperty |
                            AccessorKindProperty |
                            TypeNameProperty |
                            ClassesProperty |
                            LengthProperty |
                            SlotCountProperty |
                            AttributeCountProperty |
                            DimProperty |
                            FlagsProperty;
                        var evaluation = await globalStackFrame.TryEvaluateAndDescribeAsync("base::environment()", "Global Environment", properties, RValueRepresentations.Str());

                        var settings = Workflow.Shell.GetService <IRSettings>();
                        var e        = new RSessionDataObject(evaluation, settings.EvaluateActiveBindings); // root level doesn't truncate children and return every variables

                        _topLevelVariables.Clear();

                        var children = await e.GetChildrenAsync();

                        if (children != null)
                        {
                            foreach (var x in children)
                            {
                                _topLevelVariables[x.Name] = x; // TODO: BUGBUG: this doesn't address removed variables
                            }
                        }
                    }
                }
            } catch (REvaluationException) { } finally {
                _updating = false;
            }
        }
        private async Task UpdateList() {
            if (_updating) {
                return;
            }

            try {
                _updating = true;
                // May be null in tests
                IRSession session = Workflow.RSession;
                if (session.IsHostRunning) {
                    var stackFrames = await session.TracebackAsync();

                    var globalStackFrame = stackFrames.FirstOrDefault(s => s.IsGlobal);
                    if (globalStackFrame != null) {
                        const REvaluationResultProperties properties =
                            ExpressionProperty |
                            AccessorKindProperty |
                            TypeNameProperty |
                            ClassesProperty |
                            LengthProperty |
                            SlotCountProperty |
                            AttributeCountProperty |
                            DimProperty |
                            FlagsProperty;
                        var evaluation = await globalStackFrame.TryEvaluateAndDescribeAsync("base::environment()", "Global Environment", properties, RValueRepresentations.Str());
                        var e = new RSessionDataObject(evaluation);  // root level doesn't truncate children and return every variables

                        _topLevelVariables.Clear();

                        var children = await e.GetChildrenAsync();
                        if (children != null) {
                            foreach (var x in children) {
                                _topLevelVariables[x.Name] = x; // TODO: BUGBUG: this doesn't address removed variables
                            }
                        }
                    }
                }
            } finally {
                _updating = false;
            }
        }
        private async Task UpdateList() {
            if (_updating) {
                return;
            }

            try {
                _updating = true;
                // May be null in tests
                var sessionProvider = EditorShell.Current.ExportProvider.GetExportedValueOrDefault<IRSessionProvider>();
                var session = sessionProvider.GetOrCreate(GuidList.InteractiveWindowRSessionGuid, null);
                if (session.IsHostRunning) {
                    var debugSessionProvider = EditorShell.Current.ExportProvider.GetExportedValueOrDefault<IDebugSessionProvider>();
                    if (debugSessionProvider != null) {
                        var debugSession = await debugSessionProvider.GetDebugSessionAsync(Session);
                        if (debugSession != null) {
                            var stackFrames = await debugSession.GetStackFramesAsync();

                            var globalStackFrame = stackFrames.FirstOrDefault(s => s.IsGlobal);
                            if (globalStackFrame != null) {
                                DebugEvaluationResult evaluation = await globalStackFrame.EvaluateAsync("base::environment()", "Global Environment");
                                var e = new RSessionDataObject(evaluation);  // root level doesn't truncate children and return every variables

                                _topLevelVariables.Clear();

                                var children = await e.GetChildrenAsync();
                                if (children != null) {
                                    foreach (var x in children) {
                                        _topLevelVariables[x.Name] = x; // TODO: BUGBUG: this doesn't address removed variables
                                    }
                                }
                            }
                        }
                    }
                }
            } finally {
                _updating = false;
            }
        }