Пример #1
0
        /// <summary>
        /// Create new instance of <see cref="DataEvaluation"/>
        /// </summary>
        /// <param name="evaluation">R session's evaluation result</param>
        public RSessionDataObject(IREvaluationResultInfo evaluation, int?maxChildrenCount = null) : this()
        {
            DebugEvaluation = evaluation;

            Name = DebugEvaluation.Name?.TrimStart(NameTrimChars);

            if (DebugEvaluation is IRValueInfo)
            {
                var valueEvaluation = (IRValueInfo)DebugEvaluation;

                Value    = GetValue(valueEvaluation)?.Trim();
                TypeName = valueEvaluation.TypeName;

                if (valueEvaluation.Classes != null)
                {
                    var escaped = valueEvaluation.Classes.Select((x) => x.IndexOf(' ') >= 0 ? "'" + x + "'" : x);
                    Class = string.Join(", ", escaped); // TODO: escape ',' in class names
                }

                HasChildren = valueEvaluation.HasChildren;

                if (valueEvaluation.Dim != null)
                {
                    Dimensions = valueEvaluation.Dim;
                }
                else if (valueEvaluation.Length.HasValue)
                {
                    Dimensions = new List <int>()
                    {
                        valueEvaluation.Length.Value, 1
                    };
                }
                else
                {
                    Dimensions = new List <int>();
                }
            }
            else if (DebugEvaluation is IRPromiseInfo)
            {
                var promiseInfo = (IRPromiseInfo)DebugEvaluation;
                Value = promiseInfo.Code;
                Class = TypeName = "<promise>";
            }
            else if (DebugEvaluation is IRActiveBindingInfo)
            {
                const string ActiveBindingValue = "<active binding>";
                var          activeBinding      = (IRActiveBindingInfo)DebugEvaluation;

                Value    = ActiveBindingValue;
                TypeName = ActiveBindingValue;
                Class    = ActiveBindingValue;
            }

            if (Dimensions == null)
            {
                Dimensions = new List <int>();
            }

            MaxChildrenCount = maxChildrenCount;
        }
Пример #2
0
        /// <summary>
        /// Create new instance of <see cref="DataEvaluation"/>
        /// </summary>
        /// <param name="evaluation">R session's evaluation result</param>
        public RSessionDataObject(IREvaluationResultInfo evaluation, int? maxChildrenCount = null) : this() {
            DebugEvaluation = evaluation;

            Name = DebugEvaluation.Name?.TrimStart(NameTrimChars);

            if (DebugEvaluation is IRValueInfo) {
                var valueEvaluation = (IRValueInfo)DebugEvaluation;
                Initalize(valueEvaluation);
            } else if (DebugEvaluation is IRPromiseInfo) {
                var promiseInfo = (IRPromiseInfo)DebugEvaluation;
                Value = promiseInfo.Code;
                Class = TypeName = "<promise>";
            } else if (DebugEvaluation is IRActiveBindingInfo) {
                const string ActiveBindingText = "<active binding>";
                var activeBinding = (IRActiveBindingInfo)DebugEvaluation;
                if(activeBinding.ComputedValue != null) {
                    Initalize(activeBinding.ComputedValue);
                } else {
                    Value = ActiveBindingText;
                    TypeName = ActiveBindingText;
                    Class = ActiveBindingText;
                }
            }

            if (Dimensions == null) Dimensions = new List<int>();

            MaxChildrenCount = maxChildrenCount;
        }
Пример #3
0
 public void ShowDataGrid(IREvaluationResultInfo evaluationResult) {
     var wrapper = new VariableViewModel(evaluationResult, _aggregator);
     if (!wrapper.CanShowDetail) {
         throw new InvalidOperationException("Cannot show data grid on evaluation result " + evaluationResult);
     }
     wrapper.ShowDetailCommand.Execute(null);
 }
