Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Rewrite/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
tab-width = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{build,config,csproj,js,json,proj,props,targets,xml,ruleset,xsd,yml,yaml}]
indent_size = 2
tab-width = 2
max_line_length = 160

[*.{cs,cshtml,ascx,aspx}]
4 changes: 4 additions & 0 deletions Rewrite/ClearBinObjFolders.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S bin') DO RMDIR /S /Q "%%G"
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S obj') DO RMDIR /S /Q "%%G"
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S tmp') DO RMDIR /S /Q "%%G"
FOR /F "tokens=*" %%G IN ('DIR /B /AD /S target') DO RMDIR /S /Q "%%G"
7 changes: 6 additions & 1 deletion Rewrite/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<Project>
<PropertyGroup>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup>
<Company>Moderne Inc.</Company>
<PackageIcon>openrewrite.png</PackageIcon>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<Version>0.8.4</Version>

<RewriteRemoteVersion>0.8.0-preview-10</RewriteRemoteVersion>
<RewriteRemoteDir Condition="'$(RewriteRemoteDir)'==''">..\..\..\..\..\moderneinc\rewrite-remote\Rewrite.Remote</RewriteRemoteDir>
</PropertyGroup>
Expand Down
7 changes: 6 additions & 1 deletion Rewrite/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
<ItemGroup>
<None Include="$(SolutionDir)resources\$(PackageIcon)" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1" PrivateAssets="all"/>
</ItemGroup>
<ItemGroup>
<Using Include="JetBrains.Annotations" />
</ItemGroup>
<Target Name="EnsuringPackageIconPresence" BeforeTargets="Pack">
<Copy
SourceFiles="$(SolutionDir)resources\$(PackageIcon)"
Expand Down
117 changes: 117 additions & 0 deletions Rewrite/Rewrite.Sources.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Core", "src\Rewrite.Core\Rewrite.Core.csproj", "{FB30394C-7930-4BFF-97E2-400CFADE92C2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Properties", "src\Rewrite.Properties\Rewrite.Properties.csproj", "{C7E280C5-E841-4690-8AA3-653ECBC7C78B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Yaml", "src\Rewrite.Yaml\Rewrite.Yaml.csproj", "{F7F4F27F-2CAE-422B-B6CE-25A88C3603A1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Xml", "src\Rewrite.Xml\Rewrite.Xml.csproj", "{D38BB305-3276-4AE1-87B1-C19C7A9F3840}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Json", "src\Rewrite.Json\Rewrite.Json.csproj", "{5DD7D88A-5A10-457D-B1A2-30F7CF67AD9F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Java", "src\Rewrite.Java\Rewrite.Java.csproj", "{06BCC1C7-9D8C-4D3B-934D-072C35A5C984}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.CSharp", "src\Rewrite.CSharp\Rewrite.CSharp.csproj", "{25208A27-E598-4BE3-9CD9-0618A6B9598F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.CSharp.Tests", "tests\Rewrite.CSharp.Tests\Rewrite.CSharp.Tests.csproj", "{25EEACCB-9BAE-4361-A980-9E9CDA37602E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Test", "src\Rewrite.Test\Rewrite.Test.csproj", "{D3F48947-C702-4D1A-B6EE-96B89D13953D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.CSharp.Test.Api", "src\Rewrite.CSharp.Test.Api\Rewrite.CSharp.Test.Api.csproj", "{3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C7A4A8F9-0343-4A3E-AB77-101C458C23B5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{7B268266-B9CD-4D85-ABC5-3B2C4611FD74}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_solution", "_solution", "{B5C675AF-506B-47E6-AB10-4E7BC36531D2}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.CSharp.Test", "..\..\..\moderneinc\rewrite-remote\Rewrite.Remote\src\Rewrite.CSharp.Test\Rewrite.CSharp.Test.csproj", "{E3A7B93C-310E-4109-8F80-C469215FB93B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "commercial", "commercial", "{45B6292D-DC7E-46A7-A86E-7455BBEAED70}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Remote", "..\..\..\moderneinc\rewrite-remote\Rewrite.Remote\src\Rewrite.Remote\Rewrite.Remote.csproj", "{0E364862-1ACA-4C94-8EA0-23724FF67AA2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.MSBuild", "..\..\..\moderneinc\rewrite-remote\Rewrite.Remote\src\Rewrite.MSBuild\Rewrite.MSBuild.csproj", "{DE03049F-95A3-483F-939C-C2325548D590}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FB30394C-7930-4BFF-97E2-400CFADE92C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FB30394C-7930-4BFF-97E2-400CFADE92C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB30394C-7930-4BFF-97E2-400CFADE92C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB30394C-7930-4BFF-97E2-400CFADE92C2}.Release|Any CPU.Build.0 = Release|Any CPU
{C7E280C5-E841-4690-8AA3-653ECBC7C78B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7E280C5-E841-4690-8AA3-653ECBC7C78B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7E280C5-E841-4690-8AA3-653ECBC7C78B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7E280C5-E841-4690-8AA3-653ECBC7C78B}.Release|Any CPU.Build.0 = Release|Any CPU
{F7F4F27F-2CAE-422B-B6CE-25A88C3603A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F7F4F27F-2CAE-422B-B6CE-25A88C3603A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7F4F27F-2CAE-422B-B6CE-25A88C3603A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7F4F27F-2CAE-422B-B6CE-25A88C3603A1}.Release|Any CPU.Build.0 = Release|Any CPU
{D38BB305-3276-4AE1-87B1-C19C7A9F3840}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D38BB305-3276-4AE1-87B1-C19C7A9F3840}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D38BB305-3276-4AE1-87B1-C19C7A9F3840}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D38BB305-3276-4AE1-87B1-C19C7A9F3840}.Release|Any CPU.Build.0 = Release|Any CPU
{5DD7D88A-5A10-457D-B1A2-30F7CF67AD9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5DD7D88A-5A10-457D-B1A2-30F7CF67AD9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DD7D88A-5A10-457D-B1A2-30F7CF67AD9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DD7D88A-5A10-457D-B1A2-30F7CF67AD9F}.Release|Any CPU.Build.0 = Release|Any CPU
{06BCC1C7-9D8C-4D3B-934D-072C35A5C984}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06BCC1C7-9D8C-4D3B-934D-072C35A5C984}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06BCC1C7-9D8C-4D3B-934D-072C35A5C984}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06BCC1C7-9D8C-4D3B-934D-072C35A5C984}.Release|Any CPU.Build.0 = Release|Any CPU
{25208A27-E598-4BE3-9CD9-0618A6B9598F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{25208A27-E598-4BE3-9CD9-0618A6B9598F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25208A27-E598-4BE3-9CD9-0618A6B9598F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{25208A27-E598-4BE3-9CD9-0618A6B9598F}.Release|Any CPU.Build.0 = Release|Any CPU
{25EEACCB-9BAE-4361-A980-9E9CDA37602E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{25EEACCB-9BAE-4361-A980-9E9CDA37602E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25EEACCB-9BAE-4361-A980-9E9CDA37602E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{25EEACCB-9BAE-4361-A980-9E9CDA37602E}.Release|Any CPU.Build.0 = Release|Any CPU
{D3F48947-C702-4D1A-B6EE-96B89D13953D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3F48947-C702-4D1A-B6EE-96B89D13953D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3F48947-C702-4D1A-B6EE-96B89D13953D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3F48947-C702-4D1A-B6EE-96B89D13953D}.Release|Any CPU.Build.0 = Release|Any CPU
{3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}.Release|Any CPU.Build.0 = Release|Any CPU
{E3A7B93C-310E-4109-8F80-C469215FB93B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3A7B93C-310E-4109-8F80-C469215FB93B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3A7B93C-310E-4109-8F80-C469215FB93B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3A7B93C-310E-4109-8F80-C469215FB93B}.Release|Any CPU.Build.0 = Release|Any CPU
{0E364862-1ACA-4C94-8EA0-23724FF67AA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0E364862-1ACA-4C94-8EA0-23724FF67AA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E364862-1ACA-4C94-8EA0-23724FF67AA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E364862-1ACA-4C94-8EA0-23724FF67AA2}.Release|Any CPU.Build.0 = Release|Any CPU
{DE03049F-95A3-483F-939C-C2325548D590}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE03049F-95A3-483F-939C-C2325548D590}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE03049F-95A3-483F-939C-C2325548D590}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE03049F-95A3-483F-939C-C2325548D590}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{25EEACCB-9BAE-4361-A980-9E9CDA37602E} = {7B268266-B9CD-4D85-ABC5-3B2C4611FD74}
{FB30394C-7930-4BFF-97E2-400CFADE92C2} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{25208A27-E598-4BE3-9CD9-0618A6B9598F} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{3D70D4FA-3BA2-4230-B474-5A70DB23B8CE} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{06BCC1C7-9D8C-4D3B-934D-072C35A5C984} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{5DD7D88A-5A10-457D-B1A2-30F7CF67AD9F} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{C7E280C5-E841-4690-8AA3-653ECBC7C78B} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{D3F48947-C702-4D1A-B6EE-96B89D13953D} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{D38BB305-3276-4AE1-87B1-C19C7A9F3840} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{F7F4F27F-2CAE-422B-B6CE-25A88C3603A1} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{0E364862-1ACA-4C94-8EA0-23724FF67AA2} = {45B6292D-DC7E-46A7-A86E-7455BBEAED70}
{DE03049F-95A3-483F-939C-C2325548D590} = {45B6292D-DC7E-46A7-A86E-7455BBEAED70}
{E3A7B93C-310E-4109-8F80-C469215FB93B} = {45B6292D-DC7E-46A7-A86E-7455BBEAED70}
EndGlobalSection
EndGlobal
4 changes: 4 additions & 0 deletions Rewrite/Rewrite.Sources.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=bb4e4856_002Db1d2_002D4dca_002D8d98_002Ddb2099929197/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from &amp;lt;tests&amp;gt;\&amp;lt;Rewrite.CSharp.Tests&amp;gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;Project Location="C:\projects\openrewrite\rewrite-csharp\Rewrite\tests\Rewrite.CSharp.Tests" Presentation="&amp;lt;tests&amp;gt;\&amp;lt;Rewrite.CSharp.Tests&amp;gt;" /&gt;&#xD;
&lt;/SessionState&gt;</s:String></wpf:ResourceDictionary>
24 changes: 24 additions & 0 deletions Rewrite/Rewrite.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.Test", "src\Rewrite
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rewrite.CSharp.Test.Api", "src\Rewrite.CSharp.Test.Api\Rewrite.CSharp.Test.Api.csproj", "{3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C7A4A8F9-0343-4A3E-AB77-101C458C23B5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{7B268266-B9CD-4D85-ABC5-3B2C4611FD74}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_solution", "_solution", "{B5C675AF-506B-47E6-AB10-4E7BC36531D2}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -67,4 +79,16 @@ Global
{3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D70D4FA-3BA2-4230-B474-5A70DB23B8CE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{25EEACCB-9BAE-4361-A980-9E9CDA37602E} = {7B268266-B9CD-4D85-ABC5-3B2C4611FD74}
{FB30394C-7930-4BFF-97E2-400CFADE92C2} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{25208A27-E598-4BE3-9CD9-0618A6B9598F} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{3D70D4FA-3BA2-4230-B474-5A70DB23B8CE} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{06BCC1C7-9D8C-4D3B-934D-072C35A5C984} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{5DD7D88A-5A10-457D-B1A2-30F7CF67AD9F} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{C7E280C5-E841-4690-8AA3-653ECBC7C78B} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{D3F48947-C702-4D1A-B6EE-96B89D13953D} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{D38BB305-3276-4AE1-87B1-C19C7A9F3840} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
{F7F4F27F-2CAE-422B-B6CE-25A88C3603A1} = {C7A4A8F9-0343-4A3E-AB77-101C458C23B5}
EndGlobalSection
EndGlobal
4 changes: 2 additions & 2 deletions Rewrite/src/Rewrite.CSharp.Test.Api/Assertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ internal class UnknownDetector : JavaVisitor<int>
public override J VisitUnknown(J.Unknown unknown, int p)
{
var parentCursor = Cursor.Parent!;
object container = unknown;
object? container = unknown;
while (parentCursor.Value is not Core.Tree)
{
container = parentCursor.Value;
Expand Down Expand Up @@ -120,4 +120,4 @@ public override J VisitUnknown(J.Unknown unknown, int p)
unknown.Should().BeNull(because: "parser must not produce `J.Unknown` nodes");
return unknown;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<IsTestProject>false</IsTestProject>
<Description>C# recipe test support for the automated code refactoring framework OpenRewrite.</Description>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Rewrite.Core\Rewrite.Core.csproj" />
<ProjectReference Include="..\Rewrite.Java\Rewrite.Java.csproj" />
Expand All @@ -28,17 +28,16 @@


<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2024.2.0" />
<PackageReference Include="FluentAssertions" Version="7.0.0-alpha.4" />
<PackageReference Include="xunit" Version="2.8.1" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="bin\Resources\**\*">
<LogicalName>%(RecursiveDir)%(Filename)%(Extension)</LogicalName>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<Content Include="obj\project.assets.json" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Rewrite/src/Rewrite.CSharp/CSharpParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public IEnumerable<SourceFile> ParseInputs(IEnumerable<Core.Parser.Input> source
var semanticModel = compilation.GetSemanticModel(syntaxTree);

var visitor = new CSharpParserVisitor(semanticModel);
cs = visitor.Visit(root) as Cs.CompilationUnit;
cs = visitor.Visit(root) as Cs.CompilationUnit ?? throw new InvalidOperationException("Visitor.Visit returned null instead of Compilation Unit");
}
catch (Exception t)
{
Expand Down
9 changes: 6 additions & 3 deletions Rewrite/src/Rewrite.CSharp/CSharpPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,19 @@ public override Markers VisitMarkers(Markers? markers, PrintOutputCapture<P> p)
}
}

return markers;
return Markers.EMPTY;
}

public Space VisitSpace(Space space, CsSpace.Location loc, PrintOutputCapture<P> p)
//todo: AS: review if base method can be virtual and this one should just be override
protected override Space VisitSpace(Space space, CsSpace.Location loc, PrintOutputCapture<P> p)
{
return VisitSpace(space, Space.Location.LANGUAGE_EXTENSION, p);
}

public override Space VisitSpace(Space? space, Space.Location? loc, PrintOutputCapture<P> p)
{
if (space == null)
return Space.EMPTY;
p.Append(space.Whitespace);
foreach (var comment in space.Comments)
{
Expand Down Expand Up @@ -274,4 +277,4 @@ public override J VisitClassDeclaration(J.ClassDeclaration classDecl, PrintOutpu
return classDecl;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
#pragma warning disable CS0108
using System.Diagnostics.CodeAnalysis;
using Rewrite.Core;
using Rewrite.RewriteCSharp.Tree;
Expand Down Expand Up @@ -291,7 +299,7 @@ public override bool IsAcceptable(SourceFile sourceFile, P p)
return propertyDeclaration;
}

protected JContainer<J2>? VisitContainer<J2>(JContainer<J2>? container, CsContainer.Location loc, P p) where J2 : J
protected virtual JContainer<J2>? VisitContainer<J2>(JContainer<J2>? container, CsContainer.Location loc, P p) where J2 : J
{
if (container == null) {
return null;
Expand All @@ -309,7 +317,7 @@ public override bool IsAcceptable(SourceFile sourceFile, P p)
JContainer<J2>.Build(before!, js, container.Markers);
}

protected JLeftPadded<J2>? VisitLeftPadded<J2>(JLeftPadded<J2>? left, CsLeftPadded.Location loc, P p)
protected virtual JLeftPadded<J2>? VisitLeftPadded<J2>(JLeftPadded<J2>? left, CsLeftPadded.Location loc, P p)
{
if (left == null)
{
Expand All @@ -334,7 +342,7 @@ public override bool IsAcceptable(SourceFile sourceFile, P p)
return t == null ? null : new JLeftPadded<J2>(before, t, left.Markers);
}

protected JRightPadded<J2>? VisitRightPadded<J2>(JRightPadded<J2>? right, CsRightPadded.Location loc, P p)
protected virtual JRightPadded<J2>? VisitRightPadded<J2>(JRightPadded<J2>? right, CsRightPadded.Location loc, P p)
{
if (right == null)
{
Expand All @@ -360,7 +368,7 @@ public override bool IsAcceptable(SourceFile sourceFile, P p)
return right;
}

protected Space VisitSpace(Space space, CsSpace.Location loc, P p)
protected virtual Space VisitSpace(Space space, CsSpace.Location loc, P p)
{
return VisitSpace(space, Space.Location.LANGUAGE_EXTENSION, p);
}
Expand Down
Loading