-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Break and Tab Parameters with Attributes #333
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Doc> | ||
{ | ||
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<Doc>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I'm thinking this through correctly, I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At a certain point it was holding onto a separate grouping logic, but that's no longer the case so yes it can be simplified now! |
||
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.GroupWithId(groupId, docs.ToArray()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest adding a new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just realized @shocklateboy92 had a similar idea and created an issue for it #334 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could solve that issue as part of this, not a big issue to do so. |
||
} | ||
else | ||
{ | ||
docs.AddRange(paramDocs); | ||
return Doc.Concat(docs); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it makes sense to ignore the whole directory.
There are a couple of things that are useful to share between people in the team (e.g. build tasks, extensions, format-on-save etc.)
Why don't you just commit your project specific settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I typically ignore the root
.vscode
folder until someone has those reusable config items mentioned. In my case I'm using VsCodium which needs to leverage an environment path-specific debugger. Folks don't need my dev environment items in their codebase.If a useful item pops up from another dev, they could add a caveat line to allow it.