Пример #4
0
 /// <summary>
 /// Like <see cref="RSessionExtensions.DescribeChildrenAsync"/>, but returns children of the object described
 /// by the provided evaluation info.
 /// </summary>
 public static Task <IReadOnlyList <IREvaluationResultInfo> > DescribeChildrenAsync(
     this IREvaluationResultInfo info,
     REvaluationResultProperties properties,
     string repr,
     int?maxCount = null,
     CancellationToken cancellationToken = default(CancellationToken)
     ) =>
 info.Evaluator.DescribeChildrenAsync(info.EnvironmentExpression, info.Expression, properties, repr, maxCount, cancellationToken);
Пример #5
0
 /// <summary>
 /// If this evaluation result corresponds to an expression that is a valid assignment target (i.e. valid on the
 /// left side of R operator <c>&lt;-</c>, such as a variable), assigns the specified value to that target.
 /// </summary>
 /// <param name="value">Value to assign. Must be a valid R expression.</param>
 /// <returns>
 /// A task that is completed once the assignment completes. Failure to assign is reported as exception on the task.
 /// </returns>
 public static Task AssignAsync(this IREvaluationResultInfo info, string value, CancellationToken cancellationToken = default(CancellationToken))
 {
     if (string.IsNullOrEmpty(info.Expression))
     {
         throw new InvalidOperationException(Invariant($"{nameof(AssignAsync)} is not supported for this {nameof(REvaluationResultInfo)} because it doesn't have an associated {nameof(info.Expression)}."));
     }
     return(info.Evaluator.ExecuteAsync(Invariant($"{info.Expression} <- {value}"), cancellationToken));
 }
Пример #6
0
        public AD7Property(AD7StackFrame stackFrame, IREvaluationResultInfo result, bool isSynthetic = false, bool isFrameEnvironment = false) {
            StackFrame = stackFrame;
            EvaluationResult = result;
            IsSynthetic = isSynthetic;
            IsFrameEnvironment = isFrameEnvironment;

            _children = Lazy.Create(CreateChildren);
            _reprToString = Lazy.Create(GetReprToString);
        }
Пример #7
0
        /// <summary>
        /// Create new instance of <see cref="VariableViewModel"/>
        /// </summary>
        /// <param name="evaluation">R session's evaluation result</param>
        /// <param name="truncateChildren">true to truncate children returned by GetChildrenAsync</param>
        public VariableViewModel(IREvaluationResultInfo evaluation, IObjectDetailsViewerAggregator aggregator, int index = -1, int? maxChildrenCount = null) :
            base(evaluation, maxChildrenCount) {
            _aggregator = aggregator;

            Index = index;
            var result = DebugEvaluation as IRValueInfo;
            if (result != null) {
                SetViewButtonStatus(result);
            }
        }
Пример #8
0
        public AD7Property(AD7StackFrame stackFrame, IREvaluationResultInfo result, bool isSynthetic = false, bool isFrameEnvironment = false)
        {
            StackFrame         = stackFrame;
            EvaluationResult   = result;
            IsSynthetic        = isSynthetic;
            IsFrameEnvironment = isFrameEnvironment;

            _children     = Lazy.Create(CreateChildren);
            _reprToString = Lazy.Create(GetReprToString);
        }
Пример #9
0
        public void ShowDataGrid(IREvaluationResultInfo evaluationResult)
        {
            var wrapper = new VariableViewModel(evaluationResult, _aggregator);

            if (!wrapper.CanShowDetail)
            {
                throw new InvalidOperationException("Cannot show data grid on evaluation result " + evaluationResult);
            }
            wrapper.ShowDetailCommand.Execute(null);
        }
Пример #10
0
        public AD7Property(AD7StackFrame stackFrame, IREvaluationResultInfo result, bool isSynthetic = false, bool isFrameEnvironment = false)
        {
            StackFrame         = stackFrame;
            EvaluationResult   = result;
            IsSynthetic        = isSynthetic;
            IsFrameEnvironment = isFrameEnvironment;

            _children     = Lazy.Create(CreateChildren);
            _reprToString = Lazy.Create(GetReprToString);
            _settings     = stackFrame.Engine.Shell.GetService <IRToolsSettings>();
        }
