Beispiel #1
0
            //this runs as a glib idle handler so it can add/remove text editor markers
            //in order to to block the GUI thread, we batch them in UPDATE_COUNT
            bool IdleHandler()
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    return(false);
                }
                var editor = ext.Editor;

                if (editor == null || editor.Document == null)
                {
                    return(false);
                }
                //clear the old results out at the same rate we add in the new ones
                for (int i = 0; oldMarkers > 0 && i < UPDATE_COUNT; i++)
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return(false);
                    }
                    editor.Document.RemoveMarker(ext.markers.Dequeue());
                    oldMarkers--;
                }
                //add in the new markers
                for (int i = 0; i < UPDATE_COUNT; i++)
                {
                    if (!enumerator.MoveNext())
                    {
                        ext.OnTasksUpdated(EventArgs.Empty);
                        return(false);
                    }
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return(false);
                    }
                    var currentResult = (Result)enumerator.Current;

                    if (currentResult.InspectionMark != IssueMarker.None)
                    {
                        var marker = new ResultMarker(currentResult);
                        marker.IsVisible = currentResult.Underline;
                        editor.Document.AddMarker(marker.Line, marker);
                        ext.markers.Enqueue(marker);
                    }

                    ext.tasks.Add(new QuickTask(currentResult.Message, currentResult.Region.Begin, currentResult.Level));
                }

                return(true);
            }
Beispiel #2
0
        //this runs as a glib idle handler so it can add/remove text editor markers
        //in order to to block the GUI thread, we batch them in UPDATE_COUNT
        bool ResultsUpdater()
        {
            lock (updaterLock) {
                if (nextResults != null)
                {
                    currentResults = nextResults;
                    nextResults    = null;
                    updateIndex    = 0;
                    oldMarkers    += markers.Count;
                }
                //stop the updater when we're done updating results
                if (currentResults.Count == updateIndex && oldMarkers == 0)
                {
                    currentResults = null;
                    updaterRunning = false;
                    UpdateQuickTasks();
                    return(false);
                }
            }

            if (Editor == null || Editor.Document == null)
            {
                return(false);                // prevents endless idle loop
            }
            //clear the old results out at the same rate we add in the new ones
            for (int i = 0; oldMarkers > 0 && i < UPDATE_COUNT; i++)
            {
                Editor.Document.RemoveMarker(markers.Dequeue());
                oldMarkers--;
            }

            //add in the new markers
            int targetIndex = updateIndex + UPDATE_COUNT;

            for (; updateIndex < targetIndex && updateIndex < currentResults.Count; updateIndex++)
            {
                var marker = new ResultMarker(currentResults [updateIndex]);
                marker.IsVisible = currentResults [updateIndex].Underline;
                Editor.Document.AddMarker(marker.Line, marker);
                markers.Enqueue(marker);
            }
            return(true);
        }
			//this runs as a glib idle handler so it can add/remove text editor markers
			//in order to to block the GUI thread, we batch them in UPDATE_COUNT
			bool IdleHandler ()
			{
				if (cancellationToken.IsCancellationRequested)
					return false;
				var editor = ext.Editor;
				if (editor == null || editor.Document == null)
					return false;
				//clear the old results out at the same rate we add in the new ones
				for (int i = 0; oldMarkers > 0 && i < UPDATE_COUNT; i++) {
					if (cancellationToken.IsCancellationRequested)
						return false;
					editor.Document.RemoveMarker (ext.markers.Dequeue ());
					oldMarkers--;
				}
				//add in the new markers
				for (int i = 0; i < UPDATE_COUNT; i++) {
					if (!enumerator.MoveNext ()) {
						ext.OnTasksUpdated (EventArgs.Empty);
						return false;
					}
					if (cancellationToken.IsCancellationRequested)
						return false;
					var currentResult = (Result)enumerator.Current;
					
					if (currentResult.InspectionMark != IssueMarker.None) {
						int start = editor.LocationToOffset (currentResult.Region.Begin);
						int end = editor.LocationToOffset (currentResult.Region.End);
						if (start >= end)
							continue;
						if (currentResult.InspectionMark == IssueMarker.GrayOut) {
							var marker = new GrayOutMarker (currentResult, TextSegment.FromBounds (start, end));
							marker.IsVisible = currentResult.Underline;
							editor.Document.AddMarker (marker);
							ext.markers.Enqueue (marker);
							editor.Parent.TextViewMargin.RemoveCachedLine (editor.GetLineByOffset (start));
							editor.Parent.QueueDraw ();
						} else {
							var marker = new ResultMarker (currentResult, TextSegment.FromBounds (start, end));
							marker.IsVisible = currentResult.Underline;
							editor.Document.AddMarker (marker);
							ext.markers.Enqueue (marker);
						}
					}
					
					ext.tasks.Add (new QuickTask (currentResult.Message, currentResult.Region.Begin, currentResult.Level));
				}
				
				return true;
			}
		//this runs as a glib idle handler so it can add/remove text editor markers
		//in order to to block the GUI thread, we batch them in UPDATE_COUNT
		bool ResultsUpdater ()
		{
			lock (updaterLock) {
				if (nextResults != null) {
					currentResults = nextResults;
					nextResults = null;
					updateIndex = 0;
					oldMarkers += markers.Count;
				}
				//stop the updater when we're done updating results
				if (currentResults.Count == updateIndex && oldMarkers == 0) {
					currentResults = null;
					updaterRunning = false;
					UpdateQuickTasks ();
					return false;
				}
			}
			
			if (Editor == null || Editor.Document == null) 
				return false; // prevents endless idle loop
			
			//clear the old results out at the same rate we add in the new ones
			for (int i = 0; oldMarkers > 0 && i < UPDATE_COUNT; i++) {
				Editor.Document.RemoveMarker (markers.Dequeue ());
				oldMarkers--;
			}
			
			//add in the new markers
			int targetIndex = updateIndex + UPDATE_COUNT;
			for (; updateIndex < targetIndex && updateIndex < currentResults.Count; updateIndex++) {
				var marker = new ResultMarker (currentResults [updateIndex]);
				marker.IsVisible = currentResults [updateIndex].Underline;
				Editor.Document.AddMarker (marker.Line, marker);
				markers.Enqueue (marker);
			}
			return true;
		}
