Browse Source

Some improvements to output visitor.

newNRvisualizers
Daniel Grunwald 15 years ago
parent
commit
a92606cb97
  1. 13
      ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs

13
ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs

@ -148,13 +148,14 @@ namespace ICSharpCode.NRefactory.CSharp
/// Writes a comma. /// Writes a comma.
/// </summary> /// </summary>
/// <param name="nextNode">The next node after the comma.</param> /// <param name="nextNode">The next node after the comma.</param>
void Comma(AstNode nextNode) /// <param name="noSpacesAfterComma">When set prevents printing a space after comma.</param>
void Comma(AstNode nextNode, bool noSpaceAfterComma = false)
{ {
WriteSpecialsUpToRole(AstNode.Roles.Comma, nextNode); WriteSpecialsUpToRole(AstNode.Roles.Comma, nextNode);
Space(policy.SpacesBeforeComma); Space(policy.SpacesBeforeComma);
formatter.WriteToken(","); formatter.WriteToken(",");
lastWritten = LastWritten.Other; lastWritten = LastWritten.Other;
Space(policy.SpacesAfterComma); Space(!noSpaceAfterComma && policy.SpacesAfterComma);
} }
void WriteCommaSeparatedList(IEnumerable<AstNode> list) void WriteCommaSeparatedList(IEnumerable<AstNode> list)
@ -1108,7 +1109,8 @@ namespace ICSharpCode.NRefactory.CSharp
StartNode(attribute); StartNode(attribute);
attribute.Type.AcceptVisitor(this, data); attribute.Type.AcceptVisitor(this, data);
Space(policy.BeforeMethodCallParentheses); Space(policy.BeforeMethodCallParentheses);
WriteCommaSeparatedListInParenthesis(attribute.Arguments, policy.WithinMethodCallParentheses); if (attribute.Arguments.Count != 0 || !attribute.GetChildByRole(AstNode.Roles.LPar).IsNull)
WriteCommaSeparatedListInParenthesis(attribute.Arguments, policy.WithinMethodCallParentheses);
return EndNode(attribute); return EndNode(attribute);
} }
@ -1123,7 +1125,8 @@ namespace ICSharpCode.NRefactory.CSharp
} }
WriteCommaSeparatedList(attributeSection.Attributes.SafeCast<Attribute, AstNode>()); WriteCommaSeparatedList(attributeSection.Attributes.SafeCast<Attribute, AstNode>());
WriteToken("]", AstNode.Roles.RBracket); WriteToken("]", AstNode.Roles.RBracket);
NewLine(); if (!(attributeSection.Parent is ParameterDeclaration))
NewLine();
return EndNode(attributeSection); return EndNode(attributeSection);
} }
@ -1201,7 +1204,7 @@ namespace ICSharpCode.NRefactory.CSharp
if (first) { if (first) {
first = false; first = false;
} else { } else {
Comma(member); Comma(member, noSpaceAfterComma: true);
NewLine(); NewLine();
} }
member.AcceptVisitor(this, data); member.AcceptVisitor(this, data);

Loading…
Cancel
Save