Пример #11
0
        /// <summary>
        /// Create new instance of <see cref="VariableViewModel"/>
        /// </summary>
        /// <param name="evaluation">R session's evaluation result</param>
        /// <param name="truncateChildren">true to truncate children returned by GetChildrenAsync</param>
        public VariableViewModel(IREvaluationResultInfo evaluation, IServiceContainer services, int index = -1, int?maxChildrenCount = null) :
            base(evaluation, services, maxChildrenCount)
        {
            _aggregator = services.GetService <IObjectDetailsViewerAggregator>();
            Index       = index;
            var result = DebugEvaluation as IRValueInfo;

            if (result != null)
            {
                SetViewButtonStatus(result);
            }
        }
Пример #12
0
        protected int?GetMaxChildrenCount(IREvaluationResultInfo parent)
        {
            var value = parent as IRValueInfo;

            if (value != null)
            {
                if (value.Classes.Contains("data.frame"))
                {
                    return(null);
                }
            }
            return(DefaultMaxGrandChildren);
        }
Пример #13
0
        /// <summary>
        /// Create new instance of <see cref="VariableViewModel"/>
        /// </summary>
        /// <param name="evaluation">R session's evaluation result</param>
        /// <param name="truncateChildren">true to truncate children returned by GetChildrenAsync</param>
        public VariableViewModel(IREvaluationResultInfo evaluation, IObjectDetailsViewerAggregator aggregator, int index = -1, int?maxChildrenCount = null) :
            base(evaluation, maxChildrenCount)
        {
            _aggregator = aggregator;

            Index = index;
            var result = DebugEvaluation as IRValueInfo;

            if (result != null)
            {
                SetViewButtonStatus(result);
            }
        }
Пример #14
0
        private static async Task CreateCsvAndStartProcess(IREvaluationResultInfo result, IRSession session, string file)
        {
            await TaskUtilities.SwitchToBackgroundThread();

            var sep = CultureInfo.CurrentCulture.TextInfo.ListSeparator;
            var dec = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;

            using (var e = await session.BeginEvaluationAsync()) {
                await e.EvaluateAsync($"write.table({result.Expression}, qmethod='double', col.names=NA, file={file.ToRPath().ToRStringLiteral()}, sep={sep.ToRStringLiteral()}, dec={dec.ToRStringLiteral()})", REvaluationKind.Normal);
            }

            if (File.Exists(file))
            {
                Process.Start(file);
            }
        }
Пример #15
0
        public static async Task OpenDataCsvApp(IREvaluationResultInfo result, IApplicationShell appShell, IFileSystem fileSystem, IProcessServices processServices)
        {
            await appShell.SwitchToMainThreadAsync();

            if (Interlocked.Exchange(ref _busy, 1) > 0)
            {
                return;
            }

            var workflow = appShell.ExportProvider.GetExportedValue <IRInteractiveWorkflowProvider>().GetOrCreate();
            var session  = workflow.RSession;

            var folder = GetTempCsvFilesFolder();

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            var pss          = appShell.ExportProvider.GetExportedValue <IProjectSystemServices>();
            var variableName = result.Name ?? _variableNameReplacement;
            var csvFileName  = MakeCsvFileName(appShell, pss, variableName);

            var file = pss.GetUniqueFileName(folder, csvFileName, "csv", appendUnderscore: true);

            string currentStatusText;
            var    statusBar = appShell.GetGlobalService <IVsStatusbar>(typeof(SVsStatusbar));

            statusBar.GetText(out currentStatusText);

            try {
                statusBar.SetText(Resources.Status_WritingCSV);
                appShell.ProgressDialog.Show(async(p, ct) => await CreateCsvAndStartProcess(result, session, file, fileSystem, p), Resources.Status_WritingCSV, 100, 500);
                if (fileSystem.FileExists(file))
                {
                    processServices.Start(file);
                }
            } catch (Win32Exception ex) {
                appShell.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.Error_CannotOpenCsv, ex.Message));
            } catch (IOException ex) {
                appShell.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.Error_CannotOpenCsv, ex.Message));
            } finally {
                statusBar.SetText(currentStatusText);
            }

            Interlocked.Exchange(ref _busy, 0);
        }
