1 28 29 package org.jruby.ast.visitor.rewriter.utils; 30 31 import org.jruby.ast.NewlineNode; 32 import org.jruby.ast.visitor.rewriter.ReWriteVisitor; 33 import org.jruby.evaluator.Instruction; 34 35 public class ShortIfNodeReWriteVisitor extends ReWriteVisitor { 36 37 public ShortIfNodeReWriteVisitor(ReWriterContext config) { 38 super(config); 39 } 40 41 protected void printNewlineAndIndentation() { 42 print("; "); 43 } 44 45 public Instruction visitNewlineNode(NewlineNode iVisited) { 46 if (config.getSource().charAt(getEndOffset(iVisited) - 1) == ')') { 47 print('('); 48 visitNode(iVisited.getNextNode()); 49 print(')'); 50 } else { 51 print("; "); 52 visitNode(iVisited.getNextNode()); 53 } 54 return null; 55 } 56 } | Popular Tags |