Skip to content
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

Print checked the same way as an invocationExpression #329

Merged
merged 1 commit into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ class ClassName
checked
{
checked(++i);

checked(printsLikeInvocations + whenItsFlat);

checked(
printsLikeInvocations + whenItBreaks______________________________________________
);

checked(
printsLikeInvocations
+ whenItLongBreaks_______________________________________________
);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using CSharpier.DocTypes;
using CSharpier.SyntaxPrinter;
using Microsoft.CodeAnalysis.CSharp.Syntax;

namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters
Expand All @@ -10,9 +9,12 @@ public static Doc Print(CheckedExpressionSyntax node)
{
return Doc.Concat(
Token.Print(node.Keyword),
Token.Print(node.OpenParenToken),
Node.Print(node.Expression),
Token.Print(node.CloseParenToken)
Doc.Group(
Token.Print(node.OpenParenToken),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we maybe have a helper method for invocation expression like things?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a similar thought, but it was different enough from how parameters are printed for Invocations that I didn't think it made sense to try to combine them. I just looked around and there are a lot of SyntaxNodePrinters that print the same style for the parens, but they all seem different enough that it would be hard to share the logic. : /

Doc.Indent(Doc.SoftLine, Node.Print(node.Expression)),
Doc.SoftLine,
Token.Print(node.CloseParenToken)
)
);
}
}
Expand Down