Пример #16
0
        private static async Task CreateCsvAndStartProcess(IREvaluationResultInfo result, IRSession session, string fileName, IFileSystem fileSystem, IProcessServices processServices)
        {
            await TaskUtilities.SwitchToBackgroundThread();

            var sep = CultureInfo.CurrentCulture.TextInfo.ListSeparator;
            var dec = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;

            using (var e = await session.BeginEvaluationAsync()) {
                var csvData = await e.EvaluateAsync <byte[]>($"rtvs:::export_to_csv({result.Expression}, sep={sep.ToRStringLiteral()}, dec={dec.ToRStringLiteral()})", REvaluationKind.Normal);

                fileSystem.FileWriteAllBytes(fileName, csvData);
            }

            if (fileSystem.FileExists(fileName))
            {
                processServices.Start(fileName);
            }
        }
Пример #17
0
        public static async Task OpenDataCsvApp(IREvaluationResultInfo result)
        {
            await VsAppShell.Current.SwitchToMainThreadAsync();

            if (Interlocked.Exchange(ref _busy, 1) > 0)
            {
                return;
            }

            var workflowProvider = VsAppShell.Current.ExportProvider.GetExportedValue <IRInteractiveWorkflowProvider>();
            var workflow         = workflowProvider.GetOrCreate();
            var session          = workflow.RSession;

            var folder = GetTempCsvFilesFolder();

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            var variableName = result.Name ?? _variableNameReplacement;
            var csvFileName  = MakeCsvFileName(variableName);
            var file         = ProjectUtilities.GetUniqueFileName(folder, csvFileName, "csv", appendUnderscore: true);

            string currentStatusText;
            var    statusBar = VsAppShell.Current.GetGlobalService <IVsStatusbar>(typeof(SVsStatusbar));

            statusBar.GetText(out currentStatusText);

            try {
                statusBar.SetText(Resources.Status_WritingCSV);
                await CreateCsvAndStartProcess(result, session, file);
            } catch (Win32Exception ex) {
                VsAppShell.Current.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.Error_CannotOpenCsv, ex.Message));
            } catch (FileNotFoundException ex) {
                VsAppShell.Current.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.Error_CannotOpenCsv, ex.Message));
            } finally {
                statusBar.SetText(currentStatusText);
            }

            Interlocked.Exchange(ref _busy, 0);
        }
Пример #18
0
        public RSessionDataObject(IREvaluationResultInfo evaluation, bool evaluateActiveBindings, int?maxChildrenCount = null) : this()
        {
            DebugEvaluation         = evaluation;
            Name                    = DebugEvaluation.Name?.TrimStart(NameTrimChars);
            _evaluateActiveBindings = evaluateActiveBindings;

            if (DebugEvaluation is IRValueInfo)
            {
                var valueEvaluation = (IRValueInfo)DebugEvaluation;
                Initalize(valueEvaluation);
            }
            else if (DebugEvaluation is IRPromiseInfo)
            {
                var promiseInfo = (IRPromiseInfo)DebugEvaluation;
                Value = promiseInfo.Code;
                Class = TypeName = "<promise>";
            }
            else if (DebugEvaluation is IRActiveBindingInfo)
            {
                const string ActiveBindingText = "<active binding>";
                var          activeBinding     = (IRActiveBindingInfo)DebugEvaluation;
                if (activeBinding.ComputedValue != null)
                {
                    Initalize(activeBinding.ComputedValue);
                }
                else
                {
                    Value    = ActiveBindingText;
                    TypeName = ActiveBindingText;
                    Class    = ActiveBindingText;
                }
            }

            if (Dimensions == null)
            {
                Dimensions = new List <long>();
            }

            MaxChildrenCount = maxChildrenCount;
        }
