From baa313878373a970e5472f53f932d5e1303bdabe Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Thu, 26 Dec 2024 11:53:12 -0600 Subject: [PATCH] Some refactoring that was in the csproj branch but didn't really belng there (#1415) --- .editorconfig | 26 ++++++++ CSharpier.sln | 1 + Directory.Build.props | 2 + Src/CSharpier.Benchmarks/Program.cs | 3 +- Src/CSharpier.Cli.Tests/CliTests.cs | 4 +- .../EditorConfig/SectionTests.cs | 4 +- Src/CSharpier.Cli.Tests/ServerTests.cs | 7 ++- Src/CSharpier.Cli/CommandLineFormatter.cs | 3 +- Src/CSharpier.Cli/CommandLineOptions.cs | 42 +++++-------- Src/CSharpier.Cli/ConsoleLogger.cs | 25 +++----- Src/CSharpier.Cli/EditorConfig/GlobMatcher.cs | 41 ++++++------- Src/CSharpier.Cli/EditorConfig/Section.cs | 31 +++------- Src/CSharpier.Cli/FileIssueLogger.cs | 17 ++---- Src/CSharpier.Cli/FormattingCache.cs | 42 +++++-------- Src/CSharpier.Cli/IgnoreFile.cs | 13 +--- .../Options/CaseInsensitiveEnumConverter.cs | 4 +- Src/CSharpier.Cli/Options/ConfigFileParser.cs | 6 +- .../Options/ConfigurationFileOptions.cs | 4 +- Src/CSharpier.Cli/Options/OptionsProvider.cs | 4 +- .../PhysicalFileInfoAndWriter.cs | 9 +-- .../PipeMultipleFilesFormatter.cs | 16 ++--- Src/CSharpier.Cli/Program.cs | 7 +-- .../Server/CSharpierServiceImplementation.cs | 4 +- Src/CSharpier.Cli/Server/FormatFileResult.cs | 4 +- Src/CSharpier.Cli/Server/ServerFormatter.cs | 4 +- .../StdOutFormattedFileWriter.cs | 11 +--- Src/CSharpier.FakeGenerators/CodeContext.cs | 9 +-- Src/CSharpier.FakeGenerators/Ignored.cs | 26 +++----- .../SyntaxNodeComparerGenerator.cs | 3 +- .../NodePrinterGenerator.sbntxt | 8 +-- .../Controllers/FormatController.cs | 38 +----------- .../Pages/Error.cshtml.cs | 7 --- Src/CSharpier.Playground/Startup.cs | 9 +-- .../.intellijPlatform/self-update.lock | 1 + Src/CSharpier.Tests/CSharpierIgnoreTests.cs | 16 ++--- .../Cli/Options/ConfigFileParserTests.cs | 4 +- Src/CSharpier.Tests/CodeFormatterTests.cs | 3 +- .../CommandLineFormatterTests.cs | 15 +++-- Src/CSharpier.Tests/DocUtilitiesTests.cs | 4 +- .../CSharp/PreprocessorSymbolsTests.cs | 4 +- .../FormattingTests/BaseTest.cs | 5 +- .../FormattingTests/LineEndingEdgeCase.cs | 4 +- Src/CSharpier.Tests/MissingTypeChecker.cs | 6 +- Src/CSharpier.Tests/OptionsProviderTests.cs | 4 +- Src/CSharpier.Tests/Samples/Samples.cs | 3 +- .../SyntaxNodeComparerTests.cs | 3 +- Src/CSharpier/CSharpFormatter.cs | 46 ++++++++------ Src/CSharpier/CodeFormatterResult.cs | 3 +- Src/CSharpier/DocPrinter/DocPrinter.cs | 2 +- Src/CSharpier/DocPrinter/Indent.cs | 13 ++-- Src/CSharpier/DocTypes/AlwaysFits.cs | 9 +-- Src/CSharpier/DocTypes/Concat.cs | 9 +-- Src/CSharpier/DocTypes/Region.cs | 9 +-- Src/CSharpier/DocTypes/StringDoc.cs | 12 +--- .../CSharp/BooleanExpressionParser.cs | 4 +- .../Formatters/CSharp/PreprocessorSymbols.cs | 10 +-- Src/CSharpier/GeneratedCodeUtilities.cs | 6 +- Src/CSharpier/SyntaxNodeJsonWriter.cs | 4 +- .../SyntaxPrinter/ArgumentListLikeSyntax.cs | 2 +- Src/CSharpier/SyntaxPrinter/AttributeLists.cs | 2 +- .../SyntaxPrinter/CSharpierIgnore.cs | 12 ++-- .../SyntaxPrinter/ConstraintClauses.cs | 2 +- .../SyntaxPrinter/FormattingContext.cs | 44 ------------- .../SyntaxPrinter/MembersWithForcedLines.cs | 7 +-- Src/CSharpier/SyntaxPrinter/Modifiers.cs | 14 ++--- .../SyntaxPrinter/NamespaceLikePrinter.cs | 6 +- Src/CSharpier/SyntaxPrinter/OptionalBraces.cs | 2 +- .../SyntaxPrinter/PrintingContext.cs | 61 +++++++++++++++++++ Src/CSharpier/SyntaxPrinter/RightHandSide.cs | 2 +- .../SyntaxPrinter/SeparatedSyntaxList.cs | 16 ++--- .../SyntaxNodePrinters/AliasQualifiedName.cs | 2 +- .../AnonymousMethodExpression.cs | 2 +- .../AnonymousObjectCreationExpression.cs | 2 +- .../AnonymousObjectMemberDeclarator.cs | 2 +- .../SyntaxNodePrinters/Argument.cs | 4 +- .../SyntaxNodePrinters/ArgumentList.cs | 2 +- .../ArrayCreationExpression.cs | 2 +- .../SyntaxNodePrinters/ArrayRankSpecifier.cs | 2 +- .../SyntaxNodePrinters/ArrayType.cs | 2 +- .../ArrowExpressionClause.cs | 2 +- .../AssignmentExpression.cs | 2 +- .../SyntaxNodePrinters/AttributeList.cs | 2 +- .../SyntaxNodePrinters/AwaitExpression.cs | 2 +- .../SyntaxNodePrinters/BaseExpression.cs | 2 +- .../SyntaxNodePrinters/BaseExpressionColon.cs | 2 +- .../BaseFieldDeclaration.cs | 2 +- .../BaseMethodDeclaration.cs | 16 +++-- .../BasePropertyDeclaration.cs | 6 +- .../SyntaxNodePrinters/BaseTypeDeclaration.cs | 2 +- .../SyntaxNodePrinters/BinaryExpression.cs | 16 +++-- .../SyntaxNodePrinters/BinaryPattern.cs | 2 +- .../SyntaxPrinter/SyntaxNodePrinters/Block.cs | 2 +- .../BracketedArgumentList.cs | 2 +- .../BracketedParameterList.cs | 2 +- .../SyntaxNodePrinters/BreakStatement.cs | 2 +- .../CasePatternSwitchLabel.cs | 2 +- .../SyntaxNodePrinters/CaseSwitchLabel.cs | 2 +- .../SyntaxNodePrinters/CastExpression.cs | 2 +- .../SyntaxNodePrinters/CatchClause.cs | 2 +- .../SyntaxNodePrinters/CheckedExpression.cs | 2 +- .../SyntaxNodePrinters/CheckedStatement.cs | 2 +- .../ClassOrStructConstraint.cs | 2 +- .../CollectionExpression.cs | 2 +- .../CommonForEachStatement.cs | 2 +- .../SyntaxNodePrinters/CompilationUnit.cs | 2 +- .../ConditionalAccessExpression.cs | 2 +- .../ConditionalExpression.cs | 6 +- .../SyntaxNodePrinters/ConstantPattern.cs | 2 +- .../ConstructorConstraint.cs | 2 +- .../SyntaxNodePrinters/ContinueStatement.cs | 2 +- .../DeclarationExpression.cs | 2 +- .../SyntaxNodePrinters/DeclarationPattern.cs | 2 +- .../SyntaxNodePrinters/DefaultConstraint.cs | 2 +- .../SyntaxNodePrinters/DefaultExpression.cs | 2 +- .../SyntaxNodePrinters/DefaultSwitchLabel.cs | 2 +- .../SyntaxNodePrinters/DelegateDeclaration.cs | 2 +- .../SyntaxNodePrinters/DiscardDesignation.cs | 2 +- .../SyntaxNodePrinters/DiscardPattern.cs | 2 +- .../SyntaxNodePrinters/DoStatement.cs | 2 +- .../ElementAccessExpression.cs | 2 +- .../ElementBindingExpression.cs | 2 +- .../SyntaxNodePrinters/ElseClause.cs | 2 +- .../SyntaxNodePrinters/EmptyStatement.cs | 2 +- .../EnumMemberDeclaration.cs | 2 +- .../SyntaxNodePrinters/EqualsValueClause.cs | 2 +- .../ExplicitInterfaceSpecifier.cs | 2 +- .../SyntaxNodePrinters/ExpressionElement.cs | 2 +- .../SyntaxNodePrinters/ExpressionStatement.cs | 2 +- .../ExternAliasDirective.cs | 2 +- .../FileScopedNamespaceDeclaration.cs | 2 +- .../SyntaxNodePrinters/FinallyClause.cs | 2 +- .../SyntaxNodePrinters/FixedStatement.cs | 2 +- .../SyntaxNodePrinters/ForStatement.cs | 2 +- .../SyntaxNodePrinters/FromClause.cs | 2 +- .../SyntaxNodePrinters/FunctionPointerType.cs | 4 +- .../SyntaxNodePrinters/GenericName.cs | 2 +- .../SyntaxNodePrinters/GlobalStatement.cs | 2 +- .../SyntaxNodePrinters/GotoStatement.cs | 2 +- .../SyntaxNodePrinters/GroupClause.cs | 2 +- .../SyntaxNodePrinters/IdentifierName.cs | 2 +- .../SyntaxNodePrinters/IfStatement.cs | 2 +- .../ImplicitArrayCreationExpression.cs | 2 +- .../ImplicitElementAccess.cs | 2 +- .../ImplicitObjectCreationExpression.cs | 2 +- ...plicitStackAllocArrayCreationExpression.cs | 2 +- .../SyntaxNodePrinters/IncompleteMember.cs | 2 +- .../InitializerExpression.cs | 2 +- .../InterpolatedStringExpression.cs | 6 +- .../InterpolatedStringText.cs | 2 +- .../SyntaxNodePrinters/Interpolation.cs | 2 +- .../InvocationExpression.cs | 6 +- .../SyntaxNodePrinters/IsPatternExpression.cs | 2 +- .../SyntaxNodePrinters/JoinClause.cs | 2 +- .../SyntaxNodePrinters/LabeledStatement.cs | 2 +- .../SyntaxNodePrinters/LetClause.cs | 2 +- .../SyntaxNodePrinters/ListPattern.cs | 2 +- .../SyntaxNodePrinters/LiteralExpression.cs | 2 +- .../LocalDeclarationStatement.cs | 2 +- .../LocalFunctionStatement.cs | 2 +- .../SyntaxNodePrinters/LockStatement.cs | 2 +- .../SyntaxNodePrinters/MakeRefExpression.cs | 2 +- .../MemberAccessExpression.cs | 2 +- .../MemberBindingExpression.cs | 2 +- .../SyntaxNodePrinters/NameEquals.cs | 2 +- .../NamespaceDeclaration.cs | 2 +- .../SyntaxNodePrinters/NullableType.cs | 2 +- .../ObjectCreationExpression.cs | 2 +- .../OmittedArraySizeExpression.cs | 2 +- .../SyntaxNodePrinters/OmittedTypeArgument.cs | 2 +- .../SyntaxNodePrinters/OrderByClause.cs | 2 +- .../SyntaxNodePrinters/Parameter.cs | 2 +- .../SyntaxNodePrinters/ParameterList.cs | 4 +- .../ParenthesizedExpression.cs | 2 +- .../ParenthesizedLambdaExpression.cs | 6 +- .../ParenthesizedPattern.cs | 2 +- .../ParenthesizedVariableDesignation.cs | 2 +- .../SyntaxNodePrinters/PointerType.cs | 2 +- .../PostfixUnaryExpression.cs | 2 +- .../SyntaxNodePrinters/PredefinedType.cs | 2 +- .../PrefixUnaryExpression.cs | 2 +- .../PrimaryConstructorBaseType.cs | 2 +- .../SyntaxNodePrinters/QualifiedName.cs | 2 +- .../SyntaxNodePrinters/QueryBody.cs | 2 +- .../SyntaxNodePrinters/QueryContinuation.cs | 2 +- .../SyntaxNodePrinters/QueryExpression.cs | 2 +- .../SyntaxNodePrinters/RangeExpression.cs | 2 +- .../SyntaxNodePrinters/RecursivePattern.cs | 10 +-- .../SyntaxNodePrinters/RefExpression.cs | 2 +- .../SyntaxNodePrinters/RefType.cs | 2 +- .../SyntaxNodePrinters/RefTypeExpression.cs | 2 +- .../SyntaxNodePrinters/RefValueExpression.cs | 2 +- .../SyntaxNodePrinters/RelationalPattern.cs | 2 +- .../SyntaxNodePrinters/ReturnStatement.cs | 2 +- .../SyntaxNodePrinters/SelectClause.cs | 2 +- .../SyntaxNodePrinters/SimpleBaseType.cs | 2 +- .../SimpleLambdaExpression.cs | 6 +- .../SingleVariableDesignation.cs | 2 +- .../SyntaxNodePrinters/SizeOfExpression.cs | 2 +- .../SyntaxNodePrinters/SlicePattern.cs | 2 +- .../SyntaxNodePrinters/SpreadElement.cs | 2 +- .../StackAllocArrayCreationExpression.cs | 2 +- .../SyntaxNodePrinters/SwitchExpression.cs | 4 +- .../SyntaxNodePrinters/SwitchSection.cs | 2 +- .../SyntaxNodePrinters/SwitchStatement.cs | 2 +- .../SyntaxNodePrinters/ThisExpression.cs | 2 +- .../SyntaxNodePrinters/ThrowExpression.cs | 2 +- .../SyntaxNodePrinters/ThrowStatement.cs | 2 +- .../SyntaxNodePrinters/TryStatement.cs | 2 +- .../SyntaxNodePrinters/TupleElement.cs | 2 +- .../SyntaxNodePrinters/TupleExpression.cs | 2 +- .../SyntaxNodePrinters/TupleType.cs | 2 +- .../SyntaxNodePrinters/TypeArgumentList.cs | 2 +- .../SyntaxNodePrinters/TypeConstraint.cs | 2 +- .../SyntaxNodePrinters/TypeOfExpression.cs | 2 +- .../SyntaxNodePrinters/TypeParameter.cs | 2 +- .../TypeParameterConstraintClause.cs | 2 +- .../SyntaxNodePrinters/TypeParameterList.cs | 2 +- .../SyntaxNodePrinters/TypePattern.cs | 2 +- .../SyntaxNodePrinters/UnaryPattern.cs | 2 +- .../SyntaxNodePrinters/UnsafeStatement.cs | 2 +- .../SyntaxNodePrinters/UsingDirective.cs | 2 +- .../SyntaxNodePrinters/UsingStatement.cs | 2 +- .../SyntaxNodePrinters/VarPattern.cs | 2 +- .../SyntaxNodePrinters/VariableDeclaration.cs | 2 +- .../SyntaxNodePrinters/VariableDeclarator.cs | 2 +- .../SyntaxNodePrinters/WhenClause.cs | 2 +- .../SyntaxNodePrinters/WhereClause.cs | 2 +- .../SyntaxNodePrinters/WhileStatement.cs | 2 +- .../SyntaxNodePrinters/WithExpression.cs | 2 +- .../SyntaxNodePrinters/YieldStatement.cs | 2 +- Src/CSharpier/SyntaxPrinter/Token.cs | 42 ++++++------- Src/CSharpier/SyntaxPrinter/TrailingComma.cs | 2 +- Src/CSharpier/SyntaxPrinter/UnhandledNode.cs | 2 +- .../SyntaxPrinter/UsingDirectives.cs | 11 ++-- .../Utilities/DictionaryExtensions.cs | 16 +++++ Src/CSharpier/Utilities/StackExtensions.cs | 4 +- .../Utilities/StringBuilderExtensions.cs | 4 +- Src/SyntaxFinder/Ignored.cs | 6 +- Src/SyntaxFinder/SyntaxFinderWalker.cs | 4 +- Src/SyntaxFinder/SyntaxTriviaExtensions.cs | 4 +- Src/SyntaxFinder/Walkers/ExampleWalker.cs | 4 +- Src/SyntaxFinder/Walkers/ModifiersWalker.cs | 9 +-- .../NestedConditionalExpressionsWalker.cs | 4 +- .../Walkers/ObjectInitializerWalker.cs | 14 ++--- Src/SyntaxFinder/Walkers/SpreadWalker.cs | 13 ++-- 245 files changed, 607 insertions(+), 723 deletions(-) create mode 100644 Src/CSharpier.Rider/.intellijPlatform/self-update.lock delete mode 100644 Src/CSharpier/SyntaxPrinter/FormattingContext.cs create mode 100644 Src/CSharpier/SyntaxPrinter/PrintingContext.cs create mode 100644 Src/CSharpier/Utilities/DictionaryExtensions.cs diff --git a/.editorconfig b/.editorconfig index bd26ec482..cc3b0ea87 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,5 +2,31 @@ indent_size = 2 indent_style = space +csharp_using_directive_placement = outside_namespace +csharp_style_inlined_variable_declaration = true +csharp_style_pattern_matching_over_is_with_cast_check = true +csharp_style_var_elsewhere = true +csharp_style_var_for_built_in_types = true +csharp_style_var_when_type_is_apparent = true + [*.{cs,vb}] dotnet_diagnostic.RS0041.severity = warning +dotnet_diagnostic.IDE0007.severity = warning +dotnet_diagnostic.IDE0018.severity = warning +dotnet_diagnostic.IDE0019.severity = warning +dotnet_diagnostic.IDE0020.severity = warning +dotnet_diagnostic.IDE0029.severity = warning +dotnet_diagnostic.IDE0030.severity = warning +dotnet_diagnostic.IDE0031.severity = warning +dotnet_diagnostic.IDE0032.severity = warning +dotnet_diagnostic.IDE0036.severity = warning +dotnet_diagnostic.IDE0038.severity = warning +dotnet_diagnostic.IDE0065.severity = warning +dotnet_diagnostic.IDE0075.severity = warning +dotnet_diagnostic.IDE0078.severity = warning +dotnet_diagnostic.IDE0150.severity = warning +dotnet_diagnostic.IDE0290.severity = warning +dotnet_diagnostic.IDE0300.severity = warning +dotnet_diagnostic.IDE0301.severity = warning + + diff --git a/CSharpier.sln b/CSharpier.sln index eb9d3cf27..6b7e56d30 100644 --- a/CSharpier.sln +++ b/CSharpier.sln @@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Directory.Build.props = Directory.Build.props Directory.Packages.props = Directory.Packages.props Nuget\Build.props = Nuget\Build.props + .editorconfig = .editorconfig EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CSharpier.Benchmarks", "Src\CSharpier.Benchmarks\CSharpier.Benchmarks.csproj", "{A338903F-69AD-4950-B827-8EE75F98B620}" diff --git a/Directory.Build.props b/Directory.Build.props index 30111e3a6..8acb86109 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -7,5 +7,7 @@ CS8032 true + true + true diff --git a/Src/CSharpier.Benchmarks/Program.cs b/Src/CSharpier.Benchmarks/Program.cs index d487de6a6..7b4d20346 100644 --- a/Src/CSharpier.Benchmarks/Program.cs +++ b/Src/CSharpier.Benchmarks/Program.cs @@ -2,11 +2,10 @@ using System.Threading; using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Running; +using Microsoft.CodeAnalysis; namespace CSharpier.Benchmarks; -using Microsoft.CodeAnalysis; - [MemoryDiagnoser] public class Benchmarks { diff --git a/Src/CSharpier.Cli.Tests/CliTests.cs b/Src/CSharpier.Cli.Tests/CliTests.cs index 74d1d85e7..f9d92840a 100644 --- a/Src/CSharpier.Cli.Tests/CliTests.cs +++ b/Src/CSharpier.Cli.Tests/CliTests.cs @@ -1,5 +1,3 @@ -namespace CSharpier.Cli.Tests; - using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,6 +6,8 @@ namespace CSharpier.Cli.Tests; using FluentAssertions; using NUnit.Framework; +namespace CSharpier.Cli.Tests; + // these tests are kind of nice as c# because they run in the same place. // except the one test that has issues with console input redirection // they used to be powershell, but doing the multiple file thing didn't work diff --git a/Src/CSharpier.Cli.Tests/EditorConfig/SectionTests.cs b/Src/CSharpier.Cli.Tests/EditorConfig/SectionTests.cs index 03b028f1b..5cf8729d1 100644 --- a/Src/CSharpier.Cli.Tests/EditorConfig/SectionTests.cs +++ b/Src/CSharpier.Cli.Tests/EditorConfig/SectionTests.cs @@ -1,10 +1,10 @@ -namespace CSharpier.Cli.Tests.EditorConfig; - using CSharpier.Cli.EditorConfig; using FluentAssertions; using IniParser.Model; using NUnit.Framework; +namespace CSharpier.Cli.Tests.EditorConfig; + [TestFixture] public class SectionTests { diff --git a/Src/CSharpier.Cli.Tests/ServerTests.cs b/Src/CSharpier.Cli.Tests/ServerTests.cs index 91ba2b642..fdf994d90 100644 --- a/Src/CSharpier.Cli.Tests/ServerTests.cs +++ b/Src/CSharpier.Cli.Tests/ServerTests.cs @@ -1,5 +1,3 @@ -namespace CSharpier.Cli.Tests; - using System.Diagnostics; using System.Net.Http.Json; using System.Text; @@ -9,6 +7,8 @@ namespace CSharpier.Cli.Tests; using FluentAssertions; using NUnit.Framework; +namespace CSharpier.Cli.Tests; + [TestFixture] public class ServerTests { @@ -79,7 +79,8 @@ public void RunTwo() async Task NewFunction() { - var command = Cli.Wrap("dotnet") + var command = CliWrap + .Cli.Wrap("dotnet") .WithArguments(path + " --server") .WithValidation(CommandResultValidation.None); diff --git a/Src/CSharpier.Cli/CommandLineFormatter.cs b/Src/CSharpier.Cli/CommandLineFormatter.cs index e56c050ab..c4815bf52 100644 --- a/Src/CSharpier.Cli/CommandLineFormatter.cs +++ b/Src/CSharpier.Cli/CommandLineFormatter.cs @@ -3,12 +3,11 @@ using System.Text; using CSharpier.Cli.Options; using CSharpier.Utilities; +using Microsoft.CodeAnalysis; using Microsoft.Extensions.Logging; namespace CSharpier.Cli; -using Microsoft.CodeAnalysis; - internal static class CommandLineFormatter { public static async Task Format( diff --git a/Src/CSharpier.Cli/CommandLineOptions.cs b/Src/CSharpier.Cli/CommandLineOptions.cs index d12dfc1fd..1ed067ca0 100644 --- a/Src/CSharpier.Cli/CommandLineOptions.cs +++ b/Src/CSharpier.Cli/CommandLineOptions.cs @@ -1,12 +1,11 @@ using System.CommandLine; +using Microsoft.Extensions.Logging; namespace CSharpier.Cli; -using Microsoft.Extensions.Logging; - internal class CommandLineOptions { - public string[] DirectoryOrFilePaths { get; init; } = Array.Empty(); + public string[] DirectoryOrFilePaths { get; init; } = []; public bool Check { get; init; } public bool Fast { get; init; } public bool SkipWrite { get; init; } @@ -17,7 +16,7 @@ internal class CommandLineOptions public bool IncludeGenerated { get; init; } public string? StandardInFileContents { get; init; } public string? ConfigPath { get; init; } - public string[] OriginalDirectoryOrFilePaths { get; init; } = Array.Empty(); + public string[] OriginalDirectoryOrFilePaths { get; init; } = []; internal delegate Task Handler( string[] directoryOrFile, @@ -47,57 +46,48 @@ public static RootCommand Create() Description = "One or more paths to a directory containing C# files to format or a C# file to format. It may be ommited when piping data via stdin.", }.LegalFilePathsOnly(), - new Option( - new[] { "--check" }, - "Check that files are formatted. Will not write any changes." - ), + new Option(["--check"], "Check that files are formatted. Will not write any changes."), new Option( - new[] { "--loglevel" }, + ["--loglevel"], () => LogLevel.Information.ToString(), "Specify the log level - Debug, Information (default), Warning, Error, None" ), new Option( - new[] { "--no-cache" }, + ["--no-cache"], "Bypass the cache to determine if a file needs to be formatted." ), new Option( - new[] { "--no-msbuild-check" }, + ["--no-msbuild-check"], "Bypass the check to determine if a csproj files references a different version of CSharpier.MsBuild." ), new Option( - new[] { "--include-generated" }, + ["--include-generated"], "Include files generated by the SDK and files that begin with comments" ), new Option( - new[] { "--fast" }, + ["--fast"], "Skip comparing syntax tree of formatted file to original file to validate changes." ), new Option( - new[] { "--skip-write" }, + ["--skip-write"], "Skip writing changes. Generally used for testing to ensure csharpier doesn't throw any errors or cause syntax tree validation failures." ), + new Option(["--write-stdout"], "Write the results of formatting any files to stdout."), new Option( - new[] { "--write-stdout" }, - "Write the results of formatting any files to stdout." - ), - new Option( - new[] { "--pipe-multiple-files" }, + ["--pipe-multiple-files"], "Keep csharpier running so that multiples files can be piped to it via stdin." ), new Option( - new[] { "--server" }, + ["--server"], "Run CSharpier as a server so that multiple files may be formatted." ), new Option( - new[] { "--server-port" }, + ["--server-port"], "Specify the port that CSharpier should start on. Defaults to a random unused port." ), - new Option( - new[] { "--config-path" }, - "Path to the CSharpier configuration file" - ), + new Option(["--config-path"], "Path to the CSharpier configuration file"), new Option( - new[] { "--compilation-errors-as-warnings" }, + ["--compilation-errors-as-warnings"], "Treat compilation errors from files as warnings instead of errors." ), }; diff --git a/Src/CSharpier.Cli/ConsoleLogger.cs b/Src/CSharpier.Cli/ConsoleLogger.cs index c4783b86e..aa314d505 100644 --- a/Src/CSharpier.Cli/ConsoleLogger.cs +++ b/Src/CSharpier.Cli/ConsoleLogger.cs @@ -2,19 +2,10 @@ namespace CSharpier.Cli; -internal class ConsoleLogger : ILogger +internal class ConsoleLogger(IConsole console, LogLevel loggingLevel) : ILogger { private static readonly object ConsoleLock = new(); - private readonly IConsole console; - private readonly LogLevel loggingLevel; - - public ConsoleLogger(IConsole console, LogLevel loggingLevel) - { - this.console = console; - this.loggingLevel = loggingLevel; - } - public virtual void Log( LogLevel logLevel, EventId eventId, @@ -23,7 +14,7 @@ public virtual void Log( Func formatter ) { - if (logLevel < this.loggingLevel) + if (logLevel < loggingLevel) { return; } @@ -32,11 +23,11 @@ void Write(string value) { if (logLevel >= LogLevel.Error) { - this.console.WriteError(value); + console.WriteError(value); } else { - this.console.Write(value); + console.Write(value); } } @@ -44,11 +35,11 @@ void WriteLine(string? value = null) { if (logLevel >= LogLevel.Error) { - this.console.WriteErrorLine(value); + console.WriteErrorLine(value); } else { - this.console.WriteLine(value); + console.WriteLine(value); } } @@ -63,9 +54,9 @@ void WriteLine(string? value = null) if (logLevel >= LogLevel.Warning) { - this.console.ForegroundColor = GetColorLevel(logLevel); + console.ForegroundColor = GetColorLevel(logLevel); Write($"{logLevel} "); - this.console.ResetColor(); + console.ResetColor(); } var stringReader = new StringReader(message); diff --git a/Src/CSharpier.Cli/EditorConfig/GlobMatcher.cs b/Src/CSharpier.Cli/EditorConfig/GlobMatcher.cs index 3332886e1..68b0ebdfd 100644 --- a/Src/CSharpier.Cli/EditorConfig/GlobMatcher.cs +++ b/Src/CSharpier.Cli/EditorConfig/GlobMatcher.cs @@ -5,9 +5,6 @@ * From https://github.com/SLaks/Minimatch */ -#nullable disable - -namespace CSharpier.Cli.EditorConfig; using System; using System.Collections.Generic; @@ -16,6 +13,10 @@ namespace CSharpier.Cli.EditorConfig; using System.Text; using System.Text.RegularExpressions; +#nullable disable + +namespace CSharpier.Cli.EditorConfig; + // ReSharper disable UnusedAutoPropertyAccessor.Global ///Contains options that control how Minimatch matches strings. @@ -86,8 +87,8 @@ private GlobMatcher( this.myEmpty = empty; } - private static readonly char[] ourUnixPathSeparators = { '/' }; - private static readonly char[] ourWinPathSeparators = { '/', '\\' }; + private static readonly char[] ourUnixPathSeparators = ['/']; + private static readonly char[] ourWinPathSeparators = ['/', '\\']; ///Checks whether a given string matches this pattern. public bool IsMatch(string input) @@ -645,7 +646,7 @@ public void Build() for (var i = 0; i < this.Count; i++) { var item = this[i]; - if (item is PathSeparator || item is DoubleAsterisk) + if (item is PathSeparator or DoubleAsterisk) { this.HasPathSeparators = true; } @@ -696,27 +697,19 @@ public void Build() private interface IPatternElement { } - private class Literal : IPatternElement + private class Literal(string source) : IPatternElement { - public Literal(string source) => this.Source = source; - - public string Source { get; } + public string Source { get; } = source; } - private class OneChar : IPatternElement + private class OneChar(string possibleChars, bool negate) : IPatternElement { static OneChar() { } public static readonly OneChar EmptyInstance = new OneChar(null, false); - public OneChar(string possibleChars, bool negate) - { - this.PossibleChars = possibleChars; - this.Negate = negate; - } - - private string PossibleChars { get; } - private bool Negate { get; } + private string PossibleChars { get; } = possibleChars; + private bool Negate { get; } = negate; public bool CheckChar(GlobMatcherOptions options, char c, StringComparison comparison) { @@ -847,7 +840,7 @@ private static IList BraceExpand(string pattern, GlobMatcherOptions opti if (options.NoBrace || !ourHasBraces.IsMatch(pattern)) { // shortcut. no need to expand. - return new[] { pattern }; + return [pattern]; } var escaping = false; @@ -893,7 +886,7 @@ private static IList BraceExpand(string pattern, GlobMatcherOptions opti if (prefix == null) { // console.error("no sets") - return new[] { pattern }; + return [pattern]; } var braceExpand = BraceExpand(pattern.Substring(i), options); @@ -1050,7 +1043,7 @@ private static IList BraceExpand(string pattern, GlobMatcherOptions opti private static PatternCase Parse(GlobMatcherOptions options, string pattern) { if (pattern == "") - return new PatternCase(); + return []; var result = new PatternCase(); var sb = new StringBuilder(); @@ -1122,7 +1115,7 @@ void AppendChar(char c1) FinishLiteral(); - if (!(result.LastOrDefault() is PathSeparator)) + if (result.LastOrDefault() is not PathSeparator) { result.Add(PathSeparator.Instance); } @@ -1174,7 +1167,7 @@ void AppendChar(char c1) result.RemoveAt(result.Count - 1); result.Add(new DoubleAsterisk()); } - else if (!(result.LastOrDefault() is SimpleAsterisk)) + else if (result.LastOrDefault() is not SimpleAsterisk) { result.Add(new SimpleAsterisk()); } diff --git a/Src/CSharpier.Cli/EditorConfig/Section.cs b/Src/CSharpier.Cli/EditorConfig/Section.cs index f50f312d2..96017dff3 100644 --- a/Src/CSharpier.Cli/EditorConfig/Section.cs +++ b/Src/CSharpier.Cli/EditorConfig/Section.cs @@ -1,28 +1,17 @@ -namespace CSharpier.Cli.EditorConfig; - using IniParser.Model; -internal class Section -{ - private readonly GlobMatcher matcher; +namespace CSharpier.Cli.EditorConfig; - public string? IndentStyle { get; } - public string? IndentSize { get; } - public string? TabWidth { get; } - public string? MaxLineLength { get; } - public string? EndOfLine { get; } - public string? Formatter { get; } +internal class Section(SectionData section, string directory) +{ + private readonly GlobMatcher matcher = Globber.Create(section.SectionName, directory); - public Section(SectionData section, string directory) - { - this.matcher = Globber.Create(section.SectionName, directory); - this.IndentStyle = section.Keys["indent_style"]; - this.IndentSize = section.Keys["indent_size"]; - this.TabWidth = section.Keys["tab_width"]; - this.MaxLineLength = section.Keys["max_line_length"]; - this.EndOfLine = section.Keys["end_of_line"]; - this.Formatter = section.Keys["csharpier_formatter"]; - } + public string? IndentStyle { get; } = section.Keys["indent_style"]; + public string? IndentSize { get; } = section.Keys["indent_size"]; + public string? TabWidth { get; } = section.Keys["tab_width"]; + public string? MaxLineLength { get; } = section.Keys["max_line_length"]; + public string? EndOfLine { get; } = section.Keys["end_of_line"]; + public string? Formatter { get; } = section.Keys["csharpier_formatter"]; public bool IsMatch(string fileName) { diff --git a/Src/CSharpier.Cli/FileIssueLogger.cs b/Src/CSharpier.Cli/FileIssueLogger.cs index 5c4902af9..a3fc96994 100644 --- a/Src/CSharpier.Cli/FileIssueLogger.cs +++ b/Src/CSharpier.Cli/FileIssueLogger.cs @@ -2,29 +2,20 @@ namespace CSharpier.Cli; -internal class FileIssueLogger +internal class FileIssueLogger(string filePath, ILogger logger) { - private readonly string filePath; - private readonly ILogger logger; - - public FileIssueLogger(string filePath, ILogger logger) - { - this.filePath = filePath; - this.logger = logger; - } - public void WriteError(string value, Exception? exception = null) { - this.logger.LogError(exception, $"{this.GetPath()} - {value}"); + logger.LogError(exception, $"{this.GetPath()} - {value}"); } public void WriteWarning(string value) { - this.logger.LogWarning($"{this.GetPath()} - {value}"); + logger.LogWarning($"{this.GetPath()} - {value}"); } private string GetPath() { - return this.filePath; + return filePath; } } diff --git a/Src/CSharpier.Cli/FormattingCache.cs b/Src/CSharpier.Cli/FormattingCache.cs index ee86cd315..8dc4f0cf5 100644 --- a/Src/CSharpier.Cli/FormattingCache.cs +++ b/Src/CSharpier.Cli/FormattingCache.cs @@ -3,12 +3,11 @@ using System.IO.Hashing; using System.Text; using System.Text.Json; +using CSharpier.Cli.Options; using CSharpier.Utilities; namespace CSharpier.Cli; -using CSharpier.Cli.Options; - internal interface IFormattingCache { Task ResolveAsync(CancellationToken cancellationToken); @@ -89,37 +88,26 @@ CancellationToken cancellationToken return new FormattingCache(optionsProvider, CacheFilePath, cacheDictionary, fileSystem); } - private class FormattingCache : IFormattingCache + private class FormattingCache( + OptionsProvider optionsProvider, + string cacheFile, + ConcurrentDictionary cacheDictionary, + IFileSystem fileSystem + ) : IFormattingCache { - private readonly string optionsHash; - private readonly string cacheFile; - private readonly ConcurrentDictionary cacheDictionary; - private readonly IFileSystem fileSystem; - - public FormattingCache( - OptionsProvider optionsProvider, - string cacheFile, - ConcurrentDictionary cacheDictionary, - IFileSystem fileSystem - ) - { - this.optionsHash = GetOptionsHash(optionsProvider); - this.cacheFile = cacheFile; - this.cacheDictionary = cacheDictionary; - this.fileSystem = fileSystem; - } + private readonly string optionsHash = GetOptionsHash(optionsProvider); public bool CanSkipFormatting(FileToFormatInfo fileToFormatInfo) { var currentHash = Hash(fileToFormatInfo.FileContents) + this.optionsHash; - if (this.cacheDictionary.TryGetValue(fileToFormatInfo.Path, out var cachedHash)) + if (cacheDictionary.TryGetValue(fileToFormatInfo.Path, out var cachedHash)) { if (currentHash == cachedHash) { return true; } - this.cacheDictionary.TryRemove(fileToFormatInfo.Path, out _); + cacheDictionary.TryRemove(fileToFormatInfo.Path, out _); } return false; @@ -127,7 +115,7 @@ public bool CanSkipFormatting(FileToFormatInfo fileToFormatInfo) public void CacheResult(string code, FileToFormatInfo fileToFormatInfo) { - this.cacheDictionary[fileToFormatInfo.Path] = Hash(code) + this.optionsHash; + cacheDictionary[fileToFormatInfo.Path] = Hash(code) + this.optionsHash; } private static string GetOptionsHash(OptionsProvider optionsProvider) @@ -144,12 +132,12 @@ private static string Hash(string input) public async Task ResolveAsync(CancellationToken cancellationToken) { - this.fileSystem.FileInfo.New(this.cacheFile).EnsureDirectoryExists(); + fileSystem.FileInfo.New(cacheFile).EnsureDirectoryExists(); async Task WriteFile() { - await using var fileStream = this.fileSystem.File.Open( - this.cacheFile, + await using var fileStream = fileSystem.File.Open( + cacheFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None @@ -157,7 +145,7 @@ async Task WriteFile() await using var streamWriter = new StreamWriter(fileStream); await streamWriter.WriteAsync( JsonSerializer.Serialize( - this.cacheDictionary + cacheDictionary #if DEBUG , new JsonSerializerOptions { WriteIndented = true } diff --git a/Src/CSharpier.Cli/IgnoreFile.cs b/Src/CSharpier.Cli/IgnoreFile.cs index 5542f77c3..eb370742e 100644 --- a/Src/CSharpier.Cli/IgnoreFile.cs +++ b/Src/CSharpier.Cli/IgnoreFile.cs @@ -6,11 +6,7 @@ internal class IgnoreFile { protected Ignore.Ignore Ignore { get; } protected string IgnoreBaseDirectoryPath { get; } - private static readonly string[] alwaysIgnored = - { - "**/node_modules/**/*.cs", - "**/obj/**/*.cs", - }; + private static readonly string[] alwaysIgnored = ["**/node_modules/**/*.cs", "**/obj/**/*.cs"]; protected IgnoreFile(Ignore.Ignore ignore, string ignoreBaseDirectoryPath) { @@ -105,8 +101,5 @@ var line in await fileSystem.File.ReadAllLinesAsync(ignoreFilePath, cancellation } } -internal class InvalidIgnoreFileException : Exception -{ - public InvalidIgnoreFileException(string message, Exception exception) - : base(message, exception) { } -} +internal class InvalidIgnoreFileException(string message, Exception exception) + : Exception(message, exception); diff --git a/Src/CSharpier.Cli/Options/CaseInsensitiveEnumConverter.cs b/Src/CSharpier.Cli/Options/CaseInsensitiveEnumConverter.cs index 2968d3ab4..c5820c85d 100644 --- a/Src/CSharpier.Cli/Options/CaseInsensitiveEnumConverter.cs +++ b/Src/CSharpier.Cli/Options/CaseInsensitiveEnumConverter.cs @@ -1,8 +1,8 @@ -namespace CSharpier.Cli.Options; - using System.Text.Json; using System.Text.Json.Serialization; +namespace CSharpier.Cli.Options; + internal class CaseInsensitiveEnumConverter : JsonConverter where TEnum : struct { diff --git a/Src/CSharpier.Cli/Options/ConfigFileParser.cs b/Src/CSharpier.Cli/Options/ConfigFileParser.cs index 5591d2f4a..80d924ba2 100644 --- a/Src/CSharpier.Cli/Options/ConfigFileParser.cs +++ b/Src/CSharpier.Cli/Options/ConfigFileParser.cs @@ -1,14 +1,14 @@ -namespace CSharpier.Cli.Options; - using System.IO.Abstractions; using System.Text.Json; using Microsoft.Extensions.Logging; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; +namespace CSharpier.Cli.Options; + internal static class ConfigFileParser { - private static readonly string[] validExtensions = { ".csharpierrc", ".json", ".yml", ".yaml" }; + private static readonly string[] validExtensions = [".csharpierrc", ".json", ".yml", ".yaml"]; /// Finds all configs above the given directory as well as within the subtree of this directory internal static List FindForDirectoryName( diff --git a/Src/CSharpier.Cli/Options/ConfigurationFileOptions.cs b/Src/CSharpier.Cli/Options/ConfigurationFileOptions.cs index eeaaa72ac..c0c743a55 100644 --- a/Src/CSharpier.Cli/Options/ConfigurationFileOptions.cs +++ b/Src/CSharpier.Cli/Options/ConfigurationFileOptions.cs @@ -1,8 +1,8 @@ -namespace CSharpier.Cli.Options; - using System.Text.Json.Serialization; using CSharpier.Cli.EditorConfig; +namespace CSharpier.Cli.Options; + internal class ConfigurationFileOptions { public int PrintWidth { get; init; } = 100; diff --git a/Src/CSharpier.Cli/Options/OptionsProvider.cs b/Src/CSharpier.Cli/Options/OptionsProvider.cs index 2497b0be2..00728a368 100644 --- a/Src/CSharpier.Cli/Options/OptionsProvider.cs +++ b/Src/CSharpier.Cli/Options/OptionsProvider.cs @@ -1,10 +1,10 @@ -namespace CSharpier.Cli.Options; - using System.IO.Abstractions; using System.Text.Json; using CSharpier.Cli.EditorConfig; using Microsoft.Extensions.Logging; +namespace CSharpier.Cli.Options; + internal class OptionsProvider { private readonly IList editorConfigs; diff --git a/Src/CSharpier.Cli/PhysicalFileInfoAndWriter.cs b/Src/CSharpier.Cli/PhysicalFileInfoAndWriter.cs index 751156fa3..7796f754c 100644 --- a/Src/CSharpier.Cli/PhysicalFileInfoAndWriter.cs +++ b/Src/CSharpier.Cli/PhysicalFileInfoAndWriter.cs @@ -2,14 +2,9 @@ namespace CSharpier.Cli; -internal class FileSystemFormattedFileWriter : IFormattedFileWriter +internal class FileSystemFormattedFileWriter(IFileSystem fileSystem) : IFormattedFileWriter { - public IFileSystem FileSystem { get; } - - public FileSystemFormattedFileWriter(IFileSystem fileSystem) - { - this.FileSystem = fileSystem; - } + public IFileSystem FileSystem { get; } = fileSystem; public void WriteResult(CodeFormatterResult result, FileToFormatInfo fileToFormatInfo) { diff --git a/Src/CSharpier.Cli/PipeMultipleFilesFormatter.cs b/Src/CSharpier.Cli/PipeMultipleFilesFormatter.cs index 861455f5d..9e4cee613 100644 --- a/Src/CSharpier.Cli/PipeMultipleFilesFormatter.cs +++ b/Src/CSharpier.Cli/PipeMultipleFilesFormatter.cs @@ -1,9 +1,9 @@ -namespace CSharpier.Cli; - using System.IO.Abstractions; using System.Text; using Microsoft.Extensions.Logging; +namespace CSharpier.Cli; + internal static class PipeMultipleFilesFormatter { public static async Task StartServer( @@ -52,16 +52,16 @@ CancellationToken cancellationToken { var commandLineOptions = new CommandLineOptions { - DirectoryOrFilePaths = new[] - { + DirectoryOrFilePaths = + [ Path.Combine(Directory.GetCurrentDirectory(), fileName), - }, - OriginalDirectoryOrFilePaths = new[] - { + ], + OriginalDirectoryOrFilePaths = + [ Path.IsPathRooted(fileName) ? fileName : fileName.StartsWith(".") ? fileName : "./" + fileName, - }, + ], StandardInFileContents = stringBuilder.ToString(), Fast = true, WriteStdout = true, diff --git a/Src/CSharpier.Cli/Program.cs b/Src/CSharpier.Cli/Program.cs index be5ddf5fe..ca941719e 100644 --- a/Src/CSharpier.Cli/Program.cs +++ b/Src/CSharpier.Cli/Program.cs @@ -2,12 +2,11 @@ using System.CommandLine.Invocation; using System.IO.Abstractions; using System.Text; +using CSharpier.Cli.Server; using Microsoft.Extensions.Logging; namespace CSharpier.Cli; -using CSharpier.Cli.Server; - internal class Program { public static async Task Main(string[] args) @@ -76,8 +75,8 @@ CancellationToken cancellationToken #endif ); - directoryOrFile = new[] { Directory.GetCurrentDirectory() }; - originalDirectoryOrFile = new[] { Directory.GetCurrentDirectory() }; + directoryOrFile = [Directory.GetCurrentDirectory()]; + originalDirectoryOrFile = [Directory.GetCurrentDirectory()]; } else { diff --git a/Src/CSharpier.Cli/Server/CSharpierServiceImplementation.cs b/Src/CSharpier.Cli/Server/CSharpierServiceImplementation.cs index 11771c437..35b17640e 100644 --- a/Src/CSharpier.Cli/Server/CSharpierServiceImplementation.cs +++ b/Src/CSharpier.Cli/Server/CSharpierServiceImplementation.cs @@ -1,9 +1,9 @@ -namespace CSharpier.Cli.Server; - using System.IO.Abstractions; using CSharpier.Cli.Options; using Microsoft.Extensions.Logging; +namespace CSharpier.Cli.Server; + internal class CSharpierServiceImplementation(string? configPath, ILogger logger) { private readonly IFileSystem fileSystem = new FileSystem(); diff --git a/Src/CSharpier.Cli/Server/FormatFileResult.cs b/Src/CSharpier.Cli/Server/FormatFileResult.cs index cffdafe7d..bf66113d1 100644 --- a/Src/CSharpier.Cli/Server/FormatFileResult.cs +++ b/Src/CSharpier.Cli/Server/FormatFileResult.cs @@ -1,7 +1,7 @@ -namespace CSharpier.Cli.Server; - using System.Text.Json.Serialization; +namespace CSharpier.Cli.Server; + public class FormatFileResult(Status status) { public string? formattedFile { get; set; } diff --git a/Src/CSharpier.Cli/Server/ServerFormatter.cs b/Src/CSharpier.Cli/Server/ServerFormatter.cs index 555ee3806..e3ff8ae0b 100644 --- a/Src/CSharpier.Cli/Server/ServerFormatter.cs +++ b/Src/CSharpier.Cli/Server/ServerFormatter.cs @@ -1,5 +1,3 @@ -namespace CSharpier.Cli.Server; - using System.Net; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -9,6 +7,8 @@ namespace CSharpier.Cli.Server; using Microsoft.Extensions.Logging; using NReco.Logging.File; +namespace CSharpier.Cli.Server; + internal static class ServerFormatter { public static async Task StartServer( diff --git a/Src/CSharpier.Cli/StdOutFormattedFileWriter.cs b/Src/CSharpier.Cli/StdOutFormattedFileWriter.cs index 8c21b43ab..09610eaa4 100644 --- a/Src/CSharpier.Cli/StdOutFormattedFileWriter.cs +++ b/Src/CSharpier.Cli/StdOutFormattedFileWriter.cs @@ -1,16 +1,9 @@ namespace CSharpier.Cli; -internal class StdOutFormattedFileWriter : IFormattedFileWriter +internal class StdOutFormattedFileWriter(IConsole console) : IFormattedFileWriter { - private readonly IConsole console; - - public StdOutFormattedFileWriter(IConsole console) - { - this.console = console; - } - public void WriteResult(CodeFormatterResult result, FileToFormatInfo fileToFormatInfo) { - this.console.Write(result.Code); + console.Write(result.Code); } } diff --git a/Src/CSharpier.FakeGenerators/CodeContext.cs b/Src/CSharpier.FakeGenerators/CodeContext.cs index 940957c7a..821c3d1af 100644 --- a/Src/CSharpier.FakeGenerators/CodeContext.cs +++ b/Src/CSharpier.FakeGenerators/CodeContext.cs @@ -1,13 +1,8 @@ namespace CSharpier.FakeGenerators; -public class CodeContext +public class CodeContext(string folder) { - public string Folder { get; set; } - - public CodeContext(string folder) - { - this.Folder = folder; - } + public string Folder { get; set; } = folder; public void AddSource(string name, string source) { diff --git a/Src/CSharpier.FakeGenerators/Ignored.cs b/Src/CSharpier.FakeGenerators/Ignored.cs index 05b0c4051..88e5db60b 100644 --- a/Src/CSharpier.FakeGenerators/Ignored.cs +++ b/Src/CSharpier.FakeGenerators/Ignored.cs @@ -7,7 +7,7 @@ namespace CSharpier.FakeGenerators; public static class Ignored { public static readonly string[] Properties = - { + [ "language", "parent", "parentTrivia", @@ -19,26 +19,18 @@ public static class Ignored "hasStructuredTrivia", "containsSkippedText", "containsAnnotations", - }; + ]; - public static readonly Type[] Types = { typeof(TextSpan), typeof(SyntaxTree) }; + public static readonly Type[] Types = [typeof(TextSpan), typeof(SyntaxTree)]; public static readonly Dictionary PropertiesByType = new() { - { typeof(PropertyDeclarationSyntax), new[] { "semicolon" } }, - { typeof(IndexerDeclarationSyntax), new[] { "semicolon" } }, - { typeof(SyntaxTrivia), new[] { "token" } }, - { typeof(SyntaxToken), new[] { "value", "valueText" } }, - { typeof(ParameterSyntax), new[] { "exclamationExclamationToken" } }, + { typeof(PropertyDeclarationSyntax), ["semicolon"] }, + { typeof(IndexerDeclarationSyntax), ["semicolon"] }, + { typeof(SyntaxTrivia), ["token"] }, + { typeof(SyntaxToken), ["value", "valueText"] }, + { typeof(ParameterSyntax), ["exclamationExclamationToken"] }, }; - public static readonly HashSet UnsupportedNodes = new() - { - // if new versions of c# add node types, we need to ignore them in the generators - // until codeAnalysis + sdks are updated - // global.json doesn't seem to always be respected for builds (namely VS but rider started having the same problem) - // which causes the generators to generate code for the new node types - // but then the build fails because those types don't exist in the packages the actual project references - // "ListPatternSyntax", "SlicePatternSyntax" - }; + public static readonly HashSet UnsupportedNodes = []; } diff --git a/Src/CSharpier.FakeGenerators/SyntaxNodeComparerGenerator.cs b/Src/CSharpier.FakeGenerators/SyntaxNodeComparerGenerator.cs index cd63884b9..dd2973825 100644 --- a/Src/CSharpier.FakeGenerators/SyntaxNodeComparerGenerator.cs +++ b/Src/CSharpier.FakeGenerators/SyntaxNodeComparerGenerator.cs @@ -1,11 +1,10 @@ using System.Text; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; namespace CSharpier.FakeGenerators; -using Microsoft.CodeAnalysis.CSharp.Syntax; - public class SyntaxNodeComparerGenerator { // this would probably be easier to understand as a scriban template but is a lot of effort diff --git a/Src/CSharpier.Generators/NodePrinterGenerator.sbntxt b/Src/CSharpier.Generators/NodePrinterGenerator.sbntxt index 337ebc08f..6711e8cbb 100644 --- a/Src/CSharpier.Generators/NodePrinterGenerator.sbntxt +++ b/Src/CSharpier.Generators/NodePrinterGenerator.sbntxt @@ -9,14 +9,14 @@ namespace CSharpier.SyntaxPrinter { internal static class Node { - public static Doc Print(SyntaxNode? syntaxNode, FormattingContext context) + public static Doc Print(SyntaxNode? syntaxNode, PrintingContext context) { if (syntaxNode == null) { return Doc.Null; } - if (context.PrintingDepth > 200) + if (context.State.PrintingDepth > 200) { throw new InTooDeepException(); } @@ -26,7 +26,7 @@ namespace CSharpier.SyntaxPrinter return CSharpierIgnore.PrintWithoutFormatting(syntaxNode, context).Trim(); } - context.PrintingDepth++; + context.State.PrintingDepth++; try { switch (syntaxNode) @@ -41,7 +41,7 @@ namespace CSharpier.SyntaxPrinter } finally { - context.PrintingDepth--; + context.State.PrintingDepth--; } } } diff --git a/Src/CSharpier.Playground/Controllers/FormatController.cs b/Src/CSharpier.Playground/Controllers/FormatController.cs index 1464b15c1..20f992ba0 100644 --- a/Src/CSharpier.Playground/Controllers/FormatController.cs +++ b/Src/CSharpier.Playground/Controllers/FormatController.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using CSharpier.Utilities; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.CodeAnalysis; @@ -9,8 +10,6 @@ namespace CSharpier.Playground.Controllers; -using CSharpier.Utilities; - public class FormatResult { public required string Code { get; set; } @@ -28,20 +27,9 @@ public class FormatError [ApiController] [Route("[controller]")] -public class FormatController : ControllerBase +public class FormatController() : ControllerBase { - private readonly IWebHostEnvironment webHostEnvironment; - private readonly ILogger logger; - // ReSharper disable once SuggestBaseTypeForParameter - public FormatController( - IWebHostEnvironment webHostEnvironment, - ILogger logger - ) - { - this.webHostEnvironment = webHostEnvironment; - this.logger = logger; - } public class PostModel { @@ -100,26 +88,4 @@ private FormatError ConvertError(Diagnostic diagnostic) var lineSpan = diagnostic.Location.SourceTree!.GetLineSpan(diagnostic.Location.SourceSpan); return new FormatError { LineSpan = lineSpan, Description = diagnostic.ToString() }; } - - public string ExecuteApplication(string pathToExe, string workingDirectory, string args) - { - var processStartInfo = new ProcessStartInfo(pathToExe, args) - { - UseShellExecute = false, - RedirectStandardError = true, - WindowStyle = ProcessWindowStyle.Hidden, - WorkingDirectory = workingDirectory, - CreateNoWindow = true, - }; - - var process = Process.Start(processStartInfo); - var output = process!.StandardError.ReadToEnd(); - process.WaitForExit(); - - this.logger.LogInformation( - "Output from '" + pathToExe + " " + args + "' was: " + Environment.NewLine + output - ); - - return output; - } } diff --git a/Src/CSharpier.Playground/Pages/Error.cshtml.cs b/Src/CSharpier.Playground/Pages/Error.cshtml.cs index 79688e481..6852aad3e 100644 --- a/Src/CSharpier.Playground/Pages/Error.cshtml.cs +++ b/Src/CSharpier.Playground/Pages/Error.cshtml.cs @@ -8,13 +8,6 @@ namespace CSharpier.Playground.Pages; [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public class ErrorModel : PageModel { - private readonly ILogger _logger; - - public ErrorModel(ILogger logger) - { - this._logger = logger; - } - public string? RequestId { get; set; } public bool ShowRequestId => !string.IsNullOrEmpty(this.RequestId); diff --git a/Src/CSharpier.Playground/Startup.cs b/Src/CSharpier.Playground/Startup.cs index 969c4520d..4e320156d 100644 --- a/Src/CSharpier.Playground/Startup.cs +++ b/Src/CSharpier.Playground/Startup.cs @@ -8,14 +8,9 @@ namespace CSharpier.Playground; -public class Startup +public class Startup(IConfiguration configuration) { - public Startup(IConfiguration configuration) - { - this.Configuration = configuration; - } - - public IConfiguration Configuration { get; } + public IConfiguration Configuration { get; } = configuration; public void ConfigureServices(IServiceCollection services) { diff --git a/Src/CSharpier.Rider/.intellijPlatform/self-update.lock b/Src/CSharpier.Rider/.intellijPlatform/self-update.lock new file mode 100644 index 000000000..b21eb642b --- /dev/null +++ b/Src/CSharpier.Rider/.intellijPlatform/self-update.lock @@ -0,0 +1 @@ +2024-12-26 \ No newline at end of file diff --git a/Src/CSharpier.Tests/CSharpierIgnoreTests.cs b/Src/CSharpier.Tests/CSharpierIgnoreTests.cs index 264d3e1d2..7d9ddfd52 100644 --- a/Src/CSharpier.Tests/CSharpierIgnoreTests.cs +++ b/Src/CSharpier.Tests/CSharpierIgnoreTests.cs @@ -1,10 +1,9 @@ +using CSharpier.SyntaxPrinter; +using FluentAssertions; using NUnit.Framework; namespace CSharpier.Tests; -using CSharpier.SyntaxPrinter; -using FluentAssertions; - [TestFixture] public class CSharpierIgnoreTests { @@ -67,11 +66,14 @@ private string PrintWithoutFormatting(string code) return CSharpierIgnore .PrintWithoutFormatting( code, - new FormattingContext + new PrintingContext { - LineEnding = Environment.NewLine, - IndentSize = 4, - UseTabs = false, + Options = new PrintingContext.PrintingContextOptions + { + LineEnding = Environment.NewLine, + IndentSize = 4, + UseTabs = false, + }, } ) .ReplaceLineEndings("\n"); diff --git a/Src/CSharpier.Tests/Cli/Options/ConfigFileParserTests.cs b/Src/CSharpier.Tests/Cli/Options/ConfigFileParserTests.cs index 8dbf3cd1f..d206bb708 100644 --- a/Src/CSharpier.Tests/Cli/Options/ConfigFileParserTests.cs +++ b/Src/CSharpier.Tests/Cli/Options/ConfigFileParserTests.cs @@ -1,9 +1,9 @@ -namespace CSharpier.Tests.Cli.Options; - using CSharpier.Cli.Options; using FluentAssertions; using NUnit.Framework; +namespace CSharpier.Tests.Cli.Options; + [TestFixture] public class ConfigFileParserTests { diff --git a/Src/CSharpier.Tests/CodeFormatterTests.cs b/Src/CSharpier.Tests/CodeFormatterTests.cs index da686609c..e60b3adc8 100644 --- a/Src/CSharpier.Tests/CodeFormatterTests.cs +++ b/Src/CSharpier.Tests/CodeFormatterTests.cs @@ -1,11 +1,10 @@ +using CSharpier.Utilities; using FluentAssertions; using Microsoft.CodeAnalysis.CSharp; using NUnit.Framework; namespace CSharpier.Tests; -using CSharpier.Utilities; - // TODO xml move these around [TestFixture] [Parallelizable(ParallelScope.All)] diff --git a/Src/CSharpier.Tests/CommandLineFormatterTests.cs b/Src/CSharpier.Tests/CommandLineFormatterTests.cs index f517e29d1..c489514b0 100644 --- a/Src/CSharpier.Tests/CommandLineFormatterTests.cs +++ b/Src/CSharpier.Tests/CommandLineFormatterTests.cs @@ -2,12 +2,11 @@ using System.Text; using CSharpier.Cli; using FluentAssertions; +using Microsoft.Extensions.Logging; using NUnit.Framework; namespace CSharpier.Tests; -using Microsoft.Extensions.Logging; - [TestFixture] [Parallelizable(ParallelScope.All)] public class CommandLineFormatterTests @@ -512,7 +511,7 @@ public void Multiple_Files_Should_Use_Root_Ignore() var result = this.Format( context, - directoryOrFilePaths: new[] { unformattedFilePath1, unformattedFilePath2 } + directoryOrFilePaths: [unformattedFilePath1, unformattedFilePath2] ); result.OutputLines.FirstOrDefault().Should().StartWith("Formatted 0 files in "); @@ -531,7 +530,7 @@ public void Multiple_Files_Should_Use_Multiple_Ignores() var result = this.Format( context, - directoryOrFilePaths: new[] { unformattedFilePath1, unformattedFilePath2 } + directoryOrFilePaths: [unformattedFilePath1, unformattedFilePath2] ); result.OutputLines.FirstOrDefault().Should().StartWith("Formatted 0 files in "); @@ -731,8 +730,8 @@ params string[] directoryOrFilePaths var originalDirectoryOrFilePaths = directoryOrFilePaths; if (directoryOrFilePaths.Length == 0) { - directoryOrFilePaths = new[] { context.GetRootPath() }; - originalDirectoryOrFilePaths = new[] { "." }; + directoryOrFilePaths = [context.GetRootPath()]; + originalDirectoryOrFilePaths = ["."]; } else { @@ -802,8 +801,8 @@ IList ErrorOutputLines private class TestConsole : IConsole { - private readonly List lines = new(); - private readonly List errorLines = new(); + private readonly List lines = []; + private readonly List errorLines = []; public List GetLines() { diff --git a/Src/CSharpier.Tests/DocUtilitiesTests.cs b/Src/CSharpier.Tests/DocUtilitiesTests.cs index 58815b68f..d1852fd63 100644 --- a/Src/CSharpier.Tests/DocUtilitiesTests.cs +++ b/Src/CSharpier.Tests/DocUtilitiesTests.cs @@ -48,7 +48,7 @@ public void RemoveInitialDoubleHardLine_Should_Not_Remove_Concated_HardLine() DocUtilities.RemoveInitialDoubleHardLine(doc); - concat.Contents.Should().BeEquivalentTo(new[] { Doc.HardLine }); + concat.Contents.Should().BeEquivalentTo([Doc.HardLine]); } [Test] @@ -70,7 +70,7 @@ public void RemoveInitialDoubleHardLine_Should_Not_Remove_Deep_Concated_HardLine DocUtilities.RemoveInitialDoubleHardLine(doc); - concat.Contents.Should().BeEquivalentTo(new[] { Doc.HardLine }); + concat.Contents.Should().BeEquivalentTo([Doc.HardLine]); } [Test] diff --git a/Src/CSharpier.Tests/Formatters/CSharp/PreprocessorSymbolsTests.cs b/Src/CSharpier.Tests/Formatters/CSharp/PreprocessorSymbolsTests.cs index ffff8d9ad..02cf29399 100644 --- a/Src/CSharpier.Tests/Formatters/CSharp/PreprocessorSymbolsTests.cs +++ b/Src/CSharpier.Tests/Formatters/CSharp/PreprocessorSymbolsTests.cs @@ -1,9 +1,9 @@ -namespace CSharpier.Tests.Formatters.CSharp; - using CSharpier.Formatters.CSharp; using FluentAssertions; using NUnit.Framework; +namespace CSharpier.Tests.Formatters.CSharp; + [TestFixture] public class PreprocessorSymbolsTests { diff --git a/Src/CSharpier.Tests/FormattingTests/BaseTest.cs b/Src/CSharpier.Tests/FormattingTests/BaseTest.cs index cbb8f8d30..abf488e31 100644 --- a/Src/CSharpier.Tests/FormattingTests/BaseTest.cs +++ b/Src/CSharpier.Tests/FormattingTests/BaseTest.cs @@ -2,14 +2,13 @@ using System.Text; using CSharpier.Cli; using CSharpier.SyntaxPrinter; +using CSharpier.Utilities; using DiffEngine; using FluentAssertions; +using Microsoft.CodeAnalysis; namespace CSharpier.Tests.FormattingTests; -using CSharpier.Utilities; -using Microsoft.CodeAnalysis; - public class BaseTest { private readonly DirectoryInfo rootDirectory = DirectoryFinder.FindParent("CSharpier.Tests"); diff --git a/Src/CSharpier.Tests/FormattingTests/LineEndingEdgeCase.cs b/Src/CSharpier.Tests/FormattingTests/LineEndingEdgeCase.cs index 74596cb11..02cd37407 100644 --- a/Src/CSharpier.Tests/FormattingTests/LineEndingEdgeCase.cs +++ b/Src/CSharpier.Tests/FormattingTests/LineEndingEdgeCase.cs @@ -1,9 +1,9 @@ -namespace CSharpier.Tests.FormattingTests; - using System.Text; using FluentAssertions; using NUnit.Framework; +namespace CSharpier.Tests.FormattingTests; + [TestFixture] internal class LineEndingEdgeCase { diff --git a/Src/CSharpier.Tests/MissingTypeChecker.cs b/Src/CSharpier.Tests/MissingTypeChecker.cs index 77c211b30..78a784793 100644 --- a/Src/CSharpier.Tests/MissingTypeChecker.cs +++ b/Src/CSharpier.Tests/MissingTypeChecker.cs @@ -70,8 +70,8 @@ public void Ensure_There_Are_No_Missing_Types() missingTypes.Should().BeEmpty(); } - private readonly HashSet ignored = new() - { + private readonly HashSet ignored = + [ "AccessorDeclarationSyntax", "AccessorListSyntax", "AttributeArgumentListSyntax", @@ -113,5 +113,5 @@ public void Ensure_There_Are_No_Missing_Types() "XmlNameSyntax", "XmlPrefixSyntax", "XmlTextAttributeSyntax", - }; + ]; } diff --git a/Src/CSharpier.Tests/OptionsProviderTests.cs b/Src/CSharpier.Tests/OptionsProviderTests.cs index be40d21ba..acff098aa 100644 --- a/Src/CSharpier.Tests/OptionsProviderTests.cs +++ b/Src/CSharpier.Tests/OptionsProviderTests.cs @@ -1,11 +1,11 @@ -namespace CSharpier.Tests; - using System.IO.Abstractions.TestingHelpers; using CSharpier.Cli.Options; using FluentAssertions; using Microsoft.Extensions.Logging.Abstractions; using NUnit.Framework; +namespace CSharpier.Tests; + [TestFixture] [Parallelizable(ParallelScope.Fixtures)] public class OptionsProviderTests diff --git a/Src/CSharpier.Tests/Samples/Samples.cs b/Src/CSharpier.Tests/Samples/Samples.cs index a2c587fe5..76de4175c 100644 --- a/Src/CSharpier.Tests/Samples/Samples.cs +++ b/Src/CSharpier.Tests/Samples/Samples.cs @@ -1,11 +1,10 @@ using System.Text; using FluentAssertions; +using Microsoft.CodeAnalysis; using NUnit.Framework; namespace CSharpier.Tests.Samples; -using Microsoft.CodeAnalysis; - [TestFixture] [Parallelizable(ParallelScope.All)] public class Samples diff --git a/Src/CSharpier.Tests/SyntaxNodeComparerTests.cs b/Src/CSharpier.Tests/SyntaxNodeComparerTests.cs index 343e0fb71..6287c9757 100644 --- a/Src/CSharpier.Tests/SyntaxNodeComparerTests.cs +++ b/Src/CSharpier.Tests/SyntaxNodeComparerTests.cs @@ -1,10 +1,9 @@ using FluentAssertions; +using Microsoft.CodeAnalysis; using NUnit.Framework; namespace CSharpier.Tests; -using Microsoft.CodeAnalysis; - [TestFixture] [Parallelizable(ParallelScope.All)] public class SyntaxNodeComparerTests diff --git a/Src/CSharpier/CSharpFormatter.cs b/Src/CSharpier/CSharpFormatter.cs index b2c5e0d0e..487e76449 100644 --- a/Src/CSharpier/CSharpFormatter.cs +++ b/Src/CSharpier/CSharpFormatter.cs @@ -1,10 +1,10 @@ -namespace CSharpier; - using System.Text; using System.Text.Json; using CSharpier.Formatters.CSharp; using CSharpier.SyntaxPrinter; +namespace CSharpier; + internal class CSharpScriptFormatter : CSharpFormatter { } internal class CSharpFormatter : IFormatter @@ -120,17 +120,22 @@ bool TryGetCompilationFailure(out CodeFormatterResult compilationResult) try { var lineEnding = PrinterOptions.GetLineEnding(syntaxTree.ToString(), printerOptions); - var formattingContext = new FormattingContext + var PrintingContext = new PrintingContext { - LineEnding = lineEnding, - IndentSize = printerOptions.IndentSize, - UseTabs = printerOptions.UseTabs, + Options = new PrintingContext.PrintingContextOptions + { + LineEnding = lineEnding, + IndentSize = printerOptions.IndentSize, + UseTabs = printerOptions.UseTabs, + }, }; - var document = Node.Print(rootNode, formattingContext); + var document = Node.Print(rootNode, PrintingContext); var formattedCode = DocPrinter.DocPrinter.Print(document, printerOptions, lineEnding); - var reorderedModifiers = formattingContext.ReorderedModifiers; - var reorderedUsingsWithDisabledText = formattingContext.ReorderedUsingsWithDisabledText; - var movedTrailingTrivia = formattingContext.MovedTrailingTrivia; + var reorderedModifiers = PrintingContext.State.ReorderedModifiers; + var reorderedUsingsWithDisabledText = PrintingContext + .State + .ReorderedUsingsWithDisabledText; + var movedTrailingTrivia = PrintingContext.State.MovedTrailingTrivia; foreach (var symbolSet in PreprocessorSymbols.GetSets(syntaxTree)) { @@ -141,22 +146,27 @@ bool TryGetCompilationFailure(out CodeFormatterResult compilationResult) return result; } - var formattingContext2 = new FormattingContext + var PrintingContext2 = new PrintingContext { - LineEnding = lineEnding, - IndentSize = printerOptions.IndentSize, - UseTabs = printerOptions.UseTabs, + Options = new PrintingContext.PrintingContextOptions + { + LineEnding = lineEnding, + IndentSize = printerOptions.IndentSize, + UseTabs = printerOptions.UseTabs, + }, }; document = Node.Print( await syntaxTree.GetRootAsync(cancellationToken), - formattingContext2 + PrintingContext2 ); formattedCode = DocPrinter.DocPrinter.Print(document, printerOptions, lineEnding); - reorderedModifiers = reorderedModifiers || formattingContext2.ReorderedModifiers; + reorderedModifiers = + reorderedModifiers || PrintingContext2.State.ReorderedModifiers; reorderedUsingsWithDisabledText = reorderedUsingsWithDisabledText - || formattingContext2.ReorderedUsingsWithDisabledText; - movedTrailingTrivia = movedTrailingTrivia || formattingContext2.MovedTrailingTrivia; + || PrintingContext2.State.ReorderedUsingsWithDisabledText; + movedTrailingTrivia = + movedTrailingTrivia || PrintingContext2.State.MovedTrailingTrivia; } return new CodeFormatterResult diff --git a/Src/CSharpier/CodeFormatterResult.cs b/Src/CSharpier/CodeFormatterResult.cs index 253cf151c..2a7ab18fd 100644 --- a/Src/CSharpier/CodeFormatterResult.cs +++ b/Src/CSharpier/CodeFormatterResult.cs @@ -7,8 +7,7 @@ internal CodeFormatterResult() { } public string Code { get; internal init; } = string.Empty; internal string DocTree { get; init; } = string.Empty; internal string AST { get; init; } = string.Empty; - public IEnumerable CompilationErrors { get; internal init; } = - Enumerable.Empty(); + public IEnumerable CompilationErrors { get; internal init; } = []; internal string FailureMessage { get; init; } = string.Empty; diff --git a/Src/CSharpier/DocPrinter/DocPrinter.cs b/Src/CSharpier/DocPrinter/DocPrinter.cs index 8354fd47d..57474ebbe 100644 --- a/Src/CSharpier/DocPrinter/DocPrinter.cs +++ b/Src/CSharpier/DocPrinter/DocPrinter.cs @@ -56,7 +56,7 @@ private void EnsureOutputEndsWithSingleNewLine() var trimmed = 0; for (; trimmed < this.Output.Length; trimmed++) { - if (this.Output[^(trimmed + 1)] != '\r' && this.Output[^(trimmed + 1)] != '\n') + if (this.Output[^(trimmed + 1)] is not '\r' and not '\n') { break; } diff --git a/Src/CSharpier/DocPrinter/Indent.cs b/Src/CSharpier/DocPrinter/Indent.cs index 1fe31d3d1..3de44af1a 100644 --- a/Src/CSharpier/DocPrinter/Indent.cs +++ b/Src/CSharpier/DocPrinter/Indent.cs @@ -23,14 +23,9 @@ internal class AlignType : IIndentType public int Width { get; init; } } -internal class Indenter +internal class Indenter(PrinterOptions printerOptions) { - protected readonly PrinterOptions PrinterOptions; - - public Indenter(PrinterOptions printerOptions) - { - this.PrinterOptions = printerOptions; - } + protected readonly PrinterOptions PrinterOptions = printerOptions; public static Indent GenerateRoot() { @@ -88,7 +83,7 @@ private Indent MakeIndentWithTypesForTabs(Indent indent, IIndentType nextIndentT // if it doesn't exist yet, then all values on it are regular indents, not aligns if (indent.TypesForTabs == null) { - types = new List(); + types = []; for (var x = 0; x < indent.Value.Length; x++) { types.Add(IndentType.Instance); @@ -99,7 +94,7 @@ private Indent MakeIndentWithTypesForTabs(Indent indent, IIndentType nextIndentT else { var placeTab = false; - types = new List(indent.TypesForTabs) { nextIndentType }; + types = [.. indent.TypesForTabs, nextIndentType]; for (var x = types.Count - 1; x >= 0; x--) { if (types[x] == IndentType.Instance) diff --git a/Src/CSharpier/DocTypes/AlwaysFits.cs b/Src/CSharpier/DocTypes/AlwaysFits.cs index ba876d817..aff4b0848 100644 --- a/Src/CSharpier/DocTypes/AlwaysFits.cs +++ b/Src/CSharpier/DocTypes/AlwaysFits.cs @@ -1,11 +1,6 @@ namespace CSharpier.DocTypes; -internal class AlwaysFits : Doc +internal class AlwaysFits(Doc printedTrivia) : Doc { - public readonly Doc Contents; - - public AlwaysFits(Doc printedTrivia) - { - this.Contents = printedTrivia; - } + public readonly Doc Contents = printedTrivia; } diff --git a/Src/CSharpier/DocTypes/Concat.cs b/Src/CSharpier/DocTypes/Concat.cs index 9ee46c3ba..dad293294 100644 --- a/Src/CSharpier/DocTypes/Concat.cs +++ b/Src/CSharpier/DocTypes/Concat.cs @@ -1,11 +1,6 @@ namespace CSharpier.DocTypes; -internal class Concat : Doc +internal class Concat(IList contents) : Doc { - public IList Contents { get; set; } - - public Concat(IList contents) - { - this.Contents = contents; - } + public IList Contents { get; set; } = contents; } diff --git a/Src/CSharpier/DocTypes/Region.cs b/Src/CSharpier/DocTypes/Region.cs index ff5ffb372..4d5a7f477 100644 --- a/Src/CSharpier/DocTypes/Region.cs +++ b/Src/CSharpier/DocTypes/Region.cs @@ -1,12 +1,7 @@ namespace CSharpier.DocTypes; -internal class Region : Doc +internal class Region(string text) : Doc { - public Region(string text) - { - this.Text = text; - } - - public string Text { get; } + public string Text { get; } = text; public bool IsEnd { get; init; } } diff --git a/Src/CSharpier/DocTypes/StringDoc.cs b/Src/CSharpier/DocTypes/StringDoc.cs index 80cb08844..e1b84f9a5 100644 --- a/Src/CSharpier/DocTypes/StringDoc.cs +++ b/Src/CSharpier/DocTypes/StringDoc.cs @@ -1,13 +1,7 @@ namespace CSharpier.DocTypes; -internal class StringDoc : Doc +internal class StringDoc(string value, bool isDirective = false) : Doc { - public string Value { get; } - public bool IsDirective { get; } - - public StringDoc(string value, bool isDirective = false) - { - this.Value = value; - this.IsDirective = isDirective; - } + public string Value { get; } = value; + public bool IsDirective { get; } = isDirective; } diff --git a/Src/CSharpier/Formatters/CSharp/BooleanExpressionParser.cs b/Src/CSharpier/Formatters/CSharp/BooleanExpressionParser.cs index 8c8f62f28..ff7f112ea 100644 --- a/Src/CSharpier/Formatters/CSharp/BooleanExpressionParser.cs +++ b/Src/CSharpier/Formatters/CSharp/BooleanExpressionParser.cs @@ -1,8 +1,8 @@ -namespace CSharpier.Formatters.CSharp; - using System.Collections.Concurrent; using System.Linq.Expressions; +namespace CSharpier.Formatters.CSharp; + internal abstract class BooleanExpressionParser { private static readonly ConcurrentDictionary parsedExpressions = diff --git a/Src/CSharpier/Formatters/CSharp/PreprocessorSymbols.cs b/Src/CSharpier/Formatters/CSharp/PreprocessorSymbols.cs index 834b4f498..c89b0de18 100644 --- a/Src/CSharpier/Formatters/CSharp/PreprocessorSymbols.cs +++ b/Src/CSharpier/Formatters/CSharp/PreprocessorSymbols.cs @@ -2,8 +2,8 @@ namespace CSharpier.Formatters.CSharp; internal class PreprocessorSymbols : CSharpSyntaxWalker { - private readonly List symbolSets = new(); - private readonly HashSet squashedSymbolSets = new(); + private readonly List symbolSets = []; + private readonly HashSet squashedSymbolSets = []; private SymbolContext CurrentContext = new() { ParentContext = new SymbolContext { ParentContext = null! }, @@ -136,7 +136,7 @@ private string[] GetSymbols(BooleanExpression booleanExpression) ); return possibleParameters == null - ? Array.Empty() + ? [] : possibleParameters.Where(o => o.Value).Select(o => o.Key).OrderBy(o => o).ToArray(); } @@ -154,7 +154,7 @@ private static List> GenerateCombinations(List { if (!parameterNames.Any()) { - return new List> { new() }; + return [new()]; } var subCombinations = GenerateCombinations(parameterNames.Skip(1).ToList()); @@ -181,6 +181,6 @@ private static List> GenerateCombinations(List private class SymbolContext { public required SymbolContext ParentContext { get; init; } - public List booleanExpressions { get; } = new(); + public List booleanExpressions { get; } = []; } } diff --git a/Src/CSharpier/GeneratedCodeUtilities.cs b/Src/CSharpier/GeneratedCodeUtilities.cs index 638126326..8c386fa51 100644 --- a/Src/CSharpier/GeneratedCodeUtilities.cs +++ b/Src/CSharpier/GeneratedCodeUtilities.cs @@ -23,11 +23,7 @@ public static bool IsGeneratedCodeFile(string filePath) || fileNameWithoutExtension.EndsWithIgnoreCase(".g.i"); } - private static readonly string[] AutoGeneratedStrings = new[] - { - " arguments, SyntaxToken closeParenToken, - FormattingContext context + PrintingContext context ) { var lambdaId = Guid.NewGuid(); diff --git a/Src/CSharpier/SyntaxPrinter/AttributeLists.cs b/Src/CSharpier/SyntaxPrinter/AttributeLists.cs index eb53deca3..3aa8006c3 100644 --- a/Src/CSharpier/SyntaxPrinter/AttributeLists.cs +++ b/Src/CSharpier/SyntaxPrinter/AttributeLists.cs @@ -5,7 +5,7 @@ internal static class AttributeLists public static Doc Print( SyntaxNode node, SyntaxList attributeLists, - FormattingContext context + PrintingContext context ) { if (attributeLists.Count == 0) diff --git a/Src/CSharpier/SyntaxPrinter/CSharpierIgnore.cs b/Src/CSharpier/SyntaxPrinter/CSharpierIgnore.cs index fb4e750bd..3cf14283d 100644 --- a/Src/CSharpier/SyntaxPrinter/CSharpierIgnore.cs +++ b/Src/CSharpier/SyntaxPrinter/CSharpierIgnore.cs @@ -1,8 +1,8 @@ -namespace CSharpier.SyntaxPrinter; - using System.Text; using System.Text.RegularExpressions; +namespace CSharpier.SyntaxPrinter; + internal static class CSharpierIgnore { private static readonly Regex IgnoreRegex = new("^// csharpier-ignore($| -)"); @@ -36,7 +36,7 @@ or NamespaceDeclarationSyntax public static List PrintNodesRespectingRangeIgnore( SyntaxList list, - FormattingContext context + PrintingContext context ) where T : SyntaxNode { @@ -75,14 +75,14 @@ FormattingContext context return statements; } - public static string PrintWithoutFormatting(SyntaxNode syntaxNode, FormattingContext context) + public static string PrintWithoutFormatting(SyntaxNode syntaxNode, PrintingContext context) { return PrintWithoutFormatting(syntaxNode.GetText().ToString(), context); } - public static string PrintWithoutFormatting(string code, FormattingContext context) + public static string PrintWithoutFormatting(string code, PrintingContext context) { // trim trailing whitespace + replace only existing line endings - return Regex.Replace(code, @"[\t\v\f ]*(\r\n?|\n)", context.LineEnding); + return Regex.Replace(code, @"[\t\v\f ]*(\r\n?|\n)", context.Options.LineEnding); } } diff --git a/Src/CSharpier/SyntaxPrinter/ConstraintClauses.cs b/Src/CSharpier/SyntaxPrinter/ConstraintClauses.cs index 84dd6c938..87ee221b9 100644 --- a/Src/CSharpier/SyntaxPrinter/ConstraintClauses.cs +++ b/Src/CSharpier/SyntaxPrinter/ConstraintClauses.cs @@ -4,7 +4,7 @@ internal static class ConstraintClauses { public static Doc Print( IEnumerable constraintClauses, - FormattingContext context + PrintingContext context ) { var constraintClausesList = constraintClauses.ToList(); diff --git a/Src/CSharpier/SyntaxPrinter/FormattingContext.cs b/Src/CSharpier/SyntaxPrinter/FormattingContext.cs deleted file mode 100644 index a6e6a56a8..000000000 --- a/Src/CSharpier/SyntaxPrinter/FormattingContext.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace CSharpier.SyntaxPrinter; - -// TODO rename this to PrintingContext -internal class FormattingContext -{ - // TODO these go into Options - // context.Options.LineEnding - public required string LineEnding { get; init; } - public required int IndentSize { get; init; } - public required bool UseTabs { get; init; } - - // TODO the rest of these go into State - // context.State.PrintingDepth - public int PrintingDepth { get; set; } - public bool NextTriviaNeedsLine { get; set; } - public bool SkipNextLeadingTrivia { get; set; } - - // we need to keep track if we reordered modifiers because when modifiers are moved inside - // of an #if, then we can't compare the before and after disabled text in the source file - public bool ReorderedModifiers { get; set; } - - // we also need to keep track if we move around usings with disabledText - public bool ReorderedUsingsWithDisabledText { get; set; } - - // when adding a trailing comma in front of a trailing comment it is very hard to determine how to compare - // that trailing comment, so just ignore all trailing trivia - public bool MovedTrailingTrivia { get; set; } - - public TrailingCommaContext? TrailingComma { get; set; } - - public FormattingContext WithSkipNextLeadingTrivia() - { - this.SkipNextLeadingTrivia = true; - return this; - } - - public FormattingContext WithTrailingComma(SyntaxTrivia syntaxTrivia, Doc doc) - { - this.TrailingComma = new TrailingCommaContext(syntaxTrivia, doc); - return this; - } - - public record TrailingCommaContext(SyntaxTrivia TrailingComment, Doc PrintedTrailingComma); -} diff --git a/Src/CSharpier/SyntaxPrinter/MembersWithForcedLines.cs b/Src/CSharpier/SyntaxPrinter/MembersWithForcedLines.cs index 6e858fb89..ff0b644b6 100644 --- a/Src/CSharpier/SyntaxPrinter/MembersWithForcedLines.cs +++ b/Src/CSharpier/SyntaxPrinter/MembersWithForcedLines.cs @@ -1,15 +1,14 @@ using System.Collections.Immutable; +using System.Text; namespace CSharpier.SyntaxPrinter; -using System.Text; - internal static class MembersWithForcedLines { public static List Print( CSharpSyntaxNode node, IReadOnlyList members, - FormattingContext context, + PrintingContext context, bool skipFirstHardLine = false ) where T : MemberDeclarationSyntax @@ -191,7 +190,7 @@ or SyntaxKind.EndRegionDirectiveTrivia ) ) { - context.NextTriviaNeedsLine = true; + context.State.NextTriviaNeedsLine = true; } result.Add(Doc.HardLine, Node.Print(member, context)); diff --git a/Src/CSharpier/SyntaxPrinter/Modifiers.cs b/Src/CSharpier/SyntaxPrinter/Modifiers.cs index 63f9302a0..9f3449a32 100644 --- a/Src/CSharpier/SyntaxPrinter/Modifiers.cs +++ b/Src/CSharpier/SyntaxPrinter/Modifiers.cs @@ -6,7 +6,7 @@ private class DefaultOrder : IComparer { // use the default order from https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0036 private static readonly string[] DefaultOrdered = - { + [ "public", "private", "protected", @@ -24,7 +24,7 @@ private class DefaultOrder : IComparer "required", "volatile", "async", - }; + ]; public int Compare(string? x, string? y) { @@ -40,7 +40,7 @@ private static int GetIndex(string? value) private static readonly DefaultOrder Comparer = new(); - public static Doc Print(SyntaxTokenList modifiers, FormattingContext context) + public static Doc Print(SyntaxTokenList modifiers, PrintingContext context) { if (modifiers.Count == 0) { @@ -50,7 +50,7 @@ public static Doc Print(SyntaxTokenList modifiers, FormattingContext context) return Doc.Group(Doc.Join(" ", modifiers.Select(o => Token.Print(o, context))), " "); } - public static Doc PrintSorted(SyntaxTokenList modifiers, FormattingContext context) + public static Doc PrintSorted(SyntaxTokenList modifiers, PrintingContext context) { return PrintWithSortedModifiers( modifiers, @@ -62,7 +62,7 @@ public static Doc PrintSorted(SyntaxTokenList modifiers, FormattingContext conte public static Doc PrintSorterWithoutLeadingTrivia( SyntaxTokenList modifiers, - FormattingContext context + PrintingContext context ) { return PrintWithSortedModifiers( @@ -86,7 +86,7 @@ FormattingContext context private static Doc PrintWithSortedModifiers( SyntaxTokenList modifiers, - FormattingContext context, + PrintingContext context, Func, Doc> print ) { @@ -111,7 +111,7 @@ Func, Doc> print && sortedModifiers.Zip(modifiers, (original, sorted) => original != sorted).Any() ) { - context.ReorderedModifiers = true; + context.State.ReorderedModifiers = true; } return print(sortedModifiers.ToArray()); diff --git a/Src/CSharpier/SyntaxPrinter/NamespaceLikePrinter.cs b/Src/CSharpier/SyntaxPrinter/NamespaceLikePrinter.cs index dd34f36d9..d18ef3200 100644 --- a/Src/CSharpier/SyntaxPrinter/NamespaceLikePrinter.cs +++ b/Src/CSharpier/SyntaxPrinter/NamespaceLikePrinter.cs @@ -5,13 +5,13 @@ internal static class NamespaceLikePrinter public static void Print( BaseNamespaceDeclarationSyntax node, List docs, - FormattingContext context + PrintingContext context ) { Print(node, node.Externs, node.Usings, node.Members, docs, context); } - public static void Print(CompilationUnitSyntax node, List docs, FormattingContext context) + public static void Print(CompilationUnitSyntax node, List docs, PrintingContext context) { Print(node, node.Externs, node.Usings, node.Members, docs, context); } @@ -22,7 +22,7 @@ private static void Print( SyntaxList usings, SyntaxList members, List docs, - FormattingContext context + PrintingContext context ) { if (externs.Count > 0) diff --git a/Src/CSharpier/SyntaxPrinter/OptionalBraces.cs b/Src/CSharpier/SyntaxPrinter/OptionalBraces.cs index f489294b8..0d54ac58d 100644 --- a/Src/CSharpier/SyntaxPrinter/OptionalBraces.cs +++ b/Src/CSharpier/SyntaxPrinter/OptionalBraces.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter; internal static class OptionalBraces { - public static Doc Print(StatementSyntax node, FormattingContext context) + public static Doc Print(StatementSyntax node, PrintingContext context) { return node is BlockSyntax blockSyntax ? Block.Print(blockSyntax, context) diff --git a/Src/CSharpier/SyntaxPrinter/PrintingContext.cs b/Src/CSharpier/SyntaxPrinter/PrintingContext.cs new file mode 100644 index 000000000..aa117d606 --- /dev/null +++ b/Src/CSharpier/SyntaxPrinter/PrintingContext.cs @@ -0,0 +1,61 @@ +namespace CSharpier.SyntaxPrinter; + +// TODO #819 make this change in main so that the PR is easier to review +// TODO #819 also move around the namespaces in main + +internal class PrintingContext +{ + public required PrintingContextOptions Options { get; init; } + public PrintingContextState State { get; } = new(); + + private readonly Dictionary groupNumberByValue = new(); + + public string GroupFor(string value) + { + var number = this.groupNumberByValue.GetValueOrDefault(value, 0) + 1; + this.groupNumberByValue[value] = number; + + return value + " #" + number; + } + + public PrintingContext WithSkipNextLeadingTrivia() + { + this.State.SkipNextLeadingTrivia = true; + return this; + } + + public PrintingContext WithTrailingComma(SyntaxTrivia syntaxTrivia, Doc doc) + { + this.State.TrailingComma = new TrailingCommaContext(syntaxTrivia, doc); + return this; + } + + public class PrintingContextOptions + { + public required string LineEnding { get; init; } + public required int IndentSize { get; init; } + public required bool UseTabs { get; init; } + } + + public class PrintingContextState + { + public int PrintingDepth { get; set; } + public bool NextTriviaNeedsLine { get; set; } + public bool SkipNextLeadingTrivia { get; set; } + + // we need to keep track if we reordered modifiers because when modifiers are moved inside + // of an #if, then we can't compare the before and after disabled text in the source file + public bool ReorderedModifiers { get; set; } + + // we also need to keep track if we move around usings with disabledText + public bool ReorderedUsingsWithDisabledText { get; set; } + + public TrailingCommaContext? TrailingComma { get; set; } + + // when adding a trailing comma in front of a trailing comment it is very hard to determine how to compare + // that trailing comment, so just ignore all trailing trivia + public bool MovedTrailingTrivia { get; set; } + } + + public record TrailingCommaContext(SyntaxTrivia TrailingComment, Doc PrintedTrailingComma); +} diff --git a/Src/CSharpier/SyntaxPrinter/RightHandSide.cs b/Src/CSharpier/SyntaxPrinter/RightHandSide.cs index 0ebe99cb5..dc5ecced7 100644 --- a/Src/CSharpier/SyntaxPrinter/RightHandSide.cs +++ b/Src/CSharpier/SyntaxPrinter/RightHandSide.cs @@ -7,7 +7,7 @@ public static Doc Print( Doc leftDoc, Doc operatorDoc, ExpressionSyntax rightNode, - FormattingContext context + PrintingContext context ) { var layout = DetermineLayout(leftNode, rightNode); diff --git a/Src/CSharpier/SyntaxPrinter/SeparatedSyntaxList.cs b/Src/CSharpier/SyntaxPrinter/SeparatedSyntaxList.cs index ca2551974..ef1544af2 100644 --- a/Src/CSharpier/SyntaxPrinter/SeparatedSyntaxList.cs +++ b/Src/CSharpier/SyntaxPrinter/SeparatedSyntaxList.cs @@ -1,14 +1,14 @@ -namespace CSharpier.SyntaxPrinter; - using System.Text; +namespace CSharpier.SyntaxPrinter; + internal static class SeparatedSyntaxList { public static Doc Print( SeparatedSyntaxList list, - Func printFunc, + Func printFunc, Doc afterSeparator, - FormattingContext context, + PrintingContext context, int startingIndex = 0 ) where T : SyntaxNode @@ -18,9 +18,9 @@ public static Doc Print( public static Doc PrintWithTrailingComma( SeparatedSyntaxList list, - Func printFunc, + Func printFunc, Doc afterSeparator, - FormattingContext context, + PrintingContext context, SyntaxToken? closingToken = null ) where T : SyntaxNode @@ -33,9 +33,9 @@ public static Doc PrintWithTrailingComma( // and if you pass null to PrintWithTrailingComma it won't add a trailing comma if there isn't one private static Doc Print( SeparatedSyntaxList list, - Func printFunc, + Func printFunc, Doc afterSeparator, - FormattingContext context, + PrintingContext context, int startingIndex, SyntaxToken? closingToken ) diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AliasQualifiedName.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AliasQualifiedName.cs index aaabe3c9e..1d3800509 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AliasQualifiedName.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AliasQualifiedName.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class AliasQualifiedName { - public static Doc Print(AliasQualifiedNameSyntax node, FormattingContext context) + public static Doc Print(AliasQualifiedNameSyntax node, PrintingContext context) { return Doc.Concat( Node.Print(node.Alias, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousMethodExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousMethodExpression.cs index c923b23ed..844cdbfb5 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousMethodExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousMethodExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class AnonymousMethodExpression { - public static Doc Print(AnonymousMethodExpressionSyntax node, FormattingContext context) + public static Doc Print(AnonymousMethodExpressionSyntax node, PrintingContext context) { var docs = new List { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousObjectCreationExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousObjectCreationExpression.cs index 1051985d5..cc20626f6 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousObjectCreationExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousObjectCreationExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class AnonymousObjectCreationExpression { - public static Doc Print(AnonymousObjectCreationExpressionSyntax node, FormattingContext context) + public static Doc Print(AnonymousObjectCreationExpressionSyntax node, PrintingContext context) { var alwaysBreak = node.Initializers.Count >= 3; diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousObjectMemberDeclarator.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousObjectMemberDeclarator.cs index 8d9e23d8b..12cc173b8 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousObjectMemberDeclarator.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AnonymousObjectMemberDeclarator.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class AnonymousObjectMemberDeclarator { - public static Doc Print(AnonymousObjectMemberDeclaratorSyntax node, FormattingContext context) + public static Doc Print(AnonymousObjectMemberDeclaratorSyntax node, PrintingContext context) { var docs = new List(); if ( diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Argument.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Argument.cs index b94bdd5e6..0f298149a 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Argument.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Argument.cs @@ -2,12 +2,12 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class Argument { - public static Doc Print(ArgumentSyntax node, FormattingContext context) + public static Doc Print(ArgumentSyntax node, PrintingContext context) { return Doc.Concat(PrintModifiers(node, context), Node.Print(node.Expression, context)); } - public static Doc PrintModifiers(ArgumentSyntax node, FormattingContext context) + public static Doc PrintModifiers(ArgumentSyntax node, PrintingContext context) { var docs = new List(2); if (node.NameColon != null) diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArgumentList.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArgumentList.cs index 93dce6275..88770e133 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArgumentList.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArgumentList.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ArgumentList { - public static Doc Print(ArgumentListSyntax node, FormattingContext context) + public static Doc Print(ArgumentListSyntax node, PrintingContext context) { return Doc.Group( Doc.IndentIf( diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrayCreationExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrayCreationExpression.cs index 763d53919..ee8bc4020 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrayCreationExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrayCreationExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ArrayCreationExpression { - public static Doc Print(ArrayCreationExpressionSyntax node, FormattingContext context) + public static Doc Print(ArrayCreationExpressionSyntax node, PrintingContext context) { return Doc.Group( Token.PrintWithSuffix(node.NewKeyword, " ", context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrayRankSpecifier.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrayRankSpecifier.cs index 2d720b278..4693d535f 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrayRankSpecifier.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrayRankSpecifier.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ArrayRankSpecifier { - public static Doc Print(ArrayRankSpecifierSyntax node, FormattingContext context) + public static Doc Print(ArrayRankSpecifierSyntax node, PrintingContext context) { if (node.Sizes.All(o => o is OmittedArraySizeExpressionSyntax)) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrayType.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrayType.cs index 32b276a49..9e873307e 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrayType.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrayType.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ArrayType { - public static Doc Print(ArrayTypeSyntax node, FormattingContext context) + public static Doc Print(ArrayTypeSyntax node, PrintingContext context) { return Doc.Concat( Node.Print(node.ElementType, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrowExpressionClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrowExpressionClause.cs index d602ab984..b8a1a3808 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrowExpressionClause.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ArrowExpressionClause.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ArrowExpressionClause { - public static Doc Print(ArrowExpressionClauseSyntax node, FormattingContext context) + public static Doc Print(ArrowExpressionClauseSyntax node, PrintingContext context) { return Doc.Group( Doc.Indent( diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AssignmentExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AssignmentExpression.cs index e3565f20c..6f79d491f 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AssignmentExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AssignmentExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class AssignmentExpression { - public static Doc Print(AssignmentExpressionSyntax node, FormattingContext context) + public static Doc Print(AssignmentExpressionSyntax node, PrintingContext context) { Doc possibleNewLines = Doc.Null; diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AttributeList.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AttributeList.cs index 2027e817c..ceefe81cc 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AttributeList.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AttributeList.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class AttributeList { - public static Doc Print(AttributeListSyntax node, FormattingContext context) + public static Doc Print(AttributeListSyntax node, PrintingContext context) { if (node.Parent is BaseMethodDeclarationSyntax && CSharpierIgnore.HasIgnoreComment(node)) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AwaitExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AwaitExpression.cs index bb812ba73..05e733a9d 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AwaitExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/AwaitExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class AwaitExpression { - public static Doc Print(AwaitExpressionSyntax node, FormattingContext context) + public static Doc Print(AwaitExpressionSyntax node, PrintingContext context) { var precedesQueryExpression = node.Expression is QueryExpressionSyntax; diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseExpression.cs index 77d074442..dccc7c2e5 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class BaseExpression { - public static Doc Print(BaseExpressionSyntax node, FormattingContext context) + public static Doc Print(BaseExpressionSyntax node, PrintingContext context) { return Token.Print(node.Token, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseExpressionColon.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseExpressionColon.cs index be01d20e9..addfe8764 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseExpressionColon.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseExpressionColon.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class BaseExpressionColon { - public static Doc Print(BaseExpressionColonSyntax node, FormattingContext context) + public static Doc Print(BaseExpressionColonSyntax node, PrintingContext context) { return Doc.Concat( Node.Print(node.Expression, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseFieldDeclaration.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseFieldDeclaration.cs index c4dba0534..c0c2a3a19 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseFieldDeclaration.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseFieldDeclaration.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class BaseFieldDeclaration { - public static Doc Print(BaseFieldDeclarationSyntax node, FormattingContext context) + public static Doc Print(BaseFieldDeclarationSyntax node, PrintingContext context) { var docs = new List { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseMethodDeclaration.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseMethodDeclaration.cs index 69d36fa04..76018a01b 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseMethodDeclaration.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseMethodDeclaration.cs @@ -1,10 +1,10 @@ -namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; - using System.Text.RegularExpressions; +namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; + internal static class BaseMethodDeclaration { - public static Doc Print(CSharpSyntaxNode node, FormattingContext context) + public static Doc Print(CSharpSyntaxNode node, PrintingContext context) { SyntaxList? attributeLists = null; SyntaxTokenList? modifiers = null; @@ -95,7 +95,11 @@ void PrintMethodUnformattedWithoutAttributes(SyntaxTriviaList syntaxTriviaList) .Trim(); docs.Add( - Regex.Replace(methodWithoutAttributes, @"\s*(\r\n?|\n)", context.LineEnding) + Regex.Replace( + methodWithoutAttributes, + @"\s*(\r\n?|\n)", + context.Options.LineEnding + ) ); } @@ -127,11 +131,11 @@ void PrintMethodUnformattedWithoutAttributes(SyntaxTriviaList syntaxTriviaList) if (modifiers is not { Count: > 0 }) { docs.Add(Token.PrintLeadingTrivia(returnType.GetLeadingTrivia(), context)); - context.SkipNextLeadingTrivia = true; + context.State.SkipNextLeadingTrivia = true; } declarationGroup.Add(Node.Print(returnType, context), " "); - context.SkipNextLeadingTrivia = false; + context.State.SkipNextLeadingTrivia = false; } if (explicitInterfaceSpecifier != null) diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BasePropertyDeclaration.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BasePropertyDeclaration.cs index e0a11fadf..cc13ccf03 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BasePropertyDeclaration.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BasePropertyDeclaration.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class BasePropertyDeclaration { - public static Doc Print(BasePropertyDeclarationSyntax node, FormattingContext context) + public static Doc Print(BasePropertyDeclarationSyntax node, PrintingContext context) { EqualsValueClauseSyntax? initializer = null; ExplicitInterfaceSpecifierSyntax? explicitInterfaceSpecifierSyntax = null; @@ -64,7 +64,7 @@ public static Doc Print(BasePropertyDeclarationSyntax node, FormattingContext co private static Doc Contents( BasePropertyDeclarationSyntax node, ArrowExpressionClauseSyntax? expressionBody, - FormattingContext context + PrintingContext context ) { Doc contents = string.Empty; @@ -109,7 +109,7 @@ FormattingContext context private static Doc PrintAccessorDeclarationSyntax( AccessorDeclarationSyntax node, Doc separator, - FormattingContext context + PrintingContext context ) { var docs = new List(); diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseTypeDeclaration.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseTypeDeclaration.cs index 7ef35ffe1..30176b119 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseTypeDeclaration.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BaseTypeDeclaration.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class BaseTypeDeclaration { - public static Doc Print(BaseTypeDeclarationSyntax node, FormattingContext context) + public static Doc Print(BaseTypeDeclarationSyntax node, PrintingContext context) { ParameterListSyntax? parameterList = null; TypeParameterListSyntax? typeParameterList = null; diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BinaryExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BinaryExpression.cs index 7387952eb..6e4672a8f 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BinaryExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BinaryExpression.cs @@ -3,7 +3,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; // this is loosely based on prettier/src/language-js/print/binaryish.js internal static class BinaryExpression { - public static Doc Print(BinaryExpressionSyntax node, FormattingContext context) + public static Doc Print(BinaryExpressionSyntax node, PrintingContext context) { var docs = PrintBinaryExpression(node, context); @@ -48,19 +48,19 @@ node.Parent is ConditionalExpressionSyntax conditionalExpressionSyntax && three != four && five != six */ - private static List PrintBinaryExpression(SyntaxNode node, FormattingContext context) + private static List PrintBinaryExpression(SyntaxNode node, PrintingContext context) { if (node is not BinaryExpressionSyntax binaryExpressionSyntax) { - return new List { Doc.Group(Node.Print(node, context)) }; + return [Doc.Group(Node.Print(node, context))]; } - if (context.PrintingDepth > 200) + if (context.State.PrintingDepth > 200) { throw new InTooDeepException(); } - context.PrintingDepth++; + context.State.PrintingDepth++; try { var docs = new List(); @@ -112,9 +112,7 @@ possibleBinary is BinaryExpressionSyntax childBinary if (binaryOnTheRight) { - return shouldGroup - ? new List { docs[0], Doc.Group(docs.Skip(1).ToList()) } - : docs; + return shouldGroup ? [docs[0], Doc.Group(docs.Skip(1).ToList())] : docs; } var right = Doc.Concat( @@ -129,7 +127,7 @@ possibleBinary is BinaryExpressionSyntax childBinary } finally { - context.PrintingDepth--; + context.State.PrintingDepth--; } } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BinaryPattern.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BinaryPattern.cs index 2a4b89981..09e938dc8 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BinaryPattern.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BinaryPattern.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class BinaryPattern { - public static Doc Print(BinaryPatternSyntax node, FormattingContext context) + public static Doc Print(BinaryPatternSyntax node, PrintingContext context) { return Doc.IndentIf( node.Parent is SubpatternSyntax or IsPatternExpressionSyntax, diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Block.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Block.cs index 9fc456fb5..9a3469a23 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Block.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Block.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class Block { - public static Doc Print(BlockSyntax node, FormattingContext context) + public static Doc Print(BlockSyntax node, PrintingContext context) { if ( node.Statements.Count == 0 diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BracketedArgumentList.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BracketedArgumentList.cs index 6701c467b..76cc104fd 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BracketedArgumentList.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BracketedArgumentList.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class BracketedArgumentList { - public static Doc Print(BracketedArgumentListSyntax node, FormattingContext context) + public static Doc Print(BracketedArgumentListSyntax node, PrintingContext context) { return Doc.Group( Token.Print(node.OpenBracketToken, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BracketedParameterList.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BracketedParameterList.cs index afd922195..b4e5ddbc2 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BracketedParameterList.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BracketedParameterList.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class BracketedParameterList { - public static Doc Print(BracketedParameterListSyntax node, FormattingContext context) + public static Doc Print(BracketedParameterListSyntax node, PrintingContext context) { return ParameterList.Print(node, node.OpenBracketToken, node.CloseBracketToken, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BreakStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BreakStatement.cs index 51a06163c..fbf28b770 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BreakStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/BreakStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class BreakStatement { - public static Doc Print(BreakStatementSyntax node, FormattingContext context) + public static Doc Print(BreakStatementSyntax node, PrintingContext context) { return Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CasePatternSwitchLabel.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CasePatternSwitchLabel.cs index 4beba5233..087133c7e 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CasePatternSwitchLabel.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CasePatternSwitchLabel.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class CasePatternSwitchLabel { - public static Doc Print(CasePatternSwitchLabelSyntax node, FormattingContext context) + public static Doc Print(CasePatternSwitchLabelSyntax node, PrintingContext context) { return Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CaseSwitchLabel.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CaseSwitchLabel.cs index deb24a906..cecd91e54 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CaseSwitchLabel.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CaseSwitchLabel.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class CaseSwitchLabel { - public static Doc Print(CaseSwitchLabelSyntax node, FormattingContext context) + public static Doc Print(CaseSwitchLabelSyntax node, PrintingContext context) { return Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CastExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CastExpression.cs index b3980405f..00ed1ddef 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CastExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CastExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class CastExpression { - public static Doc Print(CastExpressionSyntax node, FormattingContext context) + public static Doc Print(CastExpressionSyntax node, PrintingContext context) { return node.Expression is ParenthesizedExpressionSyntax diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CatchClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CatchClause.cs index d94d2e5b2..ed03b4e1c 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CatchClause.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CatchClause.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class CatchClause { - public static Doc Print(CatchClauseSyntax node, FormattingContext context) + public static Doc Print(CatchClauseSyntax node, PrintingContext context) { return Doc.Concat( Token.Print(node.CatchKeyword, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CheckedExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CheckedExpression.cs index 51263e5e5..1298e7675 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CheckedExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CheckedExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class CheckedExpression { - public static Doc Print(CheckedExpressionSyntax node, FormattingContext context) + public static Doc Print(CheckedExpressionSyntax node, PrintingContext context) { return Doc.Concat( Token.Print(node.Keyword, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CheckedStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CheckedStatement.cs index d51042f2d..8f56302fe 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CheckedStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CheckedStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class CheckedStatement { - public static Doc Print(CheckedStatementSyntax node, FormattingContext context) + public static Doc Print(CheckedStatementSyntax node, PrintingContext context) { return Doc.Concat(Token.Print(node.Keyword, context), Block.Print(node.Block, context)); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ClassOrStructConstraint.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ClassOrStructConstraint.cs index 97d707458..1fff703fd 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ClassOrStructConstraint.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ClassOrStructConstraint.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ClassOrStructConstraint { - public static Doc Print(ClassOrStructConstraintSyntax node, FormattingContext context) + public static Doc Print(ClassOrStructConstraintSyntax node, PrintingContext context) { return Doc.Concat( Token.Print(node.ClassOrStructKeyword, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CollectionExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CollectionExpression.cs index 1d52c938e..a86a8ad05 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CollectionExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CollectionExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class CollectionExpression { - public static Doc Print(CollectionExpressionSyntax node, FormattingContext context) + public static Doc Print(CollectionExpressionSyntax node, PrintingContext context) { Doc separator = node.Parent is ArgumentSyntax { NameColon: null } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CommonForEachStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CommonForEachStatement.cs index 6c54c129b..940fe0294 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CommonForEachStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CommonForEachStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class CommonForEachStatement { - public static Doc Print(CommonForEachStatementSyntax node, FormattingContext context) + public static Doc Print(CommonForEachStatementSyntax node, PrintingContext context) { var variable = node switch { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CompilationUnit.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CompilationUnit.cs index 7b1be5641..6d82305d7 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CompilationUnit.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CompilationUnit.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class CompilationUnit { - public static Doc Print(CompilationUnitSyntax node, FormattingContext context) + public static Doc Print(CompilationUnitSyntax node, PrintingContext context) { var docs = new List(); diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConditionalAccessExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConditionalAccessExpression.cs index 91d2bbd50..68d3ef300 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConditionalAccessExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConditionalAccessExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ConditionalAccessExpression { - public static Doc Print(ConditionalAccessExpressionSyntax node, FormattingContext context) + public static Doc Print(ConditionalAccessExpressionSyntax node, PrintingContext context) { return InvocationExpression.PrintMemberChain(node, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConditionalExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConditionalExpression.cs index e75f859f1..ffe1e6ee3 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConditionalExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConditionalExpression.cs @@ -4,7 +4,7 @@ internal static class ConditionalExpression { // TODO a decent amount of edgecases to figure out in // https://github.com/belav/csharpier-repos/pull/110/files - public static Doc Print(ConditionalExpressionSyntax node, FormattingContext context) + public static Doc Print(ConditionalExpressionSyntax node, PrintingContext context) { if ( node.WhenTrue is not ConditionalExpressionSyntax @@ -21,7 +21,7 @@ node.WhenTrue is not ConditionalExpressionSyntax public static Doc PrintWithRegularFormatting( ConditionalExpressionSyntax node, - FormattingContext context + PrintingContext context ) { var whenTrue = node.WhenTrue is ConditionalExpressionSyntax c1 @@ -73,7 +73,7 @@ node.Parent is ConditionalExpressionSyntax or ArgumentSyntax or ReturnStatementS // they are essentially a switch expression private static Doc PrintWithChainedFormatting( ConditionalExpressionSyntax node, - FormattingContext context + PrintingContext context ) { var whenTrue = node.WhenTrue is ConditionalExpressionSyntax c1 diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConstantPattern.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConstantPattern.cs index 5b82394bc..668bdbfd9 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConstantPattern.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConstantPattern.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ConstantPattern { - public static Doc Print(ConstantPatternSyntax node, FormattingContext context) + public static Doc Print(ConstantPatternSyntax node, PrintingContext context) { return Node.Print(node.Expression, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConstructorConstraint.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConstructorConstraint.cs index 71d781e40..60c6b6a6f 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConstructorConstraint.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ConstructorConstraint.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ConstructorConstraint { - public static Doc Print(ConstructorConstraintSyntax node, FormattingContext context) + public static Doc Print(ConstructorConstraintSyntax node, PrintingContext context) { return Doc.Concat( Token.Print(node.NewKeyword, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ContinueStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ContinueStatement.cs index 7ada5b6d1..3d4bb5ea6 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ContinueStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ContinueStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ContinueStatement { - public static Doc Print(ContinueStatementSyntax node, FormattingContext context) + public static Doc Print(ContinueStatementSyntax node, PrintingContext context) { return Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DeclarationExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DeclarationExpression.cs index a21294047..77b37bf28 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DeclarationExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DeclarationExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class DeclarationExpression { - public static Doc Print(DeclarationExpressionSyntax node, FormattingContext context) + public static Doc Print(DeclarationExpressionSyntax node, PrintingContext context) { return Doc.Concat( Node.Print(node.Type, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DeclarationPattern.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DeclarationPattern.cs index 8ed9c3d3d..37c77a307 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DeclarationPattern.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DeclarationPattern.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class DeclarationPattern { - public static Doc Print(DeclarationPatternSyntax node, FormattingContext context) + public static Doc Print(DeclarationPatternSyntax node, PrintingContext context) { return Doc.Concat( Node.Print(node.Type, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DefaultConstraint.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DefaultConstraint.cs index fc2c6ecbc..b2a455eaf 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DefaultConstraint.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DefaultConstraint.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class DefaultConstraint { - public static Doc Print(DefaultConstraintSyntax node, FormattingContext context) + public static Doc Print(DefaultConstraintSyntax node, PrintingContext context) { return Token.Print(node.DefaultKeyword, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DefaultExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DefaultExpression.cs index 58783fe3a..b29e667f8 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DefaultExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DefaultExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class DefaultExpression { - public static Doc Print(DefaultExpressionSyntax node, FormattingContext context) + public static Doc Print(DefaultExpressionSyntax node, PrintingContext context) { return Doc.Concat( Token.Print(node.Keyword, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DefaultSwitchLabel.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DefaultSwitchLabel.cs index 99bd52d2f..c070a311a 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DefaultSwitchLabel.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DefaultSwitchLabel.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class DefaultSwitchLabel { - public static Doc Print(DefaultSwitchLabelSyntax node, FormattingContext context) + public static Doc Print(DefaultSwitchLabelSyntax node, PrintingContext context) { return Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DelegateDeclaration.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DelegateDeclaration.cs index 029dba5ce..ffe1b5496 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DelegateDeclaration.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DelegateDeclaration.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class DelegateDeclaration { - public static Doc Print(DelegateDeclarationSyntax node, FormattingContext context) + public static Doc Print(DelegateDeclarationSyntax node, PrintingContext context) { var docs = new List { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DiscardDesignation.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DiscardDesignation.cs index 963e358a0..5c6e08f3a 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DiscardDesignation.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DiscardDesignation.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class DiscardDesignation { - public static Doc Print(DiscardDesignationSyntax node, FormattingContext context) + public static Doc Print(DiscardDesignationSyntax node, PrintingContext context) { return Token.Print(node.UnderscoreToken, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DiscardPattern.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DiscardPattern.cs index 84c6bf1cd..d793bfdd5 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DiscardPattern.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DiscardPattern.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class DiscardPattern { - public static Doc Print(DiscardPatternSyntax node, FormattingContext context) + public static Doc Print(DiscardPatternSyntax node, PrintingContext context) { return Token.Print(node.UnderscoreToken, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DoStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DoStatement.cs index ef1847f08..4aadd9f84 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DoStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/DoStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class DoStatement { - public static Doc Print(DoStatementSyntax node, FormattingContext context) + public static Doc Print(DoStatementSyntax node, PrintingContext context) { return Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ElementAccessExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ElementAccessExpression.cs index 2cb7060bf..d59defe52 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ElementAccessExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ElementAccessExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ElementAccessExpression { - public static Doc Print(ElementAccessExpressionSyntax node, FormattingContext context) + public static Doc Print(ElementAccessExpressionSyntax node, PrintingContext context) { return Doc.Concat( Node.Print(node.Expression, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ElementBindingExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ElementBindingExpression.cs index c2a87c315..62fb1d539 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ElementBindingExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ElementBindingExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ElementBindingExpression { - public static Doc Print(ElementBindingExpressionSyntax node, FormattingContext context) + public static Doc Print(ElementBindingExpressionSyntax node, PrintingContext context) { return Node.Print(node.ArgumentList, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ElseClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ElseClause.cs index ef79e7916..e6def2db6 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ElseClause.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ElseClause.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ElseClause { - public static Doc Print(ElseClauseSyntax node, FormattingContext context) + public static Doc Print(ElseClauseSyntax node, PrintingContext context) { return Doc.Concat( Token.Print(node.ElseKeyword, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EmptyStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EmptyStatement.cs index ca4c18b59..226ca118a 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EmptyStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EmptyStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class EmptyStatement { - public static Doc Print(EmptyStatementSyntax node, FormattingContext context) + public static Doc Print(EmptyStatementSyntax node, PrintingContext context) { return Token.Print(node.SemicolonToken, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EnumMemberDeclaration.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EnumMemberDeclaration.cs index 6c0460187..f1f545a92 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EnumMemberDeclaration.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EnumMemberDeclaration.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class EnumMemberDeclaration { - public static Doc Print(EnumMemberDeclarationSyntax node, FormattingContext context) + public static Doc Print(EnumMemberDeclarationSyntax node, PrintingContext context) { var docs = new List { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EqualsValueClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EqualsValueClause.cs index f85394be7..363634c52 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EqualsValueClause.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/EqualsValueClause.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class EqualsValueClause { - public static Doc Print(EqualsValueClauseSyntax node, FormattingContext context) + public static Doc Print(EqualsValueClauseSyntax node, PrintingContext context) { Doc separator = Doc.Line; if (node.Parent is PropertyDeclarationSyntax) diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExplicitInterfaceSpecifier.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExplicitInterfaceSpecifier.cs index 42fd2ff89..c36814b4a 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExplicitInterfaceSpecifier.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExplicitInterfaceSpecifier.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ExplicitInterfaceSpecifier { - public static Doc Print(ExplicitInterfaceSpecifierSyntax node, FormattingContext context) + public static Doc Print(ExplicitInterfaceSpecifierSyntax node, PrintingContext context) { return Doc.Concat(Node.Print(node.Name, context), Token.Print(node.DotToken, context)); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExpressionElement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExpressionElement.cs index 8f77075e7..384a6c79c 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExpressionElement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExpressionElement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ExpressionElement { - public static Doc Print(ExpressionElementSyntax node, FormattingContext context) + public static Doc Print(ExpressionElementSyntax node, PrintingContext context) { return Node.Print(node.Expression, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExpressionStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExpressionStatement.cs index 02d7a6472..289690598 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExpressionStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExpressionStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ExpressionStatement { - public static Doc Print(ExpressionStatementSyntax node, FormattingContext context) + public static Doc Print(ExpressionStatementSyntax node, PrintingContext context) { return Doc.Group( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExternAliasDirective.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExternAliasDirective.cs index 03aa2f0e7..c95f3bb28 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExternAliasDirective.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ExternAliasDirective.cs @@ -4,7 +4,7 @@ internal static class ExternAliasDirective { public static Doc Print( ExternAliasDirectiveSyntax node, - FormattingContext context, + PrintingContext context, bool printExtraLines = true ) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FileScopedNamespaceDeclaration.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FileScopedNamespaceDeclaration.cs index 96bf3049c..5c48990a6 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FileScopedNamespaceDeclaration.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FileScopedNamespaceDeclaration.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class FileScopedNamespaceDeclaration { - public static Doc Print(FileScopedNamespaceDeclarationSyntax node, FormattingContext context) + public static Doc Print(FileScopedNamespaceDeclarationSyntax node, PrintingContext context) { var docs = new List { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FinallyClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FinallyClause.cs index 47d0564af..b277b07c5 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FinallyClause.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FinallyClause.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class FinallyClause { - public static Doc Print(FinallyClauseSyntax node, FormattingContext context) + public static Doc Print(FinallyClauseSyntax node, PrintingContext context) { return Doc.Concat( Token.Print(node.FinallyKeyword, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FixedStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FixedStatement.cs index c76317f2e..af78463a7 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FixedStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FixedStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class FixedStatement { - public static Doc Print(FixedStatementSyntax node, FormattingContext context) + public static Doc Print(FixedStatementSyntax node, PrintingContext context) { return Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ForStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ForStatement.cs index a246b5c3b..d73e19e6b 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ForStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ForStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ForStatement { - public static Doc Print(ForStatementSyntax node, FormattingContext context) + public static Doc Print(ForStatementSyntax node, PrintingContext context) { var docs = new List { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FromClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FromClause.cs index 55d8b18ff..d2957b25c 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FromClause.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FromClause.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class FromClause { - public static Doc Print(FromClauseSyntax node, FormattingContext context) + public static Doc Print(FromClauseSyntax node, PrintingContext context) { return Doc.Concat( Token.PrintWithSuffix(node.FromKeyword, " ", context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FunctionPointerType.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FunctionPointerType.cs index af22ae0ee..4ffea9fe0 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FunctionPointerType.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/FunctionPointerType.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class FunctionPointerType { - public static Doc Print(FunctionPointerTypeSyntax node, FormattingContext context) + public static Doc Print(FunctionPointerTypeSyntax node, PrintingContext context) { return Doc.Concat( Token.Print(node.DelegateKeyword, context), @@ -33,7 +33,7 @@ public static Doc Print(FunctionPointerTypeSyntax node, FormattingContext contex private static Doc PrintCallingConvention( FunctionPointerCallingConventionSyntax node, - FormattingContext context + PrintingContext context ) { return Doc.Concat( diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GenericName.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GenericName.cs index 9b26b6145..df988b62a 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GenericName.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GenericName.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class GenericName { - public static Doc Print(GenericNameSyntax node, FormattingContext context) + public static Doc Print(GenericNameSyntax node, PrintingContext context) { return Doc.Group( Token.Print(node.Identifier, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GlobalStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GlobalStatement.cs index 00530cbfb..66353917d 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GlobalStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GlobalStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class GlobalStatement { - public static Doc Print(GlobalStatementSyntax node, FormattingContext context) + public static Doc Print(GlobalStatementSyntax node, PrintingContext context) { return Doc.Concat( AttributeLists.Print(node, node.AttributeLists, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GotoStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GotoStatement.cs index f200df71c..8e6826026 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GotoStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GotoStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class GotoStatement { - public static Doc Print(GotoStatementSyntax node, FormattingContext context) + public static Doc Print(GotoStatementSyntax node, PrintingContext context) { var expression = node.Expression != null diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GroupClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GroupClause.cs index 939e5f0dd..6ddeae57b 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GroupClause.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/GroupClause.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class GroupClause { - public static Doc Print(GroupClauseSyntax node, FormattingContext context) + public static Doc Print(GroupClauseSyntax node, PrintingContext context) { return Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IdentifierName.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IdentifierName.cs index 54219ec01..d2d9105aa 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IdentifierName.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IdentifierName.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class IdentifierName { - public static Doc Print(IdentifierNameSyntax node, FormattingContext context) + public static Doc Print(IdentifierNameSyntax node, PrintingContext context) { return Token.Print(node.Identifier, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IfStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IfStatement.cs index d917742d5..bff6cd2dc 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IfStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IfStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class IfStatement { - public static Doc Print(IfStatementSyntax node, FormattingContext context) + public static Doc Print(IfStatementSyntax node, PrintingContext context) { var docs = new List(); if (node.Parent is not ElseClauseSyntax) diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitArrayCreationExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitArrayCreationExpression.cs index 591981e61..f9859263c 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitArrayCreationExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitArrayCreationExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ImplicitArrayCreationExpression { - public static Doc Print(ImplicitArrayCreationExpressionSyntax node, FormattingContext context) + public static Doc Print(ImplicitArrayCreationExpressionSyntax node, PrintingContext context) { var commas = node.Commas.Select(o => Token.Print(o, context)).ToArray(); return Doc.Group( diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitElementAccess.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitElementAccess.cs index 476e75ee4..69b7e8e4d 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitElementAccess.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitElementAccess.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ImplicitElementAccess { - public static Doc Print(ImplicitElementAccessSyntax node, FormattingContext context) + public static Doc Print(ImplicitElementAccessSyntax node, PrintingContext context) { return Node.Print(node.ArgumentList, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitObjectCreationExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitObjectCreationExpression.cs index 863a3b549..d9ae24589 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitObjectCreationExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitObjectCreationExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ImplicitObjectCreationExpression { - public static Doc Print(ImplicitObjectCreationExpressionSyntax node, FormattingContext context) + public static Doc Print(ImplicitObjectCreationExpressionSyntax node, PrintingContext context) { return ObjectCreationExpression.BreakParentIfNested( node, diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitStackAllocArrayCreationExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitStackAllocArrayCreationExpression.cs index ad17513bf..36320846f 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitStackAllocArrayCreationExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ImplicitStackAllocArrayCreationExpression.cs @@ -4,7 +4,7 @@ internal static class ImplicitStackAllocArrayCreationExpression { public static Doc Print( ImplicitStackAllocArrayCreationExpressionSyntax node, - FormattingContext context + PrintingContext context ) { return Doc.Concat( diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IncompleteMember.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IncompleteMember.cs index e1e6d70fb..1c3c5e092 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IncompleteMember.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IncompleteMember.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class IncompleteMember { - public static Doc Print(IncompleteMemberSyntax node, FormattingContext context) + public static Doc Print(IncompleteMemberSyntax node, PrintingContext context) { return string.Empty; } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InitializerExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InitializerExpression.cs index 9d0f53834..b18b0e1ff 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InitializerExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InitializerExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class InitializerExpression { - public static Doc Print(InitializerExpressionSyntax node, FormattingContext context) + public static Doc Print(InitializerExpressionSyntax node, PrintingContext context) { Doc separator = node.Parent is AssignmentExpressionSyntax diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InterpolatedStringExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InterpolatedStringExpression.cs index 9d1a7b6db..30cc21d0c 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InterpolatedStringExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InterpolatedStringExpression.cs @@ -2,9 +2,9 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class InterpolatedStringExpression { - internal static readonly string[] lineSeparators = new[] { "\r\n", "\r", "\n" }; + internal static readonly string[] lineSeparators = ["\r\n", "\r", "\n"]; - public static Doc Print(InterpolatedStringExpressionSyntax node, FormattingContext context) + public static Doc Print(InterpolatedStringExpressionSyntax node, PrintingContext context) { // if any of the expressions in the interpolation contain a newline then don't force this flat // ideally we would format the expressions in some way, but determining how much to indent is a hard problem @@ -41,7 +41,7 @@ public static Doc Print(InterpolatedStringExpressionSyntax node, FormattingConte ); } - private static Doc RawString(InterpolatedStringExpressionSyntax node, FormattingContext context) + private static Doc RawString(InterpolatedStringExpressionSyntax node, PrintingContext context) { var lastLineIsIndented = node.StringEndToken.Text.Replace("\r", string.Empty).Replace("\n", string.Empty)[0] diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InterpolatedStringText.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InterpolatedStringText.cs index c8021679f..f5618901f 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InterpolatedStringText.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InterpolatedStringText.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class InterpolatedStringText { - public static Doc Print(InterpolatedStringTextSyntax node, FormattingContext context) + public static Doc Print(InterpolatedStringTextSyntax node, PrintingContext context) { return Token.Print(node.TextToken, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Interpolation.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Interpolation.cs index 5da86c342..b36b11c29 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Interpolation.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Interpolation.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class Interpolation { - public static Doc Print(InterpolationSyntax node, FormattingContext context) + public static Doc Print(InterpolationSyntax node, PrintingContext context) { var docs = new List { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs index 6bb53b739..0e655c410 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/InvocationExpression.cs @@ -11,12 +11,12 @@ internal record PrintedNode(CSharpSyntaxNode Node, Doc Doc); // https://github.com/prettier/prettier/pull/7889 internal static class InvocationExpression { - public static Doc Print(InvocationExpressionSyntax node, FormattingContext context) + public static Doc Print(InvocationExpressionSyntax node, PrintingContext context) { return PrintMemberChain(node, context); } - public static Doc PrintMemberChain(ExpressionSyntax node, FormattingContext context) + public static Doc PrintMemberChain(ExpressionSyntax node, PrintingContext context) { var parent = node.Parent; var printedNodes = new List(); @@ -111,7 +111,7 @@ is ArrayCreationExpressionSyntax private static void FlattenAndPrintNodes( ExpressionSyntax expression, List printedNodes, - FormattingContext context + PrintingContext context ) { /* diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IsPatternExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IsPatternExpression.cs index 136fbc39c..ae6877fed 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IsPatternExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/IsPatternExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class IsPatternExpression { - public static Doc Print(IsPatternExpressionSyntax node, FormattingContext context) + public static Doc Print(IsPatternExpressionSyntax node, PrintingContext context) { if (node.Parent is not (IfStatementSyntax or ParenthesizedExpressionSyntax)) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/JoinClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/JoinClause.cs index 8774cc072..689798e20 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/JoinClause.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/JoinClause.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class JoinClause { - public static Doc Print(JoinClauseSyntax node, FormattingContext context) + public static Doc Print(JoinClauseSyntax node, PrintingContext context) { return Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LabeledStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LabeledStatement.cs index 8cf8afe53..9915bb888 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LabeledStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LabeledStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class LabeledStatement { - public static Doc Print(LabeledStatementSyntax node, FormattingContext context) + public static Doc Print(LabeledStatementSyntax node, PrintingContext context) { var docs = new List { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LetClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LetClause.cs index d45bb7107..da458ef99 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LetClause.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LetClause.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class LetClause { - public static Doc Print(LetClauseSyntax node, FormattingContext context) + public static Doc Print(LetClauseSyntax node, PrintingContext context) { return Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ListPattern.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ListPattern.cs index b73300ade..c232dd32f 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ListPattern.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ListPattern.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ListPattern { - public static Doc Print(ListPatternSyntax node, FormattingContext context) + public static Doc Print(ListPatternSyntax node, PrintingContext context) { return Doc.Group( Token.Print(node.OpenBracketToken, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LiteralExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LiteralExpression.cs index 06d471227..39e43252b 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LiteralExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LiteralExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class LiteralExpression { - public static Doc Print(LiteralExpressionSyntax node, FormattingContext context) + public static Doc Print(LiteralExpressionSyntax node, PrintingContext context) { return Token.Print(node.Token, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LocalDeclarationStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LocalDeclarationStatement.cs index 057faa73a..146d15983 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LocalDeclarationStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LocalDeclarationStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class LocalDeclarationStatement { - public static Doc Print(LocalDeclarationStatementSyntax node, FormattingContext context) + public static Doc Print(LocalDeclarationStatementSyntax node, PrintingContext context) { return Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LocalFunctionStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LocalFunctionStatement.cs index 7eb63fb16..a5252ba2f 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LocalFunctionStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LocalFunctionStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class LocalFunctionStatement { - public static Doc Print(LocalFunctionStatementSyntax node, FormattingContext context) + public static Doc Print(LocalFunctionStatementSyntax node, PrintingContext context) { return BaseMethodDeclaration.Print(node, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LockStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LockStatement.cs index c2594670d..79311bb22 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LockStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/LockStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class LockStatement { - public static Doc Print(LockStatementSyntax node, FormattingContext context) + public static Doc Print(LockStatementSyntax node, PrintingContext context) { var statement = Node.Print(node.Statement, context); diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/MakeRefExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/MakeRefExpression.cs index c305dc58e..70849b635 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/MakeRefExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/MakeRefExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class MakeRefExpression { - public static Doc Print(MakeRefExpressionSyntax node, FormattingContext context) + public static Doc Print(MakeRefExpressionSyntax node, PrintingContext context) { return Doc.Concat( Token.Print(node.Keyword, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/MemberAccessExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/MemberAccessExpression.cs index 8e15498e5..fa62c9e5f 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/MemberAccessExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/MemberAccessExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class MemberAccessExpression { - public static Doc Print(MemberAccessExpressionSyntax node, FormattingContext context) + public static Doc Print(MemberAccessExpressionSyntax node, PrintingContext context) { return InvocationExpression.PrintMemberChain(node, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/MemberBindingExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/MemberBindingExpression.cs index d67a12503..625363b1d 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/MemberBindingExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/MemberBindingExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class MemberBindingExpression { - public static Doc Print(MemberBindingExpressionSyntax node, FormattingContext context) + public static Doc Print(MemberBindingExpressionSyntax node, PrintingContext context) { return Doc.Concat(Token.Print(node.OperatorToken, context), Node.Print(node.Name, context)); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NameEquals.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NameEquals.cs index ed336cd11..e96eece3e 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NameEquals.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NameEquals.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class NameEquals { - public static Doc Print(NameEqualsSyntax node, FormattingContext context) + public static Doc Print(NameEqualsSyntax node, PrintingContext context) { return Doc.Concat( Node.Print(node.Name, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NamespaceDeclaration.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NamespaceDeclaration.cs index 52b4554b1..18a64fda6 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NamespaceDeclaration.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NamespaceDeclaration.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class NamespaceDeclaration { - public static Doc Print(NamespaceDeclarationSyntax node, FormattingContext context) + public static Doc Print(NamespaceDeclarationSyntax node, PrintingContext context) { var docs = new List { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NullableType.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NullableType.cs index 23653d821..31069eef0 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NullableType.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/NullableType.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class NullableType { - public static Doc Print(NullableTypeSyntax node, FormattingContext context) + public static Doc Print(NullableTypeSyntax node, PrintingContext context) { return Doc.Concat( Node.Print(node.ElementType, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ObjectCreationExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ObjectCreationExpression.cs index c39fb0402..2be373bb3 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ObjectCreationExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ObjectCreationExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ObjectCreationExpression { - public static Doc Print(ObjectCreationExpressionSyntax node, FormattingContext context) + public static Doc Print(ObjectCreationExpressionSyntax node, PrintingContext context) { return BreakParentIfNested( node, diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OmittedArraySizeExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OmittedArraySizeExpression.cs index e3ec64f52..42f0457eb 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OmittedArraySizeExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OmittedArraySizeExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class OmittedArraySizeExpression { - public static Doc Print(OmittedArraySizeExpressionSyntax node, FormattingContext context) + public static Doc Print(OmittedArraySizeExpressionSyntax node, PrintingContext context) { return Doc.Null; } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OmittedTypeArgument.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OmittedTypeArgument.cs index 2b8e525e5..6fb152846 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OmittedTypeArgument.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OmittedTypeArgument.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class OmittedTypeArgument { - public static Doc Print(OmittedTypeArgumentSyntax node, FormattingContext context) + public static Doc Print(OmittedTypeArgumentSyntax node, PrintingContext context) { return Doc.Null; } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OrderByClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OrderByClause.cs index 2f506a8cf..2e80b77d7 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OrderByClause.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/OrderByClause.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class OrderByClause { - public static Doc Print(OrderByClauseSyntax node, FormattingContext context) + public static Doc Print(OrderByClauseSyntax node, PrintingContext context) { return Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Parameter.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Parameter.cs index d5630ad36..a3b79a314 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Parameter.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/Parameter.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class Parameter { - public static Doc Print(ParameterSyntax node, FormattingContext context) + public static Doc Print(ParameterSyntax node, PrintingContext context) { var hasAttribute = node.AttributeLists.Any(); var groupId = hasAttribute ? Guid.NewGuid().ToString() : string.Empty; diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParameterList.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParameterList.cs index 6f2d27b93..1b58bdc35 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParameterList.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParameterList.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ParameterList { - public static Doc Print(ParameterListSyntax node, FormattingContext context) + public static Doc Print(ParameterListSyntax node, PrintingContext context) { return Print(node, node.OpenParenToken, node.CloseParenToken, context); } @@ -11,7 +11,7 @@ public static Doc Print( BaseParameterListSyntax node, SyntaxToken openToken, SyntaxToken closeToken, - FormattingContext context + PrintingContext context ) { return Doc.Group( diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedExpression.cs index 36bdc289e..3ad6811b8 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ParenthesizedExpression { - public static Doc Print(ParenthesizedExpressionSyntax node, FormattingContext context) + public static Doc Print(ParenthesizedExpressionSyntax node, PrintingContext context) { return Doc.Group( Token.Print(node.OpenParenToken, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedLambdaExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedLambdaExpression.cs index 80c949dd4..50e3ca7f9 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedLambdaExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedLambdaExpression.cs @@ -4,12 +4,12 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ParenthesizedLambdaExpression { - public static Doc Print(ParenthesizedLambdaExpressionSyntax node, FormattingContext context) + public static Doc Print(ParenthesizedLambdaExpressionSyntax node, PrintingContext context) { return Doc.Concat(PrintHead(node, context), PrintBody(node, context)); } - public static Doc PrintHead(ParenthesizedLambdaExpressionSyntax node, FormattingContext context) + public static Doc PrintHead(ParenthesizedLambdaExpressionSyntax node, PrintingContext context) { return Doc.Concat( AttributeLists.Print(node, node.AttributeLists, context), @@ -23,7 +23,7 @@ public static Doc PrintHead(ParenthesizedLambdaExpressionSyntax node, Formatting ); } - public static Doc PrintBody(ParenthesizedLambdaExpressionSyntax node, FormattingContext context) + public static Doc PrintBody(ParenthesizedLambdaExpressionSyntax node, PrintingContext context) { return node.Body switch { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedPattern.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedPattern.cs index a8e96db04..8ea9e5dc8 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedPattern.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedPattern.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ParenthesizedPattern { - public static Doc Print(ParenthesizedPatternSyntax node, FormattingContext context) + public static Doc Print(ParenthesizedPatternSyntax node, PrintingContext context) { return Doc.Group( Token.Print(node.OpenParenToken, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedVariableDesignation.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedVariableDesignation.cs index 78517c49d..0a6b99e62 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedVariableDesignation.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ParenthesizedVariableDesignation.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ParenthesizedVariableDesignation { - public static Doc Print(ParenthesizedVariableDesignationSyntax node, FormattingContext context) + public static Doc Print(ParenthesizedVariableDesignationSyntax node, PrintingContext context) { return Doc.Group( Token.Print(node.OpenParenToken, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PointerType.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PointerType.cs index b38fa6723..19d81e530 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PointerType.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PointerType.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class PointerType { - public static Doc Print(PointerTypeSyntax node, FormattingContext context) + public static Doc Print(PointerTypeSyntax node, PrintingContext context) { return Doc.Concat( Node.Print(node.ElementType, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PostfixUnaryExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PostfixUnaryExpression.cs index 80f929aa2..866e3497c 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PostfixUnaryExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PostfixUnaryExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class PostfixUnaryExpression { - public static Doc Print(PostfixUnaryExpressionSyntax node, FormattingContext context) + public static Doc Print(PostfixUnaryExpressionSyntax node, PrintingContext context) { if ( node.Kind() is SyntaxKind.SuppressNullableWarningExpression diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PredefinedType.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PredefinedType.cs index cdd7f432d..f6344b051 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PredefinedType.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PredefinedType.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class PredefinedType { - public static Doc Print(PredefinedTypeSyntax node, FormattingContext context) + public static Doc Print(PredefinedTypeSyntax node, PrintingContext context) { return Token.Print(node.Keyword, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PrefixUnaryExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PrefixUnaryExpression.cs index 31e9affae..46a198085 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PrefixUnaryExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PrefixUnaryExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class PrefixUnaryExpression { - public static Doc Print(PrefixUnaryExpressionSyntax node, FormattingContext context) + public static Doc Print(PrefixUnaryExpressionSyntax node, PrintingContext context) { return Doc.Concat( Token.Print(node.OperatorToken, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PrimaryConstructorBaseType.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PrimaryConstructorBaseType.cs index 2291b7851..4806267a6 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PrimaryConstructorBaseType.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/PrimaryConstructorBaseType.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class PrimaryConstructorBaseType { - public static Doc Print(PrimaryConstructorBaseTypeSyntax node, FormattingContext context) + public static Doc Print(PrimaryConstructorBaseTypeSyntax node, PrintingContext context) { return Doc.Concat( Node.Print(node.Type, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QualifiedName.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QualifiedName.cs index ea2fcd53a..8409fe0cb 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QualifiedName.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QualifiedName.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class QualifiedName { - public static Doc Print(QualifiedNameSyntax node, FormattingContext context) + public static Doc Print(QualifiedNameSyntax node, PrintingContext context) { return Doc.Concat( Node.Print(node.Left, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryBody.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryBody.cs index f983f443c..f90af3771 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryBody.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryBody.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class QueryBody { - public static Doc Print(QueryBodySyntax node, FormattingContext context) + public static Doc Print(QueryBodySyntax node, PrintingContext context) { var docs = new List { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryContinuation.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryContinuation.cs index 573098c0d..74ffa33bd 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryContinuation.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryContinuation.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class QueryContinuation { - public static Doc Print(QueryContinuationSyntax node, FormattingContext context) + public static Doc Print(QueryContinuationSyntax node, PrintingContext context) { return Doc.Concat( Token.PrintWithSuffix(node.IntoKeyword, " ", context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryExpression.cs index 52fa3ff04..4a1592062 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/QueryExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class QueryExpression { - public static Doc Print(QueryExpressionSyntax node, FormattingContext context) + public static Doc Print(QueryExpressionSyntax node, PrintingContext context) { return Doc.Concat( FromClause.Print(node.FromClause, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RangeExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RangeExpression.cs index 5674120d6..5dae9d576 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RangeExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RangeExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class RangeExpression { - public static Doc Print(RangeExpressionSyntax node, FormattingContext context) + public static Doc Print(RangeExpressionSyntax node, PrintingContext context) { return Doc.Concat( node.LeftOperand != null ? Node.Print(node.LeftOperand, context) : Doc.Null, diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RecursivePattern.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RecursivePattern.cs index 2e4ccb90a..c5d6ff827 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RecursivePattern.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RecursivePattern.cs @@ -2,21 +2,17 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class RecursivePattern { - public static Doc PrintWithOutType(RecursivePatternSyntax node, FormattingContext context) + public static Doc PrintWithOutType(RecursivePatternSyntax node, PrintingContext context) { return Print(node, false, context); } - public static Doc Print(RecursivePatternSyntax node, FormattingContext context) + public static Doc Print(RecursivePatternSyntax node, PrintingContext context) { return Print(node, true, context); } - private static Doc Print( - RecursivePatternSyntax node, - bool includeType, - FormattingContext context - ) + private static Doc Print(RecursivePatternSyntax node, bool includeType, PrintingContext context) { var result = new List(); if (node.Type != null && includeType) diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefExpression.cs index eaad743b2..2123a8845 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class RefExpression { - public static Doc Print(RefExpressionSyntax node, FormattingContext context) + public static Doc Print(RefExpressionSyntax node, PrintingContext context) { return Doc.Concat( Token.PrintWithSuffix(node.RefKeyword, " ", context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefType.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefType.cs index 697641e7c..85cf2edb1 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefType.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefType.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class RefType { - public static Doc Print(RefTypeSyntax node, FormattingContext context) + public static Doc Print(RefTypeSyntax node, PrintingContext context) { return Doc.Concat( Token.PrintWithSuffix(node.RefKeyword, " ", context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefTypeExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefTypeExpression.cs index 170721882..2a59a6d58 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefTypeExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefTypeExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class RefTypeExpression { - public static Doc Print(RefTypeExpressionSyntax node, FormattingContext context) + public static Doc Print(RefTypeExpressionSyntax node, PrintingContext context) { return Doc.Concat( Token.Print(node.Keyword, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefValueExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefValueExpression.cs index 595ef9390..c28ea6650 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefValueExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RefValueExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class RefValueExpression { - public static Doc Print(RefValueExpressionSyntax node, FormattingContext context) + public static Doc Print(RefValueExpressionSyntax node, PrintingContext context) { return Doc.Concat( Token.Print(node.Keyword, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RelationalPattern.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RelationalPattern.cs index a5df4d2c6..0b6d0210b 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RelationalPattern.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/RelationalPattern.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class RelationalPattern { - public static Doc Print(RelationalPatternSyntax node, FormattingContext context) + public static Doc Print(RelationalPatternSyntax node, PrintingContext context) { return Doc.Concat( Token.PrintWithSuffix(node.OperatorToken, " ", context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ReturnStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ReturnStatement.cs index c7d5dc489..142ec8983 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ReturnStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ReturnStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ReturnStatement { - public static Doc Print(ReturnStatementSyntax node, FormattingContext context) + public static Doc Print(ReturnStatementSyntax node, PrintingContext context) { return Doc.Group( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SelectClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SelectClause.cs index 6df48a02d..b3738447d 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SelectClause.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SelectClause.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class SelectClause { - public static Doc Print(SelectClauseSyntax node, FormattingContext context) + public static Doc Print(SelectClauseSyntax node, PrintingContext context) { return Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleBaseType.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleBaseType.cs index 9c15540c4..aed32c406 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleBaseType.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleBaseType.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class SimpleBaseType { - public static Doc Print(SimpleBaseTypeSyntax node, FormattingContext context) + public static Doc Print(SimpleBaseTypeSyntax node, PrintingContext context) { return Node.Print(node.Type, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleLambdaExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleLambdaExpression.cs index 4f5ca08cb..ca8b18d3f 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleLambdaExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SimpleLambdaExpression.cs @@ -2,12 +2,12 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class SimpleLambdaExpression { - public static Doc Print(SimpleLambdaExpressionSyntax node, FormattingContext context) + public static Doc Print(SimpleLambdaExpressionSyntax node, PrintingContext context) { return Doc.Group(PrintHead(node, context), PrintBody(node, context)); } - public static Doc PrintHead(SimpleLambdaExpressionSyntax node, FormattingContext context) + public static Doc PrintHead(SimpleLambdaExpressionSyntax node, PrintingContext context) { return Doc.Concat( Modifiers.PrintSorted(node.Modifiers, context), @@ -17,7 +17,7 @@ public static Doc PrintHead(SimpleLambdaExpressionSyntax node, FormattingContext ); } - public static Doc PrintBody(SimpleLambdaExpressionSyntax node, FormattingContext context) + public static Doc PrintBody(SimpleLambdaExpressionSyntax node, PrintingContext context) { return node.Body switch { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SingleVariableDesignation.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SingleVariableDesignation.cs index e87c2bcae..d3705780a 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SingleVariableDesignation.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SingleVariableDesignation.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class SingleVariableDesignation { - public static Doc Print(SingleVariableDesignationSyntax node, FormattingContext context) + public static Doc Print(SingleVariableDesignationSyntax node, PrintingContext context) { return Token.Print(node.Identifier, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SizeOfExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SizeOfExpression.cs index 97dd8e009..634f6e4f3 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SizeOfExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SizeOfExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class SizeOfExpression { - public static Doc Print(SizeOfExpressionSyntax node, FormattingContext context) + public static Doc Print(SizeOfExpressionSyntax node, PrintingContext context) { return Doc.Concat( Token.Print(node.Keyword, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SlicePattern.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SlicePattern.cs index 2e8544a3b..3eedfb316 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SlicePattern.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SlicePattern.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class SlicePattern { - public static Doc Print(SlicePatternSyntax node, FormattingContext context) + public static Doc Print(SlicePatternSyntax node, PrintingContext context) { if (node.Pattern is null) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SpreadElement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SpreadElement.cs index 80f108961..defcb06a4 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SpreadElement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SpreadElement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class SpreadElement { - public static Doc Print(SpreadElementSyntax node, FormattingContext context) + public static Doc Print(SpreadElementSyntax node, PrintingContext context) { return Doc.Group( Token.Print(node.OperatorToken, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/StackAllocArrayCreationExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/StackAllocArrayCreationExpression.cs index afb8be959..4ad5f885e 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/StackAllocArrayCreationExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/StackAllocArrayCreationExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class StackAllocArrayCreationExpression { - public static Doc Print(StackAllocArrayCreationExpressionSyntax node, FormattingContext context) + public static Doc Print(StackAllocArrayCreationExpressionSyntax node, PrintingContext context) { return Doc.Concat( Token.PrintWithSuffix(node.StackAllocKeyword, " ", context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchExpression.cs index 6edea519d..0dbee38fd 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class SwitchExpression { - public static Doc Print(SwitchExpressionSyntax node, FormattingContext context) + public static Doc Print(SwitchExpressionSyntax node, PrintingContext context) { var sections = Doc.Group( Doc.Indent( @@ -33,7 +33,7 @@ public static Doc Print(SwitchExpressionSyntax node, FormattingContext context) private static Doc PrintArm( SwitchExpressionArmSyntax switchExpressionArm, - FormattingContext context + PrintingContext context ) { var arrowHasComment = switchExpressionArm.EqualsGreaterThanToken.LeadingTrivia.Any(o => diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchSection.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchSection.cs index f3f6d08da..b8783a818 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchSection.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchSection.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class SwitchSection { - public static Doc Print(SwitchSectionSyntax node, FormattingContext context) + public static Doc Print(SwitchSectionSyntax node, PrintingContext context) { var docs = new List { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchStatement.cs index dd8e7638c..b1c5da6f2 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/SwitchStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class SwitchStatement { - public static Doc Print(SwitchStatementSyntax node, FormattingContext context) + public static Doc Print(SwitchStatementSyntax node, PrintingContext context) { var sections = node.Sections.Count == 0 diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ThisExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ThisExpression.cs index 3d41b96a4..268fec99b 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ThisExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ThisExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ThisExpression { - public static Doc Print(ThisExpressionSyntax node, FormattingContext context) + public static Doc Print(ThisExpressionSyntax node, PrintingContext context) { return Token.Print(node.Token, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ThrowExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ThrowExpression.cs index 8df02c3ab..7974788df 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ThrowExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ThrowExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ThrowExpression { - public static Doc Print(ThrowExpressionSyntax node, FormattingContext context) + public static Doc Print(ThrowExpressionSyntax node, PrintingContext context) { return Doc.Concat( Token.PrintWithSuffix(node.ThrowKeyword, " ", context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ThrowStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ThrowStatement.cs index 27366ece4..b903cefba 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ThrowStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/ThrowStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class ThrowStatement { - public static Doc Print(ThrowStatementSyntax node, FormattingContext context) + public static Doc Print(ThrowStatementSyntax node, PrintingContext context) { var expression = node.Expression != null diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TryStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TryStatement.cs index 10abaf7b1..453439374 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TryStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TryStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class TryStatement { - public static Doc Print(TryStatementSyntax node, FormattingContext context) + public static Doc Print(TryStatementSyntax node, PrintingContext context) { var docs = new List { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TupleElement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TupleElement.cs index 703abe8d4..8908ddd47 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TupleElement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TupleElement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class TupleElement { - public static Doc Print(TupleElementSyntax node, FormattingContext context) + public static Doc Print(TupleElementSyntax node, PrintingContext context) { return Doc.Concat( Node.Print(node.Type, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TupleExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TupleExpression.cs index 82e49bde2..9d45d7006 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TupleExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TupleExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class TupleExpression { - public static Doc Print(TupleExpressionSyntax node, FormattingContext context) => + public static Doc Print(TupleExpressionSyntax node, PrintingContext context) => Doc.Group( ArgumentListLike.Print( node.OpenParenToken, diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TupleType.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TupleType.cs index 5551758e5..2122dfbbf 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TupleType.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TupleType.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class TupleType { - public static Doc Print(TupleTypeSyntax node, FormattingContext context) + public static Doc Print(TupleTypeSyntax node, PrintingContext context) { return Doc.Group( Token.Print(node.OpenParenToken, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeArgumentList.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeArgumentList.cs index 74cc2136a..42eac40b0 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeArgumentList.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeArgumentList.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class TypeArgumentList { - public static Doc Print(TypeArgumentListSyntax node, FormattingContext context) + public static Doc Print(TypeArgumentListSyntax node, PrintingContext context) { Doc separator = node.Arguments.FirstOrDefault() is not OmittedTypeArgumentSyntax diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeConstraint.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeConstraint.cs index d83ca9211..80a811b43 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeConstraint.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeConstraint.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class TypeConstraint { - public static Doc Print(TypeConstraintSyntax node, FormattingContext context) + public static Doc Print(TypeConstraintSyntax node, PrintingContext context) { return Node.Print(node.Type, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeOfExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeOfExpression.cs index 4e3f9a26e..3c31599da 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeOfExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeOfExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class TypeOfExpression { - public static Doc Print(TypeOfExpressionSyntax node, FormattingContext context) + public static Doc Print(TypeOfExpressionSyntax node, PrintingContext context) { return Doc.Concat( Token.Print(node.Keyword, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeParameter.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeParameter.cs index e8a6d9f06..c6f767724 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeParameter.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeParameter.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class TypeParameter { - public static Doc Print(TypeParameterSyntax node, FormattingContext context) + public static Doc Print(TypeParameterSyntax node, PrintingContext context) { var hasAttribute = node.AttributeLists.Any(); var groupId = hasAttribute ? Guid.NewGuid().ToString() : string.Empty; diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeParameterConstraintClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeParameterConstraintClause.cs index 6912c3b28..51a7a6942 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeParameterConstraintClause.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeParameterConstraintClause.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class TypeParameterConstraintClause { - public static Doc Print(TypeParameterConstraintClauseSyntax node, FormattingContext context) + public static Doc Print(TypeParameterConstraintClauseSyntax node, PrintingContext context) { return Doc.Group( Token.PrintWithSuffix(node.WhereKeyword, " ", context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeParameterList.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeParameterList.cs index 3cbbacd37..8bc73a2ed 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeParameterList.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypeParameterList.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class TypeParameterList { - public static Doc Print(TypeParameterListSyntax node, FormattingContext context) + public static Doc Print(TypeParameterListSyntax node, PrintingContext context) { if (node.Parameters.Count == 0) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypePattern.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypePattern.cs index 6d5480085..082f44ecd 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypePattern.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/TypePattern.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class TypePattern { - public static Doc Print(TypePatternSyntax node, FormattingContext context) + public static Doc Print(TypePatternSyntax node, PrintingContext context) { return Node.Print(node.Type, context); } diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UnaryPattern.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UnaryPattern.cs index 19ad5daa5..c2f246e29 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UnaryPattern.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UnaryPattern.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class UnaryPattern { - public static Doc Print(UnaryPatternSyntax node, FormattingContext context) + public static Doc Print(UnaryPatternSyntax node, PrintingContext context) { return Doc.Concat( Token.PrintWithSuffix(node.OperatorToken, " ", context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UnsafeStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UnsafeStatement.cs index b389184b7..34ecca1a0 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UnsafeStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UnsafeStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class UnsafeStatement { - public static Doc Print(UnsafeStatementSyntax node, FormattingContext context) + public static Doc Print(UnsafeStatementSyntax node, PrintingContext context) { return Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UsingDirective.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UsingDirective.cs index a0e4e9005..041c86f77 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UsingDirective.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UsingDirective.cs @@ -4,7 +4,7 @@ internal static class UsingDirective { public static Doc Print( UsingDirectiveSyntax node, - FormattingContext context, + PrintingContext context, bool printExtraLines = true ) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UsingStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UsingStatement.cs index 6b2b7073b..a0c2abce3 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UsingStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/UsingStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class UsingStatement { - public static Doc Print(UsingStatementSyntax node, FormattingContext context) + public static Doc Print(UsingStatementSyntax node, PrintingContext context) { var docs = new List { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/VarPattern.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/VarPattern.cs index 61cc7bbd0..cdc7594c7 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/VarPattern.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/VarPattern.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class VarPattern { - public static Doc Print(VarPatternSyntax node, FormattingContext context) + public static Doc Print(VarPatternSyntax node, PrintingContext context) { return Doc.Concat( Token.PrintWithSuffix(node.VarKeyword, " ", context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/VariableDeclaration.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/VariableDeclaration.cs index 1aef8efcc..51dee43ca 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/VariableDeclaration.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/VariableDeclaration.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class VariableDeclaration { - public static Doc Print(VariableDeclarationSyntax node, FormattingContext context) + public static Doc Print(VariableDeclarationSyntax node, PrintingContext context) { if (node.Variables.Count > 1) { diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/VariableDeclarator.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/VariableDeclarator.cs index 89386edd0..687b56ffb 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/VariableDeclarator.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/VariableDeclarator.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class VariableDeclarator { - public static Doc Print(VariableDeclaratorSyntax node, FormattingContext context) + public static Doc Print(VariableDeclaratorSyntax node, PrintingContext context) { var docs = new List { Token.Print(node.Identifier, context) }; if (node.ArgumentList != null) diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhenClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhenClause.cs index 887288479..f54314080 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhenClause.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhenClause.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class WhenClause { - public static Doc Print(WhenClauseSyntax node, FormattingContext context) + public static Doc Print(WhenClauseSyntax node, PrintingContext context) { return Doc.Group( Doc.Indent( diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhereClause.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhereClause.cs index 33b2f522a..3d891d7e9 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhereClause.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhereClause.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class WhereClause { - public static Doc Print(WhereClauseSyntax node, FormattingContext context) + public static Doc Print(WhereClauseSyntax node, PrintingContext context) { return Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhileStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhileStatement.cs index 0f01e9282..6c673ce1d 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhileStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WhileStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class WhileStatement { - public static Doc Print(WhileStatementSyntax node, FormattingContext context) + public static Doc Print(WhileStatementSyntax node, PrintingContext context) { var result = Doc.Concat( ExtraNewLines.Print(node), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WithExpression.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WithExpression.cs index bbd5b5ef6..15d469034 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WithExpression.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/WithExpression.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class WithExpression { - public static Doc Print(WithExpressionSyntax node, FormattingContext context) + public static Doc Print(WithExpressionSyntax node, PrintingContext context) { return Doc.Concat( Node.Print(node.Expression, context), diff --git a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/YieldStatement.cs b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/YieldStatement.cs index bba400b86..28b0ce725 100644 --- a/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/YieldStatement.cs +++ b/Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/YieldStatement.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter.SyntaxNodePrinters; internal static class YieldStatement { - public static Doc Print(YieldStatementSyntax node, FormattingContext context) + public static Doc Print(YieldStatementSyntax node, PrintingContext context) { Doc expression = node.Expression != null diff --git a/Src/CSharpier/SyntaxPrinter/Token.cs b/Src/CSharpier/SyntaxPrinter/Token.cs index 38f29245d..f21becad8 100644 --- a/Src/CSharpier/SyntaxPrinter/Token.cs +++ b/Src/CSharpier/SyntaxPrinter/Token.cs @@ -1,20 +1,20 @@ -namespace CSharpier.SyntaxPrinter; - using System.Text.RegularExpressions; +namespace CSharpier.SyntaxPrinter; + internal static class Token { - public static Doc PrintWithoutLeadingTrivia(SyntaxToken syntaxToken, FormattingContext context) + public static Doc PrintWithoutLeadingTrivia(SyntaxToken syntaxToken, PrintingContext context) { return PrintSyntaxToken(syntaxToken, context, skipLeadingTrivia: true); } - public static Doc PrintWithoutTrailingTrivia(SyntaxToken syntaxToken, FormattingContext context) + public static Doc PrintWithoutTrailingTrivia(SyntaxToken syntaxToken, PrintingContext context) { return PrintSyntaxToken(syntaxToken, context, skipTrailingTrivia: true); } - public static Doc Print(SyntaxToken syntaxToken, FormattingContext context) + public static Doc Print(SyntaxToken syntaxToken, PrintingContext context) { return PrintSyntaxToken(syntaxToken, context); } @@ -22,18 +22,18 @@ public static Doc Print(SyntaxToken syntaxToken, FormattingContext context) public static Doc PrintWithSuffix( SyntaxToken syntaxToken, Doc suffixDoc, - FormattingContext context, + PrintingContext context, bool skipLeadingTrivia = false ) { return PrintSyntaxToken(syntaxToken, context, suffixDoc, skipLeadingTrivia); } - internal static readonly string[] lineSeparators = new[] { "\r\n", "\r", "\n" }; + internal static readonly string[] lineSeparators = ["\r\n", "\r", "\n"]; private static Doc PrintSyntaxToken( SyntaxToken syntaxToken, - FormattingContext context, + PrintingContext context, Doc? suffixDoc = null, bool skipLeadingTrivia = false, bool skipTrailingTrivia = false @@ -45,7 +45,7 @@ private static Doc PrintSyntaxToken( } var docs = new List(); - if (!skipLeadingTrivia && !context.SkipNextLeadingTrivia) + if (!skipLeadingTrivia && !context.State.SkipNextLeadingTrivia) { var leadingTrivia = PrintLeadingTrivia(syntaxToken, context); if (leadingTrivia != Doc.Null) @@ -54,7 +54,7 @@ private static Doc PrintSyntaxToken( } } - context.SkipNextLeadingTrivia = false; + context.State.SkipNextLeadingTrivia = false; if ( ( @@ -126,14 +126,14 @@ or SyntaxKind.InterpolatedRawStringEndToken if (trailingTrivia != Doc.Null) { if ( - context.TrailingComma is not null + context.State.TrailingComma is not null && syntaxToken.TrailingTrivia.FirstOrDefault(o => o.IsComment()) - == context.TrailingComma.TrailingComment + == context.State.TrailingComma.TrailingComment ) { - docs.Add(context.TrailingComma.PrintedTrailingComma); - context.MovedTrailingTrivia = true; - context.TrailingComma = null; + docs.Add(context.State.TrailingComma.PrintedTrailingComma); + context.State.MovedTrailingTrivia = true; + context.State.TrailingComma = null; } docs.Add(trailingTrivia); @@ -153,7 +153,7 @@ context.TrailingComma is not null }; } - public static Doc PrintLeadingTrivia(SyntaxToken syntaxToken, FormattingContext context) + public static Doc PrintLeadingTrivia(SyntaxToken syntaxToken, PrintingContext context) { var isClosingBrace = syntaxToken.RawSyntaxKind() == SyntaxKind.CloseBraceToken @@ -204,14 +204,14 @@ public static Doc PrintLeadingTrivia(SyntaxToken syntaxToken, FormattingContext : printedTrivia; } - public static Doc PrintLeadingTrivia(SyntaxTriviaList leadingTrivia, FormattingContext context) + public static Doc PrintLeadingTrivia(SyntaxTriviaList leadingTrivia, PrintingContext context) { return PrivatePrintLeadingTrivia(leadingTrivia, context); } public static Doc PrintLeadingTriviaWithNewLines( SyntaxTriviaList leadingTrivia, - FormattingContext context + PrintingContext context ) { return PrivatePrintLeadingTrivia(leadingTrivia, context, includeInitialNewLines: true); @@ -219,7 +219,7 @@ FormattingContext context private static Doc PrivatePrintLeadingTrivia( SyntaxTriviaList leadingTrivia, - FormattingContext context, + PrintingContext context, bool includeInitialNewLines = false, bool skipLastHardline = false ) @@ -322,7 +322,7 @@ void AddLeadingComment(CommentType commentType) docs.RemoveAt(docs.Count - 1); } - if (context.NextTriviaNeedsLine) + if (context.State.NextTriviaNeedsLine) { if (leadingTrivia.Any(o => o.RawSyntaxKind() is SyntaxKind.IfDirectiveTrivia)) { @@ -348,7 +348,7 @@ void AddLeadingComment(CommentType commentType) docs.Insert(index + 1, Doc.HardLineSkipBreakIfFirstInGroup); } } - context.NextTriviaNeedsLine = false; + context.State.NextTriviaNeedsLine = false; } return docs.Count > 0 ? Doc.Concat(docs) : Doc.Null; diff --git a/Src/CSharpier/SyntaxPrinter/TrailingComma.cs b/Src/CSharpier/SyntaxPrinter/TrailingComma.cs index 23fdbd76a..5d5aedc3a 100644 --- a/Src/CSharpier/SyntaxPrinter/TrailingComma.cs +++ b/Src/CSharpier/SyntaxPrinter/TrailingComma.cs @@ -4,7 +4,7 @@ internal static class TrailingComma { public static Doc Print( SyntaxToken closingToken, - FormattingContext context, + PrintingContext context, bool skipIfBreak = false ) { diff --git a/Src/CSharpier/SyntaxPrinter/UnhandledNode.cs b/Src/CSharpier/SyntaxPrinter/UnhandledNode.cs index ea9b120da..14c8220d8 100644 --- a/Src/CSharpier/SyntaxPrinter/UnhandledNode.cs +++ b/Src/CSharpier/SyntaxPrinter/UnhandledNode.cs @@ -2,7 +2,7 @@ namespace CSharpier.SyntaxPrinter; internal static class UnhandledNode { - public static Doc Print(SyntaxNode node, FormattingContext context) + public static Doc Print(SyntaxNode node, PrintingContext context) { // full string includes comments/directives but also any whitespace, which we need to strip return node.ToFullString().Trim(); diff --git a/Src/CSharpier/SyntaxPrinter/UsingDirectives.cs b/Src/CSharpier/SyntaxPrinter/UsingDirectives.cs index 0be66f3c5..74e20a342 100644 --- a/Src/CSharpier/SyntaxPrinter/UsingDirectives.cs +++ b/Src/CSharpier/SyntaxPrinter/UsingDirectives.cs @@ -6,7 +6,7 @@ internal static class UsingDirectives public static Doc PrintWithSorting( SyntaxList usings, - FormattingContext context, + PrintingContext context, bool printExtraLines ) { @@ -35,8 +35,9 @@ bool printExtraLines break; } if ( - leadingTrivia.RawSyntaxKind() == SyntaxKind.DefineDirectiveTrivia - || leadingTrivia.RawSyntaxKind() == SyntaxKind.UndefDirectiveTrivia + leadingTrivia.RawSyntaxKind() + is SyntaxKind.DefineDirectiveTrivia + or SyntaxKind.UndefDirectiveTrivia ) { initialComments = usings.First().GetLeadingTrivia().ToList(); @@ -122,7 +123,7 @@ var groupOfUsingData in GroupUsings( if (reorderedDirectives && usings.Any(o => o.ToFullString().Contains("#endif"))) { - context.ReorderedUsingsWithDisabledText = true; + context.State.ReorderedUsingsWithDisabledText = true; } return Doc.Concat(docs); @@ -131,7 +132,7 @@ var groupOfUsingData in GroupUsings( private static IEnumerable> GroupUsings( List usings, SyntaxTriviaList triviaOnFirstUsing, - FormattingContext context + PrintingContext context ) { var globalSystemUsings = new List(); diff --git a/Src/CSharpier/Utilities/DictionaryExtensions.cs b/Src/CSharpier/Utilities/DictionaryExtensions.cs new file mode 100644 index 000000000..e25967988 --- /dev/null +++ b/Src/CSharpier/Utilities/DictionaryExtensions.cs @@ -0,0 +1,16 @@ +#if NETSTANDARD2_0 +namespace CSharpier.Utilities; + +internal static class DictionaryExtensions +{ + public static TValue GetValueOrDefault( + this Dictionary dictionary, + TKey key, + TValue defaultValue + ) + where TKey : notnull + { + return dictionary.TryGetValue(key, out var value) ? value : defaultValue; + } +} +#endif diff --git a/Src/CSharpier/Utilities/StackExtensions.cs b/Src/CSharpier/Utilities/StackExtensions.cs index 78ff09c64..a465419cd 100644 --- a/Src/CSharpier/Utilities/StackExtensions.cs +++ b/Src/CSharpier/Utilities/StackExtensions.cs @@ -1,7 +1,7 @@ -namespace CSharpier.Utilities; - using System.Diagnostics.CodeAnalysis; +namespace CSharpier.Utilities; + internal static class StackExtensions { #if NETSTANDARD2_0 diff --git a/Src/CSharpier/Utilities/StringBuilderExtensions.cs b/Src/CSharpier/Utilities/StringBuilderExtensions.cs index 3a8a295ee..8cbb4b9fe 100644 --- a/Src/CSharpier/Utilities/StringBuilderExtensions.cs +++ b/Src/CSharpier/Utilities/StringBuilderExtensions.cs @@ -9,7 +9,7 @@ public static bool EndsWithNewLineAndWhitespace(this StringBuilder stringBuilder for (var index = 1; index <= stringBuilder.Length; index++) { var next = stringBuilder[^index]; - if (next == ' ' || next == '\t') + if (next is ' ' or '\t') { continue; } @@ -36,7 +36,7 @@ public static int TrimTrailingWhitespace(this StringBuilder stringBuilder) var trimmed = 0; for (; trimmed < stringBuilder.Length; trimmed++) { - if (stringBuilder[^(trimmed + 1)] != ' ' && stringBuilder[^(trimmed + 1)] != '\t') + if (stringBuilder[^(trimmed + 1)] is not ' ' and not '\t') { break; } diff --git a/Src/SyntaxFinder/Ignored.cs b/Src/SyntaxFinder/Ignored.cs index 37be8cfab..e8ecd11d4 100644 --- a/Src/SyntaxFinder/Ignored.cs +++ b/Src/SyntaxFinder/Ignored.cs @@ -7,8 +7,8 @@ public static bool Is(string file) return ignored.Any(file.Replace("\\", "/").Contains); } - private static string[] ignored = new[] - { + private static string[] ignored = + [ "roslyn/src/Compilers/Test/Core/Assert/ConditionalFactAttribute.cs", "roslyn/src/Compilers/Test/Core/Compilation/RuntimeUtilities.cs", "runtime/src/libraries/System.Net.Primitives/tests/FunctionalTests/SocketAddressTest.cs", @@ -81,5 +81,5 @@ public static bool Is(string file) "runtime/src/tests/Loader/classloader/generics/Instantiation/Nesting/NestedGenericClasses.cs", "runtime/src/tests/Loader/classloader/generics/Instantiation/Nesting/NestedGenericTypesMix.cs", "runtime/src/tests/Loader/classloader/generics/Instantiation/Nesting/NestedGenericStructs.cs", - }; + ]; } diff --git a/Src/SyntaxFinder/SyntaxFinderWalker.cs b/Src/SyntaxFinder/SyntaxFinderWalker.cs index 79bd461a1..849b375e0 100644 --- a/Src/SyntaxFinder/SyntaxFinderWalker.cs +++ b/Src/SyntaxFinder/SyntaxFinderWalker.cs @@ -1,8 +1,8 @@ -namespace SyntaxFinder; - using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; +namespace SyntaxFinder; + public abstract class SyntaxFinderWalker(string file) : CSharpSyntaxWalker { private bool wroteFile; diff --git a/Src/SyntaxFinder/SyntaxTriviaExtensions.cs b/Src/SyntaxFinder/SyntaxTriviaExtensions.cs index 3d67990b0..79d545180 100644 --- a/Src/SyntaxFinder/SyntaxTriviaExtensions.cs +++ b/Src/SyntaxFinder/SyntaxTriviaExtensions.cs @@ -1,8 +1,8 @@ -namespace SyntaxFinder; - using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; +namespace SyntaxFinder; + public static class SyntaxTriviaExtensions { public static bool IsComment(this SyntaxTrivia syntaxTrivia) diff --git a/Src/SyntaxFinder/Walkers/ExampleWalker.cs b/Src/SyntaxFinder/Walkers/ExampleWalker.cs index 43424381f..451c45aa9 100644 --- a/Src/SyntaxFinder/Walkers/ExampleWalker.cs +++ b/Src/SyntaxFinder/Walkers/ExampleWalker.cs @@ -1,10 +1,10 @@ -namespace SyntaxFinder.Walkers; - using System.Collections.Concurrent; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; +namespace SyntaxFinder.Walkers; + public class ExampleWalker(string file) : SyntaxFinderWalker(file) { public static readonly ConcurrentDictionary> MembersInType = new(); diff --git a/Src/SyntaxFinder/Walkers/ModifiersWalker.cs b/Src/SyntaxFinder/Walkers/ModifiersWalker.cs index 868184db4..bfd1da43e 100644 --- a/Src/SyntaxFinder/Walkers/ModifiersWalker.cs +++ b/Src/SyntaxFinder/Walkers/ModifiersWalker.cs @@ -1,12 +1,9 @@ -namespace SyntaxFinder.Walkers; - using Microsoft.CodeAnalysis.CSharp.Syntax; -public class ModifiersWalker : SyntaxFinderWalker -{ - public ModifiersWalker(string file) - : base(file) { } +namespace SyntaxFinder.Walkers; +public class ModifiersWalker(string file) : SyntaxFinderWalker(file) +{ public override void VisitParenthesizedLambdaExpression( ParenthesizedLambdaExpressionSyntax node ) diff --git a/Src/SyntaxFinder/Walkers/NestedConditionalExpressionsWalker.cs b/Src/SyntaxFinder/Walkers/NestedConditionalExpressionsWalker.cs index 13ccd77cc..6ed98bf15 100644 --- a/Src/SyntaxFinder/Walkers/NestedConditionalExpressionsWalker.cs +++ b/Src/SyntaxFinder/Walkers/NestedConditionalExpressionsWalker.cs @@ -1,10 +1,10 @@ -namespace SyntaxFinder.Walkers; - using System.Collections.Concurrent; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; +namespace SyntaxFinder.Walkers; + public class NestedConditionalExpressionsWalker(string file) : SyntaxFinderWalker(file) { public static readonly ConcurrentDictionary> MembersInType = new(); diff --git a/Src/SyntaxFinder/Walkers/ObjectInitializerWalker.cs b/Src/SyntaxFinder/Walkers/ObjectInitializerWalker.cs index 903540254..e8a7a4df8 100644 --- a/Src/SyntaxFinder/Walkers/ObjectInitializerWalker.cs +++ b/Src/SyntaxFinder/Walkers/ObjectInitializerWalker.cs @@ -1,21 +1,15 @@ -namespace SyntaxFinder.Walkers; - using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -public class ObjectInitializerWalker : CSharpSyntaxWalker +namespace SyntaxFinder.Walkers; + +public class ObjectInitializerWalker(string file) : CSharpSyntaxWalker { private static int total; private static int matching; private static double totalExpressions; - private readonly string file; private static HashSet matchingFiles = new(); - public ObjectInitializerWalker(string file) - { - this.file = file; - } - public override void VisitInitializerExpression(InitializerExpressionSyntax node) { if (node.Kind() is SyntaxKind.ObjectInitializerExpression) @@ -40,7 +34,7 @@ private void VisitNode(InitializerExpressionSyntax node) { Interlocked.Increment(ref matching); matchingFiles.Add( - node.SyntaxTree.GetLineSpan(node.Span).StartLinePosition.Line + " - " + this.file + node.SyntaxTree.GetLineSpan(node.Span).StartLinePosition.Line + " - " + file ); } } diff --git a/Src/SyntaxFinder/Walkers/SpreadWalker.cs b/Src/SyntaxFinder/Walkers/SpreadWalker.cs index ba5ae061f..06cf6b1db 100644 --- a/Src/SyntaxFinder/Walkers/SpreadWalker.cs +++ b/Src/SyntaxFinder/Walkers/SpreadWalker.cs @@ -1,18 +1,13 @@ -namespace SyntaxFinder.Walkers; - using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -public class SpreadWalker : CSharpSyntaxWalker +namespace SyntaxFinder.Walkers; + +public class SpreadWalker(string file) : CSharpSyntaxWalker { private static int total; private static int matching; - private readonly string file; - - public SpreadWalker(string file) - { - this.file = file; - } + private readonly string file = file; public override void VisitSpreadElement(SpreadElementSyntax node) {