public RoslynCodeAnalysisHelper(IWpfTextView view, ITextDocument document, IVsTaskList tasks, DTE2 dte, SVsServiceProvider serviceProvider, IVsActivityLog log) { _view = view; _document = document; _text = new Adornment(); _tasks = tasks; _serviceProvider = serviceProvider; _log = log; _dispatcher = Dispatcher.CurrentDispatcher; _adornmentLayer = view.GetAdornmentLayer(RoslynCodeAnalysisFactory.LayerName); _view.ViewportHeightChanged += SetAdornmentLocation; _view.ViewportWidthChanged += SetAdornmentLocation; _text.MouseUp += (s, e) => dte.ExecuteCommand("View.ErrorList"); _timer = new Timer(750); _timer.Elapsed += (s, e) => { _timer.Stop(); System.Threading.Tasks.Task.Run(() => { _dispatcher.Invoke(new Action(() => Update(false)), DispatcherPriority.ApplicationIdle, null); }); }; _timer.Start(); }
public ErrorHighlighter(IWpfTextView view, ITextDocument document, IVsTaskList tasks, DTE2 dte, SVsServiceProvider serviceProvider) { _view = view; _document = document; _text = new Adornment(); _tasks = tasks; _serviceProvider = serviceProvider; _dispatcher = Dispatcher.CurrentDispatcher; _adornmentLayer = view.GetAdornmentLayer(ErrorHighlighterFactory.LayerName); _view.ViewportHeightChanged += SetAdornmentLocation; _view.ViewportWidthChanged += SetAdornmentLocation; _text.MouseUp += (s, e) => { dte.ExecuteCommand("View.ErrorList"); }; _timer = new Timer(750); _timer.Elapsed += (s, e) => { _timer.Stop(); System.Threading.Tasks.Task.Run(() => { _dispatcher.Invoke(new Action(() => { Update(false); }), DispatcherPriority.ApplicationIdle, null); }); }; _timer.Start(); }
private void RemoveProvider_Click(object sender, RoutedEventArgs e) { if ((_service != null) && (_providerCookie != VSConstants.VSCOOKIE_NIL)) { _provider.ClearItems(); _service.RefreshTasks(_providerCookie); int hr = _service.UnregisterTaskProvider(_providerCookie); if (ErrorHandler.Succeeded(hr)) { _providerCookie = VSConstants.VSCOOKIE_NIL; _provider = null; _service = null; this.RemoveProvider.Foreground = Brushes.Green; this.CreateProvider.IsEnabled = true; this.Refresh.IsEnabled = false; this.Add1000.IsEnabled = false; this.RemoveHalf.IsEnabled = false; this.RemoveProvider.IsEnabled = false; this.RemoveProvider.IsEnabled = false; return; } } this.RemoveProvider.Foreground = Brushes.Red; }
protected virtual void Dispose(bool disposing) { if (disposing) { if (tasks != null && !inFinalRelease) { tasks.Clear(); tasks = null; } if (taskList != null) { try { // Don't check for the result code because here we can't do anything in case of failure taskList.UnregisterTaskProvider(taskListCookie); } catch (Exception) { /* do nothing */ } taskList = null; } if (imageList != null) { imageList.Dispose(); imageList = null; } } }
// Activates the window and makes it visible. This should only be called // at the completion of a build process. /// <include file='doc\TaskProvider.uex' path='docs/doc[@for="ErrorListProvider.BringToFront"]/*' /> public void BringToFront() { IVsTaskList tasklist = this.VsTaskList; NativeMethods.ThrowOnFailure(errorList.BringToFront()); tasklist = null; }
private void Refresh() { IVsTaskList taskList = _serviceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList; int hr = taskList.RefreshTasks(_cookie); Debug.Assert(hr == VSConstants.S_OK, "RefreshTasks did not return S_OK."); }
// Forces the error toggle "on", so that errors are visible in the list. Warnings and // informational messages are not affected. /// <include file='doc\TaskProvider.uex' path='docs/doc[@for="ErrorListProvider.ForceShowErrors"]/*' /> public void ForceShowErrors() { IVsTaskList tasklist = this.VsTaskList; NativeMethods.ThrowOnFailure(errorList.ForceShowErrors()); tasklist = null; }
private void CreateProvider_Click(object sender, RoutedEventArgs e) { _service = this.GetService(); if (_service != null) { _provider = new MyTaskProvider(); _provider.AddItems(new MyTaskItem(_provider, document: @"d:\test\a.txt", text: "test 1 2 3", category: VSTASKCATEGORY.CAT_BUILDCOMPILE), new MyTaskItem(_provider, document: @"d:\test\b.txt", text: "test 4 5 6", subcategoryIndex: 1)); int hr = _service.RegisterTaskProvider(_provider, out _providerCookie); if (ErrorHandler.Succeeded(hr)) { this.CreateProvider.Foreground = Brushes.Green; this.RemoveProvider.IsEnabled = true; this.Refresh.IsEnabled = true; this.Add1000.IsEnabled = true; this.RemoveHalf.IsEnabled = true; this.CreateProvider.IsEnabled = false; return; } } this.CreateProvider.Foreground = Brushes.Red; }
public ErrorHighlighter(IWpfTextView view, ITextDocument document, IVsTaskList tasks, DTE2 dte) { _view = view; _document = document; _text = new Adornment(); _tasks = tasks; _dispatcher = Dispatcher.CurrentDispatcher; _adornmentLayer = view.GetAdornmentLayer(ErrorHighlighterFactory.LayerName); _view.ViewportHeightChanged += SetAdornmentLocation; _view.ViewportWidthChanged += SetAdornmentLocation; _text.MouseUp += (s, e) => { dte.ExecuteCommand("View.ErrorList"); }; _timer = new Timer(750); _timer.Elapsed += (s, e) => { _timer.Stop(); Task.Run(() => { _dispatcher.Invoke(new Action(() => { Update(false); }), DispatcherPriority.ApplicationIdle, null); }); }; _timer.Start(); }
public TaskProvider(IServiceProvider site){ this.site = site; this.taskList = (IVsTaskList)this.site.GetService(typeof(SVsTaskList)); items = new ArrayList(); RegisterProvider(); taskTokens = new TaskTokens(site); taskTokens.Refresh(); }
public ErrorTaskProvider(IServiceProvider serviceProvider, IVsTaskList taskList, IErrorProviderFactory errorProvider) : base(serviceProvider, taskList, errorProvider) { if (taskList is IVsErrorList) { _errorList = taskList as IVsErrorList; } }
private void InitializeTaskProvider() { taskList = Common.GetService(typeof(SVsTaskList)) as IVsTaskList; if (taskList != null) { taskList.RegisterTaskProvider(this, out taskListCookie); } }
public TaskProvider(ServiceProvider site) { this.site = site; this.taskList = (IVsTaskList)this.site.QueryService(VsConstants.SID_SVsTaskList, typeof(IVsTaskList)); items = new ArrayList(); RegisterProvider(); taskTokens = new TaskTokens(site); taskTokens.Refresh(); }
public void OnTaskListFinalRelease(IVsTaskList pTaskList) { if (dwCookie != 0) { this.taskList.UnregisterTaskProvider(dwCookie); dwCookie = 0; } }
public void Close() { ClearErrors(); if (this.taskList != null && dwCookie != 0) { OnTaskListFinalRelease(this.taskList); } this.site = null; this.taskList = null; }
public int OnTaskListFinalRelease(IVsTaskList pTaskList) { if (dwCookie != 0) { this.taskList.UnregisterTaskProvider(dwCookie); dwCookie = 0; } return(0); }
/// <summary> /// Refresh the TaskList on the screen. /// </summary> public void Refresh() { IVsTaskList taskList = serviceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList; if (taskList != null) { taskList.RefreshTasks(cookie); } }
private void ProcessBuildDoneEvents(vsBuildScope scope, vsBuildAction action) { if (_eventProcessor.HasIslandwoodProjects()) { IVsTaskList errorList = GetService(typeof(SVsErrorList)) as IVsTaskList; _eventProcessor.SendErrorDetails(errorList); } }
/// <include file='doc\VsTaskProvider.uex' path='docs/doc[@for="VsTaskProvider.Dispose"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void Dispose() { if (taskListCookie != 0) { Tasks.Clear(); TaskList.UnregisterTaskProvider(taskListCookie); taskList = null; } }
public TaskProvider(IServiceProvider site) { this.site = site; this.taskList = (IVsTaskList)this.site.GetService(typeof(SVsTaskList)); items = new ArrayList(); RegisterProvider(); taskTokens = new TaskTokens(site); taskTokens.Refresh(); }
public TaskProvider(ServiceProvider site) { this.site = site; this.taskList = (IVsTaskList)this.site.QueryService(VsConstants.SID_SVsTaskList, typeof(IVsTaskList)); items = new ArrayList(); RegisterProvider(); taskTokens = new TaskTokens(site); taskTokens.Refresh(); }
public TaskProvider(IServiceProvider serviceProvider, IVsTaskList taskList, IErrorProviderFactory errorProvider) { _serviceProvider = serviceProvider; _items = new Dictionary <EntryKey, List <TaskProviderItem> >(); _errorSources = new Dictionary <EntryKey, HashSet <ITextBuffer> >(); _taskList = taskList; _errorProvider = errorProvider; }
public TaskProvider(IServiceProvider serviceProvider, IVsTaskList taskList, IErrorProviderFactory errorProvider) { _serviceProvider = serviceProvider; _items = new Dictionary <EntryKey, List <TaskProviderItem> >(); _errorSources = new Dictionary <EntryKey, HashSet <ITextBuffer> >(); _taskList = taskList; _errorProvider = errorProvider; _workerQueue = new BlockingCollection <WorkerMessage>(); }
public int OnTaskListFinalRelease(IVsTaskList pTaskList) { if ((_cookie != 0) && (null != pTaskList)) { int hr = pTaskList.UnregisterTaskProvider(_cookie); Debug.Assert(hr == VSConstants.S_OK, "UnregisterTaskProvider did not return S_OK."); } return(VSConstants.S_OK); }
public void Close() { ClearErrors(); if (this.taskList != null && dwCookie != 0) { OnTaskListFinalRelease(this.taskList); } this.site = null; this.taskList = null; }
public TaskProvider(IServiceProvider serviceProvider, IVsTaskList taskList, IErrorProviderFactory errorProvider, IEnumerable <string> monikers) { _serviceProvider = serviceProvider; _items = new Dictionary <EntryKey, List <TaskProviderItem> >(); _errorSources = new Dictionary <EntryKey, HashSet <ITextBuffer> >(); _monikers = new HashSet <string>(monikers.MaybeEnumerate(), StringComparer.OrdinalIgnoreCase); _taskList = taskList; _errorProvider = errorProvider; }
int IVsTaskProvider.OnTaskListFinalRelease(IVsTaskList pTaskList) { if (pTaskList != null && cookie != 0) { pTaskList.UnregisterTaskProvider(cookie); cookie = 0; return(VSConstants.S_OK); } return(VSConstants.S_FALSE); }
private void InitializeTaskProvider() { taskList = Common.GetService(typeof(SVsErrorList)) as IVsTaskList; if (taskList != null) { taskList.RegisterTaskProvider(this, out taskListCookie); #if DEBUG System.Diagnostics.Debugger.Launch(); #endif } }
public int OnTaskListFinalRelease(IVsTaskList pTaskList) { if (pTaskList != null) { if (taskListCookie != 0) { pTaskList.UnregisterTaskProvider(taskListCookie); taskListCookie = 0; taskList = null; } } return(0); }
public TaskProvider(IServiceProvider provider) { _serviceProvider = provider; IVsTaskList taskList = _serviceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList; int hr = taskList.RegisterTaskProvider(this, out _cookie); Debug.Assert(hr == VSConstants.S_OK, "RegisterTaskProvider did not return S_OK."); Debug.Assert(_cookie != 0, "RegisterTaskProvider did not return a nonzero cookie."); SetCommandHandlers(); ListenForProjectUnload(); }
public TaskProvider(IVsTaskList errorList, IErrorProviderFactory errorProvider) { _items = new Dictionary <EntryKey, List <TaskProviderItem> >(); _errorSources = new Dictionary <EntryKey, HashSet <ITextBuffer> >(); _errorList = errorList; if (_errorList != null) { ErrorHandler.ThrowOnFailure(_errorList.RegisterTaskProvider(this, out _cookie)); } _errorProvider = errorProvider; _workerQueue = new BlockingCollection <WorkerMessage>(); }
public Threading.Task SendErrorDetails(IVsTaskList errorList) { Threading.Task processTaskListTask = new System.Threading.Tasks.Task(() => { _processorStopwatch.Start(); IVsEnumTaskItems taskEnum = null; IVsTaskItem[] oneItem = new IVsTaskItem[1]; if (errorList != null) { errorList.EnumTaskItems(out taskEnum); if (taskEnum != null) { int maxItems = 10000; Int32.TryParse(Properties.Resources.MaxErrorsToProcess, out maxItems); taskEnum.Next(1, oneItem, null); for (int i = 0; (i < maxItems) && (oneItem[0] != null); ++i) { ProcessTaskListItem(oneItem[0]); taskEnum.Next(1, oneItem, null); } // send all events in case the Visual Studio instance is closed or solution unloaded BuildTelemetryClient.FlushEvents(); } } _processorStopwatch.Stop(); Dictionary <string, string> perfProperties = new Dictionary <string, string>(); perfProperties.Add("BuildId", _currentBuildGuid.ToString()); perfProperties.Add("ProjectId", _firstIslandwoodProjectGuid.ToString()); Dictionary <string, double> perfMetrics = new Dictionary <string, double>(); perfMetrics.Add("ProcessTasks", _processorStopwatch.ElapsedMilliseconds); BuildTelemetryClient.TrackEvent("IslandwoodBuildMonitorPerformance", perfProperties, perfMetrics); // reset state in case projects/solutions are unloaded before next build _firstIslandwoodProjectGuid = Guid.Empty; }); processTaskListTask.Start(); return(processTaskListTask); }
public CommentTaskProvider(MainPackage package) : base(package.ServiceProvider) { this.ServiceProvider = package.ServiceProvider; package.Options.Applied += this.Options_Applied; // In some cases the task list may not be available (e.g., during devenv.exe /build). IVsTaskList taskList = this.ServiceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList; if (taskList == null) { this.disposed = true; } else { // Register a custom category so Visual Studio will invoke our IVsTaskListEvents callbacks. VSTASKCATEGORY[] assignedCategory = new VSTASKCATEGORY[1]; int hr = this.VsTaskList.RegisterCustomCategory(CategoryId, (uint)TaskCategory.Comments + 1, assignedCategory); ErrorHandler.ThrowOnFailure(hr); this.CustomCategory = (TaskCategory)assignedCategory[0]; // The TaskProvider.ProviderGuid Property help says: // "The task list groups all tasks from multiple providers with the same GUID into a single list." // So the ProviderGuid is really just the group we're providing tasks for and not unique to us. this.ProviderGuid = ProviderId; this.ProviderName = "Tasks (" + MainPackage.Title + ")"; // Hide this provider since we're using our own Tasks tool window. this.AlwaysVisible = false; this.DisableAutoRoute = false; this.MaintainInitialTaskOrder = false; this.foregroundTimer = new System.Windows.Forms.Timer(); this.foregroundTimer.Interval = (int)TimeSpan.FromSeconds(1).TotalMilliseconds; this.foregroundTimer.Tick += this.ForegroundTimer_Tick; this.ScanDelay = TimeSpan.FromSeconds(2); this.CacheCommentTokens(); this.solutionMonitor = new SolutionMonitor(this); this.documentMonitor = new DocumentMonitor(this); this.fileMonitor = new FileMonitor(this); this.manager = new FileItemManager(this, this.fileMonitor, package.Options); // Enable the timers last. The BackgroundTimerCallback will fire after ScanDelay (on a worker thread), // so we have to ensure that everything is initialized before its first callback. this.foregroundTimer.Enabled = true; this.backgroundTimer = new System.Threading.Timer(this.BackgroundTimerCallback, null, this.ScanDelay, this.ScanDelay); } }
/// <summary> /// Registers current task provider inside the VisualStudio IDE. /// </summary> public void Register(string guid, string name) { // get access to TaskList: IVsTaskList taskListService = serviceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList; IVsTaskList2 taskListService2 = taskListService as IVsTaskList2; this.guid = new Guid(guid); this.name = name; if (taskListService != null && taskListService2 != null) { ErrorHandler.ThrowOnFailure(taskListService.RegisterTaskProvider(this, out cookie)); ErrorHandler.ThrowOnFailure(taskListService2.SetActiveProvider(ref this.guid)); } }
public TaskProvider(IServiceProvider provider) { _imageList.ImageSize = new Size(9, 16); _imageList.Images.AddStrip(Resources.priority); _imageList.TransparentColor = Color.FromArgb(0, 255, 0); _serviceProvider = provider; IVsTaskList taskList = _serviceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList; int hr = taskList.RegisterTaskProvider(this, out _cookie); Debug.Assert(hr == VSConstants.S_OK, "RegisterTaskProvider did not return S_OK."); Debug.Assert(_cookie != 0, "RegisterTaskProvider did not return a nonzero cookie."); SetCommandHandlers(); ListenForProjectUnload(); }
/// <include file='doc\TaskProvider.uex' path='docs/doc[@for="TaskProvider.IVsTaskProvider2.OnTaskListFinalRelease"]/*' /> /// <internalonly/> int IVsTaskProvider2.OnTaskListFinalRelease(IVsTaskList taskList) { return ((IVsTaskProvider)this).OnTaskListFinalRelease(taskList); }
public Threading.Task SendErrorDetails(IVsTaskList errorList) { Threading.Task processTaskListTask = new System.Threading.Tasks.Task(() => { _processorStopwatch.Start(); IVsEnumTaskItems taskEnum = null; IVsTaskItem[] oneItem = new IVsTaskItem[1]; if (errorList != null) { try { errorList.EnumTaskItems(out taskEnum); if (taskEnum != null) { int maxItems = 10000; Int32.TryParse(Properties.Resources.MaxErrorsToProcess, out maxItems); taskEnum.Next(1, oneItem, null); for (int i = 0; (i < maxItems) && (oneItem[0] != null); ++i) { ProcessTaskListItem(oneItem[0]); taskEnum.Next(1, oneItem, null); } } } catch (Exception e) { Dictionary<string, string> exceptionDetails = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); exceptionDetails.Add("BuildId", _currentBuildGuid.ToString()); exceptionDetails.Add("ProjectId", _firstIslandwoodProjectGuid.ToString()); exceptionDetails.Add("Exception", e.GetType().ToString()); exceptionDetails.Add("Message", e.Message); exceptionDetails.Add("InnerException", (e.InnerException == null ? "null" : e.InnerException.GetType().ToString())); exceptionDetails.Add("InnerMessage", (e.InnerException == null ? "null" : e.InnerException.Message)); BuildTelemetryClient.TrackEvent("IslandwoodBuildMonitorException", exceptionDetails, null); } finally { // send all events in case the Visual Studio instance is closed or solution unloaded BuildTelemetryClient.FlushEvents(); } } _processorStopwatch.Stop(); Dictionary<string, string> perfProperties = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); perfProperties.Add("BuildId", _currentBuildGuid.ToString()); perfProperties.Add("ProjectId", _firstIslandwoodProjectGuid.ToString()); Dictionary<string, double> perfMetrics = new Dictionary<string, double>(StringComparer.OrdinalIgnoreCase); perfMetrics.Add("ProcessTasks", _processorStopwatch.ElapsedMilliseconds); BuildTelemetryClient.TrackEvent("IslandwoodBuildMonitorPerformance", perfProperties, perfMetrics); // reset state in case projects/solutions are unloaded before next build _firstIslandwoodProjectGuid = Guid.Empty; }); processTaskListTask.Start(); return processTaskListTask; }
public int OnTaskListFinalRelease(IVsTaskList pTaskList) { if (pTaskList != null) { if (taskListCookie != 0) { pTaskList.UnregisterTaskProvider(taskListCookie); taskListCookie = 0; taskList = null; } } return 0; }
private void InitializeTaskProvider() { taskList = Common.GetService(typeof(SVsErrorList)) as IVsTaskList; if (taskList != null) { taskList.RegisterTaskProvider(this, out taskListCookie); #if DEBUG System.Diagnostics.Debugger.Launch(); #endif } }
public int OnTaskListFinalRelease(IVsTaskList pTaskList) { if ((_cookie != 0) && (null != pTaskList)) { int hr = pTaskList.UnregisterTaskProvider(_cookie); Debug.Assert(hr == VSConstants.S_OK, "UnregisterTaskProvider did not return S_OK."); } return VSConstants.S_OK; }
public void OnTaskListFinalRelease(IVsTaskList pTaskList){ if (dwCookie != 0) { this.taskList.UnregisterTaskProvider(dwCookie); dwCookie = 0; } }
/// <include file='doc\TaskProvider.uex' path='docs/doc[@for="TaskProvider.IVsTaskProvider.OnTaskListFinalRelease"]/*' /> /// <internalonly/> int IVsTaskProvider.OnTaskListFinalRelease(IVsTaskList taskList) { inFinalRelease = true; Dispose(true); return NativeMethods.S_OK; }
private void InitializeTaskProvider() { taskList = Common.GetService(typeof(SVsTaskList)) as IVsTaskList; if (taskList != null) { taskList.RegisterTaskProvider(this, out taskListCookie); } }
protected virtual void Dispose(bool disposing) { if (disposing) { if (tasks != null && !inFinalRelease) { tasks.Clear(); tasks = null; } if (taskList != null) { try { // Don't check for the result code because here we can't do anything in case of failure taskList.UnregisterTaskProvider(taskListCookie); } catch (Exception) { /* do nothing */ } taskList = null; } if (imageList != null) { imageList.Dispose(); imageList = null; } } }
public int OnTaskListFinalRelease(IVsTaskList taskList) { return VSConstants.E_NOTIMPL; }