Пример #1
0
        public async Task InitializeProjectFromDiskAsync()
        {
            await Project.CreateInMemoryImport();

            _fileWatcher.Start();

            await _threadHandling.SwitchToUIThread();

            // Make sure R package is loaded
            VsAppShell.EnsurePackageLoaded(RGuidList.RPackageGuid);

            // Verify project is not on a network share and give warning if it is
            CheckRemoteDrive(_projectDirectory);

            _workflow = _coreShell.GetService <IRInteractiveWorkflowVisualProvider>().GetOrCreate();
            _session  = _workflow.RSession;
            _history  = _workflow.History;

            if (_workflow.ActiveWindow == null)
            {
                var window = await _workflow.GetOrCreateVisualComponentAsync();

                window.Container.Show(focus: true, immediate: false);
            }

            try {
                await _session.HostStarted;
            } catch (Exception) {
                return;
            }

            // TODO: need to compute the proper paths for remote, but they might not even exist if the project hasn't been deployed.
            // https://github.com/Microsoft/RTVS/issues/2223
            if (!_session.IsRemote)
            {
                var  rdataPath            = Path.Combine(_projectDirectory, DefaultRDataName);
                bool loadDefaultWorkspace = _coreShell.FileSystem().FileExists(rdataPath) && await GetLoadDefaultWorkspace(rdataPath);

                if (loadDefaultWorkspace)
                {
                    await _session.LoadWorkspaceAsync(rdataPath);
                }
                await _session.SetWorkingDirectoryAsync(_projectDirectory);

                _settings.WorkingDirectory = _projectDirectory;
            }

            _history.TryLoadFromFile(Path.Combine(_projectDirectory, DefaultRHistoryName));
            CheckSurveyNews();
        }
Пример #2
0
        public CurrentDirectoryTest()
        {
            var connectionsProvider   = VsAppShell.Current.GetService <IConnectionManagerProvider>();
            var historyProvider       = VsAppShell.Current.GetService <IRHistoryProvider>();
            var packagesProvider      = VsAppShell.Current.GetService <IRPackageManagerProvider>();
            var plotsProvider         = VsAppShell.Current.GetService <IRPlotManagerProvider>();
            var activeTextViewTracker = new ActiveTextViewTrackerMock(string.Empty, string.Empty);
            var debuggerModeTracker   = new TestDebuggerModeTracker();

            _interactiveWorkflow = UIThreadHelper.Instance.Invoke(() => new RInteractiveWorkflow(
                                                                      connectionsProvider, historyProvider, packagesProvider, plotsProvider, activeTextViewTracker,
                                                                      debuggerModeTracker, VsAppShell.Current));

            _sessionProvider = _interactiveWorkflow.RSessions;
        }
Пример #3
0
 public HistoryNavigationCommand(ITextView textView, IRInteractiveWorkflowVisual interactiveWorkflow, ICompletionBroker completionBroker, IEditorOperationsFactoryService editorFactory) :
     base(textView, new[] {
     new CommandId(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.UP),
     new CommandId(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.DOWN),
     new CommandId(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.LEFT),
     new CommandId(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.RIGHT),
     new CommandId(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.UP_EXT),
     new CommandId(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.DOWN_EXT),
     new CommandId(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.LEFT_EXT),
     new CommandId(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.RIGHT_EXT)
 }, false)
 {
     _completionBroker    = completionBroker;
     _editorFactory       = editorFactory;
     _interactiveWorkflow = interactiveWorkflow;
     _history             = interactiveWorkflow.History;
 }
Пример #4
0
        public WorkingDirectoryCommand(IRInteractiveWorkflowVisual interactiveWorkflow) :
            base(new[] {
            new CommandId(RGuidList.RCmdSetGuid, RPackageCommandId.icmdGetDirectoryList),
            new CommandId(RGuidList.RCmdSetGuid, RPackageCommandId.icmdSetWorkingDirectory)
        }, false)
        {
            _interactiveWorkflow = interactiveWorkflow;
            _settings            = _interactiveWorkflow.Shell.GetService <IRSettings>();

            _session                   = interactiveWorkflow.RSession;
            _session.Connected        += OnSessionConnected;
            _session.DirectoryChanged += OnCurrentDirectoryChanged;

            if (InitializationTask == null && _session.IsHostRunning)
            {
                InitializationTask = UpdateRUserDirectoryAsync();
            }
        }
