Ejemplo n.º 1
0
        private async void UpdateHighlightLineAsync(VersionedHighlightedLine line)
        {
            try
            {
                await Task.Run(async() =>
                {
                    await initialDelayTask.ConfigureAwait(false);
                    line.CancellationToken.ThrowIfCancellationRequested();

                    var documentLine   = line.DocumentLine;
                    var currentVersion = Document.Version;
                    if (line.Version == null || !currentVersion.BelongsToSameDocumentAs(line.Version) || currentVersion.CompareAge(line.Version) != 0)
                    {
                        return;
                    }
                    var spans = await GetClassifiedSpansAsync(documentLine, line.CancellationToken).ConfigureAwait(false);
                    line.CancellationToken.ThrowIfCancellationRequested();

                    await TaskHelper.Run(() =>
                    {
                        if (line.CancellationToken.IsCancellationRequested)
                        {
                            return;
                        }

                        var newLineSections = new List <HighlightedSection>();
                        foreach (var classifiedSpan in spans)
                        {
                            if (IsOutsideLine(documentLine, classifiedSpan.TextSpan.Start, classifiedSpan.TextSpan.Length))
                            {
                                continue;
                            }
                            newLineSections.Add(new HighlightedSection
                            {
                                Color  = CodeHighlightColors.GetHighlightingColor(classifiedSpan.ClassificationType),
                                Offset = classifiedSpan.TextSpan.Start,
                                Length = classifiedSpan.TextSpan.Length
                            });
                        }
                        if (!line.Sections.SequenceEqual(newLineSections, HighlightedSectionComparer.Default))
                        {
                            line.Sections.Clear();
                            foreach (var newSection in newLineSections)
                            {
                                line.Sections.Add(newSection);
                            }
                            HighlightingStateChanged?.Invoke(documentLine.LineNumber, documentLine.LineNumber);
                        }
                    }, uiTaskScheduler).ConfigureAwait(false);
                }, line.CancellationToken);
            }
            catch (OperationCanceledException) { }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Enforces a highlighting state update (triggering the HighlightingStateChanged event if necessary)
        /// for all lines up to (and inclusive) the specified line number.
        /// </summary>
        public void UpdateHighlightingState(int lineNumber)
        {
            if (lineNumber > 0)
            {
                var cnt = Math.Min(_cachedLines.Count - 1, lineNumber);
                for (int i = 0; i <= cnt; ++i)
                {
                    _cachedLines.Remove(i);
                }

                HighlightingStateChanged?.Invoke(1, lineNumber);
            }
        }
        private void UpdateHighlightingSections(HighlightedLine line, List <HighlightedSection> sections)
        {
            var lineNumber = line.DocumentLine.LineNumber;

            _syncContext.Post(o =>
            {
                line.Sections.Clear();
                foreach (var section in sections)
                {
                    line.Sections.Add(section);
                }
                HighlightingStateChanged?.Invoke(lineNumber, lineNumber);
            }, null);
        }
Ejemplo n.º 4
0
        async Task CheckForSemanticChange()
        {
            var document = workspace.GetDocument(DocumentId);

            if (document == null)
            {
                return;
            }
            var projectVersion = await document.Project.GetDependentSemanticVersionAsync(CancellationToken.None);

            if (lastSemanticVersion != projectVersion)
            {
                lastSemanticVersion = projectVersion;
                await Runtime.RunInMainThread(delegate {
                    HighlightingStateChanged?.Invoke(null, LineEventArgs.AllLines);
                });
            }
        }
Ejemplo n.º 5
0
 void OnHighlightingStateChanged(LineEventArgs e)
 {
     HighlightingStateChanged?.Invoke(this, e);
 }
Ejemplo n.º 6
0
 protected virtual void OnHighlightingStateChanged(global::MonoDevelop.Ide.Editor.LineEventArgs e)
 {
     HighlightingStateChanged?.Invoke(this, e);
 }
 private void OnHighlightingStateChanged(int fromLineNumber, int toLineNumber)
 {
     _syncContext.Post(o => HighlightingStateChanged?.Invoke(fromLineNumber, toLineNumber), null);
 }
Ejemplo n.º 8
0
 // ReSharper disable once UnusedMember.Local
 private void OnHighlightingStateChanged(int fromLineNumber, int toLineNumber)
 {
     HighlightingStateChanged?.Invoke(fromLineNumber, toLineNumber);
 }