Пример #19
0
        public static async Task OpenDataCsvApp(IREvaluationResultInfo result, IApplicationShell appShell, IFileSystem fileSystem, IProcessServices processServices) {
            await appShell.SwitchToMainThreadAsync();

            if (Interlocked.Exchange(ref _busy, 1) > 0) {
                return;
            }

            var workflow = appShell.ExportProvider.GetExportedValue<IRInteractiveWorkflowProvider>().GetOrCreate();
            var session = workflow.RSession;

            var folder = GetTempCsvFilesFolder();
            if (!Directory.Exists(folder)) {
                Directory.CreateDirectory(folder);
            }

            var pss = appShell.ExportProvider.GetExportedValue<IProjectSystemServices>();
            var variableName = result.Name ?? _variableNameReplacement;
            var csvFileName = MakeCsvFileName(appShell, pss, variableName);

            var file = pss.GetUniqueFileName(folder, csvFileName, "csv", appendUnderscore: true);

            string currentStatusText;
            var statusBar = appShell.GetGlobalService<IVsStatusbar>(typeof(SVsStatusbar));
            statusBar.GetText(out currentStatusText);

            try {
                statusBar.SetText(Resources.Status_WritingCSV);
                appShell.ProgressDialog.Show(async (p, ct) => await CreateCsvAndStartProcess(result, session, file, fileSystem, p, ct), Resources.Status_WritingCSV, 100, 500);
                if (fileSystem.FileExists(file)) {
                    processServices.Start(file);
                }
            } catch (Exception ex) when (ex is Win32Exception || ex is IOException || ex is UnauthorizedAccessException) {
                appShell.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.Error_CannotOpenCsv, ex.Message));
            } finally {
                statusBar.SetText(currentStatusText);
            }

            Interlocked.Exchange(ref _busy, 0);
        }
Пример #20
0
        private static async Task CreateCsvAndStartProcess(
            IREvaluationResultInfo result, 
            IRSession session, 
            string fileName, 
            IFileSystem fileSystem, 
            IProgress<ProgressDialogData> progress,
            CancellationToken cancellationToken) {
            await TaskUtilities.SwitchToBackgroundThread();

            var sep = CultureInfo.CurrentCulture.TextInfo.ListSeparator;
            var dec = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;

            var csvDataBlobId = await session.EvaluateAsync<ulong>($"rtvs:::export_to_csv({result.Expression}, sep={sep.ToRStringLiteral()}, dec={dec.ToRStringLiteral()})", REvaluationKind.Normal, cancellationToken);
            using (DataTransferSession dts = new DataTransferSession(session, fileSystem)) {
                var total = await session.GetBlobSizeAsync(csvDataBlobId, cancellationToken);
                progress.Report(new ProgressDialogData(0, statusBarText: Resources.Status_WritingCSV, waitMessage: Resources.Status_WritingCSV));
                await dts.FetchAndDecompressFileAsync(new RBlobInfo(csvDataBlobId), fileName, true, new Progress<long>(b => {
                    var step = (int)(b * 100 / total);
                    progress.Report(new ProgressDialogData(step, statusBarText: Resources.Status_WritingCSV, waitMessage: Resources.Status_WritingCSV));
                }), cancellationToken);
                progress.Report(new ProgressDialogData(100, statusBarText: Resources.Status_WritingCSV, waitMessage: Resources.Status_WritingCSV));
            }
        }
Пример #21
0
        private static async Task CreateCsvAndStartProcess(IREvaluationResultInfo result, IRSession session, string fileName, IFileSystem fileSystem, IProgress <ProgressDialogData> progress)
        {
            await TaskUtilities.SwitchToBackgroundThread();

            var sep = CultureInfo.CurrentCulture.TextInfo.ListSeparator;
            var dec = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;

            using (var e = await session.BeginEvaluationAsync()) {
                var csvDataBlobId = await e.EvaluateAsync <ulong>($"rtvs:::export_to_csv({result.Expression}, sep={sep.ToRStringLiteral()}, dec={dec.ToRStringLiteral()})", REvaluationKind.Normal);

                using (DataTransferSession dts = new DataTransferSession(session, fileSystem)) {
                    var total = await session.GetBlobSizeAsync(csvDataBlobId, CancellationToken.None);

                    progress.Report(new ProgressDialogData(0, statusBarText: Resources.Status_WritingCSV, waitMessage: Resources.Status_WritingCSV));
                    await dts.FetchFileAsync(new RBlobInfo(csvDataBlobId), fileName, true, new Progress <long>(b => {
                        var step = (int)(b * 100 / total);
                        progress.Report(new ProgressDialogData(step, statusBarText: Resources.Status_WritingCSV, waitMessage: Resources.Status_WritingCSV));
                    }));

                    progress.Report(new ProgressDialogData(100, statusBarText: Resources.Status_WritingCSV, waitMessage: Resources.Status_WritingCSV));
                }
            }
        }
