Posted 3 years ago
by Adam Driscoll
Version: 21.1.1
Platform: .NET 4.6
Environment: Windows 10 (64-bit)
Hello,
I have several tagger that use the TaggerBase class and register with the syntax editor. The squiggles show up but when I hover, I do not see the text that I am providing. Here's my tagger.
using ActiproSoftware.Text;
using ActiproSoftware.Text.Tagging;
using ActiproSoftware.Text.Tagging.Implementation;
using ActiproSoftware.Text.Utility;
using ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt.Implementation;
using Common.Analysis;
using PSScriptpad.Language;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FormDesigner.Host.Language
{
class PowerShellAnalyzerTagger : TaggerBase<ISquiggleTag>
{
private readonly ICodeDocument document;
private PSParseData parseData;
public PowerShellAnalyzerTagger(ICodeDocument document) : base(nameof(PowerShellAnalyzerTagger), new List<Ordering>(), document)
{
this.document = document;
this.document.ParseDataChanged += Document_ParseDataChanged;
}
private void Document_ParseDataChanged(object sender, ActiproSoftware.Text.Parsing.ParseDataPropertyChangedEventArgs e)
{
parseData = (PSParseData)e.NewValue;
OnTagsChanged(new TagsChangedEventArgs(parseData.SnapshotRange));
}
public override IEnumerable<TagSnapshotRange<ISquiggleTag>> GetTags(NormalizedTextSnapshotRangeCollection snapshotRanges, object parameter)
{
if (document.Properties.ContainsKey("terminal")) yield break;
if (parseData == null) yield break;
if (snapshotRanges == null) yield break;
if (string.IsNullOrEmpty(parseData.Text)) yield break;
var issues = PowerShellLanguage.Instance.AnalysisService.StartAnalysis(new AnalysisRequest {
String = parseData.Text,
RequestId = Guid.NewGuid().ToString()
});
var snapshot = snapshotRanges.FirstOrDefault().Snapshot;
if (snapshot == null) yield break;
foreach (var issue in issues)
{
SquiggleTag tag = new SquiggleTag();
tag.ContentProvider = new PlainTextContentProvider(issue.Message);
tag.ClassificationType = ClassificationTypes.Comment;
var range = snapshot.PositionRangeToTextRange(new TextPositionRange(issue.Line - 1, issue.Column - 1, issue.Line - 1, snapshot.Lines[issue.Line - 1].Length - issue.Column - 1));
var textSnapshotRange = new TextSnapshotRange(snapshot, range);
yield return new TagSnapshotRange<ISquiggleTag>(textSnapshotRange, tag);
}
}
}
}
When I hover, it just shows the document's file path.