From 1a1487fd5b95d87d4d38feb5c54bbaa853316162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Wed, 18 Apr 2012 21:23:19 +0200 Subject: [PATCH] [Formatting] Checked token for null, before using the parent. --- .../Formatter/AstFormattingVisitor.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs b/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs index 62be4557eb..5794d76353 100644 --- a/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs @@ -874,8 +874,10 @@ namespace ICSharpCode.NRefactory.CSharp } ForceSpacesBeforeRemoveNewLines(rParToken, spaceWithinMethodCallParentheses); } - foreach (CSharpTokenNode comma in rParToken.Parent.Children.Where(n => n.Role == Roles.Comma)) { - ForceSpacesBefore(comma, spaceBeforeMethodCallParameterComma); + if (!rParToken.IsNull) { + foreach (CSharpTokenNode comma in rParToken.Parent.Children.Where(n => n.Role == Roles.Comma)) { + ForceSpacesBefore(comma, spaceBeforeMethodCallParameterComma); + } } } @@ -1777,8 +1779,10 @@ namespace ICSharpCode.NRefactory.CSharp } ForceSpacesBeforeRemoveNewLines(rParToken, spaceWithinMethodCallParentheses); } - foreach (CSharpTokenNode comma in rParToken.Parent.Children.Where(n => n.Role == Roles.Comma)) { - ForceSpacesBefore(comma, spaceBeforeMethodCallParameterComma); + if (!rParToken.IsNull) { + foreach (CSharpTokenNode comma in rParToken.Parent.Children.Where(n => n.Role == Roles.Comma)) { + ForceSpacesBefore(comma, spaceBeforeMethodCallParameterComma); + } } }