Пример #22
0
        private static async Task CreateCsvAndStartProcess(
            IREvaluationResultInfo result,
            IRSession session,
            ICoreShell coreShell,
            string fileName,
            IFileSystem fileSystem,
            IProgress <ProgressDialogData> progress,
            CancellationToken cancellationToken)
        {
            await TaskUtilities.SwitchToBackgroundThread();

            var sep = CultureInfo.CurrentCulture.TextInfo.ListSeparator;
            var dec = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;

            try {
                var csvDataBlobId = await session.EvaluateAsync <ulong>($"rtvs:::export_to_csv({result.Expression}, sep={sep.ToRStringLiteral()}, dec={dec.ToRStringLiteral()})", REvaluationKind.Normal, cancellationToken);

                using (DataTransferSession dts = new DataTransferSession(session, fileSystem)) {
                    await dts.FetchAndDecompressFileAsync(csvDataBlobId, fileName, progress, Resources.Status_WritingCSV, cancellationToken);
                }
            } catch (RException) {
                await coreShell.ShowErrorMessageAsync(Resources.Error_CannotExportToCsv, cancellationToken);
            }
        }
Пример #23
0
        private ImageMoniker GetVariableIcon(IREvaluationResultInfo info)
        {
            if (info is IRActiveBindingInfo)
            {
                return(KnownMonikers.Property);
            }
            else if (info is IRPromiseInfo)
            {
                return(KnownMonikers.Delegate);
            }
            else if (info is IRErrorInfo)
            {
                return(KnownMonikers.StatusInvalid);
            }

            var value = info as IRValueInfo;

            if (value != null)
            {
                // Order of checks here is important, as some categories are subsets of others, and hence have to be checked first.
                // For example, all dataframes are also lists, and so we need to check for class "data.frame", and supply an icon
                // for it, before we check for type "list".
                if (value.TypeName == "S4")
                {
                    return(KnownMonikers.Class);
                }
                else if (value.Classes.Contains("refObjectGenerator"))
                {
                    return(KnownMonikers.NewClass);
                }
                else if (value.TypeName == "closure" || value.TypeName == "builtin")
                {
                    return(KnownMonikers.Procedure);
                }
                else if (value.Classes.Contains("formula"))
                {
                    return(KnownMonikers.MemberFormula);
                }
                else if (value.TypeName == "symbol" || value.TypeName == "language" || value.TypeName == "expression")
                {
                    return(KnownMonikers.Code);
                }
                else if (value.Classes.Contains("data.frame"))
                {
                    return(KnownMonikers.Table);
                }
                else if (value.Classes.Contains("matrix"))
                {
                    return(KnownMonikers.Matrix);
                }
                else if (value.TypeName == "environment")
                {
                    return(KnownMonikers.BulletList);
                }
                else if (value.TypeName == "list" || (value.IsAtomic() && value.Length > 1))
                {
                    return(KnownMonikers.OrderedList);
                }
                else
                {
                    return(KnownMonikers.BinaryRegistryValue);
                }
            }

            return(KnownMonikers.UnknownMember);
        }
Пример #24
0
        public bool CanShowDataGrid(IREvaluationResultInfo evaluationResult)
        {
            var wrapper = new VariableViewModel(evaluationResult, _coreShell.Services);

            return(wrapper.CanShowDetail);
        }
