Hello,
I let the code within the Syntax Editor code go through the .NET compiler and get the necessary Error Message, Line and Column.
Now I want to underline the right part of the code and write the error message in a tooltip which pops up when I hover over the marked text.
How is this possible?
I tried it this way:
public bool CompileFormula()
{
foreach (CompileError error in compileErrors)
{
string msg = error.Message;
int line = error.Line;
int col = error.Column;
int startIndex = syntaxEditor.SelectedView.Selection.StartOffset = line + col + 1;
int endIndex = startIndex + syntaxEditor.Text.Skip(startIndex).TakeWhile(c => !char.isWhiteSpace(c)).Count + 1;
TextRange errorRange = new TextRange(startIndex, endIndex);
this.AddSpanIndicator(SpanIndicatorLayer.SyntaxErrorKey, SpanIndicatorLayer.SyntaxErrorDisplayPriority, new WaveLineSpanIndicator(Color.Red), errorRange);
}
}
private void AddSpanIndicatorSimple(string layerKey, int layerDisplayPriority, SpanIndicator indicator, TextRange errorRange)
{
if (errorRange.Length != 0)
{
SpanIndicatorLayer layer = new SpanIndicatorLayer(layerKey, layerDisplayPriority);
if (layer != null)
{
synEditor.Document.SpanIndicatorLayers.Add(layer);
}
if (!layer.OverlapsWith(errorRange) && layer.Count != 0)
{
layer.Add(indicator, errorRange);
}
}
}
Thanks for the help!
[Modified 12 years ago]