Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/NRefactory.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Krüger <mkrueger@xamarin.com>2015-03-13 18:26:22 +0300
committerMike Krüger <mkrueger@xamarin.com>2015-03-13 18:26:22 +0300
commit89f0f074082a9356ec581a2a0c386a665179413a (patch)
treebbad82bfa88c32a4c13d8e0cfa61d5d7075f164d /ICSharpCode.NRefactory.CSharp
parent238776ab4e1a7b121e9737c2530a22efcc6e1372 (diff)
Fixed some c#6 parsing bugs.
Diffstat (limited to 'ICSharpCode.NRefactory.CSharp')
-rw-r--r--ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs31
1 files changed, 21 insertions, 10 deletions
diff --git a/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs b/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
index 7e792902..b46272c3 100644
--- a/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
+++ b/ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
@@ -966,7 +966,9 @@ namespace ICSharpCode.NRefactory.CSharp
newOperator.AddChild(new CSharpTokenNode(Convert(location [3]), Roles.RPar), Roles.RPar);
if (o.Block != null) {
- newOperator.AddChild((BlockStatement)o.Block.Accept(this), Roles.Body);
+ var blockStatement = o.Block.Accept(this) as BlockStatement;
+ if (blockStatement != null)
+ newOperator.AddChild(blockStatement, Roles.Body);
} else {
if (location != null && location.Count >= 5)
newOperator.AddChild(new CSharpTokenNode(Convert(location [4]), Roles.Semicolon), Roles.Semicolon);
@@ -1086,11 +1088,12 @@ namespace ICSharpCode.NRefactory.CSharp
AddConstraints(newMethod, m.CurrentTypeParameters);
if (m.Block != null) {
- var bodyBlock = (BlockStatement)m.Block.Accept(this);
+ var bodyBlock = m.Block.Accept(this) as BlockStatement;
// if (m.Block is ToplevelBlock) {
// newMethod.AddChild (bodyBlock.FirstChild.NextSibling, Roles.Body);
// } else {
- newMethod.AddChild(bodyBlock, Roles.Body);
+ if (bodyBlock != null)
+ newMethod.AddChild(bodyBlock, Roles.Body);
// }
} else if (location != null) {
if (location.Count < 3) {
@@ -1267,8 +1270,11 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
- if (c.Block != null)
- newConstructor.AddChild((BlockStatement)c.Block.Accept(this), Roles.Body);
+ if (c.Block != null) {
+ var blockStatement = c.Block.Accept(this) as BlockStatement;
+ if (blockStatement != null)
+ newConstructor.AddChild(blockStatement, Roles.Body);
+ }
typeStack.Peek().AddChild(newConstructor, Roles.TypeMemberRole);
}
@@ -1289,9 +1295,11 @@ namespace ICSharpCode.NRefactory.CSharp
newDestructor.AddChild(new CSharpTokenNode(Convert(location [2]), Roles.RPar), Roles.RPar);
}
- if (d.Block != null)
- newDestructor.AddChild((BlockStatement)d.Block.Accept(this), Roles.Body);
-
+ if (d.Block != null) {
+ var blockStatement = d.Block.Accept(this) as BlockStatement;
+ if (blockStatement != null)
+ newDestructor.AddChild(blockStatement, Roles.Body);
+ }
typeStack.Peek().AddChild(newDestructor, Roles.TypeMemberRole);
}
@@ -3285,8 +3293,11 @@ namespace ICSharpCode.NRefactory.CSharp
result.AddChild(new CSharpTokenNode(Convert(location [l++]), Roles.RPar), Roles.RPar);
}
}
- if (anonymousMethodExpression.Block != null)
- result.AddChild((BlockStatement)anonymousMethodExpression.Block.Accept(this), Roles.Body);
+ if (anonymousMethodExpression.Block != null) {
+ var blockStatement = anonymousMethodExpression.Block.Accept(this) as BlockStatement;
+ if (blockStatement != null)
+ result.AddChild(blockStatement, Roles.Body);
+ }
return result;
}