Browse Source

When the last statement in a block is a label, add an EmptyStatement so that the generated code is valid.

pull/129/head
Daniel Grunwald 14 years ago
parent
commit
250dba9502
  1. 10
      NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs

10
NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs

@ -1531,6 +1531,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -1531,6 +1531,16 @@ namespace ICSharpCode.NRefactory.CSharp
StartNode(labelStatement);
WriteIdentifier(labelStatement.Label);
WriteToken(":", LabelStatement.Roles.Colon);
bool foundLabelledStatement = false;
for (AstNode tmp = labelStatement.NextSibling; tmp != null; tmp = tmp.NextSibling) {
if (tmp.Role == labelStatement.Role) {
foundLabelledStatement = true;
}
}
if (!foundLabelledStatement) {
// introduce an EmptyStatement so that the output becomes syntactically valid
WriteToken(";", LabelStatement.Roles.Semicolon);
}
NewLine();
return EndNode(labelStatement);
}

Loading…
Cancel
Save