示例#1
0
        public EditorErrorTagger(ITextBuffer textBuffer, IEditorTaskList taskList, IServiceContainer services)
        {
            _taskList = taskList;

            _settings = services.GetService <IREditorSettings>();
            _idleTime = services.GetService <IIdleTimeService>();

            _document          = textBuffer.GetEditorDocument <IREditorDocument>();
            _document.Closing += OnDocumentClosing;
            _document.EditorTree.UpdateCompleted += OnTreeUpdateCompleted;
            _document.EditorTree.NodesRemoved    += OnNodesRemoved;
            _errorTags = new ErrorTagCollection(_document.EditorTree);

            _textBuffer          = _document.EditorTree.TextBuffer();
            _textBuffer.Changed += OnTextBufferChanged;

            // Don't push syntax errors to the Error List in transient
            // documents such as in document attached to a projected buffer
            // in the R interactive window
            if (_taskList != null && !_document.IsRepl)
            {
                _taskList.AddTaskSource(this);
            }

            var validator = _document.EditorBuffer.GetService <TreeValidator>();

            validator.Cleared += OnCleared;

            _resultsQueue   = validator.ValidationResults;
            _idleTime.Idle += OnIdle;
        }
示例#2
0
 public BraceHighlighter(ITextView view, ITextBuffer textBuffer, ICoreShell shell)
 {
     _textBuffer = textBuffer;
     _textView   = view;
     _shell      = shell;
     _idleTime   = _shell.GetService <IIdleTimeService>();
 }
示例#3
0
        public TreeValidator(IREditorTree editorTree, IServiceContainer services)
        {
#if DEBUG
            TraceValidation.Enabled = false;
#endif

            _editorTree = editorTree;
            _editorTree.NodesRemoved    += OnNodesRemoved;
            _editorTree.UpdateCompleted += OnTreeUpdateCompleted;
            _editorTree.Closing         += OnTreeClose;

            _settings = services.GetService <IREditorSettings>();
            _idleTime = services.GetService <IIdleTimeService>();

            // Advise to settings changed *after* accessing the RSettings,
            // since accessing the host application (VS) settings object may
            // cause it fire Changed notification in some cases.
            _settings.SettingsChanged += OnSettingsChanged;
            _syntaxCheckEnabled        = IsSyntaxCheckEnabled(_editorTree.EditorBuffer, _settings);

            // We don't want to start validation right away since it may
            // interfere with the editor perceived startup performance.

            StartValidationNextIdle();
            ValidationResults = new ConcurrentQueue <IValidationError>();

            editorTree.EditorBuffer.AddService(this);
        }
示例#4
0
        public PreviewMargin(ITextView textView, IServiceContainer services)
        {
            _idleActionTag = _idleActionTag ?? GetType();

            _textView = textView;
            _settings = services.GetService <IRMarkdownEditorSettings>();

            Browser = new BrowserView(_textView.TextBuffer.GetFileName(), services);

            if (_settings.PreviewPosition == RMarkdownPreviewPosition.Below)
            {
                CreateBottomMarginControls();
            }
            else
            {
                CreateRightMarginControls();
            }

            UpdateBrowser();

            // TODO: separate R code changes from markdown changes
            _idleTime = services.GetService <IIdleTimeService>();
            _textView.TextBuffer.Changed    += OnTextBufferChanged;
            _textView.Caret.PositionChanged += OnCaretPositionChanged;

            textView.AddService(this);
        }
示例#5
0
 public VsStatusBar(IServiceContainer services)
 {
     _services    = services;
     _mainThread  = services.MainThread();
     _idleTime    = services.GetService <IIdleTimeService>();
     _vsStatusBar = services.GetService <IVsStatusbar>(typeof(SVsStatusbar));
 }
示例#6
0
 public RLanguageHandler(ITextBuffer textBuffer, IProjectionBufferManager projectionBufferManager, IServiceContainer services) :
     base(textBuffer)
 {
     _projectionBufferManager = projectionBufferManager;
     idleTime = services.GetService <IIdleTimeService>();
     UpdateProjections();
 }