Пример #5
0
        public ConnectionManager(IStatusBar statusBar, IRSettings settings, IRInteractiveWorkflowVisual interactiveWorkflow)
        {
            _statusBar           = statusBar;
            _sessionProvider     = interactiveWorkflow.RSessions;
            _settings            = settings;
            _interactiveWorkflow = interactiveWorkflow;
            _shell               = interactiveWorkflow.Shell;
            _securityService     = _shell.GetService <ISecurityService>();
            _log                 = _shell.GetService <IActionLog>();
            _installationService = _shell.GetService <IRInstallationService>();

            _statusBarViewModel = new ConnectionStatusBarViewModel(this, interactiveWorkflow.Shell.Services);
            if (settings.ShowHostLoadMeter)
            {
                _hostLoadIndicatorViewModel =
                    new HostLoadIndicatorViewModel(_sessionProvider, interactiveWorkflow.Shell.MainThread());
            }

            _disposableBag = DisposableBag.Create <ConnectionManager>()
                             .Add(_statusBarViewModel)
                             .Add(_hostLoadIndicatorViewModel ?? Disposable.Empty)
                             .Add(() => _sessionProvider.BrokerStateChanged        -= BrokerStateChanged)
                             .Add(() => _interactiveWorkflow.RSession.Connected    -= SessionConnected)
                             .Add(() => _interactiveWorkflow.RSession.Disconnected -= SessionDisconnected)
                             .Add(() => _interactiveWorkflow.ActiveWindowChanged   -= ActiveWindowChanged);

            _sessionProvider.BrokerStateChanged += BrokerStateChanged;

            _interactiveWorkflow.RSession.Connected    += SessionConnected;
            _interactiveWorkflow.RSession.Disconnected += SessionDisconnected;
            _interactiveWorkflow.ActiveWindowChanged   += ActiveWindowChanged;

            // Get initial values
            var connections = CreateConnectionList();

            _connections = new ConcurrentDictionary <string, IConnection>(connections);

            UpdateRecentConnections(save: false);
            CompleteInitializationAsync().DoNotWait();
        }
Пример #6
0
 public TerminateRCommand(IRInteractiveWorkflowVisual interactiveWorkflow, IUIService ui)
 {
     _interactiveWorkflow = interactiveWorkflow;
     _session             = interactiveWorkflow.RSession;
     _ui = ui;
 }
Пример #7
0
 public DeleteSelectedHistoryEntriesCommand(ITextView textView, IRHistoryProvider historyProvider, IRInteractiveWorkflowVisual interactiveWorkflow)
     : base(textView, RGuidList.RCmdSetGuid, RPackageCommandId.icmdDeleteSelectedHistoryEntries, false)
 {
     _interactiveWorkflow = interactiveWorkflow;
     _history             = historyProvider.GetAssociatedRHistory(textView);
     _ui = _interactiveWorkflow.Services.UI();
 }
Пример #8
0
 public PrevHistoryReplCommand(IRInteractiveWorkflowVisual interactiveWorkflow) :
     base(interactiveWorkflow, RPackageCommandId.icmdPrevHistoryRepl)
 {
     _history = interactiveWorkflow.History;
 }
Пример #9
0
 public RHistoryTests(IServiceContainer services)
 {
     _interactiveWorkflow = InteractiveWorkflowStubFactory.CreateDefault();
     _textBuffer          = services.GetService <ITextBufferFactoryService>().CreateTextBuffer();
 }
Пример #10
0
        public SendHistoryToSourceCommand(ITextView textView, IRHistoryProvider historyProvider, IRInteractiveWorkflowVisual interactiveWorkflow, IContentTypeRegistryService contentTypeRegistry, IActiveWpfTextViewTracker textViewTracker)
            : base(textView, RGuidList.RCmdSetGuid, RPackageCommandId.icmdSendHistoryToSource, false)
        {
            _textViewTracker     = textViewTracker;
            _interactiveWorkflow = interactiveWorkflow;
            _history             = historyProvider.GetAssociatedRHistory(textView);

            _contentTypes.Add(contentTypeRegistry.GetContentType(RContentTypeDefinition.ContentType));
            _contentTypes.Add(contentTypeRegistry.GetContentType(MdProjectionContentTypeDefinition.ContentType));
        }
Пример #11
0
 public SaveHistoryCommand(ITextView textView, IRHistoryProvider historyProvider, IRInteractiveWorkflowVisual interactiveWorkflow)
     : base(textView, RGuidList.RCmdSetGuid, RPackageCommandId.icmdSaveHistory, false)
 {
     _ui = interactiveWorkflow.Shell.UI();
     _interactiveWorkflow = interactiveWorkflow;
     _settings            = _interactiveWorkflow.Shell.GetService <IRSettings>();
     _history             = historyProvider.GetAssociatedRHistory(textView);
 }
Пример #12
0
 public CopySelectedHistoryCommand(ITextView textView, IRHistoryProvider historyProvider, IRInteractiveWorkflowVisual interactiveWorkflow)
     : base(textView, VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.Copy, false)
 {
     _interactiveWorkflow = interactiveWorkflow;
     _history             = historyProvider.GetAssociatedRHistory(textView);
 }
Пример #13
0
 public PasteCurrentCodeCommand(ITextView textView, IRInteractiveWorkflowVisual interactiveWorkflow) :
     base(textView, interactiveWorkflow, new CommandId(RGuidList.RCmdSetGuid, RPackageCommandId.icmdPasteReplCmd))
 {
 }
