From 742f67753d63bd372ece35dc8d36c48799d3cdca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Thu, 13 Jun 2013 16:10:20 +0200 Subject: [PATCH] ResultOfAsyncCallShouldNotBeIgnoredIssue no longer underlines a large portion of the text. --- .../ResultOfAsyncCallShouldNotBeIgnoredIssue.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ResultOfAsyncCallShouldNotBeIgnoredIssue.cs b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ResultOfAsyncCallShouldNotBeIgnoredIssue.cs index 68dd1676ec..8cdc781b24 100644 --- a/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ResultOfAsyncCallShouldNotBeIgnoredIssue.cs +++ b/ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ResultOfAsyncCallShouldNotBeIgnoredIssue.cs @@ -42,6 +42,15 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring : base(ctx) { } + + AstNode GetNodeToUnderline(Expression target) + { + if (target is IdentifierExpression) + return target; + if (target is MemberReferenceExpression) + return ((MemberReferenceExpression)target).MemberNameToken; + return target; + } public override void VisitExpressionStatement(ExpressionStatement expressionStatement) { @@ -51,7 +60,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring return; var rr = ctx.Resolve(invocation) as InvocationResolveResult; if (rr != null && (rr.Type.IsKnownType(KnownTypeCode.Task) || rr.Type.IsKnownType(KnownTypeCode.TaskOfT))) { - AddIssue(invocation, ctx.TranslateString("Exceptions in async call will be silently ignored because the returned task is unused")); + AddIssue(GetNodeToUnderline (invocation.Target), ctx.TranslateString("Exceptions in async call will be silently ignored because the returned task is unused")); } } }