示例#7
0
        public PackageIndex(IServiceContainer services, IIntellisenseRSession host, IFunctionIndex functionIndex)
        {
            _host          = host;
            _functionIndex = functionIndex;
            _idleTime      = services.GetService <IIdleTimeService>();

            var interactiveWorkflowProvider = services.GetService <IRInteractiveWorkflowProvider>();
            var workflow = interactiveWorkflowProvider.GetOrCreate();

            var sessionProvider    = workflow.RSessions;
            var interactiveSession = workflow.RSession;

            interactiveSession.Connected         += OnSessionConnected;
            interactiveSession.PackagesInstalled += OnPackagesChanged;
            interactiveSession.PackagesRemoved   += OnPackagesChanged;

            sessionProvider.BrokerStateChanged += OnBrokerStateChanged;

            if (interactiveSession.IsHostRunning)
            {
                BuildIndexAsync().DoNotWait();
            }

            _disposableBag
            .Add(() => interactiveSession.PackagesInstalled -= OnPackagesChanged)
            .Add(() => interactiveSession.PackagesRemoved   -= OnPackagesChanged)
            .Add(() => interactiveSession.Connected         -= OnSessionConnected)
            .Add(() => sessionProvider.BrokerStateChanged   -= OnBrokerStateChanged)
            .Add(_host);
        }
        public IndexManager(IFileSystem fileSystem, PythonLanguageVersion version, string rootPath, string[] includeFiles,
                            string[] excludeFiles, IIdleTimeService idleTimeService)
        {
            Check.ArgumentNotNull(nameof(fileSystem), fileSystem);
            Check.ArgumentNotNull(nameof(includeFiles), includeFiles);
            Check.ArgumentNotNull(nameof(excludeFiles), excludeFiles);
            Check.ArgumentNotNull(nameof(idleTimeService), idleTimeService);

            _version           = version;
            _fileSystem        = fileSystem;
            _workspaceRootPath = rootPath;
            _includeFiles      = includeFiles;
            _excludeFiles      = excludeFiles;

            _userCodeSymbolIndex    = new SymbolIndex(_fileSystem, version);
            _libraryCodeSymbolIndex = new SymbolIndex(_fileSystem, version, libraryMode: true);

            idleTimeService.Idle += OnIdle;

            _disposables
            .Add(_userCodeSymbolIndex)
            .Add(_libraryCodeSymbolIndex)
            .Add(() => _disposeToken.TryMarkDisposed())
            .Add(() => idleTimeService.Idle -= OnIdle);
        }
示例#9
0
 /// <summary>
 /// Create delayed idle time action
 /// </summary>
 /// <param name="action">Action to execute on idle</param>
 /// <param name="delay">Minimum number of milliseconds to wait before executing the action</param>
 /// <param name="tag">Object that uniquely identifies the action. Typically creator object.</param>
 /// <param name="idleTime">Idle time service</param>
 public static void Create(Action action, int delay, object tag, IIdleTimeService idleTime)
 {
     if (!_idleActions.TryGetValue(tag, out IdleTimeAction existingAction))
     {
         existingAction    = new IdleTimeAction(action, delay, tag, idleTime);
         _idleActions[tag] = existingAction;
     }
 }
        public IdleTimeTaskQueue(IServiceContainer services)
        {
            _services = services;
            _idleTime = services.GetService <IIdleTimeService>();

            var taskCount = Math.Max(Environment.ProcessorCount / 2, 1);

            _runningTasks = new Task[taskCount];
        }
示例#11
0
        private IdleTimeAction(Action action, int delay, object tag, IIdleTimeService idleTime)
        {
            _action   = action;
            _delay    = delay;
            _tag      = tag;
            _idleTime = idleTime;

            ConnectToIdle();
        }
示例#12
0
 public TreeUpdateTask(EditorTree editorTree, IServiceContainer services)
 {
     _editorTree = editorTree;
     _services   = services;
     _idleTime   = services.GetService <IIdleTimeService>();
     if (_idleTime != null)
     {
         _idleTime.Idle += OnIdle;
     }
 }
示例#13
0
        public HelpVisualComponent(IServiceContainer services)
        {
            _services = services;
            _idleTime = _services.GetService <IIdleTimeService>();

            _codeColorBuilder = _services.GetService <IVignetteCodeColorBuilder>();
            var workflow = _services.GetService <IRInteractiveWorkflowProvider>().GetOrCreate();

            workflow.RSessions.BrokerStateChanged += OnBrokerStateChanged;

            _session = workflow.RSession;
            _session.Disconnected += OnRSessionDisconnected;

            _windowContentControl = new ContentControl();

            CreateBrowser();
            VSColorTheme.ThemeChanged += OnColorThemeChanged;
        }
示例#14
0
        public DiagnosticsPublisher(IVsCodeClient client, IREditorDocument document, Uri documentUri, IServiceContainer services)
        {
            _client      = client;
            _document    = document;
            _documentUri = documentUri;

            _settings   = services.GetService <IREditorSettings>();
            _idleTime   = services.GetService <IIdleTimeService>();
            _mainThread = services.GetService <IMainThreadPriority>();

            var validator = _document.EditorBuffer.GetService <TreeValidator>();

            validator.Cleared += OnCleared;
            _resultsQueue      = validator.ValidationResults;
            _idleTime.Idle    += OnIdle;

            _document.Closing += OnDocumentClosing;
            _document.EditorTree.UpdateCompleted += OnTreeUpdateCompleted;
        }
示例#15
0
        protected TextViewConnectionListener(IServiceContainer services)
        {
            Services = services;

            var ep = services.GetService <ExportProvider>();

            _textBufferListeners = Orderer.Order(ep.GetExports <ITextBufferListener, IOrderedComponentContentTypes>());
            _textViewListeners   = ep.GetExports <ITextViewListener, IOrderedComponentContentTypes>();
            _textViewListeners   = ep.GetExports <ITextViewListener, IOrderedComponentContentTypes>();
            _tdfs = services.GetService <ITextDocumentFactoryService>();

            _allInstances = _allInstances ?? new List <TextViewConnectionListener>();
            // This class is never disposed, so it always stays in the global list
            _allInstances.Add(this);
            _idleTime    = services.GetService <IIdleTimeService>();
            _application = services.GetService <IApplication>();

            _application.Terminating += OnTerminateApp;
        }
