I am currently writing a ReSharper 6 Plugin that should add Warnings
to my IDE. These are read from an XML file with a LineNumber and other data.
So far I have created an IDaemonStage
with ErrorStripeRequest.STRIPE_AND_ERRORS
and a IDaemonStageProcess
. This works and gets executed so far.
Problem is: The Warnigns don't get added to my IDE.
How do I get the correct TextRange and DocumentRange?
In my Execute()
I have this:
var violations = new List<HighlightingInfo>();
foreach (var error in errorsFromXML)
{
// assignments here
int lineNumber = 172; // example
string ruleId;
string rule;
string error;
rule = ruleId + ":" + rule;
// I guess this is what's wrong
var lineNumber =
JetBrains.Util.dataStructures.TypedIntrinsics.Int32<DocLine>.Parse(
linumber.ToString());
int start = daemonProcess.Document.GetLineStartOffset(lineNumber);
int end = daemonProcess.Document.GetLineEndOffsetNoLineBreak(lineNumber);
var textRange = new JetBrains.Util.TextRange(start, end);
var range = new JetBrains.DocumentModel.DocumentRange(
daemonProcess.Document, textRange);
// range.ToString() => (DocumentRange (6.253 - 6.262) on <WrongThread>) // example
// and this should be fine again
var highlight = new TqsHighlight(rule, error);
violations.Add(new HighlightingInfo(range, highlight, Severity.WARNING, rule + id));
}
return violations; // returns various violations
Also I have a Custom Highlight Class:
internal class TqsHighlight : IHighlighting
{
private readonly string error;
private readonly string rule;
public TqsHighlight(string rule, string error)
{
this.rule = rule;
this.error = error;
}
public bool IsValid()
{
return true;
}
public string ToolTip
{
get
{
return this.error;
}
}
public string ErrorStripeToolTip
{
get
{
return this.rule;
}
}
public int NavigationOffsetPatch
{
get
{
return 0;
}
}
}