Пример #25
0
 protected int? GetMaxChildrenCount(IREvaluationResultInfo parent) {
     var value = parent as IRValueInfo;
     if (value != null) {
         if (value.Classes.Contains("data.frame")) {
             return null;
         }
     }
     return DefaultMaxGrandChildren;
 }
Пример #26
0
 public AD7Property(AD7Property parent, IREvaluationResultInfo result, bool isSynthetic = false)
     : this(parent.StackFrame, result, isSynthetic, false) {
     Parent = parent;
 }
Пример #27
0
        public bool CanShowDataGrid(IREvaluationResultInfo evaluationResult)
        {
            var wrapper = new VariableViewModel(evaluationResult, _aggregator);

            return(wrapper.CanShowDetail);
        }
Пример #28
0
 public AD7Property(AD7Property parent, IREvaluationResultInfo result, bool isSynthetic = false)
     : this(parent.StackFrame, result, isSynthetic, false)
 {
     Parent = parent;
 }
Пример #29
0
        private ImageMoniker GetVariableIcon(IREvaluationResultInfo info) {
            if (info is IRActiveBindingInfo) {
                return KnownMonikers.Property;
            } else if (info is IRPromiseInfo) {
                return KnownMonikers.Delegate;
            } else if (info is IRErrorInfo) {
                return KnownMonikers.StatusInvalid;
            }

            var value = info as IRValueInfo;
            if (value != null) {
                // Order of checks here is important, as some categories are subsets of others, and hence have to be checked first.
                // For example, all dataframes are also lists, and so we need to check for class "data.frame", and supply an icon
                // for it, before we check for type "list".
                if (value.TypeName == "S4") {
                    return KnownMonikers.Class;
                } else if (value.Classes.Contains("refObjectGenerator")) {
                    return KnownMonikers.NewClass;
                } else if (value.TypeName == "closure" || value.TypeName == "builtin") {
                    return KnownMonikers.Procedure;
                } else if (value.Classes.Contains("formula")) {
                    return KnownMonikers.MemberFormula;
                } else if (value.TypeName == "symbol" || value.TypeName == "language" || value.TypeName == "expression") {
                    return KnownMonikers.Code;
                } else if (value.Classes.Contains("data.frame")) {
                    return KnownMonikers.Table;
                } else if (value.Classes.Contains("matrix")) {
                    return KnownMonikers.Matrix;
                } else if (value.TypeName == "environment") {
                    return KnownMonikers.BulletList;
                } else if (value.TypeName == "list" || (value.IsAtomic() && value.Length > 1)) {
                    return KnownMonikers.OrderedList;
                } else {
                    return KnownMonikers.BinaryRegistryValue;
                }
            }

            return KnownMonikers.UnknownMember;
        }
Пример #30
0
 /// <summary>
 /// Re-evaluates the expression that was used to create this evaluation object in its original context,
 /// but with a new representation function and properties.
 /// </summary>
 /// <remarks>
 /// Evaluating an expression always produces a regular value, never a promise or an active binding. Thus,
 /// this method can be used to compute the current value of an <see cref="IRActiveBindingInfo"/>, or force
 /// an <see cref="IRPromiseInfo"/>.
 /// </remarks>
 /// <exception cref="RException">Evaluation of the expression produced an error.</exception>
 public static Task <IRValueInfo> GetValueAsync(this IREvaluationResultInfo info, REvaluationResultProperties properties, string repr, CancellationToken cancellationToken = default(CancellationToken)) =>
 info.Evaluator.EvaluateAndDescribeAsync(info.EnvironmentExpression, info.Expression, info.Name, properties, repr, cancellationToken);
Пример #31
0
 /// <summary>
 /// Computes the expression that can be used to produce the same value in any environment.
 /// </summary>
 public static string GetEnvironmentIndependentExpression(this IREvaluationResultInfo info) =>
 info.EnvironmentExpression + "$" + info.Expression;
Пример #32
0
 public bool CanShowDataGrid(IREvaluationResultInfo evaluationResult) {
     var wrapper = new VariableViewModel(evaluationResult, _aggregator);
     return wrapper.CanShowDetail;
 }