Exemple #1
0
        protected override void Initialize()
        {
            Current = this;

            VsAppShell.EnsureInitialized();
            if (IsCommandLineMode())
            {
                return;
            }

            VsWpfOverrides.Apply();
            CranMirrorList.Download();

            using (var p = Current.GetDialogPage(typeof(RToolsOptionsPage)) as RToolsOptionsPage) {
                p?.LoadSettings();
            }

            RtvsTelemetry.Initialize(_packageIndex, VsAppShell.Current.ExportProvider.GetExportedValue <IRSettings>());
            base.Initialize();

            ProjectIconProvider.LoadProjectImages();
            LogCleanup.DeleteLogsAsync(DiagnosticLogs.DaysToRetain);

            BuildFunctionIndex();
            AdviseExportedWindowFrameEvents <ActiveWpfTextViewTracker>();
            AdviseExportedWindowFrameEvents <VsActiveRInteractiveWindowTracker>();
            AdviseExportedDebuggerEvents <VsDebuggerModeTracker>();

            IdleTimeAction.Create(ExpansionsCache.Load, 200, typeof(ExpansionsCache), VsAppShell.Current);
            IdleTimeAction.Create(() => RtvsTelemetry.Current.ReportConfiguration(), 5000, typeof(RtvsTelemetry), VsAppShell.Current);
        }
Exemple #2
0
        protected override void Initialize()
        {
            Current = this;

            VsAppShell.EnsureInitialized();
            if (IsCommandLineMode())
            {
                return;
            }

            VsWpfOverrides.Apply();
            CranMirrorList.Download();

            base.Initialize();

            ProjectIconProvider.LoadProjectImages(VsAppShell.Current.Services);
            LogCleanup.DeleteLogsAsync(DiagnosticLogs.DaysToRetain);

            var settings       = VsAppShell.Current.GetService <IRToolsSettings>();
            var editorSettings = VsAppShell.Current.GetService <IREditorSettings>();

            RtvsTelemetry.Initialize(_packageIndex, settings, editorSettings);

            BuildFunctionIndex();
            AdviseExportedWindowFrameEvents <ActiveWpfTextViewTracker>();
            AdviseExportedWindowFrameEvents <VsActiveRInteractiveWindowTracker>();
            AdviseExportedDebuggerEvents <VsDebuggerModeTracker>();

            System.Threading.Tasks.Task.Run(() => RtvsTelemetry.Current.ReportConfiguration());
            IdleTimeAction.Create(ExpansionsCache.Load, 200, typeof(ExpansionsCache), VsAppShell.Current);
        }
Exemple #3
0
        protected override void Initialize()
        {
            Current = this;

            VsAppShell.EnsureInitialized();
            if (IsCommandLineMode())
            {
                return;
            }

            CranMirrorList.Download();
            base.Initialize();

            _fs = Services.FileSystem();

            ProjectIconProvider.LoadProjectImages(Services);
            LogCleanup.DeleteLogsAsync(DiagnosticLogs.DaysToRetain);

            LoadEditorSettings();
            BuildFunctionIndex();
            AddConnectionStatusBar();
            RtvsTelemetry.Initialize(_packageIndex, Services);

            AdviseExportedWindowFrameEvents <ActiveWpfTextViewTracker>();
            AdviseExportedWindowFrameEvents <VsActiveRInteractiveWindowTracker>();
            AdviseExportedDebuggerEvents <VsDebuggerModeTracker>();

            System.Threading.Tasks.Task.Run(() => RtvsTelemetry.Current.ReportConfiguration());
            ExpansionsCache.Load(Services);
        }
Exemple #4
0
        private async Task <IReadOnlyList <RPackage> > GetPackagesAsync(Func <Task <JArray> > queryFunc, CancellationToken cancellationToken)
        {
            // Fetching of installed and available packages is done in a
            // separate package query session to avoid freezing the REPL.
            try {
                await _session.EnsureHostStartedAsync(new RHostStartupInfo(), null, cancellationToken : cancellationToken);

                await _session.SetVsCranSelectionAsync(CranMirrorList.UrlFromName(_settings.CranMirror), cancellationToken);

                await _session.SetCodePageAsync(_settings.RCodePage, cancellationToken);

                // Get the repos and libpaths from the REPL session and set them
                // in the package query session
                var repositories = (await DeparseRepositoriesAsync());
                if (repositories != null)
                {
                    await WrapRException(_session.ExecuteAsync($"options(repos=eval(parse(text={repositories.ToRStringLiteral()})))", cancellationToken));
                }

                var libraries = (await DeparseLibrariesAsync());
                if (libraries != null)
                {
                    await WrapRException(_session.ExecuteAsync($".libPaths(eval(parse(text={libraries.ToRStringLiteral()})))", cancellationToken));
                }

                var result = await WrapRException(queryFunc());

                return(result.Select(p => p.ToObject <RPackage>()).ToList().AsReadOnly());
            } catch (RHostDisconnectedException ex) {
                throw new RPackageManagerException(Resources.PackageManager_TransportError, ex);
            }
        }