示例#16
0
        public VsTaskListProvider(IEditorTaskListItemSource source, IServiceContainer services)
            : base(RPackage.Current)
        {
            // Registration of the provider in VS is done by the base class.

            _source                     = source;
            _source.TasksAdded         += OnTasksAdded;
            _source.TasksRemoved       += OnTasksRemoved;
            _source.TasksCleared       += OnTasksCleared;
            _source.TasksUpdated       += OnTasksUpdated;
            _source.BeginUpdatingTasks += OnBeginUpdatingTasks;
            _source.EndUpdatingTasks   += OnEndUpdatingTasks;

            _services       = services;
            _idleTime       = services.IdleTime();
            _idleTime.Idle += OnIdle;

            ProviderName = "R Language Service";
            ProviderGuid = _taskListProviderGuid;
        }
示例#17
0
        public IdleTimeAsyncTaskQueue(IServiceContainer services)
        {
            _services = services;
            _idleTime = services.GetService <IIdleTimeService>();

            var logicalCpuCount = Environment.ProcessorCount;
            var taskCount       = logicalCpuCount / 4;

            if (taskCount == 0)
            {
                taskCount = 1;
            }

            _workerTasks = new IdleTimeAsyncTask[taskCount];

            for (var i = 0; i < _workerTasks.Length; i++)
            {
                _workerTasks[i] = new IdleTimeAsyncTask(_services);
            }
        }
示例#18
0
        public PreviewMargin(ITextView textView, IServiceContainer services)
        {
            _idleActionTag = _idleActionTag ?? GetType();

            _textView = textView;
            _settings = services.GetService <IRMarkdownEditorSettings>();
            _idleTime = services.GetService <IIdleTimeService>();

            Browser = new BrowserView(_textView.TextBuffer.GetFileName(), services);
            Browser.ViewportChange += OnBrowserViewportChange;

            _marginControls = new MarginControls(this, textView, Browser.Control, _settings);

            UpdateBrowser();

            _textView.TextBuffer.Changed    += OnTextBufferChanged;
            _textView.Caret.PositionChanged += OnCaretPositionChanged;
            _textView.LayoutChanged         += OnLayoutChanged;

            textView.AddService(this);
        }
示例#19
0
        public ScrollTracker(HTMLDocument htmlDocument, IIdleTimeService idleTimeService)
        {
            _htmlDocument = htmlDocument;

            var documentEvents = (HTMLDocumentEvents2_Event)_htmlDocument;

            // Unfortunately, window.onscroll and body.onscroll do not fire in C#.
            // Therefore we will be tracking if scroll was initiated in the browser
            // pane by tracking mouse in/out and mouse wheel.
            // If mouse is over the window and viewport position changed
            // then we consider it to be a scroll event.
            documentEvents.onmousewheel += OnMouseWheel;
            documentEvents.onmouseover  += OnMouseOver;
            documentEvents.onmouseout   += OnMouseOut;

            idleTimeService.Idle += OnIdle;

            _disposableBag
            .Add(() => documentEvents.onmousewheel -= OnMouseWheel)
            .Add(() => documentEvents.onmouseover  -= OnMouseOver)
            .Add(() => documentEvents.onmouseout   -= OnMouseOut)
            .Add(() => idleTimeService.Idle        -= OnIdle);
        }
        public IndexManager(IFileSystem fileSystem, PythonLanguageVersion version, string rootPath, string[] includeFiles,
                            string[] excludeFiles, IIdleTimeService idleTimeService)
        {
            Check.ArgumentNotNull(nameof(fileSystem), fileSystem);
            Check.ArgumentNotNull(nameof(rootPath), rootPath);
            Check.ArgumentNotNull(nameof(includeFiles), includeFiles);
            Check.ArgumentNotNull(nameof(excludeFiles), excludeFiles);
            Check.ArgumentNotNull(nameof(idleTimeService), idleTimeService);

            _fileSystem        = fileSystem;
            _workspaceRootPath = rootPath;
            _includeFiles      = includeFiles;
            _excludeFiles      = excludeFiles;

            _symbolIndex          = new SymbolIndex(_fileSystem, version);
            idleTimeService.Idle += OnIdle;

            _disposables
            .Add(_symbolIndex)
            .Add(() => idleTimeService.Idle -= OnIdle);

            StartAddRootDir();
        }
示例#21
0
 public IdleTimeAsyncTask(IServiceContainer services)
 {
     _idleTime        = services.GetService <IIdleTimeService>();
     _mainThread      = services.MainThread();
     _testEnvironment = TestEnvironment.Current != null;
 }
示例#22
0
 public VsStatusBar(IServiceContainer services)
 {
     _services = services;
     _idleTime = services.GetService <IIdleTimeService>();
 }