diff --git a/.gitignore b/.gitignore index dbd733218..4fbb1f451 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,8 @@ # Jetbrains doesn't say to ignore these, but it seems like they shouldn't be committed **/.idea/**/watcherTasks.xml +.vscode + node_modules bin obj diff --git a/Src/CSharpier.Tests/TestFiles/AttributeList/AttributeLists.cst b/Src/CSharpier.Tests/TestFiles/AttributeList/AttributeLists.cst index 88efa79b6..7e2981140 100644 --- a/Src/CSharpier.Tests/TestFiles/AttributeList/AttributeLists.cst +++ b/Src/CSharpier.Tests/TestFiles/AttributeList/AttributeLists.cst @@ -59,8 +59,10 @@ class ClassName public void MethodName( int someParameter, - [LongAttributeName(SomeFlag.SomeValue)] - AnotherObject anotherObject + [ShortAttributeName] AnotherObject anotherObject, + [VeryLongAttributeName(SomeFlag.SomeValue, SomeOtherFlag.SomeOtherLongValue)] + string tabbedBreakParameter, + bool anotherParameter ) { return; } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Parameter.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Parameter.cs index 7c0890363..cefdc78f9 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Parameter.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Parameter.cs @@ -1,6 +1,6 @@ +using System; using System.Collections.Generic; using CSharpier.DocTypes; -using CSharpier.SyntaxPrinter; using CSharpier.Utilities; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -10,24 +10,37 @@ public static class Parameter { public static Doc Print(ParameterSyntax node) { + var hasAttribute = node.AttributeLists.Any(); + var groupId = hasAttribute ? Guid.NewGuid().ToString() : string.Empty; var docs = new List { AttributeLists.Print(node, node.AttributeLists), - node.AttributeLists.Any() ? Doc.Line : Doc.Null, + hasAttribute ? Doc.IndentIfBreak(Doc.Line, groupId) : Doc.Null, Modifiers.Print(node.Modifiers) }; + + var paramDocs = new List(); if (node.Type != null) { - docs.Add(Node.Print(node.Type), " "); + paramDocs.Add(Node.Print(node.Type), " "); } - docs.Add(Token.Print(node.Identifier)); + paramDocs.Add(Token.Print(node.Identifier)); if (node.Default != null) { - docs.Add(EqualsValueClause.Print(node.Default)); + paramDocs.Add(EqualsValueClause.Print(node.Default)); } - return Doc.Concat(docs); + if (hasAttribute) + { + docs.Add(Doc.Concat(paramDocs)); + return Doc.Concat(Doc.GroupWithId(groupId, docs.ToArray())); + } + else + { + docs.AddRange(paramDocs); + return Doc.Concat(docs); + } } } } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParameterList.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParameterList.cs index 6ff7fd6ba..1187d1d33 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParameterList.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParameterList.cs @@ -1,5 +1,4 @@ using CSharpier.DocTypes; -using CSharpier.SyntaxPrinter; using Microsoft.CodeAnalysis.CSharp.Syntax; namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters