Esempio n. 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);
            }
            //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)
                {
                    return(false);
                }

                if (id == null)
                {
                    foreach (var markerQueue in ext.markers)
                    {
                        while (markerQueue.Value.Count != 0)
                        {
                            editor.RemoveMarker(markerQueue.Value.Dequeue());
                        }
                    }
                    ext.markers.Clear();
                    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.RemoveMarker(ext.markers [id].Dequeue());
                    oldMarkers--;
                }

                //add in the new markers
                for (int i = 0; i < UPDATE_COUNT; i++)
                {
                    if (!enumerator.MoveNext())
                    {
                        ext.tasks [id] = builder.ToImmutable();
                        ext.OnTasksUpdated(EventArgs.Empty);
                        return(false);
                    }
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return(false);
                    }
                    var currentResult = (Result)enumerator.Current;
                    if (currentResult.InspectionMark != IssueMarker.None)
                    {
                        int start = currentResult.Region.Start;
                        int end   = currentResult.Region.End;
                        if (start >= end)
                        {
                            continue;
                        }
                        var marker = TextMarkerFactory.CreateGenericTextSegmentMarker(editor, GetSegmentMarkerEffect(currentResult.InspectionMark), TextSegment.FromBounds(start, end));
                        marker.Tag       = currentResult;
                        marker.IsVisible = currentResult.Underline;

                        if (currentResult.InspectionMark != IssueMarker.GrayOut)
                        {
                            marker.Color      = GetColor(editor, currentResult);
                            marker.IsVisible &= currentResult.Level != DiagnosticSeverity.Hidden;
                        }
                        editor.AddMarker(marker);
                        ext.markers [id].Enqueue(marker);
                    }
                    builder.Add(new QuickTask(currentResult.Message, currentResult.Region.Start, currentResult.Level));
                }

                return(true);
            }
Esempio n. 3
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);
            }
Esempio n. 4
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)
                {
                    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.RemoveMarker(ext.markers.Dequeue());
                    oldMarkers--;
                }
                //add in the new markers
                for (int i = 0; i < UPDATE_COUNT; i++)
                {
                    if (!enumerator.MoveNext())
                    {
                        ext.tasks = builder.ToImmutable();
                        ext.OnTasksUpdated(EventArgs.Empty);
                        return(false);
                    }
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return(false);
                    }
                    var currentResult = (Result)enumerator.Current;
                    if (currentResult.InspectionMark != IssueMarker.None)
                    {
                        int start = currentResult.Region.Start;
                        int end   = currentResult.Region.End;
                        if (start >= end)
                        {
                            continue;
                        }
                        if (currentResult.InspectionMark == IssueMarker.GrayOut)
                        {
                            var marker = TextMarkerFactory.CreateGenericTextSegmentMarker(editor, TextSegmentMarkerEffect.GrayOut, TextSegment.FromBounds(start, end));
                            marker.IsVisible = currentResult.Underline;
                            marker.Tag       = currentResult;
                            editor.AddMarker(marker);
                            ext.markers.Enqueue(marker);
//							editor.Parent.TextViewMargin.RemoveCachedLine (editor.GetLineByOffset (start));
//							editor.Parent.QueueDraw ();
                        }
                        else
                        {
                            var effect = currentResult.InspectionMark == IssueMarker.DottedLine ? TextSegmentMarkerEffect.DottedLine : TextSegmentMarkerEffect.WavedLine;
                            var marker = TextMarkerFactory.CreateGenericTextSegmentMarker(editor, effect, TextSegment.FromBounds(start, end));
                            marker.Color     = GetColor(editor, currentResult);
                            marker.IsVisible = currentResult.Underline;
                            marker.Tag       = currentResult;
                            editor.AddMarker(marker);
                            ext.markers.Enqueue(marker);
                        }
                    }
                    builder.Add(new QuickTask(currentResult.Message, currentResult.Region.Start, currentResult.Level));
                }

                return(true);
            }
Esempio n. 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()
            {
                var editor = ext.Editor;

                if (editor == null)
                {
                    return(false);
                }
                if (id == null)
                {
                    foreach (var markerQueue in ext.markers)
                    {
                        foreach (var marker in markerQueue.Value)
                        {
                            editor.RemoveMarker(marker);
                        }
                        PutBackCachedList(markerQueue.Value);
                    }
                    ext.markers.Clear();
                    lock (ext.tasks)
                        ext.tasks.Clear();
                    ext.OnTasksUpdated(EventArgs.Empty);
                    return(false);
                }

                if (cancellationToken.IsCancellationRequested)
                {
                    FinishUpdateRun();
                    return(false);
                }

                //clear the old results out at the same rate we add in the new ones
                for (int i = 0; oldMarkerIndex < oldMarkers.Count && i < UPDATE_COUNT; i++)
                {
                    var oldMarker = oldMarkers [oldMarkerIndex++];

                    var oldResult = (Result)oldMarker.Tag;
                    if (curResult < results.Count)
                    {
                        Result currentResult = results [curResult];
                        if (currentResult.Equals(oldResult, oldMarker.Offset))
                        {
                            oldMarker.Tag = currentResult;
                            newMarkers.Add(oldMarker);
                            if (oldResult.QuickTask != null)
                            {
                                currentResult.QuickTask = oldResult.QuickTask;
                                builder.Add(currentResult.QuickTask);
                            }
                            curResult++;
                            continue;
                        }
                    }
                    editor.RemoveMarker(oldMarker);
                }

                //add in the new markers
                for (int i = 0; i < UPDATE_COUNT; i++)
                {
                    if (curResult >= results.Count)
                    {
                        FinishUpdateRun();
                        return(false);
                    }
                    var currentResult = results [curResult++];
                    if (currentResult.InspectionMark != IssueMarker.None)
                    {
                        int start = currentResult.Region.Start;
                        int end   = currentResult.Region.End;
                        if (start > end)
                        {
                            continue;
                        }

                        // In case a diagnostic has a 0 length span, force it to 1.
                        if (start == end)
                        {
                            end = end + 1;
                        }

                        var marker = TextMarkerFactory.CreateGenericTextSegmentMarker(editor, GetSegmentMarkerEffect(currentResult.InspectionMark), TextSegment.FromBounds(start, end));
                        marker.Tag       = currentResult;
                        marker.IsVisible = currentResult.Underline;

                        if (currentResult.InspectionMark != IssueMarker.GrayOut)
                        {
                            marker.Color      = GetColor(editor, currentResult);
                            marker.IsVisible &= currentResult.Level != DiagnosticSeverity.Hidden;
                        }
                        editor.AddMarker(marker);
                        newMarkers.Add(marker);
                    }
                    builder.Add(currentResult.QuickTask = new QuickTask(currentResult.Message, currentResult.Region.Start, currentResult.Level));
                }
                return(true);
            }