Exemple #5
0
        public async Task <IRSession> StartSessionAsync(CancellationToken ct)
        {
            if (RSession == null)
            {
                var workflow = _services.GetService <IRInteractiveWorkflowProvider>().GetOrCreate();
                RSession = workflow.RSessions.GetOrCreate(_sessionId);
            }
            else
            {
                await _sessionStart;
            }

            if (!RSession.IsHostRunning)
            {
                var settings = _services.GetService <IRSettings>();
                await RSession.EnsureHostStartedAsync(new RHostStartupInfo(isInteractive : true), SessionCallback, 3000, ct);

                await RSession.SetVsCranSelectionAsync(CranMirrorList.UrlFromName(settings.CranMirror), ct);

                await RSession.SetCodePageAsync(settings.RCodePage, ct);

                await RSession.SetVsGraphicsDeviceAsync();
            }

            return(RSession);
        }
Exemple #6
0
        private async Task SetMirrorToSession()
        {
            string mirrorName = _settings.CranMirror;
            string mirrorUrl  = CranMirrorList.UrlFromName(mirrorName);

            foreach (var s in RSessions.GetSessions())
            {
                try {
                    await s.SetVsCranSelectionAsync(mirrorUrl);
                } catch (RException) { } catch (OperationCanceledException) { }
            }
        }
        private async Task SetMirrorToSession()
        {
            IRSessionProvider sessionProvider = VsAppShell.Current.ExportProvider.GetExportedValue <IRSessionProvider>();
            var    sessions   = sessionProvider.GetSessions();
            string mirrorName = RToolsSettings.Current.CranMirror;
            string mirrorUrl  = CranMirrorList.UrlFromName(mirrorName);

            foreach (var s in sessions.Where(s => s.IsHostRunning))
            {
                try {
                    using (var eval = await s.BeginEvaluationAsync()) {
                        await eval.SetVsCranSelection(mirrorUrl);
                    }
                } catch (OperationCanceledException) { }
            }
        }
Exemple #8
0
        public void CranMirrorList_DownloadTest()
        {
            ManualResetEventSlim evt = new ManualResetEventSlim();
            int eventCount           = 0;

            CranMirrorList.DownloadComplete += (e, args) => {
                eventCount++;
                CranMirrorList.MirrorNames.Should().NotBeEmpty();
                CranMirrorList.MirrorUrls.Should().NotBeEmpty();
                CranMirrorList.UrlFromName(null).Should().Be(null);
                evt.Set();
            };

            CranMirrorList.Download();
            evt.Wait(10000);
            eventCount.Should().Be(1);

            CranMirrorList.Download();
            eventCount.Should().Be(2);
        }
Exemple #9
0
        protected override void Initialize()
        {
            Current = this;

            // Force app shell creation before everything else
            var shell = VsAppShell.Current;

            if (IsCommandLineMode())
            {
                return;
            }

            VsWpfOverrides.Apply();
            CranMirrorList.Download();

            RtvsTelemetry.Initialize();

            using (var p = Current.GetDialogPage(typeof(RToolsOptionsPage)) as RToolsOptionsPage) {
                p.LoadSettings();
            }

            MicrosoftRClient.CheckInstall(VsAppShell.Current);
            base.Initialize();

            ProjectIconProvider.LoadProjectImages();
            LogCleanup.DeleteLogsAsync(DiagnosticLogs.DaysToRetain);

            _indexBuildingTask = FunctionIndex.BuildIndexAsync();

            AdviseExportedWindowFrameEvents <ActiveWpfTextViewTracker>();
            AdviseExportedWindowFrameEvents <VsActiveRInteractiveWindowTracker>();
            AdviseExportedDebuggerEvents <VsDebuggerModeTracker>();

            System.Threading.Tasks.Task.Run(() => RtvsTelemetry.Current.ReportConfiguration());

            IdleTimeAction.Create(ExpansionsCache.Load, 200, typeof(ExpansionsCache));
        }
Exemple #10
0
 /// <summary>
 /// Given CRAN mirror name returns URL
 /// </summary>
 public string CranUrlFromName(string mirrorName)
 {
     return(CranMirrorList.UrlFromName(mirrorName));
 }