Beispiel #5
0
            //this runs as a glib idle handler so it can add/remove text editor markers
            //in order to to block the GUI thread, we batch them in UPDATE_COUNT
            bool IdleHandler()
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    return(false);
                }
                var editor = ext.Editor;

                if (editor == null || editor.Document == null)
                {
                    return(false);
                }
                //clear the old results out at the same rate we add in the new ones
                for (int i = 0; oldMarkers > 0 && i < UPDATE_COUNT; i++)
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return(false);
                    }
                    editor.Document.RemoveMarker(ext.markers.Dequeue());
                    oldMarkers--;
                }
                //add in the new markers
                for (int i = 0; i < UPDATE_COUNT; i++)
                {
                    if (!enumerator.MoveNext())
                    {
                        ext.OnTasksUpdated(EventArgs.Empty);
                        return(false);
                    }
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return(false);
                    }
                    var currentResult = (Result)enumerator.Current;

                    if (currentResult.InspectionMark != IssueMarker.None)
                    {
                        int start = editor.LocationToOffset(currentResult.Region.Begin);
                        int end   = editor.LocationToOffset(currentResult.Region.End);
                        if (start >= end)
                        {
                            continue;
                        }
                        if (currentResult.InspectionMark == IssueMarker.GrayOut)
                        {
                            var marker = new GrayOutMarker(currentResult, TextSegment.FromBounds(start, end));
                            marker.IsVisible = currentResult.Underline;
                            editor.Document.AddMarker(marker);
                            ext.markers.Enqueue(marker);
                            editor.Parent.TextViewMargin.RemoveCachedLine(editor.GetLineByOffset(start));
                            editor.Parent.QueueDraw();
                        }
                        else
                        {
                            var marker = new ResultMarker(currentResult, TextSegment.FromBounds(start, end));
                            marker.IsVisible = currentResult.Underline;
                            editor.Document.AddMarker(marker);
                            ext.markers.Enqueue(marker);
                        }
                    }

                    ext.tasks.Add(new QuickTask(currentResult.Message, currentResult.Region.Begin, currentResult.Level));
                }

                return(true);
            }
			//this runs as a glib idle handler so it can add/remove text editor markers
			//in order to to block the GUI thread, we batch them in UPDATE_COUNT
			bool IdleHandler ()
			{
				if (cancellationToken.IsCancellationRequested)
					return false;
				var editor = ext.Editor;
				if (editor == null || editor.Document == null)
					return false;
				//clear the old results out at the same rate we add in the new ones
				for (int i = 0; oldMarkers > 0 && i < UPDATE_COUNT; i++) {
					if (cancellationToken.IsCancellationRequested)
						return false;
					editor.Document.RemoveMarker (ext.markers.Dequeue ());
					oldMarkers--;
				}
				//add in the new markers
				for (int i = 0; i < UPDATE_COUNT; i++) {
					if (!enumerator.MoveNext ()) {
						ext.OnTasksUpdated (EventArgs.Empty);
						return false;
					}
					if (cancellationToken.IsCancellationRequested)
						return false;
					var currentResult = (Result)enumerator.Current;
					
					if (currentResult.InspectionMark != IssueMarker.None) {
						var marker = new ResultMarker (currentResult);
						marker.IsVisible = currentResult.Underline;
						editor.Document.AddMarker (marker.Line, marker);
						ext.markers.Enqueue (marker);
					}
					
					ext.tasks.Add (new QuickTask (currentResult.Message, currentResult.Region.Begin, currentResult.Level));
				}
				
				return true;
			}