Пример #14
0
 public InteractiveWindowConsole(IRInteractiveWorkflowVisual workflow)
 {
     _workflow     = workflow;
     _disposeToken = DisposeToken.Create <InteractiveWindowConsole>();
     _mainThread   = _workflow.Shell.MainThread();
 }
Пример #15
0
 public InterruptRCommand(IRInteractiveWorkflowVisual interactiveWorkflow, IDebuggerModeTracker debuggerModeTracker)
 {
     _interactiveWorkflow = interactiveWorkflow;
     _session             = interactiveWorkflow.RSession;
     _debuggerModeTracker = debuggerModeTracker;
 }
Пример #16
0
 protected AttachDebuggerCommand(IRInteractiveWorkflowVisual interactiveWorkflow, int cmdId, DebuggerCommandVisibility visibility)
     : base(interactiveWorkflow, cmdId, visibility)
 {
     _interactiveWorkflow = interactiveWorkflow;
 }
Пример #17
0
 public ReplCommandBase(IRInteractiveWorkflowVisual interactiveWorkflow, int id) :
     base(RGuidList.RCmdSetGuid, id)
 {
     Workflow = interactiveWorkflow;
 }
Пример #18
0
 public SelectWorkingDirectoryCommand(IRInteractiveWorkflowVisual workflow) :
     base(RGuidList.RCmdSetGuid, RPackageCommandId.icmdSelectWorkingDirectory)
 {
     _workflow = workflow;
 }
 public RInteractiveWorkflowCommandTest(IServiceContainer services)
 {
     _services = services;
     _workflow = services.GetService <IRInteractiveWorkflowVisualProvider>().GetOrCreate();
     _settings = services.GetService <IRSettings>();
 }
Пример #20
0
 public RExecuteCommand(ITextView textView, IRInteractiveWorkflowVisual interactiveWorkflow, CommandId id) : base(textView, id, false)
 {
     InteractiveWorkflow = interactiveWorkflow;
 }
Пример #21
0
 public DeleteProfileCommand(IRInteractiveWorkflowVisual interactiveWorkflow)
 {
     _interactiveWorkflow = interactiveWorkflow;
 }
Пример #22
0
 public ResetReplCommand(IRInteractiveWorkflowVisual interactiveWorkflow) :
     base(interactiveWorkflow, RPackageCommandId.icmdResetRepl)
 {
 }
Пример #23
0
 protected DebuggerWrappedCommand(IRInteractiveWorkflowVisual interactiveWorkflow, int cmdId, Guid shellGroup, int shellCmdId, DebuggerCommandVisibility visibility)
     : base(interactiveWorkflow, cmdId, visibility)
 {
     _shellGroup = shellGroup;
     _shellCmdId = (uint)shellCmdId;
 }
Пример #24
0
 public InteractiveWindowConsole(IRInteractiveWorkflowVisual workflow)
 {
     _workflow   = workflow;
     _mainThread = _workflow.Shell.MainThread();
 }
Пример #25
0
 public StepIntoCommand(IRInteractiveWorkflowVisual interactiveWorkflow)
     : base(interactiveWorkflow, RPackageCommandId.icmdStepInto,
            VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.StepInto,
            DebuggerCommandVisibility.Stopped)
 {
 }
 public ToggleMultilineHistorySelectionCommand(ITextView textView, IRHistoryProvider historyProvider, IRInteractiveWorkflowVisual interactiveWorkflow)
     : base(textView, RGuidList.RCmdSetGuid, RPackageCommandId.icmdToggleMultilineSelection, false)
 {
     _history             = historyProvider.GetAssociatedRHistory(textView);
     _settings            = interactiveWorkflow.Shell.GetService <IRSettings>();
     _interactiveWorkflow = interactiveWorkflow;
 }
Пример #27
0
 public SendToReplCommand(ITextView textView, IRInteractiveWorkflowVisual interactiveWorkflow) :
     base(textView, new CommandId(RGuidList.RCmdSetGuid, (int)RPackageCommandId.icmdSendToRepl), false)
 {
     _interactiveWorkflow = interactiveWorkflow;
 }
Пример #28
0
 public AttachToRInteractiveCommand(IRInteractiveWorkflowVisual interactiveWorkflow)
     : base(interactiveWorkflow, RPackageCommandId.icmdAttachToRInteractive, DebuggerCommandVisibility.DesignMode)
 {
 }
Пример #29
0
 public HistoryWindowVsStd97CmdIdSelectAllCommand(ITextView textView, IRHistoryProvider historyProvider, IRInteractiveWorkflowVisual interactiveWorkflow)
     : base(textView, SelectAllCommandIds, false)
 {
     _interactiveWorkflow = interactiveWorkflow;
     _history             = historyProvider.GetAssociatedRHistory(textView);
 }
Пример #30
0
 public InteractiveWindowConsole(IRInteractiveWorkflowVisual workflow)
 {
     _workflow = workflow;
 }