3232import org .openrewrite .marker .Markers ;
3333
3434import java .util .List ;
35- import java .util .Objects ;
3635import java .util .function .UnaryOperator ;
3736
3837public class CSharpPrinter <P > extends CSharpVisitor <PrintOutputCapture <P >> {
@@ -43,9 +42,8 @@ public J visit(@Nullable Tree tree, PrintOutputCapture<P> p) {
4342 if (!(tree instanceof Cs )) {
4443 // re-route printing to the java printer
4544 return delegate .visit (tree , p );
46- } else {
47- return super .visit (tree , p );
4845 }
46+ return super .visit (tree , p );
4947 }
5048
5149 @ Override
@@ -92,13 +90,15 @@ public J visitOperatorDeclaration(Cs.OperatorDeclaration node, PrintOutputCaptur
9290 return node ;
9391 }
9492
93+ @ Override
9594 public J visitPointerType (Cs .PointerType node , PrintOutputCapture <P > p ) {
9695 beforeSyntax (node , CsSpace .Location .POINTER_TYPE_PREFIX , p );
9796 visitRightPadded (node .getPadding ().getElementType (), CsRightPadded .Location .POINTER_TYPE_ELEMENT_TYPE , "*" , p );
9897 afterSyntax (node , p );
9998 return node ;
10099 }
101100
101+ @ Override
102102 public Cs visitTry (Cs .Try tryable , PrintOutputCapture <P > p ) {
103103 beforeSyntax (tryable , Space .Location .TRY_PREFIX , p );
104104 p .append ("try" );
@@ -110,6 +110,7 @@ public Cs visitTry(Cs.Try tryable, PrintOutputCapture<P> p) {
110110 }
111111
112112
113+ @ Override
113114 public Cs visitTryCatch (Cs .Try .Catch catch_ , PrintOutputCapture <P > p ) {
114115 beforeSyntax (catch_ , Space .Location .CATCH_PREFIX , p );
115116 p .append ("catch" );
@@ -248,6 +249,7 @@ public J visitOrderByClause(Cs.OrderByClause node, PrintOutputCapture<P> p) {
248249 return node ;
249250 }
250251
252+ @ Override
251253 public J visitForEachVariableLoop (Cs .ForEachVariableLoop forEachLoop , PrintOutputCapture <P > p ) {
252254 beforeSyntax (forEachLoop , Space .Location .FOR_EACH_LOOP_PREFIX , p );
253255 p .append ("foreach" );
@@ -306,6 +308,7 @@ protected <T extends J> void visitRightPadded(@Nullable JRightPadded<T> rightPad
306308 }
307309 }
308310
311+ @ Override
309312 public J visitSwitchExpression (Cs .SwitchExpression node , PrintOutputCapture <P > p ) {
310313 beforeSyntax (node , CsSpace .Location .SWITCH_EXPRESSION_PREFIX , p );
311314 visitRightPadded (node .getPadding ().getExpression (), CsRightPadded .Location .SWITCH_EXPRESSION_EXPRESSION , p );
@@ -315,6 +318,7 @@ public J visitSwitchExpression(Cs.SwitchExpression node, PrintOutputCapture<P> p
315318 return node ;
316319 }
317320
321+ @ Override
318322 public J visitSwitchStatement (Cs .SwitchStatement node , PrintOutputCapture <P > p ) {
319323 beforeSyntax (node , CsSpace .Location .SWITCH_STATEMENT_PREFIX , p );
320324 p .append ("switch" );
@@ -324,6 +328,7 @@ public J visitSwitchStatement(Cs.SwitchStatement node, PrintOutputCapture<P> p)
324328 return node ;
325329 }
326330
331+ @ Override
327332 public J visitSwitchSection (Cs .SwitchSection node , PrintOutputCapture <P > p ) {
328333 beforeSyntax (node , CsSpace .Location .SWITCH_SECTION_PREFIX , p );
329334 visit (node .getLabels (), p );
@@ -332,6 +337,7 @@ public J visitSwitchSection(Cs.SwitchSection node, PrintOutputCapture<P> p) {
332337 return node ;
333338 }
334339
340+ @ Override
335341 public J visitUnsafeStatement (Cs .UnsafeStatement node , PrintOutputCapture <P > p ) {
336342 beforeSyntax (node , CsSpace .Location .UNSAFE_STATEMENT_PREFIX , p );
337343 p .append ("unsafe" );
@@ -349,6 +355,7 @@ public J visitCheckedExpression(Cs.CheckedExpression node, PrintOutputCapture<P>
349355 return node ;
350356 }
351357
358+ @ Override
352359 public J visitCheckedStatement (Cs .CheckedStatement node , PrintOutputCapture <P > p ) {
353360 beforeSyntax (node , CsSpace .Location .CHECKED_STATEMENT_PREFIX , p );
354361 visit (node .getKeyword (), p );
@@ -376,6 +383,7 @@ public J visitRefType(Cs.RefType node, PrintOutputCapture<P> p) {
376383 return node ;
377384 }
378385
386+ @ Override
379387 public J visitRangeExpression (Cs .RangeExpression node , PrintOutputCapture <P > p ) {
380388 beforeSyntax (node , CsSpace .Location .RANGE_EXPRESSION_PREFIX , p );
381389 visitRightPadded (node .getPadding ().getStart (), CsRightPadded .Location .RANGE_EXPRESSION_START , p );
@@ -385,6 +393,7 @@ public J visitRangeExpression(Cs.RangeExpression node, PrintOutputCapture<P> p)
385393 return node ;
386394 }
387395
396+ @ Override
388397 public J visitFixedStatement (Cs .FixedStatement node , PrintOutputCapture <P > p ) {
389398 beforeSyntax (node , CsSpace .Location .FIXED_STATEMENT_PREFIX , p );
390399 p .append ("fixed" );
@@ -394,6 +403,7 @@ public J visitFixedStatement(Cs.FixedStatement node, PrintOutputCapture<P> p) {
394403 return node ;
395404 }
396405
406+ @ Override
397407 public J visitLockStatement (Cs .LockStatement node , PrintOutputCapture <P > p ) {
398408 beforeSyntax (node , CsSpace .Location .LOCK_STATEMENT_PREFIX , p );
399409 p .append ("lock" );
@@ -403,6 +413,7 @@ public J visitLockStatement(Cs.LockStatement node, PrintOutputCapture<P> p) {
403413 return node ;
404414 }
405415
416+ @ Override
406417 public J visitCasePatternSwitchLabel (Cs .CasePatternSwitchLabel node , PrintOutputCapture <P > p ) {
407418 beforeSyntax (node , CsSpace .Location .CASE_PATTERN_SWITCH_LABEL_PREFIX , p );
408419 p .append ("case" );
@@ -414,6 +425,7 @@ public J visitCasePatternSwitchLabel(Cs.CasePatternSwitchLabel node, PrintOutput
414425 return node ;
415426 }
416427
428+ @ Override
417429 public J visitDefaultSwitchLabel (Cs .DefaultSwitchLabel node , PrintOutputCapture <P > p ) {
418430 beforeSyntax (node , CsSpace .Location .DEFAULT_SWITCH_LABEL_PREFIX , p );
419431 p .append ("default" );
@@ -423,6 +435,7 @@ public J visitDefaultSwitchLabel(Cs.DefaultSwitchLabel node, PrintOutputCapture<
423435 return node ;
424436 }
425437
438+ @ Override
426439 public J visitSwitchExpressionArm (Cs .SwitchExpressionArm node , PrintOutputCapture <P > p ) {
427440 beforeSyntax (node , CsSpace .Location .SWITCH_EXPRESSION_ARM_PREFIX , p );
428441 visit (node .getPattern (), p );
@@ -1374,7 +1387,7 @@ public J visitTypeParameterConstraintClause(Cs.TypeParameterConstraintClause typ
13741387 public J visitClassOrStructConstraint (Cs .ClassOrStructConstraint classOrStructConstraint , PrintOutputCapture <P > p )
13751388 {
13761389 beforeSyntax (classOrStructConstraint , CsSpace .Location .TYPE_PARAMETERS_CONSTRAINT_PREFIX , p );
1377- p .append (classOrStructConstraint .getKind (). equals ( Cs .ClassOrStructConstraint .TypeKind .Class ) ? "class" : "struct" );
1390+ p .append (classOrStructConstraint .getKind () == Cs .ClassOrStructConstraint .TypeKind .Class ? "class" : "struct" );
13781391 return classOrStructConstraint ;
13791392 }
13801393
@@ -1420,9 +1433,8 @@ public J visit(@Nullable Tree tree, PrintOutputCapture<P> p) {
14201433 if (tree instanceof Cs ) {
14211434 // re-route printing back up to groovy
14221435 return CSharpPrinter .this .visit (tree , p );
1423- } else {
1424- return super .visit (tree , p );
14251436 }
1437+ return super .visit (tree , p );
14261438 }
14271439
14281440 @ Override
0 commit comments