Browse Source

Avoid ArgumentOutOfRangeException in CSharpSyntaxIssue.CreateCodeIssue().

pull/403/head
Daniel Grunwald 12 years ago
parent
commit
31460530d9
  1. 4
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CSharpSyntaxIssue.cs

4
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CSharpSyntaxIssue.cs

@ -45,13 +45,15 @@ namespace CSharpBinding.Refactoring @@ -45,13 +45,15 @@ namespace CSharpBinding.Refactoring
if (syntaxTree == null)
return Enumerable.Empty<CodeIssue>();
return syntaxTree.Errors.Select(error => CreateCodeIssue(error, refactoringContext));
return syntaxTree.Errors.Select(error => CreateCodeIssue(error, refactoringContext)).Where(issue => issue != null);
}
CodeIssue CreateCodeIssue(Error error, SDRefactoringContext context)
{
IDocument document = context.Document;
TextLocation begin = error.Region.Begin;
if (begin.Line <= 0 || begin.Line > document.LineCount)
return null;
// Columns seem to be zero-based, SD expects 1-based columns
int offset = document.GetOffset(begin.Line, begin.Column + 1);

Loading…
Cancel
Save